Skip to content

Commit 25cef4a

Browse files
committed
Merge branch 'master' into enh/FSLb0calc
2 parents 18e58e2 + 02aa8fa commit 25cef4a

File tree

9 files changed

+1352
-917
lines changed

9 files changed

+1352
-917
lines changed

nipype/interfaces/freesurfer/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ class MRIsConvertInputSpec(FSTraitedSpec):
858858
xor=['out_datatype'], mandatory=True,
859859
desc='output filename or True to generate one')
860860

861-
out_datatype = traits.Enum("ico", "tri", "stl", "vtk", "gii", "mgh", "mgz",
861+
out_datatype = traits.Enum("asc", "ico", "tri", "stl", "vtk", "gii", "mgh", "mgz",
862862
xor=['out_file'], mandatory=True,
863863
desc="These file formats are supported: ASCII: .asc"
864864
"ICO: .ico, .tri GEO: .geo STL: .stl VTK: .vtk GIFTI: .gii MGH surface-encoded 'volume': .mgh, .mgz")

nipype/interfaces/fsl/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
Examples
2424
--------
25-
See the docstrings of the individual classes for examples.
25+
See the docstrings of the individual classes for examples.
2626
2727
"""
2828
from __future__ import print_function, division, unicode_literals, absolute_import
@@ -263,4 +263,5 @@ def no_fsl():
263263

264264
def no_fsl_course_data():
265265
"""check if fsl_course data is present"""
266-
return not ('FSL_COURSE_DATA' in os.environ and os.path.isdir(os.path.abspath(os.environ['FSL_COURSE_DATA'])))
266+
return not ('FSL_COURSE_DATA' in os.environ and
267+
os.path.isdir(os.path.abspath(os.environ['FSL_COURSE_DATA'])))

nipype/interfaces/fsl/dti.py

Lines changed: 354 additions & 217 deletions
Large diffs are not rendered by default.

nipype/interfaces/fsl/epi.py

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ def _parse_inputs(self, skip=None):
376376
# If not defined, assume index are the first N entries in the
377377
# parameters file, for N input images.
378378
if not isdefined(self.inputs.in_index):
379-
self.inputs.in_index = list(range(1, len(self.inputs.in_files) + 1))
379+
self.inputs.in_index = list(
380+
range(1, len(self.inputs.in_files) + 1))
380381

381382
return super(ApplyTOPUP, self)._parse_inputs(skip=skip)
382383

@@ -489,7 +490,8 @@ def _num_threads_update(self):
489490
if 'OMP_NUM_THREADS' in self.inputs.environ:
490491
del self.inputs.environ['OMP_NUM_THREADS']
491492
else:
492-
self.inputs.environ['OMP_NUM_THREADS'] = str(self.inputs.num_threads)
493+
self.inputs.environ['OMP_NUM_THREADS'] = str(
494+
self.inputs.num_threads)
493495

494496
def _format_arg(self, name, spec, value):
495497
if name == 'in_topup_fieldcoef':
@@ -500,8 +502,10 @@ def _format_arg(self, name, spec, value):
500502

501503
def _list_outputs(self):
502504
outputs = self.output_spec().get()
503-
outputs['out_corrected'] = os.path.abspath('%s.nii.gz' % self.inputs.out_base)
504-
outputs['out_parameter'] = os.path.abspath('%s.eddy_parameters' % self.inputs.out_base)
505+
outputs['out_corrected'] = os.path.abspath(
506+
'%s.nii.gz' % self.inputs.out_base)
507+
outputs['out_parameter'] = os.path.abspath(
508+
'%s.eddy_parameters' % self.inputs.out_base)
505509
return outputs
506510

507511

@@ -573,7 +577,8 @@ class EpiRegInputSpec(FSLCommandInputSpec):
573577
position=-3, desc='wholehead T1 image')
574578
t1_brain = File(exists=True, argstr='--t1brain=%s', mandatory=True,
575579
position=-2, desc='brain extracted T1 image')
576-
out_base = traits.String("epi2struct", desc='output base name', argstr='--out=%s',
580+
out_base = traits.String("epi2struct", desc='output base name',
581+
argstr='--out=%s',
577582
position=-1, usedefault=True)
578583
fmap = File(exists=True, argstr='--fmap=%s',
579584
desc='fieldmap image (in rad/s)')
@@ -620,7 +625,8 @@ class EpiRegOutputSpec(TraitedSpec):
620625
fullwarp = File(exists=True,
621626
desc='warpfield to unwarp epi and transform into \
622627
structural space')
623-
wmseg = File(exists=True, desc='white matter segmentation used in flirt bbr')
628+
wmseg = File(exists=True,
629+
desc='white matter segmentation used in flirt bbr')
624630
wmedge = File(exists=True, desc='white matter edges for visualization')
625631

626632

@@ -659,32 +665,34 @@ def _list_outputs(self):
659665
outputs = self.output_spec().get()
660666
outputs['out_file'] = os.path.join(os.getcwd(),
661667
self.inputs.out_base + '.nii.gz')
662-
if not (isdefined(self.inputs.no_fmapreg) and self.inputs.no_fmapreg) and isdefined(self.inputs.fmap):
663-
outputs['out_1vol'] = os.path.join(os.getcwd(),
664-
self.inputs.out_base + '_1vol.nii.gz')
665-
outputs['fmap2str_mat'] = os.path.join(os.getcwd(),
666-
self.inputs.out_base + '_fieldmap2str.mat')
667-
outputs['fmap2epi_mat'] = os.path.join(os.getcwd(),
668-
self.inputs.out_base + '_fieldmaprads2epi.mat')
669-
outputs['fmap_epi'] = os.path.join(os.getcwd(),
670-
self.inputs.out_base + '_fieldmaprads2epi.nii.gz')
671-
outputs['fmap_str'] = os.path.join(os.getcwd(),
672-
self.inputs.out_base + '_fieldmaprads2str.nii.gz')
673-
outputs['fmapmag_str'] = os.path.join(os.getcwd(),
674-
self.inputs.out_base + '_fieldmap2str.nii.gz')
675-
outputs['shiftmap'] = os.path.join(os.getcwd(),
676-
self.inputs.out_base + '_fieldmaprads2epi_shift.nii.gz')
677-
outputs['fullwarp'] = os.path.join(os.getcwd(),
678-
self.inputs.out_base + '_warp.nii.gz')
679-
outputs['epi2str_inv'] = os.path.join(os.getcwd(),
680-
self.inputs.out_base + '_inv.mat')
681-
682-
outputs['epi2str_mat'] = os.path.join(os.getcwd(),
683-
self.inputs.out_base + '.mat')
684-
outputs['wmedge'] = os.path.join(os.getcwd(),
685-
self.inputs.out_base + '_fast_wmedge.nii.gz')
686-
outputs['wmseg'] = os.path.join(os.getcwd(),
687-
self.inputs.out_base + '_fast_wmseg.nii.gz')
668+
if (not (isdefined(self.inputs.no_fmapreg) and
669+
self.inputs.no_fmapreg) and isdefined(self.inputs.fmap)):
670+
outputs['out_1vol'] = os.path.join(
671+
os.getcwd(), self.inputs.out_base + '_1vol.nii.gz')
672+
outputs['fmap2str_mat'] = os.path.join(
673+
os.getcwd(), self.inputs.out_base + '_fieldmap2str.mat')
674+
outputs['fmap2epi_mat'] = os.path.join(
675+
os.getcwd(), self.inputs.out_base + '_fieldmaprads2epi.mat')
676+
outputs['fmap_epi'] = os.path.join(
677+
os.getcwd(), self.inputs.out_base + '_fieldmaprads2epi.nii.gz')
678+
outputs['fmap_str'] = os.path.join(
679+
os.getcwd(), self.inputs.out_base + '_fieldmaprads2str.nii.gz')
680+
outputs['fmapmag_str'] = os.path.join(
681+
os.getcwd(), self.inputs.out_base + '_fieldmap2str.nii.gz')
682+
outputs['shiftmap'] = os.path.join(
683+
os.getcwd(),
684+
self.inputs.out_base + '_fieldmaprads2epi_shift.nii.gz')
685+
outputs['fullwarp'] = os.path.join(
686+
os.getcwd(), self.inputs.out_base + '_warp.nii.gz')
687+
outputs['epi2str_inv'] = os.path.join(
688+
os.getcwd(), self.inputs.out_base + '_inv.mat')
689+
690+
outputs['epi2str_mat'] = os.path.join(
691+
os.getcwd(), self.inputs.out_base + '.mat')
692+
outputs['wmedge'] = os.path.join(
693+
os.getcwd(), self.inputs.out_base + '_fast_wmedge.nii.gz')
694+
outputs['wmseg'] = os.path.join(
695+
os.getcwd(), self.inputs.out_base + '_fast_wmseg.nii.gz')
688696

689697
return outputs
690698

nipype/interfaces/fsl/maths.py

Lines changed: 66 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ class MathsInput(FSLCommandInputSpec):
2323

2424
in_file = File(position=2, argstr="%s", exists=True, mandatory=True,
2525
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)
2728
_dtypes = ["float", "char", "int", "short", "double", "input"]
2829
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)"))
3032
output_datatype = traits.Enum(*_dtypes,
3133
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)"))
3336

3437
nan2zeros = traits.Bool(position=3, argstr='-nan',
3538
desc='change NaNs to zeros before doing anything')
@@ -51,7 +54,8 @@ def _list_outputs(self):
5154
outputs = self.output_spec().get()
5255
outputs["out_file"] = self.inputs.out_file
5356
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)
5559
outputs["out_file"] = os.path.abspath(outputs["out_file"])
5660
return outputs
5761

@@ -65,7 +69,8 @@ class ChangeDataTypeInput(MathsInput):
6569

6670
_dtypes = ["float", "char", "int", "short", "double", "input"]
6771
output_datatype = traits.Enum(*_dtypes,
68-
position=-1, argstr="-odt %s", mandatory=True,
72+
position=-1, argstr="-odt %s",
73+
mandatory=True,
6974
desc="output data type")
7075

7176

@@ -83,9 +88,11 @@ class ThresholdInputSpec(MathsInput):
8388
desc="threshold value")
8489
direction = traits.Enum("below", "above", usedefault=True,
8590
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"])
8996

9097

9198
class Threshold(MathsCommand):
@@ -103,29 +110,35 @@ def _format_arg(self, name, spec, value):
103110
arg += "u"
104111
arg += "thr"
105112
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):
107115
arg += "P"
108116
else:
109117
arg += "p"
110118
arg += " %.10f" % value
111119
return arg
112120
return super(Threshold, self)._format_arg(name, spec, value)
113121

122+
114123
class StdImageInput(MathsInput):
115124

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,
117127
desc="dimension to standard deviate across")
118128

119129

120130
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.
122133
"""
123134
input_spec = StdImageInput
124135
_suffix = "_std"
125136

137+
126138
class MeanImageInput(MathsInput):
127139

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,
129142
desc="dimension to mean across")
130143

131144

@@ -139,7 +152,8 @@ class MeanImage(MathsCommand):
139152

140153
class MaxImageInput(MathsInput):
141154

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,
143157
desc="dimension to max across")
144158

145159

@@ -162,9 +176,11 @@ class MaxImage(MathsCommand):
162176

163177
class IsotropicSmoothInput(MathsInput):
164178

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",
166181
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",
168184
desc="sigma of smoothing kernel [mm]")
169185

170186

@@ -198,17 +214,22 @@ class ApplyMask(MathsCommand):
198214

199215
class KernelInput(MathsInput):
200216

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")
203221
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"],
206226
desc="use external file for kernel")
207227

208228

209229
class DilateInput(KernelInput):
210230

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,
212233
desc="filtering operation to perfoem in dilation")
213234

214235

@@ -227,8 +248,10 @@ def _format_arg(self, name, spec, value):
227248

228249
class ErodeInput(KernelInput):
229250

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"))
232255

233256

234257
class ErodeImage(MathsCommand):
@@ -248,7 +271,8 @@ def _format_arg(self, name, spec, value):
248271

249272
class SpatialFilterInput(KernelInput):
250273

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,
252276
desc="operation to filter with")
253277

254278

@@ -262,8 +286,9 @@ class SpatialFilter(MathsCommand):
262286

263287
class UnaryMathsInput(MathsInput):
264288

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",
267292
"nanm", "rand", "randn", "range",
268293
argstr="-%s", position=4, mandatory=True,
269294
desc="operation to perform")
@@ -285,14 +310,17 @@ class BinaryMathsInput(MathsInput):
285310
operation = traits.Enum("add", "sub", "mul", "div", "rem", "max", "min",
286311
mandatory=True, argstr="-%s", position=4,
287312
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"],
289315
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"],
291318
desc="value to perform operation with")
292319

293320

294321
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.
296324
297325
"""
298326
input_spec = BinaryMathsInput
@@ -301,9 +329,11 @@ class BinaryMaths(MathsCommand):
301329
class MultiImageMathsInput(MathsInput):
302330

303331
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"))
305334
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"))
307337

308338

309339
class MultiImageMaths(MathsCommand):
@@ -331,14 +361,17 @@ def _format_arg(self, name, spec, value):
331361

332362
class TemporalFilterInput(MathsInput):
333363

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,
335366
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,
337369
desc="highpass filter sigma (in volumes)")
338370

339371

340372
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.
342375
343376
"""
344377
input_spec = TemporalFilterInput

0 commit comments

Comments
 (0)