Skip to content

Commit 7578fb3

Browse files
committed
Merge pull request #418 from bpinsard/fsl/math_nan2zeros
Fsl.math nan2zeros
2 parents 653e967 + 2ee8ecc commit 7578fb3

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

nipype/interfaces/fsl/maths.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class MathsInput(FSLCommandInputSpec):
2323
output_datatype = traits.Enum(*_dtypes,
2424
position=-1, argstr="-odt %s",
2525
desc="datatype to use for output (default uses input type)")
26-
26+
27+
nan2zeros = traits.Bool(position=3, argstr='-nan',
28+
desc='change NaNs to zeros before doing anything')
2729

2830
class MathsOutput(TraitedSpec):
2931

@@ -69,7 +71,7 @@ class ChangeDataType(MathsCommand):
6971

7072
class ThresholdInputSpec(MathsInput):
7173

72-
thresh = traits.Float(mandatory=True, position=3, argstr="%s",
74+
thresh = traits.Float(mandatory=True, position=4, argstr="%s",
7375
desc="threshold value")
7476
direction = traits.Enum("below", "above", usedefault=True,
7577
desc="zero-out either below or above thresh value")
@@ -104,7 +106,7 @@ def _format_arg(self, name, spec, value):
104106

105107
class MeanImageInput(MathsInput):
106108

107-
dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True, argstr="-%smean", position=3,
109+
dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True, argstr="-%smean", position=4,
108110
desc="dimension to mean across")
109111

110112

@@ -118,9 +120,9 @@ class MeanImage(MathsCommand):
118120

119121
class IsotropicSmoothInput(MathsInput):
120122

121-
fwhm = traits.Float(mandatory=True, xor=["sigma"], position=3, argstr="-s %.5f",
123+
fwhm = traits.Float(mandatory=True, xor=["sigma"], position=4, argstr="-s %.5f",
122124
desc="fwhm of smoothing kernel")
123-
sigma = traits.Float(mandatory=True, xor=["fwhm"], position=3, argstr="-s %.5f",
125+
sigma = traits.Float(mandatory=True, xor=["fwhm"], position=4, argstr="-s %.5f",
124126
desc="sigma of smoothing kernel")
125127

126128

@@ -140,7 +142,7 @@ def _format_arg(self, name, spec, value):
140142

141143
class ApplyMaskInput(MathsInput):
142144

143-
mask_file = File(exists=True, mandatory=True, argstr="-mas %s", position=3,
145+
mask_file = File(exists=True, mandatory=True, argstr="-mas %s", position=4,
144146
desc="binary image defining mask space")
145147

146148

@@ -155,16 +157,16 @@ class ApplyMask(MathsCommand):
155157
class KernelInput(MathsInput):
156158

157159
kernel_shape = traits.Enum("3D", "2D", "box", "boxv", "gauss", "sphere", "file",
158-
argstr="-kernel %s", position=3, desc="kernel shape to use")
159-
kernel_size = traits.Float(argstr="%.4f", position=4, xor=["kernel_file"],
160+
argstr="-kernel %s", position=4, desc="kernel shape to use")
161+
kernel_size = traits.Float(argstr="%.4f", position=5, xor=["kernel_file"],
160162
desc="kernel size - voxels for box/boxv, mm for sphere, mm sigma for gauss")
161-
kernel_file = File(exists=True, argstr="%s", position=4, xor=["kernel_size"],
163+
kernel_file = File(exists=True, argstr="%s", position=5, xor=["kernel_size"],
162164
desc="use external file for kernel")
163165

164166

165167
class DilateInput(KernelInput):
166168

167-
operation = traits.Enum("mean", "modal", "max", argstr="-dil%s", position=5, mandatory=True,
169+
operation = traits.Enum("mean", "modal", "max", argstr="-dil%s", position=6, mandatory=True,
168170
desc="filtering operation to perfoem in dilation")
169171

170172

@@ -183,7 +185,7 @@ def _format_arg(self, name, spec, value):
183185

184186
class ErodeInput(KernelInput):
185187

186-
minimum_filter = traits.Bool(argstr="%s", position=5, usedefault=True, default_value=False,
188+
minimum_filter = traits.Bool(argstr="%s", position=6, usedefault=True, default_value=False,
187189
desc="if true, minimum filter rather than erosion by zeroing-out")
188190

189191

@@ -204,7 +206,7 @@ def _format_arg(self, name, spec, value):
204206

205207
class SpatialFilterInput(KernelInput):
206208

207-
operation = traits.Enum("mean", "median", "meanu", argstr="-f%s", position=5, mandatory=True,
209+
operation = traits.Enum("mean", "median", "meanu", argstr="-f%s", position=6, mandatory=True,
208210
desc="operation to filter with")
209211

210212

@@ -219,7 +221,7 @@ class SpatialFilter(MathsCommand):
219221
class UnaryMathsInput(MathsInput):
220222

221223
operation = traits.Enum("exp", "log", "sin", "cos", "sqr", "sqrt", "recip", "abs", "bin", "index",
222-
argstr="-%s", position=3, mandatory=True,
224+
argstr="-%s", position=4, mandatory=True,
223225
desc="operation to perform")
224226

225227

@@ -237,11 +239,11 @@ def _list_outputs(self):
237239
class BinaryMathsInput(MathsInput):
238240

239241
operation = traits.Enum("add", "sub", "mul", "div", "rem", "max", "min",
240-
mandatory=True, argstr="-%s", position=3,
242+
mandatory=True, argstr="-%s", position=4,
241243
desc="operation to perform")
242-
operand_file = File(exists=True, argstr="%s", mandatory=True, position=4, xor=["operand_value"],
244+
operand_file = File(exists=True, argstr="%s", mandatory=True, position=5, xor=["operand_value"],
243245
desc="second image to perform operation with")
244-
operand_value = traits.Float(argstr="%.8f", mandatory=True, position=4, xor=["operand_file"],
246+
operand_value = traits.Float(argstr="%.8f", mandatory=True, position=5, xor=["operand_file"],
245247
desc="value to perform operation with")
246248

247249

@@ -254,7 +256,7 @@ class BinaryMaths(MathsCommand):
254256

255257
class MultiImageMathsInput(MathsInput):
256258

257-
op_string = traits.String(position=3, argstr="%s", mandatory=True,
259+
op_string = traits.String(position=4, argstr="%s", mandatory=True,
258260
desc="python formatted string of operations to perform")
259261
operand_files = InputMultiPath(File(exists=True), mandatory=True,
260262
desc="list of file names to plug into op string")
@@ -285,9 +287,9 @@ def _format_arg(self, name, spec, value):
285287

286288
class TemporalFilterInput(MathsInput):
287289

288-
lowpass_sigma = traits.Float(-1, argstr="%.6f", position=4, usedefault=True,
290+
lowpass_sigma = traits.Float(-1, argstr="%.6f", position=5, usedefault=True,
289291
desc="lowpass filter sigma (in volumes)")
290-
highpass_sigma = traits.Float(-1, argstr="-bptf %.6f", position=3, usedefault=True,
292+
highpass_sigma = traits.Float(-1, argstr="-bptf %.6f", position=4, usedefault=True,
291293
desc="highpass filter sigma (in volumes)")
292294

293295

0 commit comments

Comments
 (0)