16
16
from nipype .interfaces .fsl import no_fsl , Info
17
17
18
18
19
+ def set_output_type (fsl_output_type = None ):
20
+ prev_output_type = os .environ .get ('FSLOUTPUTTYPE' , None )
21
+ if fsl_output_type is not None :
22
+ os .environ ['FSLOUTPUTTYPE' ] = fsl_output_type
23
+ return prev_output_type
24
+
19
25
def create_files_in_directory ():
20
26
testdir = os .path .realpath (mkdtemp ())
21
27
origdir = os .getcwd ()
@@ -40,7 +46,8 @@ def clean_directory(testdir, origdir):
40
46
41
47
42
48
@skipif (no_fsl )
43
- def test_maths_base ():
49
+ def test_maths_base (fsl_output_type = None ):
50
+ prev_type = set_output_type (fsl_output_type )
44
51
files , testdir , origdir , out_ext = create_files_in_directory ()
45
52
46
53
# Get some fslmaths
@@ -78,9 +85,11 @@ def test_maths_base():
78
85
79
86
# Clean up our mess
80
87
clean_directory (testdir , origdir )
88
+ set_output_type (prev_type )
81
89
82
90
@skipif (no_fsl )
83
- def test_changedt ():
91
+ def test_changedt (fsl_output_type = None ):
92
+ prev_type = set_output_type (fsl_output_type )
84
93
files , testdir , origdir , out_ext = create_files_in_directory ()
85
94
86
95
# Get some fslmaths
@@ -108,9 +117,11 @@ def test_changedt():
108
117
109
118
# Clean up our mess
110
119
clean_directory (testdir , origdir )
120
+ set_output_type (prev_type )
111
121
112
122
@skipif (no_fsl )
113
- def test_threshold ():
123
+ def test_threshold (fsl_output_type = None ):
124
+ prev_type = set_output_type (fsl_output_type )
114
125
files , testdir , origdir , out_ext = create_files_in_directory ()
115
126
116
127
# Get the command
@@ -142,10 +153,12 @@ def test_threshold():
142
153
143
154
# Clean up our mess
144
155
clean_directory (testdir , origdir )
156
+ set_output_type (prev_type )
145
157
146
158
147
159
@skipif (no_fsl )
148
- def test_meanimage ():
160
+ def test_meanimage (fsl_output_type = None ):
161
+ prev_type = set_output_type (fsl_output_type )
149
162
files , testdir , origdir , out_ext = create_files_in_directory ()
150
163
151
164
# Get the command
@@ -169,9 +182,11 @@ def test_meanimage():
169
182
170
183
# Clean up our mess
171
184
clean_directory (testdir , origdir )
185
+ set_output_type (prev_type )
172
186
173
187
@skipif (no_fsl )
174
- def test_maximage ():
188
+ def test_maximage (fsl_output_type = None ):
189
+ prev_type = set_output_type (fsl_output_type )
175
190
files , testdir , origdir , out_ext = create_files_in_directory ()
176
191
177
192
# Get the command
@@ -195,9 +210,11 @@ def test_maximage():
195
210
196
211
# Clean up our mess
197
212
clean_directory (testdir , origdir )
213
+ set_output_type (prev_type )
198
214
199
215
@skipif (no_fsl )
200
- def test_smooth ():
216
+ def test_smooth (fsl_output_type = None ):
217
+ prev_type = set_output_type (fsl_output_type )
201
218
files , testdir , origdir , out_ext = create_files_in_directory ()
202
219
203
220
# Get the command
@@ -224,9 +241,11 @@ def test_smooth():
224
241
225
242
# Clean up our mess
226
243
clean_directory (testdir , origdir )
244
+ set_output_type (prev_type )
227
245
228
246
@skipif (no_fsl )
229
- def test_mask ():
247
+ def test_mask (fsl_output_type = None ):
248
+ prev_type = set_output_type (fsl_output_type )
230
249
files , testdir , origdir , out_ext = create_files_in_directory ()
231
250
232
251
# Get the command
@@ -248,10 +267,12 @@ def test_mask():
248
267
249
268
# Clean up our mess
250
269
clean_directory (testdir , origdir )
270
+ set_output_type (prev_type )
251
271
252
272
253
273
@skipif (no_fsl )
254
- def test_dilation ():
274
+ def test_dilation (fsl_output_type = None ):
275
+ prev_type = set_output_type (fsl_output_type )
255
276
files , testdir , origdir , out_ext = create_files_in_directory ()
256
277
257
278
# Get the command
@@ -290,9 +311,11 @@ def test_dilation():
290
311
291
312
# Clean up our mess
292
313
clean_directory (testdir , origdir )
314
+ set_output_type (prev_type )
293
315
294
316
@skipif (no_fsl )
295
- def test_erosion ():
317
+ def test_erosion (fsl_output_type = None ):
318
+ prev_type = set_output_type (fsl_output_type )
296
319
files , testdir , origdir , out_ext = create_files_in_directory ()
297
320
298
321
# Get the command
@@ -314,9 +337,11 @@ def test_erosion():
314
337
315
338
# Clean up our mess
316
339
clean_directory (testdir , origdir )
340
+ set_output_type (prev_type )
317
341
318
342
@skipif (no_fsl )
319
- def test_spatial_filter ():
343
+ def test_spatial_filter (fsl_output_type = None ):
344
+ prev_type = set_output_type (fsl_output_type )
320
345
files , testdir , origdir , out_ext = create_files_in_directory ()
321
346
322
347
# Get the command
@@ -339,10 +364,12 @@ def test_spatial_filter():
339
364
340
365
# Clean up our mess
341
366
clean_directory (testdir , origdir )
367
+ set_output_type (prev_type )
342
368
343
369
344
370
@skipif (no_fsl )
345
- def test_unarymaths ():
371
+ def test_unarymaths (fsl_output_type = None ):
372
+ prev_type = set_output_type (fsl_output_type )
346
373
files , testdir , origdir , out_ext = create_files_in_directory ()
347
374
348
375
# Get the command
@@ -367,10 +394,12 @@ def test_unarymaths():
367
394
368
395
# Clean up our mess
369
396
clean_directory (testdir , origdir )
397
+ set_output_type (prev_type )
370
398
371
399
372
400
@skipif (no_fsl )
373
- def test_binarymaths ():
401
+ def test_binarymaths (fsl_output_type = None ):
402
+ prev_type = set_output_type (fsl_output_type )
374
403
files , testdir , origdir , out_ext = create_files_in_directory ()
375
404
376
405
# Get the command
@@ -403,10 +432,12 @@ def test_binarymaths():
403
432
404
433
# Clean up our mess
405
434
clean_directory (testdir , origdir )
435
+ set_output_type (prev_type )
406
436
407
437
408
438
@skipif (no_fsl )
409
- def test_multimaths ():
439
+ def test_multimaths (fsl_output_type = None ):
440
+ prev_type = set_output_type (fsl_output_type )
410
441
files , testdir , origdir , out_ext = create_files_in_directory ()
411
442
412
443
# Get the command
@@ -434,10 +465,12 @@ def test_multimaths():
434
465
435
466
# Clean up our mess
436
467
clean_directory (testdir , origdir )
468
+ set_output_type (prev_type )
437
469
438
470
439
471
@skipif (no_fsl )
440
- def test_tempfilt ():
472
+ def test_tempfilt (fsl_output_type = None ):
473
+ prev_type = set_output_type (fsl_output_type )
441
474
files , testdir , origdir , out_ext = create_files_in_directory ()
442
475
443
476
# Get the command
@@ -463,5 +496,16 @@ def test_tempfilt():
463
496
464
497
# Clean up our mess
465
498
clean_directory (testdir , origdir )
499
+ set_output_type (prev_type )
466
500
467
-
501
+ @skipif (no_fsl )
502
+ def test_all_again ():
503
+ # Rerun tests with all file types
504
+ all_func = [test_binarymaths , test_changedt , test_dilation , test_erosion ,
505
+ test_mask , test_maximage , test_meanimage , test_multimaths ,
506
+ test_smooth , test_tempfilt , test_threshold , test_unarymaths ]
507
+
508
+ for output_type in Info .ftypes :
509
+ for func in all_func :
510
+ for test in func (output_type ):
511
+ yield test
0 commit comments