]> Creatis software - clitk.git/blobdiff - cluster_tools/gate_power_merge.sh
Add merger for DoseByRegions
[clitk.git] / cluster_tools / gate_power_merge.sh
index a0c3e183318d0fbdd17c338dc6e2ecdaa315c303..7717c578fe355975af3d6aeeea5d2969ab5feeae 100755 (executable)
@@ -196,6 +196,37 @@ function merge_dose {
     echo "  ${indent}merged ${count} files"
 }
 
+doseMerger="mergeDoseByRegions.sh"
+test -x "./mergeDoseByRegions.sh" && doseMerger="./mergeDoseByRegions.sh"
+
+function merge_doseByRegions {
+    local merged="$1"
+    shift
+    echo "  ${indent}entering dose merger"
+    echo "  ${indent}merger is ${doseMerger}"
+    echo "  ${indent}creating ${merged}"
+    local count=0
+    start_bar $#
+    while test $# -gt 0
+    do
+        local partial="$1"
+        shift
+        let count++
+
+        if test ! -f "${merged}"
+        then
+            update_bar ${count} "copying first partial result ${partial}"
+            cp "${partial}" "${merged}"
+            continue
+        fi
+
+        update_bar ${count} "adding ${partial}"
+        ${doseMerger} -i "${merged}" -j "${partial}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${doseMerger}"
+    done
+    end_bar
+    echo "  ${indent}merged ${count} files"
+}
+
 txtImageMerger="clitkMergeAsciiDoseActor"
 test -f "./clitkMergeAsciiDoseActor" && txtImageMerger="./clitkMergeAsciiDoseActor"
 
@@ -409,6 +440,15 @@ function merge_dispatcher {
         fi
     fi
 
+    if test "${firstpartialoutputextension}" == "txt" && grep -qs 'vol(mm3)' "${firstpartialoutputfile}"
+    then
+        echo "${indent}this is a DoseByRegions file"
+        local mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}")"
+        merge_doseByRegions "${mergedfile}" ${partialoutputfiles} || error "error while merging"
+        return
+    fi
+
+
     if test "${firstpartialoutputextension}" == "txt"
     then
         echo "${indent}this is a non specific txt output"