-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreconstruction.sh
executable file
·81 lines (65 loc) · 1.49 KB
/
reconstruction.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
81
#!/bin/bash
#Developed by: Ivan Legorreta
#Contact information: ilegorreta@outlook.com
cd $1
cd Best_Images_crop
#appDirTBB="/neuro/arch/Linux64/packages/irtk/build-tbb-rc/bin"
appDirTBB="/neuro/labs/grantlab/research/Fetal_MRI/IRTK/build/bin/"
imageDir=$(pwd)
transformDir=""
TIMESTAMP=`date "+%m-%d-%Y - %Hhr:%Mmin:%Sseg"`
IMAGES=$(ls *.nii)
declare -A array
for IMAGE in $IMAGES
do
position=$(awk -F"." '{print NF-1}' <<< "${IMAGE}")
score=$(echo $IMAGE | cut -d'.' -f $position)
if [ "$score" = "00" ]
then
score="9999"
fi
array[$IMAGE]=$score
done
KEYS=$(
for KEY in ${!array[@]}; do
echo "${array[$KEY]}:::$KEY"
done | sort -rn | awk -F::: '{print $2}'
)
array2=()
for val in $KEYS; do
array2+=($val)
done
if [ $2 == 2 ]
then
TEMP2=${array2[0]}
array2[0]=${array2[1]}
array2[1]=$TEMP2
elif [ $2 == 3 ]
then
TEMP2=${array2[0]}
array2[0]=${array2[2]}
array2[2]=$TEMP2
fi
IMAGESCOUNT=${#array2[@]}
IMAGES_NAMES=$''
IMAGES2=$''
#IDS=$''
ONES=$''
THICKNESS=$''
for i in "${array2[@]}"
do
IMAGES_NAMES+=$imageDir'/'$i' '
#IDS+='id '
ONES+='1 '
TEMP=$(echo ${i:0:3})
THICKNESS+=$TEMP
THICKNESS+=' '
IMAGES2+=$i' '
done
echo Reconstruction order:
echo $IMAGES2 at $TIMESTAMP >> $"reconstruction_order.txt"
echo >> $"reconstruction_order.txt"
mkdir recon
cd recon
#$appDirTBB/reconstruction recon.nii $IMAGESCOUNT $IMAGES_NAMES $IDS -thickness $THICKNESS -debug -packages $ONES
$appDirTBB/reconstruction recon.nii $IMAGESCOUNT $IMAGES_NAMES -thickness $THICKNESS -debug -packages $ONES