X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=cluster_tools%2Fgate_power_merge.sh;h=ab9ac976a06c3a392cb34ac35702cdb5600953a6;hb=a845c6a04ecfeedc8eced5f4051e06ee88c59e90;hp=2733e406a823958069c7ab1f8f9aba6ed64a677a;hpb=d4355c17de8da3c4814b9428fb6c17ec7ededbe9;p=clitk.git diff --git a/cluster_tools/gate_power_merge.sh b/cluster_tools/gate_power_merge.sh index 2733e40..ab9ac97 100755 --- a/cluster_tools/gate_power_merge.sh +++ b/cluster_tools/gate_power_merge.sh @@ -420,6 +420,69 @@ function merge_dispatcher { error "unknown file type" } +function merge_dispatcher_uncertainty { + local indent=" ** " + local outputfile="${1:?"provide output filename"}" + + local partialoutputfiles="$(find "${rundir}" -mindepth 2 -type f -name "${outputfile}")" + local nboutputfiles="$(echo "${partialoutputfiles}" | wc -l)" + if test ${nboutputdirs} -ne ${nboutputfiles} + then + warning "missing files" + return + fi + + local firstpartialoutputfile="$(echo "${partialoutputfiles}" | head -n 1)" + local firstpartialoutputextension="${firstpartialoutputfile##*.}" + + if [[ "${firstpartialoutputfile}" == *Uncertainty* ]] + then + if test "${firstpartialoutputextension}" == "mhd" + then + echo "${indent}Uncertainty file found: ${firstpartialoutputfile}" + ## search for sum + local mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}")" + summed_merged_file=${mergedfile//-Uncertainty/} + if [ ! -f ${summed_merged_file} ]; + then + warning "${summed_merged_file} does not exist. Error, no uncertainty computed" + return; + fi + echo "${indent}${summed_merged_file} found" + ## search for Squared + squared_merged_file=${mergedfile//-Uncertainty/-Squared} + if [ ! -f ${squared_merged_file} ]; + then + warning "${squared_merged_file} does not exist. Error, no uncertainty computed" + return; + fi + echo "${indent}${squared_merged_file} found" + ## search for NumberOfEvent + totalEvents=0; + for outputfile in $(find "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) + do + #echo $outputfile + if grep -q 'NumberOfEvent' "${outputdir}/${outputfile}" + then + totalEvents="$(grep "NumberOfEvents" "${outputdir}/${outputfile}" | cut -d' ' -f4)" + echo "${indent}Find the NumberOfEvent in $outputfile: ${totalEvents}" + fi + done + + if test ${totalEvents} -gt 0 + then + uncerImageMerger="clitkImageUncertainty" + test -x "./clitkImageUncertainty" && uncerImageMerger="./clitkImageUncertainty" + ${uncerImageMerger} -i ${summed_merged_file} -s ${squared_merged_file} -o ${mergedfile} -n ${totalEvents} + else + warning "${totalEvents} not positive. A at least one stat file (SimulationStatisticActor) must be provided. Error, no uncertainty computed" + return; + fi + fi + fi + +} + echo "!!!! this is $0 v0.3k !!!!" rundir="${1?"provide run dir"}" @@ -436,6 +499,7 @@ then fi outputdir="$(basename "${outputdir}")" echo "output dir is ${outputdir}" + test -d "${outputdir}" && rm -r "${outputdir}" mkdir "${outputdir}" @@ -444,6 +508,13 @@ do merge_dispatcher "${outputfile}" done +echo "" +echo "Merging done. Special case for statistical uncertainty" +for outputfile in $(find "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/output.*\.(hdr|mhd|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) +do + merge_dispatcher_uncertainty "${outputfile}" +done + if [ -f "${rundir}/params.txt" ] then echo "copying params file"