Newer
Older

Paul McCarthy
committed
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
#!/usr/bin/env fsltclsh
#{{{ FEEDS - FSL Evaluation and Example Data Suite
# Stephen Smith and Matthew Webster, FMRIB Image Analysis Group
#
# Copyright (C) 2001-2011 University of Oxford
#
# Part of FSL - FMRIB's Software Library
# http://www.fmrib.ox.ac.uk/fsl
# fsl@fmrib.ox.ac.uk
#
# Developed at FMRIB (Oxford Centre for Functional Magnetic Resonance
# Imaging of the Brain), Department of Clinical Neurology, Oxford
# University, Oxford, UK
#
#
# LICENCE
#
# FMRIB Software Library, Release 4.0 (c) 2007, The University of Oxford
# (the "Software")
#
# The Software remains the property of the University of Oxford ("the
# University").
#
# The Software is distributed "AS IS" under this Licence solely for
# non-commercial use in the hope that it will be useful, but in order
# that the University as a charitable foundation protects its assets for
# the benefit of its educational and research purposes, the University
# makes clear that no condition is made or to be implied, nor is any
# warranty given or to be implied, as to the accuracy of the Software,
# or that it will be suitable for any particular purpose or for use
# under any specific conditions. Furthermore, the University disclaims
# all responsibility for the use which is made of the Software. It
# further disclaims any liability for the outcomes arising from using
# the Software.
#
# The Licensee agrees to indemnify the University and hold the
# University harmless from and against any and all claims, damages and
# liabilities asserted by third parties (including claims for
# negligence) which arise directly or indirectly from the use of the
# Software or the sale of any products based on the Software.
#
# No part of the Software may be reproduced, modified, transmitted or
# transferred in any form or by any means, electronic or mechanical,
# without the express permission of the University. The permission of
# the University is not required if the said reproduction, modification,
# transmission or transference is done without financial return, the
# conditions of this Licence are imposed upon the receiver of the
# product, and all original and amended source code is included in any
# transmitted product. You may be held legally responsible for any
# copyright infringement that is caused or encouraged by your failure to
# abide by these terms and conditions.
#
# You are not permitted under this Licence to use this Software
# commercially. Use for which any financial return is received shall be
# defined as commercial use, and includes (1) integration of all or part
# of the source code or the Software into a product for sale or license
# by or on behalf of Licensee to third parties or (2) use of the
# Software or any derivative of it for research with the final aim of
# developing software products for sale or license to a third party or
# (3) use of the Software or any derivative of it for research with the
# final aim of developing non-software products for sale or license to a
# third party, or (4) use of the Software to provide any service to an
# external organisation for which payment is received. If you are
# interested in using the Software commercially, please contact Isis
# Innovation Limited ("Isis"), the technology transfer company of the
# University, to negotiate a licence. Contact details are:
# innovation@isis.ox.ac.uk quoting reference DE/1112.
#}}}
#{{{ perror
proc perror { testimage scale } {
global FSLDIR INDIR OUTDIR PTHRESH MAXPERROR
if { ! [ imtest $OUTDIR/$testimage ] } {
set PERROR 100
puts "No output image created"
} else {
exec sh -c "${FSLDIR}/bin/fslmaths $INDIR/$testimage -sub $OUTDIR/$testimage -sqr $OUTDIR/errsq -odt float"
exec sh -c "${FSLDIR}/bin/fslmaths $INDIR/$testimage -sqr $OUTDIR/meansq -odt float"
set PERROR [ expr int ( $scale * 10000.0 * sqrt ( \
[ exec ${FSLDIR}/bin/fslstats $OUTDIR/errsq -m ] / \
[ exec ${FSLDIR}/bin/fslstats $OUTDIR/meansq -m ] ) ) / 100.00 ]
puts "% error = $PERROR"
}
if { $PERROR > $PTHRESH } {
puts "Warning - test failed!"
}
if { $PERROR > $MAXPERROR } {
set MAXPERROR $PERROR
}
return $PERROR
}
#}}}
#{{{ simpleperror
proc simpleperror { a b denom } {
global PTHRESH MAXPERROR
set PERROR [ expr int ( 10000.0 * ( $a - $b ) / $denom ) / 100.00 ]
if { $PERROR < 0 } {
set PERROR [ expr 0 - $PERROR ]
}
puts "% error = $PERROR"
if { $PERROR > $PTHRESH } {
puts "Warning - test failed!"
}
if { $PERROR > $MAXPERROR } {
set MAXPERROR $PERROR
}
return $PERROR
}
#{{{ setup vars and first printouts
set feeds_list "fdt fugue susan sienax bet2 feat melodic first fnirt"
foreach f $feeds_list {
set feeds($f) 1
}
set OUTDIR [ lindex $argv 0 ]
set INDIR "[ lindex $argv 1 ]/originalFeeds"

Paul McCarthy
committed
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
set FSLDIR $env(FSLDIR)
set PTHRESH 1
set MAXPERROR 0
set INMEDX 0
set INGUI 0
source ${FSLDIR}/tcl/fslstart.tcl
puts "\nFSL Evaluation and Example Data Suite\n"
puts "start time = [ exec date ]"
puts "hostname = [ exec hostname ]"
puts "os = [ exec uname -a ]\n"
puts "Input directory = $INDIR"
puts "Output directory = $OUTDIR"
puts "FSLDIR = $FSLDIR"
set logout $OUTDIR/LOG
#}}}
# to add ASAP:
# filmbabe (make_flobs and filmbabe) / mm / randomise
#{{{ FUGUE
if { $feeds(fugue) } {
puts "\nStarting PRELUDE & FUGUE at [ exec date ]"
fsl:exec "${FSLDIR}/bin/prelude -c $INDIR/fieldmap -o $OUTDIR/unwrapped_phase"
perror unwrapped_phase 0.5
fsl:exec "${FSLDIR}/bin/fugue -i $INDIR/epi -p $OUTDIR/unwrapped_phase -d 0.295 -u $OUTDIR/unwarped_epi"
perror unwarped_epi 0.2
}
#}}}
#{{{ SUSAN
if { $feeds(susan) } {
puts "\nStarting SUSAN at [ exec date ]"
fsl:exec "${FSLDIR}/bin/susan $INDIR/structural 2000 2 3 1 0 $OUTDIR/structural_susan"
perror structural_susan 0.25
}
#}}}
#{{{ SIENAX
if { $feeds(sienax) } {
puts "\nStarting SIENAX (including testing BET and FLIRT and FAST) at [ exec date ]"
fsl:exec "${FSLDIR}/bin/imcp $INDIR/structural $OUTDIR/structural"
fsl:exec "cd $OUTDIR ; ${FSLDIR}/bin/sienax structural -d -r"
puts "checking error on BET:"
perror structural_sienax/I_brain 0.2
puts "checking error on FLIRT:"
perror structural_sienax/I_stdmask 0.01
puts "checking error on FAST:"
puts "checking error on single-image binary segmentation:"
perror structural_sienax/I_stdmaskbrain_seg 0.05
puts "checking error on partial volume images:"
perror structural_sienax/I_stdmaskbrain_pve_0 0.02
perror structural_sienax/I_stdmaskbrain_pve_1 0.03
perror structural_sienax/I_stdmaskbrain_pve_2 0.03
puts "checking error on SIENAX volume outputs:"
foreach sienastats { pgrey vcsf GREY WHITE BRAIN } {
set r [ exec sh -c "grep $sienastats $OUTDIR/structural_sienax/report.sienax | awk '{ print \$2 }'" ]
set d [ exec sh -c "grep $sienastats $INDIR/structural_sienax/report.sienax | awk '{ print \$2 }'" ]
simpleperror $r $d 1600000
}
}
#}}}
#{{{ BET2
if { $feeds(bet2) } {
puts "\nStarting BET2 at [ exec date ]"
fsl:exec "/bin/cp $INDIR/head_t?.nii.gz $OUTDIR"
fsl:exec "cd $OUTDIR ; ${FSLDIR}/bin/bet head_t1 head_t1_brain -A2 head_t2"
puts "checking error on T1 brain extraction:"
perror head_t1_brain 0.05
puts "checking error on skull and scalp surfaces:"
perror head_t1_brain_inskull_mesh .01
perror head_t1_brain_outskull_mesh .01
perror head_t1_brain_outskin_mesh .01
}
#}}}
#{{{ FEAT
if { $feeds(feat) } {
puts "\nStarting FEAT at [ exec date ]"
# fix FEAT setup file to use INDIR, OUTDIR and FSLDIR
fsl:exec "cp ${INDIR}/fmri.feat/design.fsf ${OUTDIR}/design.fsf"
fsl:echo ${OUTDIR}/design.fsf "
set fmri(regstandard) ${FSLDIR}/data/standard/MNI152_T1_2mm_brain
set feat_files(1) ${INDIR}/fmri
set highres_files(1) ${INDIR}/structural_brain
set fmri(outputdir) ${OUTDIR}/fmri.feat"
# run FEAT
fsl:exec "${FSLDIR}/bin/feat ${OUTDIR}/design.fsf"
puts "checking error on filtered functional data:"
perror fmri.feat/filtered_func_data 0.1
puts "checking error on raw Z stat images:"
perror fmri.feat/stats/zstat1 0.02
perror fmri.feat/stats/zstat2 0.02
perror fmri.feat/stats/zfstat1 0.02
puts "checking error on thresholded Z stat images:"
perror fmri.feat/thresh_zstat1 0.02
perror fmri.feat/thresh_zstat2 0.02
perror fmri.feat/thresh_zfstat1 0.02
puts "checking error on registration images:"
perror fmri.feat/reg/example_func2highres 0.02
perror fmri.feat/reg/example_func2standard 0.02
#{{{ check error on largest cluster of Talairached zfstat1
puts "checking error on position of largest cluster of Talairached zfstat1:"
set iptr [ open ${INDIR}/fmri.feat/cluster_zfstat1_std.txt r ]
gets $iptr line
gets $iptr line
scan $line "%f %f %f %f %f %f %f %f %f" D(1) D(2) D(3) D(4) D(5) D(6) D(7) D(8) D(9)
close $iptr
set iptr [ open ${OUTDIR}/fmri.feat/cluster_zfstat1_std.txt r ]
gets $iptr line
gets $iptr line
scan $line "%f %f %f %f %f %f %f %f %f %f %f" R(1) R(2) R(3) R(4) R(5) R(6) R(7) R(8) R(9) R(10) R(11)
close $iptr
simpleperror $D(4) $R(6) 500
simpleperror $D(5) $R(7) 500
simpleperror $D(6) $R(8) 500
simpleperror $D(7) $R(9) 500
simpleperror $D(8) $R(10) 500
simpleperror $D(9) $R(11) 500
#}}}
}
#}}}
#{{{ MELODIC
if { $feeds(melodic) } {
puts "\nStarting MELODIC at [ exec date ]"
fsl:exec "${FSLDIR}/bin/melodic -i $INDIR/fmri -o $OUTDIR/fmri.ica --tr=3 --seed=2"
fsl:exec "${FSLDIR}/bin/fslcc $INDIR/fmri.ica/melodic_IC $OUTDIR/fmri.ica/melodic_IC > $OUTDIR/fmri.ica/fslcc.txt"
set MAXV 0
set MAXA 0
set iptr [ open $OUTDIR/fmri.ica/fslcc.txt r ]
while { ( [ gets $iptr line ] >= 0 ) } {
scan $line "%d %d %f" A B C
if { $A == 52 } {
if { $C > $MAXV } {
set MAXV $C
}
}
if { $A == 39 } {
if { $C > $MAXA } {
set MAXA $C
}
}
}
close $iptr
if { $MAXA < $MAXV } {
set MAXV $MAXA
}
simpleperror $MAXV 1 60
}
#}}}
#{{{ FIRST
if { $feeds(first) } {
puts "\nStarting FIRST at [ exec date ]"
fsl:exec "${FSLDIR}/bin/first_flirt $INDIR/structural $OUTDIR/structural_to_std_sub"
fsl:exec "${FSLDIR}/bin/run_first -i $INDIR/structural -t $OUTDIR/structural_to_std_sub.mat -n 20 -o $OUTDIR/structural_first_L_Hipp -m ${FSLDIR}/data/first/models_336_bin/L_Hipp_bin.bmv"
perror structural_first_L_Hipp 0.01
}
#}}}
#{{{ FDT
if { $feeds(fdt) } {
puts "\nStarting FDT (bedpost) at [ exec date ]"
fsl:exec "cp -r $INDIR/fdt_subj1 $OUTDIR"
fsl:exec "unset FSLMACHINELIST; ${FSLDIR}/bin/bedpostx $OUTDIR/fdt_subj1 -n 1"
puts "checking error on bedpost output:"
perror fdt_subj1.bedpostX/dyads1 .005
perror fdt_subj1.bedpostX/mean_f1samples .005
perror fdt_subj1.bedpostX/mean_ph1samples .003
perror fdt_subj1.bedpostX/mean_th1samples .002
perror fdt_subj1.bedpostX/merged_f1samples .005
perror fdt_subj1.bedpostX/merged_ph1samples .003
perror fdt_subj1.bedpostX/merged_th1samples .002
}
if { $feeds(fnirt) } {
puts "\nStarting FNIRT at [ exec date ]"
fsl:exec "cp -r $INDIR/feeds_fnirt* $OUTDIR"
fsl:exec "cp -r $INDIR/sad* $OUTDIR"
fsl:exec "cp -r $INDIR/happy* $OUTDIR"
set cwd [ pwd ]
cd $OUTDIR
fsl:exec "${FSLDIR}/bin/fnirt --config=feeds_fnirt"
cd $cwd
perror feeds_fnirt_sad2happy 0.1
}
#}}}
#{{{ finish up
puts "\nend time = [ exec date ]\n"
if { $MAXPERROR < $PTHRESH } {
puts "\nAll tests passed"
exit 0
} else {
puts "\nWarning - not all tests passed"
exit 1
}
#}}}