-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathants_reference_registration.sh
executable file
·129 lines (114 loc) · 2.98 KB
/
ants_reference_registration.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
# @Author: Jose Tascon
# @Date: 2020-04-17 15:58:54
# @Last Modified by: Jose Tascon
# @Last Modified time: 2021-10-12 22:32:11
register_referenced ()
{
# Argument 1: patient name
# Argument 2: images folder
# Argument 3: transform folder
# Argument 4: nthreads;
# Argument 5: debug
# Argument 6: verbose
# Argument 7: affine
echo; echo "Referenced Registration with ANTS"
echo;
opt="-l"
if [ $5 = true ]; then
opt="-d ${opt}"
fi
if [ $6 = true ]; then
opt="-v ${opt}"
fi
if [ $7 = true ]; then
opt="-a ${opt}"
fi
echo "mkdir -p $3/$1/"
mkdir -p $3/$1/
cmd="python register_referenced_ants.py ${opt} -n $4 $2/$1/fractions/ $3/$1/"
echo ${cmd}
echo;
${cmd}
}
############################################################
# Help #
############################################################
usage()
{
# Display Help
echo "Register images to a reference with ANTS."
echo
echo "Syntax: ants_reference_registration.sh [-h|v|d|a] -i input -o output [option -n <int>]"
echo "options:"
echo "i Input folder with patients image data"
echo "o Output folder with transformations"
echo "n Number of threads. Default: 16"
echo "a Affine mode."
echo "v Verbose mode."
echo "d Debug mode."
echo "h Print help."
echo
}
############################################################
# Main program #
############################################################
# Set variables
input=""
output=""
affine=false
verbose=false
debug=false
nthreads=16
############################################################
# Process the input options. Add options as needed. #
############################################################
# Get the options
while getopts ":hvdai:o:n:" option; do
case $option in
h) # display Help
usage
exit;;
i) # Input
input=$OPTARG;;
o) # Output
output=$OPTARG;;
n) # Output
nthreads=$OPTARG;;
a) # Affine
affine=true;;
v) # Verbose
verbose=true;;
d) # Debug
debug=true;;
\?) # Invalid option
echo "Error: Invalid option";
usage;
exit;;
esac
done
if [ "$input" = "" ]; then
echo "Missing input argument";
usage
exit 1;
fi
if [ "$output" = "" ]; then
echo "Missing output argument";
usage
exit 1;
fi
isint='^[0-9]+$'
if ! [[ $nthreads =~ $isint ]] ; then
echo "Error: nthreads is not an integer number";
usage;
exit 1;
fi
echo $nthreads > nthreads.txt
# input=/mnt/data/radiotherapy/liver/images/
# output=/mnt/data/radiotherapy/liver/transforms/
# echo "input: ${input} output: ${output} verbose: ${verbose} debug: ${debug}"
# Run all
for pt in $(ls ${input})
do
register_referenced ${pt} ${input} ${output} "nthreads.txt" ${debug} ${verbose} ${affine}
done