]> Creatis software - clitk.git/commitdiff
gate_power_merge sould support mhd now!!
authorPierre Gueth <gueth@linux6.dg.creatis.insa-lyon.fr>
Fri, 29 Jun 2012 14:24:07 +0000 (16:24 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Thu, 27 Jun 2013 12:47:29 +0000 (14:47 +0200)
cluster_tools/gate_power_merge.sh

index caec94a252cd829af0fc575a04c4bcc5fe9041cc..aec1ce801a6ef5d34f90a1d5a0ad4fe0a2e3289b 100755 (executable)
@@ -163,6 +163,40 @@ end_bar
 echo "  ${indent}merged ${count} files"
 }
 
+mhdImageMerger="clitkImageArithm"
+test -x "./clitkImageArithm" && mhdImageMerger="./clitkImageArithm"
+
+function merge_mhd_image {
+local merged="$1"
+local merged_bin="${merged%.*}.img"
+shift
+echo "  ${indent}entering mhd image merger"
+echo "  ${indent}merger is ${mhdImageMerger}"
+echo "  ${indent}creating ${merged}"
+local count=0
+start_bar $#
+while test $# -gt 0
+do
+    local partial="$1"
+    local partial_bin="${partial%.*}.raw"
+    shift
+    let count++
+
+    if test ! -f "${merged}"
+    then
+        update_bar ${count} "copying first partial result ${partial}"
+        cp "${partial}" "${merged}"
+        cp "${partial_bin}" "${merged_bin}"
+        continue
+    fi
+
+    update_bar ${count} "adding ${partial}"
+    ${mhdImageMerger} -t 0 -i "${partial}" -j "${merged}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${mhdImageMerger}"
+done
+end_bar
+echo "  ${indent}merged ${count} files"
+}
+
 function merge_dispatcher {
     local indent="  ** "
     local outputfile="${1:?"provide output filename"}"
@@ -188,6 +222,14 @@ function merge_dispatcher {
         return
     fi
 
+    if test "${firstpartialoutputextension}" == "mhd"
+    then
+        echo "${indent}this is a mhd image"
+        local mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}")"
+        merge_mhd_image "${mergedfile}" ${partialoutputfiles} || error "error while merging"
+        return
+    fi
+
     if test "${firstpartialoutputextension}" == "root"
     then
         echo "${indent}this is a root file"
@@ -238,7 +280,7 @@ function merge_dispatcher {
     warning "unknown file type"
 }
 
-echo "!!!! this is $0 v0.3g !!!!"
+echo "!!!! this is $0 v0.3h !!!!"
 
 rundir="${1?"provide run dir"}"
 rundir="$(echo "${rundir}" | sed 's|/*$||')"