-
Notifications
You must be signed in to change notification settings - Fork 0
/
close.sh
executable file
·301 lines (278 loc) · 5.96 KB
/
close.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#!/bin/bash
#refexe is reference executable, e.g. validated copy of fslmaths
# we assume it is in the users path
# however, this could be set explicitly, e.g.
# refexe="/Users/cr/fslmaths" batch.sh
refexe=${refexe:-fslmaths}
#newexe is new executable, e.g. we want to make sure if gives the same results as refexe
# this could also be set explicitly, e.g.
# refexe="/Users/cr/fslmaths" batch.sh
newexe=${newexe:-niimath}
#basedir is folder with "In" subfolder.
# we assume it is the same same folder as the script
# however, this could be set explicitly, e.g.
# basedir="/Users/cr/niitest" batch.sh
if [ -z ${basedir:-} ]; then
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
#### no need to edit subsequent lines
# Fail if anything not planed to go wrong, goes wrong
# set -eu
# Test if command exists.
exists() {
test -x "$(command -v "$1")"
}
# Check executables.
exists $refexe ||
{
echo >&2 "I require $refexe but it's not installed. Aborting."
exit 1
}
exists $newexe ||
{
echo >&2 "I require $newexe but it's not installed. Aborting."
exit 1
}
#folder paths
indir=${basedir}/In
newdir=${basedir}/New
refdir=${basedir}/Ref
if [ ! -d "$indir" ]; then
echo "Error: Unable to find $indir"
exit 1
fi
if [ ! -d "$refdir" ]; then
mkdir $refdir
fi
if [ ! -z "$(ls $refdir)" ]; then
echo "Cleaning output directory: $refdir"
rm $refdir/*
fi
if [ ! -d "$newdir" ]; then
mkdir $newdir
fi
if [ ! -z "$(ls $newdir)" ]; then
echo "Cleaning output directory: $newdir"
rm $newdir/*
fi
# Convert images.
refout="$refdir/img"
newout="$newdir/img"
echo Testing Bandpass temporal filter
inimg="$indir/rest4D"
# high pass
cmd="$refexe $inimg -bptf 25 -1 $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -bptf 25 -1 $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
# low pass
cmd="$refexe $inimg -bptf -1 5 $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -bptf -1 5 $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
# band pass
cmd="$refexe $inimg -bptf 25 5 $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -bptf 25 5 $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
echo ALL TESTS DONE
exit 0
echo Testing Basic statistical operations: ties impact rank and ranknorm
ops="rank ranknorm"
inimg="$indir/no_ties"
for op in $ops; do
cmd="$refexe $inimg -$op $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -$op $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
done
echo Testing Kernel operations: dilD and dilall are not exact
ops="fmedian dilM dilF ero eroF fmean fmeanu dilD dilall"
inimg="$indir/trick"
for op in $ops; do
cmd="$refexe $inimg -$op $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -$op $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
#test with spherical kernal
cmd="$refexe $inimg -kernel sphere 8 -$op $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -kernel sphere 8 -$op $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
done
ops="fmedian dilM dilD dilF dilall ero eroF fmean fmeanu"
inimg="$indir/trick"
for op in $ops; do
cmd="$refexe $inimg -$op $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -$op $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
done
imgs="tfLAS tfRAS"
echo Testing TFCE
for img in $imgs; do
inimg="$indir/$img"
cmd="$refexe $inimg -tfce 2 0.5 6 $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -tfce 2 0.5 6 $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
cmd="$refexe $inimg -tfceS 0.01 0.5 6 59 47 61 0.01 $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -tfceS 0.01 0.5 6 59 47 61 0.01 $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
done
#ALMOST subsampling
ops="subsamp2 subsamp2offc"
imgs="LAS RAS LAS1 RAS1"
echo Testing Dimensionality reduction
for op in $ops; do
for img in $imgs; do
inimg="$indir/$img"
cmd="$refexe $inimg -$op $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -$op $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
done
done
#ALMOST identical Xar1 Yar1 Zar1
ops="Xar1 Yar1 Zar1"
echo Testing Dimensionality reduction
for op in $ops; do
inimg="$indir/trick"
cmd="$refexe $inimg -$op $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -$op $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
done
echo Testing Gaussian blur
inimg="$indir/trick"
cmd="$refexe $inimg -s 2.26 $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -s 2.26 $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
#diffusion
imgs="tensorRAS tensorLAS"
echo Testing Dimensionality reduction
for img in $imgs; do
inimg="$indir/$img"
cmd="$refexe $inimg -tensor_decomp $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -tensor_decomp $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
tst="$newexe ${refout}_V1 --compare ${newout}_V1"
echo $tst
$tst
tst="$newexe ${refout}_V2 --compare ${newout}_V2"
echo $tst
$tst
tst="$newexe ${refout}_V3 --compare ${newout}_V3"
echo $tst
$tst
tst="$newexe ${refout}_MO --compare ${newout}_MO"
echo $tst
$tst
done
ops="Tar1 Xar1 Yar1 Zar1"
echo Testing Dimensionality reduction
for op in $ops; do
inimg="$indir/trick"
cmd="$refexe $inimg -$op $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -$op $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
done
echo Testing Basic Statistical Operations
inimg="$indir/stat3D"
cmd="$refexe $inimg -ztop $refout"
echo $cmd
$cmd
cmd="$newexe $inimg -ztop $newout"
echo $cmd
$cmd
tst="$newexe $refout --compare $newout"
echo $tst
$tst
refoutz="$refdir/refz"
newoutz="$newdir/newz"
inimg="$indir/stat3D"
cmd="$refexe $refout -ptoz $refoutz"
echo $cmd
$cmd
cmd="$newexe $newout -ptoz $newoutz"
echo $cmd
$cmd
tst="$newexe $refoutz --compare $newoutz"
echo $tst
$tst
echo ALL TESTS DONE
exit 0