-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathants_reference_transform.sh
executable file
·106 lines (93 loc) · 2.47 KB
/
ants_reference_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
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
#!/bin/bash
# @Author: Jose Tascon
# @Date: 2020-04-17 15:58:54
# @Last Modified by: Jose Tascon
# @Last Modified time: 2021-10-12 21:42:31
transform_referenced ()
{
# Argument 1: patient name
# Argument 2: images folder
# Argument 3: transform folder
# Argument 4: debug
# Argument 5: verbose
echo; echo "Transform with ANTS"
echo;
opt=""
if [ $4 = true ]; then
opt="-d ${opt}"
fi
if [ $5 = true ]; then
opt="-v ${opt}"
fi
cmd="python transform_referenced_ants.py $opt $2/$1/fractions/$1_fraction00.nrrd \
$2/$1/doses/ $3/$1/ants/ $3/$1/"
echo ${cmd}
echo;
${cmd}
}
############################################################
# Help #
############################################################
usage()
{
# Display Help
echo "Transform images to a reference with ANTS."
echo
echo "Syntax: ants_reference_transform.sh [-h|v|d] -i input -o output"
echo "options:"
echo "i Input folder with patients image data"
echo "o Output folder with transformations"
echo "v Verbose mode."
echo "d Debug mode."
echo "h Print help."
echo
}
############################################################
# Main program #
############################################################
# Set variables
input=""
output=""
verbose=false
debug=false
############################################################
# Process the input options. Add options as needed. #
############################################################
# Get the options
while getopts ":hvdi:o:" option; do
case $option in
h) # display Help
usage
exit;;
i) # Input
input=$OPTARG;;
o) # Output
output=$OPTARG;;
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
# 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
transform_referenced ${pt} ${input} ${output} ${debug} ${verbose}
done