]> Creatis software - vip-workflow-creaphase.git/commitdiff
CreaPhase circle workflow v0.1
authorSorina Pop <sorina.pop@creatis.insa-lyon.fr>
Fri, 24 Jun 2016 12:01:30 +0000 (14:01 +0200)
committerSorina Pop <sorina.pop@creatis.insa-lyon.fr>
Fri, 24 Jun 2016 12:01:30 +0000 (14:01 +0200)
bin/CreaPhase.sh [new file with mode: 0755]
gasw/CreaPhase.xml [new file with mode: 0644]
workflow/CreaPhase.gwendia [new file with mode: 0644]

diff --git a/bin/CreaPhase.sh b/bin/CreaPhase.sh
new file mode 100755 (executable)
index 0000000..bf04443
--- /dev/null
@@ -0,0 +1,114 @@
+#!/bin/bash
+
+#     Functions     #
+
+function info {
+  local D=`date`
+  echo [ INFO - $D ] $*
+}
+
+function warning {
+  local D=`date`
+  echo [ WARN - $D ] $*
+}
+
+function error {
+  local D=`date`
+  echo [ ERROR - $D ] $* >&2
+}
+
+function downloadLFN {
+
+  local LFN=$1
+  local LOCAL=${PWD}/`basename ${LFN}`
+
+  info "getting file size and computing sendReceiveTimeout"
+  size=`lfc-ls -l ${LFN} | awk -F' ' '{print $5}'`
+  sendReceiveTimeout=`echo $[${size}/150/1024]`
+  if [ "$sendReceiveTimeout" = "" ] || [ $sendReceiveTimeout -le 900 ]; then echo "sendReceiveTimeout empty or too small, setting it to 900s"; sendReceiveTimeout=900; else echo "sendReceiveTimeout is $sendReceiveTimeout"; fi;
+  info "Removing file ${LOCAL} in case it is already here"
+  \rm -f ${LOCAL}
+
+  info "Checking if the file is on local SE ${VO_BIOMED_DEFAULT_SE}"
+  local closeSURL=`lcg-lr lfn:${LFN} | grep ${VO_BIOMED_DEFAULT_SE}`
+  if [ "${closeSURL}" != "" ]
+  then
+    info "It is. Trying to download the file from there"
+    LINE="lcg-cp -v --connect-timeout 10 --sendreceive-timeout $sendReceiveTimeout --bdii-timeout 10 --srm-timeout 30 ${closeSURL} file:${LOCAL}"
+    info ${LINE}
+    ${LINE} &> lcg-log
+    if [ $? = 0 ]
+    then
+      info "lcg-cp worked fine"
+      lcg_source=`cat lcg-log | awk -F"://" '/Trying SURL srm/ {print $2}' | awk -F"/" '{print $1}'|awk -F":" '{print $1}'`;
+      lcg_destination=`hostname`;
+      lcg_time=`cat lcg-log | awk '/Transfer took/ {print $3$4}'`;
+      info "DownloadCommand=lcg-cp Source=$lcg_source Destination=$lcg_destination Size=$size Time=$lcg_time";
+      return 0
+    else
+      error "It failed, falling back on regular lcg-cp"
+    fi
+  else
+    info "It's not, falling back on regular lcg-cp"
+  fi
+
+info "Downloading file ${LFN}..."
+LINE="lcg-cp -v --connect-timeout 10 --sendreceive-timeout $sendReceiveTimeout --bdii-timeout 10 --srm-timeout 30 lfn:${LFN} file:${LOCAL}"
+info ${LINE}
+${LINE} &> lcg-log
+if [ $? = 0 ]
+then
+  info "lcg-cp worked fine"
+  lcg_source=`cat lcg-log | awk -F"://" '/Trying SURL srm/ {print $2}' | awk -F"/" '{print $1}'|awk -F":" '{print $1}'`;
+  lcg_destination=`hostname`;
+  lcg_time=`cat lcg-log | awk '/Transfer took/ {print $3$4}'`;
+  info "DownloadCommand=lcg-cp Source=$lcg_source Destination=$lcg_destination Size=$size Time=$lcg_time";
+else
+  error "lcg-cp failed"
+  error "`cat lcg-log`"
+  return 1
+fi
+\rm lcg-log 
+}
+
+# Arguments parsing #
+RES=$1
+COMM_LINE=`echo "${@:2:$(($#-2))}"`
+# Command-line construction #
+
+#echo "COMM line is $COMM_LINE"
+#remove flags starting with --
+#BOUTIQUES_ARGS="$(echo ${COMM_LINE} | sed 's/[--][[:alpha:]]*/,/g')"
+BOUTIQUES_ARGS="$(echo ${COMM_LINE} | sed 's/ , /, /g')"
+#remove leading ,,
+#BOUTIQUES_ARGS="$(echo ${BOUTIQUES_ARGS} | sed 's/^,, //g')"
+BOUTIQUES_COMMAND_LINE="octave --silent --eval \"SimuPBI_circle_func(${BOUTIQUES_ARGS})\""
+echo "Boutiques COMM line is $BOUTIQUES_COMMAND_LINE"
+
+
+#WARNING Cheating here : we know that outputs are written in dirOut
+DIROUT="dirOut"
+# Command-line execution #
+
+cat << DOCKERJOB > .dockerjob.sh
+#!/bin/bash -l
+cd /CreaPhase
+${BOUTIQUES_COMMAND_LINE}
+DOCKERJOB
+
+mkdir $DIROUT
+chmod 755 .dockerjob.sh
+#.dockerjob.sh script needs to be found in the workdir, ten we need to cd to /CreaPhase to be able to execute SimuPBI_circle_func
+docker run --rm -v $PWD:/gasw-dir -v $PWD/$DIROUT:/CreaPhase/$DIROUT -v $PWD/../cache:$PWD/../cache -w /gasw-dir -u `id -u`:`id -g` camarasu/creaphase ./.dockerjob.sh
+
+if [ $? != 0 ]
+then
+    echo "CreaPhase execution failed!"
+    exit 1
+fi
+
+tar -czvf result.tgz $DIROUT
+
+
+echo "Execution of CreaPhase completed."
+
diff --git a/gasw/CreaPhase.xml b/gasw/CreaPhase.xml
new file mode 100644 (file)
index 0000000..17cdc95
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description>
+  <executable name="CreaPhase.sh">
+    <access type="LFN" cached="true"/> 
+    <retrycount value="1"/>
+    <value value="[BIN_DIR]/CreaPhase.sh"/>
+    <executor value="LOCAL"/>
+    <input name="results-directory" option="no1"> 
+    </input>
+    <input name="vers" option="no2"> 
+    </input>
+    <input name="oversamp" option=","> 
+    </input>
+    <input name="basename" option=","> 
+    </input>
+    <input name="dist" option=","> 
+    </input>
+    <input name="energy" option=","> 
+    </input>
+    <input name="pixelSize" option=","> 
+    </input>
+    <input name="nbProj" option=","> 
+    </input>
+    <input name="rangeAngle" option=","> 
+    </input>
+    <input name="modelCtf" option=","> 
+    </input>
+    <input name="modelFresnel" option=","> 
+    </input>
+    <input name="muMat" option=","> 
+    </input>
+    <input name="deltaMat" option=","> 
+    </input>
+    <input name="Rcircle" option=","> 
+    </input>
+    <input name="imageSize" option=","> 
+    </input>
+    <input name="circleCenter" option=","> 
+    </input>
+    <input name="dirOut" option=","> 
+    </input>
+    <input name="noiseType" option=","> 
+    </input>
+    <input name="noiseAmount" option=","> 
+    </input>
+    <output name="resultTarball" option="no20">
+      <template value="$dir1/$na1/result.tgz"/>
+      <access type="LFN"/>
+    </output>
+  </executable>
+</description>
diff --git a/workflow/CreaPhase.gwendia b/workflow/CreaPhase.gwendia
new file mode 100644 (file)
index 0000000..afc5337
--- /dev/null
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<workflow name="CreaPhase" version="0.1">
+
+  <description>Propagation-based phase contrast images generation</description>
+
+  <interface>
+    <source name="results-directory" type="uri">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;results-directory&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;Directory&lt;/font&gt;&lt;/b&gt;): Directory where the results will be stored.
+      </source-comment>
+    </source>
+    <source name="vers" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;vers&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): are the projections calculated analytically or using the Radon transform? use the strings 'Radon' OR 'Analytical'
+      </source-comment>
+    </source>
+    <source name="oversamp" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;oversamp&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;Number&lt;/font&gt;&lt;/b&gt;): Oversampling of the projections : use 2 or 4
+      </source-comment>
+    </source>
+    <source name="basename" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;basename&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): Basename of the result file
+      </source-comment>
+    </source>
+    <source name="dist" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;dist&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;):  Distances of propagation (in m), e.g. 0 0.01 0.1 0.20 0.50
+      </source-comment>
+    </source>
+    <source name="energy" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;energy&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;Number&lt;/font&gt;&lt;/b&gt;): Energy of the incoming X-ray beam (in keV)
+      </source-comment>
+    </source>
+    <source name="pixelSize" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;pixelSize&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;Number&lt;/font&gt;&lt;/b&gt;): Pixel size of the detector (in um)
+      </source-comment>
+    </source>
+    <source name="nbProj" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;nbProj&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;Number&lt;/font&gt;&lt;/b&gt;): Number of projections (e.g., 360)
+      </source-comment>
+    </source>
+    <source name="rangeAngle" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;rangeAngle&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;Number&lt;/font&gt;&lt;/b&gt;): Range of the tomography : 180 or 360 degrees
+      </source-comment>
+    </source>
+    <source name="modelCtf" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;modelCtf&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;Number&lt;/font&gt;&lt;/b&gt;):  Which model do you want to use for the propagation? use 1 or 0
+      </source-comment>
+    </source>
+    <source name="modelFresnel" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;modelFresnel&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;Number&lt;/font&gt;&lt;/b&gt;): Which model do you want to use for the propagation? use 1 or 0
+      </source-comment>
+    </source>
+    <source name="muMat" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;muMat&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): Material of the circle (e.g., PET at 19 keV)
+      </source-comment>
+    </source>
+    <source name="deltaMat" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;deltaMat&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): Material of the circle (e.g., PET at 19 keV)
+      </source-comment>
+    </source>
+    <source name="Rcircle" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;Rcircle&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): radius of the circle
+      </source-comment>
+    </source>
+    <source name="imageSize" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;imageSize&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): Size of the image (square)
+      </source-comment>
+    </source>
+    <source name="circleCenter" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;circleCenter&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): 2D coordinates of the circle center (e.g., 200 250)
+      </source-comment>
+    </source>
+    <source name="noiseType" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;noiseType&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): Use noise='gaussian' (addition of gaussian noise) or noise='poisson' ( generation of Poisson noise) Put '&lt;b&gt;no&lt;/b&gt;' to ignore this optional input.
+      </source-comment>
+    </source>
+    <source name="noiseAmount" type="string">
+      <source-comment>&lt;b&gt;&lt;font color=blue&gt;noiseAmount&lt;/font&gt;&lt;/b&gt; (&lt;b&gt;&lt;font color=green&gt;String&lt;/font&gt;&lt;/b&gt;): If 'gaussian' (additive noise), please specify the Peak-to-peak Signe-to-noise ratio (PPSNR, in dB)
+      </source-comment>
+    </source>
+    <constant name="dirOut" type="string" value="dirOut" cardinality="scalar" />
+    <sink name="resultTarball" type="uri" />
+  </interface>
+
+  <processors>
+    <processor name="append-date" >
+      <in name="dir" type="uri" depth="0" />
+      <out name="result" type="string" depth="0" />
+      <beanshell>/*----------Beginning of Beanshell------------*/
+                        import java.text.DateFormat;
+                        import java.text.SimpleDateFormat;
+                        import java.util.Date;
+
+DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy_HH:mm:ss");
+String result = dir.toString()+"/"+(dateFormat.format(System.currentTimeMillis()));
+/*------------End of Beanshell------------*/
+      </beanshell>
+    </processor>
+    <processor name="CreaPhase" >
+      <in name="dirOut" type="string" depth="0" />
+      <in name="vers" type="string" depth="0" />
+      <in name="dist" type="string" depth="0" />
+      <in name="Rcircle" type="string" depth="0" />
+      <in name="pixelSize" type="string" depth="0" />
+      <in name="muMat" type="string" depth="0" />
+      <in name="deltaMat" type="string" depth="0" />
+      <in name="modelFresnel" type="string" depth="0" />
+      <in name="rangeAngle" type="string" depth="0" />
+      <in name="nbProj" type="string" depth="0" />
+      <in name="oversamp" type="string" depth="0" />
+      <in name="circleCenter" type="string" depth="0" />
+      <in name="basename" type="string" depth="0" />
+      <in name="modelCtf" type="string" depth="0" />
+      <in name="noiseAmount" type="string" depth="0" />
+      <in name="noiseType" type="string" depth="0" />
+      <in name="imageSize" type="string" depth="0" />
+      <in name="results-directory" type="string" depth="0" />
+      <in name="energy" type="string" depth="0" />
+      <out name="resultTarball" type="uri" depth="0" />
+      <iterationstrategy>
+        <cross>
+          <port name="results-directory" />
+          <port name="vers" />
+          <port name="oversamp" />
+          <port name="basename" />
+          <port name="dist" />
+          <port name="energy" />
+          <port name="pixelSize" />
+          <port name="nbProj" />
+          <port name="rangeAngle" />
+          <port name="modelCtf" />
+          <port name="modelFresnel" />
+          <port name="muMat" />
+          <port name="deltaMat" />
+          <port name="Rcircle" />
+          <port name="imageSize" />
+          <port name="circleCenter" />
+          <port name="dirOut" />
+          <port name="noiseType" />
+          <port name="noiseAmount" />
+        </cross>
+      </iterationstrategy>
+      <gasw descriptor="[GASW_DIR]/CreaPhase.xml"/>
+    </processor>
+    <processor name="append-brackets" >
+      <in name="inputString" type="string" depth="0" />
+      <out name="out" type="string" depth="0" />
+      <beanshell>/*----------Beginning of Beanshell------------*/
+//String toAppend="\\\"";
+out="["+inputString+"]";
+      </beanshell>
+    </processor>
+    <processor name="append-brackets_2" >
+      <in name="inputString" type="string" depth="0" />
+      <out name="out" type="string" depth="0" />
+      <beanshell>/*----------Beginning of Beanshell------------*/
+//String toAppend="\\\"";
+out="["+inputString+"]";
+      </beanshell>
+    </processor>
+    <processor name="append-simple-quotes" >
+      <in name="inputString" type="string" depth="0" />
+      <out name="out" type="string" depth="0" />
+      <beanshell>/*----------Beginning of Beanshell------------*/
+String toAppend="'";
+out=toAppend+inputString+toAppend;
+      </beanshell>
+    </processor>
+    <processor name="append-simple-quotes_2" >
+      <in name="inputString" type="string" depth="0" />
+      <out name="out" type="string" depth="0" />
+      <beanshell>/*----------Beginning of Beanshell------------*/
+String toAppend="'";
+out=toAppend+inputString+toAppend;
+      </beanshell>
+    </processor>
+    <processor name="append-simple-quotes_3" >
+      <in name="inputString" type="string" depth="0" />
+      <out name="out" type="string" depth="0" />
+      <beanshell>/*----------Beginning of Beanshell------------*/
+String toAppend="'";
+out=toAppend+inputString+toAppend;
+      </beanshell>
+    </processor>
+    <processor name="append-simple-quotes_4" >
+      <in name="inputString" type="string" depth="0" />
+      <out name="out" type="string" depth="0" />
+      <beanshell>/*----------Beginning of Beanshell------------*/
+String toAppend="'";
+out=toAppend+inputString+toAppend;
+      </beanshell>
+    </processor>
+  </processors>
+
+  <links>
+      <link from="results-directory" to="append-date:dir" />
+      <link from="append-date:result" to="CreaPhase:results-directory" />
+      <link from="oversamp" to="CreaPhase:oversamp" />
+      <link from="energy" to="CreaPhase:energy" />
+      <link from="pixelSize" to="CreaPhase:pixelSize" />
+      <link from="nbProj" to="CreaPhase:nbProj" />
+      <link from="rangeAngle" to="CreaPhase:rangeAngle" />
+      <link from="modelCtf" to="CreaPhase:modelCtf" />
+      <link from="modelFresnel" to="CreaPhase:modelFresnel" />
+      <link from="muMat" to="CreaPhase:muMat" />
+      <link from="deltaMat" to="CreaPhase:deltaMat" />
+      <link from="Rcircle" to="CreaPhase:Rcircle" />
+      <link from="imageSize" to="CreaPhase:imageSize" />
+      <link from="noiseAmount" to="CreaPhase:noiseAmount" />
+      <link from="CreaPhase:resultTarball" to="resultTarball" />
+      <link from="dist" to="append-brackets:inputString" />
+      <link from="circleCenter" to="append-brackets_2:inputString" />
+      <link from="append-brackets_2:out" to="CreaPhase:circleCenter" />
+      <link from="append-brackets:out" to="CreaPhase:dist" />
+      <link from="vers" to="append-simple-quotes:inputString" />
+      <link from="append-simple-quotes:out" to="CreaPhase:vers" />
+      <link from="basename" to="append-simple-quotes_2:inputString" />
+      <link from="append-simple-quotes_2:out" to="CreaPhase:basename" />
+      <link from="append-simple-quotes_3:out" to="CreaPhase:dirOut" />
+      <link from="noiseType" to="append-simple-quotes_4:inputString" />
+      <link from="append-simple-quotes_4:out" to="CreaPhase:noiseType" />
+      <link from="dirOut" to="append-simple-quotes_3:inputString" />
+  </links>
+
+</workflow>