-
Notifications
You must be signed in to change notification settings - Fork 3
/
transform.sh
executable file
·80 lines (62 loc) · 1.86 KB
/
transform.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
start=`date +%s`
function launch {
echo "*************************************************************"
echo "Executing : $1 "
$1
echo "*************************************************************"
}
# Inspired from NiftyReg script : https://sourceforge.net/p/niftyreg/git/ci/master/tree/reg-apps/groupwise_niftyreg_run.sh
if [ $# -lt 2 ]
then
echo ""
echo "*******************************************************************************"
echo "Two arguments are expected to run this script:"
echo "- File with contains parameters"
echo "- output spacing"
echo "example: $0 params.sh 2 "
echo "*******************************************************************************"
echo ""
exit
fi
# read input parameters
. $1
# check arguments
if [ ${#IMG_INPUT[@]} -lt 2 ]
then
echo "Less than 2 images have been specified"
echo "Exit ..."
exit
fi
IMG_NUMBER=${#IMG_INPUT[@]}
echo ""
echo "******************************************************"
echo ">>> There are ${IMG_NUMBER} input images to transform :"
for (( CUR_IT=0; CUR_IT<${IMG_NUMBER}; CUR_IT++ ))
do
echo ${IMG_INPUT[CUR_IT]}
done
echo "******************************************************"
# SETUP EXECUTABLES
ROOT_DIR=$(cd `dirname $0` && pwd)
AVERAGEVOLUMES=$ROOT_DIR/bin/AverageVolumes
DUMMYVOLUMEGENERATOR=$ROOT_DIR/bin/DummyVolumeGenerator
VOLUMETRANSFORM=$ROOT_DIR/bin/VolumeTransform
cd $RES_FOLDER
launch "$DUMMYVOLUMEGENERATOR bbox.json $2"
files="";
for (( CUR_IT=0; CUR_IT<${IMG_NUMBER}; CUR_IT++ ))
do
IMG=${IMG_INPUT[CUR_IT]};
TRANS=transformed$CUR_IT.nii.gz
if [ ! -e "$TRANS" ]; then
launch "$VOLUMETRANSFORM $IMG dummy.mhd -t transforms/$CUR_IT.json -o $TRANS"
else
echo "Transformed file $TRANS already exists, skip transformation"
fi
files+=" $TRANS"
done
launch "$AVERAGEVOLUMES $files"
end=`date +%s`
runtime=$((end-start))
echo "Total processing time : $runtime seconds"