@@ -23,13 +23,16 @@ class MathsInput(FSLCommandInputSpec):
23
23
24
24
in_file = File (position = 2 , argstr = "%s" , exists = True , mandatory = True ,
25
25
desc = "image to operate on" )
26
- out_file = File (genfile = True , position = - 2 , argstr = "%s" , desc = "image to write" , hash_files = False )
26
+ out_file = File (genfile = True , position = - 2 , argstr = "%s" ,
27
+ desc = "image to write" , hash_files = False )
27
28
_dtypes = ["float" , "char" , "int" , "short" , "double" , "input" ]
28
29
internal_datatype = traits .Enum (* _dtypes , position = 1 , argstr = "-dt %s" ,
29
- desc = "datatype to use for calculations (default is float)" )
30
+ desc = ("datatype to use for calculations "
31
+ "(default is float)" ))
30
32
output_datatype = traits .Enum (* _dtypes ,
31
33
position = - 1 , argstr = "-odt %s" ,
32
- desc = "datatype to use for output (default uses input type)" )
34
+ desc = ("datatype to use for output (default "
35
+ "uses input type)" ))
33
36
34
37
nan2zeros = traits .Bool (position = 3 , argstr = '-nan' ,
35
38
desc = 'change NaNs to zeros before doing anything' )
@@ -51,7 +54,8 @@ def _list_outputs(self):
51
54
outputs = self .output_spec ().get ()
52
55
outputs ["out_file" ] = self .inputs .out_file
53
56
if not isdefined (self .inputs .out_file ):
54
- outputs ["out_file" ] = self ._gen_fname (self .inputs .in_file , suffix = self ._suffix )
57
+ outputs ["out_file" ] = self ._gen_fname (self .inputs .in_file ,
58
+ suffix = self ._suffix )
55
59
outputs ["out_file" ] = os .path .abspath (outputs ["out_file" ])
56
60
return outputs
57
61
@@ -65,7 +69,8 @@ class ChangeDataTypeInput(MathsInput):
65
69
66
70
_dtypes = ["float" , "char" , "int" , "short" , "double" , "input" ]
67
71
output_datatype = traits .Enum (* _dtypes ,
68
- position = - 1 , argstr = "-odt %s" , mandatory = True ,
72
+ position = - 1 , argstr = "-odt %s" ,
73
+ mandatory = True ,
69
74
desc = "output data type" )
70
75
71
76
@@ -83,9 +88,11 @@ class ThresholdInputSpec(MathsInput):
83
88
desc = "threshold value" )
84
89
direction = traits .Enum ("below" , "above" , usedefault = True ,
85
90
desc = "zero-out either below or above thresh value" )
86
- use_robust_range = traits .Bool (desc = "interpret thresh as percentage (0-100) of robust range" )
87
- use_nonzero_voxels = traits .Bool (desc = "use nonzero voxels to calculate robust range" ,
88
- requires = ["use_robust_range" ])
91
+ use_robust_range = traits .Bool (
92
+ desc = "interpret thresh as percentage (0-100) of robust range" )
93
+ use_nonzero_voxels = traits .Bool (
94
+ desc = "use nonzero voxels to calculate robust range" ,
95
+ requires = ["use_robust_range" ])
89
96
90
97
91
98
class Threshold (MathsCommand ):
@@ -103,29 +110,35 @@ def _format_arg(self, name, spec, value):
103
110
arg += "u"
104
111
arg += "thr"
105
112
if isdefined (_si .use_robust_range ) and _si .use_robust_range :
106
- if isdefined (_si .use_nonzero_voxels ) and _si .use_nonzero_voxels :
113
+ if (isdefined (_si .use_nonzero_voxels ) and
114
+ _si .use_nonzero_voxels ):
107
115
arg += "P"
108
116
else :
109
117
arg += "p"
110
118
arg += " %.10f" % value
111
119
return arg
112
120
return super (Threshold , self )._format_arg (name , spec , value )
113
121
122
+
114
123
class StdImageInput (MathsInput ):
115
124
116
- dimension = traits .Enum ("T" , "X" , "Y" , "Z" , usedefault = True , argstr = "-%sstd" , position = 4 ,
125
+ dimension = traits .Enum ("T" , "X" , "Y" , "Z" , usedefault = True ,
126
+ argstr = "-%sstd" , position = 4 ,
117
127
desc = "dimension to standard deviate across" )
118
128
119
129
120
130
class StdImage (MathsCommand ):
121
- """Use fslmaths to generate a standard deviation in an image across a given dimension.
131
+ """Use fslmaths to generate a standard deviation in an image across a given
132
+ dimension.
122
133
"""
123
134
input_spec = StdImageInput
124
135
_suffix = "_std"
125
136
137
+
126
138
class MeanImageInput (MathsInput ):
127
139
128
- dimension = traits .Enum ("T" , "X" , "Y" , "Z" , usedefault = True , argstr = "-%smean" , position = 4 ,
140
+ dimension = traits .Enum ("T" , "X" , "Y" , "Z" , usedefault = True ,
141
+ argstr = "-%smean" , position = 4 ,
129
142
desc = "dimension to mean across" )
130
143
131
144
@@ -139,7 +152,8 @@ class MeanImage(MathsCommand):
139
152
140
153
class MaxImageInput (MathsInput ):
141
154
142
- dimension = traits .Enum ("T" , "X" , "Y" , "Z" , usedefault = True , argstr = "-%smax" , position = 4 ,
155
+ dimension = traits .Enum ("T" , "X" , "Y" , "Z" , usedefault = True ,
156
+ argstr = "-%smax" , position = 4 ,
143
157
desc = "dimension to max across" )
144
158
145
159
@@ -162,9 +176,11 @@ class MaxImage(MathsCommand):
162
176
163
177
class IsotropicSmoothInput (MathsInput ):
164
178
165
- fwhm = traits .Float (mandatory = True , xor = ["sigma" ], position = 4 , argstr = "-s %.5f" ,
179
+ fwhm = traits .Float (mandatory = True , xor = ["sigma" ],
180
+ position = 4 , argstr = "-s %.5f" ,
166
181
desc = "fwhm of smoothing kernel [mm]" )
167
- sigma = traits .Float (mandatory = True , xor = ["fwhm" ], position = 4 , argstr = "-s %.5f" ,
182
+ sigma = traits .Float (mandatory = True , xor = ["fwhm" ],
183
+ position = 4 , argstr = "-s %.5f" ,
168
184
desc = "sigma of smoothing kernel [mm]" )
169
185
170
186
@@ -198,17 +214,22 @@ class ApplyMask(MathsCommand):
198
214
199
215
class KernelInput (MathsInput ):
200
216
201
- kernel_shape = traits .Enum ("3D" , "2D" , "box" , "boxv" , "gauss" , "sphere" , "file" ,
202
- argstr = "-kernel %s" , position = 4 , desc = "kernel shape to use" )
217
+ kernel_shape = traits .Enum ("3D" , "2D" , "box" , "boxv" , "gauss" , "sphere" ,
218
+ "file" ,
219
+ argstr = "-kernel %s" , position = 4 ,
220
+ desc = "kernel shape to use" )
203
221
kernel_size = traits .Float (argstr = "%.4f" , position = 5 , xor = ["kernel_file" ],
204
- desc = "kernel size - voxels for box/boxv, mm for sphere, mm sigma for gauss" )
205
- kernel_file = File (exists = True , argstr = "%s" , position = 5 , xor = ["kernel_size" ],
222
+ desc = ("kernel size - voxels for box/boxv, mm "
223
+ "for sphere, mm sigma for gauss" ))
224
+ kernel_file = File (exists = True , argstr = "%s" , position = 5 ,
225
+ xor = ["kernel_size" ],
206
226
desc = "use external file for kernel" )
207
227
208
228
209
229
class DilateInput (KernelInput ):
210
230
211
- operation = traits .Enum ("mean" , "modal" , "max" , argstr = "-dil%s" , position = 6 , mandatory = True ,
231
+ operation = traits .Enum ("mean" , "modal" , "max" , argstr = "-dil%s" ,
232
+ position = 6 , mandatory = True ,
212
233
desc = "filtering operation to perfoem in dilation" )
213
234
214
235
@@ -227,8 +248,10 @@ def _format_arg(self, name, spec, value):
227
248
228
249
class ErodeInput (KernelInput ):
229
250
230
- minimum_filter = traits .Bool (argstr = "%s" , position = 6 , usedefault = True , default_value = False ,
231
- desc = "if true, minimum filter rather than erosion by zeroing-out" )
251
+ minimum_filter = traits .Bool (argstr = "%s" , position = 6 , usedefault = True ,
252
+ default_value = False ,
253
+ desc = ("if true, minimum filter rather than "
254
+ "erosion by zeroing-out" ))
232
255
233
256
234
257
class ErodeImage (MathsCommand ):
@@ -248,7 +271,8 @@ def _format_arg(self, name, spec, value):
248
271
249
272
class SpatialFilterInput (KernelInput ):
250
273
251
- operation = traits .Enum ("mean" , "median" , "meanu" , argstr = "-f%s" , position = 6 , mandatory = True ,
274
+ operation = traits .Enum ("mean" , "median" , "meanu" , argstr = "-f%s" ,
275
+ position = 6 , mandatory = True ,
252
276
desc = "operation to filter with" )
253
277
254
278
@@ -262,8 +286,9 @@ class SpatialFilter(MathsCommand):
262
286
263
287
class UnaryMathsInput (MathsInput ):
264
288
265
- operation = traits .Enum ("exp" , "log" , "sin" , "cos" , "tan" , "asin" , "acos" , "atan" , "sqr" , "sqrt" ,
266
- "recip" , "abs" , "bin" , "binv" , "fillh" , "fillh26" , "index" , "edge" , "nan" ,
289
+ operation = traits .Enum ("exp" , "log" , "sin" , "cos" , "tan" , "asin" , "acos" ,
290
+ "atan" , "sqr" , "sqrt" , "recip" , "abs" , "bin" ,
291
+ "binv" , "fillh" , "fillh26" , "index" , "edge" , "nan" ,
267
292
"nanm" , "rand" , "randn" , "range" ,
268
293
argstr = "-%s" , position = 4 , mandatory = True ,
269
294
desc = "operation to perform" )
@@ -285,14 +310,17 @@ class BinaryMathsInput(MathsInput):
285
310
operation = traits .Enum ("add" , "sub" , "mul" , "div" , "rem" , "max" , "min" ,
286
311
mandatory = True , argstr = "-%s" , position = 4 ,
287
312
desc = "operation to perform" )
288
- operand_file = File (exists = True , argstr = "%s" , mandatory = True , position = 5 , xor = ["operand_value" ],
313
+ operand_file = File (exists = True , argstr = "%s" , mandatory = True ,
314
+ position = 5 , xor = ["operand_value" ],
289
315
desc = "second image to perform operation with" )
290
- operand_value = traits .Float (argstr = "%.8f" , mandatory = True , position = 5 , xor = ["operand_file" ],
316
+ operand_value = traits .Float (argstr = "%.8f" , mandatory = True ,
317
+ position = 5 , xor = ["operand_file" ],
291
318
desc = "value to perform operation with" )
292
319
293
320
294
321
class BinaryMaths (MathsCommand ):
295
- """Use fslmaths to perform mathematical operations using a second image or a numeric value.
322
+ """Use fslmaths to perform mathematical operations using a second image or
323
+ a numeric value.
296
324
297
325
"""
298
326
input_spec = BinaryMathsInput
@@ -301,9 +329,11 @@ class BinaryMaths(MathsCommand):
301
329
class MultiImageMathsInput (MathsInput ):
302
330
303
331
op_string = traits .String (position = 4 , argstr = "%s" , mandatory = True ,
304
- desc = "python formatted string of operations to perform" )
332
+ desc = ("python formatted string of operations "
333
+ "to perform" ))
305
334
operand_files = InputMultiPath (File (exists = True ), mandatory = True ,
306
- desc = "list of file names to plug into op string" )
335
+ desc = ("list of file names to plug into op "
336
+ "string" ))
307
337
308
338
309
339
class MultiImageMaths (MathsCommand ):
@@ -331,14 +361,17 @@ def _format_arg(self, name, spec, value):
331
361
332
362
class TemporalFilterInput (MathsInput ):
333
363
334
- lowpass_sigma = traits .Float (- 1 , argstr = "%.6f" , position = 5 , usedefault = True ,
364
+ lowpass_sigma = traits .Float (- 1 , argstr = "%.6f" , position = 5 ,
365
+ usedefault = True ,
335
366
desc = "lowpass filter sigma (in volumes)" )
336
- highpass_sigma = traits .Float (- 1 , argstr = "-bptf %.6f" , position = 4 , usedefault = True ,
367
+ highpass_sigma = traits .Float (- 1 , argstr = "-bptf %.6f" , position = 4 ,
368
+ usedefault = True ,
337
369
desc = "highpass filter sigma (in volumes)" )
338
370
339
371
340
372
class TemporalFilter (MathsCommand ):
341
- """Use fslmaths to apply a low, high, or bandpass temporal filter to a timeseries.
373
+ """Use fslmaths to apply a low, high, or bandpass temporal filter to a
374
+ timeseries.
342
375
343
376
"""
344
377
input_spec = TemporalFilterInput
0 commit comments