X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=scripts%2Fmidp_common.sh;h=1ac9529223840adf5bbb52232e172dc91839378e;hb=9b9e0b969b87e4e5799436d503e9cde6ea551ca7;hp=aa500ae9a959885bd66eb8ee1cbf82426565e8ea;hpb=1d616cc7be31f7195c8bba4142e02350cd2fb958;p=clitk.git diff --git a/scripts/midp_common.sh b/scripts/midp_common.sh index aa500ae..1ac9529 100755 --- a/scripts/midp_common.sh +++ b/scripts/midp_common.sh @@ -18,9 +18,9 @@ abort_on_error() { if [ $2 != 0 ]; then echo Aborted at $1 with code $2 - if [ $# = 3 ]; then - eval $3 - fi + #if [ $# = 3 ]; then + # eval $3 + #fi exit $2 fi @@ -173,3 +173,39 @@ extract_4d_phases_ref() fi done } + +# +# replacement for clitkCombineImage +combine_image() +{ +# eg: -i $result_in -j $result_out -o $out_result -m $motion_mask + local tmp1=$RANDOM + local tmp2=$RANDOM + + clitkSetBackground -i $1 -o $tmp1.mhd -m $4 + clitkSetBackground -i $2 -o $tmp2.mhd -m $4 --fg + + clitkImageArithm -i $tmp1.mhd -j $tmp2.mhd -o $3 + rm $tmp1.* $tmp2.* +} + +# +# replacement for clitkAverageTemporalDimension +average_temporal_dimension() +{ + # eg: -i $midp_dir/midp_4D.mhd -o $midp_dir/midp_avg.mhd + local tmp=$RANDOM + local tot=$tmp.mhd + + local dir=`dirname $1` + local first=`grep raw $1 | sed 's/raw/mhd/g' | head -n 1` + clitkImageArithm -i $dir/$first -o $tot -t 1 -s 0 + + local nbphases=`grep raw $1 | sed 's/raw/mhd/g' | wc -l` + for i in $(grep raw $1 | sed 's/raw/mhd/g'); do + clitkImageArithm -i $dir/$i -j $tot -o $tot + done + + clitkImageArithm -i $tot -o $2 -t 11 -s $nbphases + rm $tmp.* +}