From 642bf315fabffed48bd83089b5ca754d66e06363 Mon Sep 17 00:00:00 2001 From: Pierre Gueth Date: Fri, 29 Jun 2012 16:24:07 +0200 Subject: [PATCH] gate_power_merge sould support mhd now!! --- cluster_tools/gate_power_merge.sh | 44 ++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/cluster_tools/gate_power_merge.sh b/cluster_tools/gate_power_merge.sh index caec94a..aec1ce8 100755 --- a/cluster_tools/gate_power_merge.sh +++ b/cluster_tools/gate_power_merge.sh @@ -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|/*$||')" -- 2.47.1