Skip to content

Commit 2ba1099

Browse files
committed
FSL maths interface, add the remaining dimension reduction operations: MaxnImage, MinImage, MedianImage, PercentileImage, AR1Image (-Tmaxn etc.).
1 parent 482ac61 commit 2ba1099

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

nipype/interfaces/fsl/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
TractSkeleton, MakeDyadicVectors, BEDPOSTX5, XFibres5)
3030
from .maths import (ChangeDataType, Threshold, MeanImage, ApplyMask,
3131
IsotropicSmooth, TemporalFilter, DilateImage, ErodeImage,
32-
SpatialFilter, UnaryMaths, BinaryMaths, MultiImageMaths)
32+
SpatialFilter, UnaryMaths, BinaryMaths, MultiImageMaths,
33+
MaxnImage, MinImage, MedianImage, PercentileImage,
34+
AR1Image)
3335

3436
from .possum import B0Calc

nipype/interfaces/fsl/maths.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,98 @@ class MaxImage(MathsCommand):
174174
_suffix = "_max"
175175

176176

177+
class PercentileImageInput(MathsInput):
178+
179+
dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True,
180+
argstr="-%sperc", position=4,
181+
desc="dimension to percentile across")
182+
perc = traits.Range(low=0, high=100, usedefault=False,
183+
argstr="%f", position=5,
184+
desc=("nth percentile (0-100) of FULL RANGE "
185+
"across dimension"))
186+
187+
188+
class PercentileImage(MathsCommand):
189+
"""Use fslmaths to generate a percentile image across a given dimension.
190+
191+
Examples
192+
--------
193+
>>> from nipype.interfaces.fsl.maths import MaxImage
194+
>>> percer = PercentileImage()
195+
>>> percer.inputs.in_file = "functional.nii" # doctest: +SKIP
196+
>>> percer.dimension = "T"
197+
>>> percer.perc = 90
198+
>>> percer.cmdline # doctest: +SKIP
199+
'fslmaths functional.nii -Tperc 90 functional_perc.nii'
200+
201+
"""
202+
input_spec = PercentileImageInput
203+
_suffix = "_perc"
204+
205+
206+
class MaxnImageInput(MathsInput):
207+
208+
dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True,
209+
argstr="-%smaxn", position=4,
210+
desc="dimension to index max across")
211+
212+
213+
class MaxnImage(MathsCommand):
214+
"""Use fslmaths to generate an image of index of max across
215+
a given dimension.
216+
217+
"""
218+
input_spec = MaxnImageInput
219+
_suffix = "_maxn"
220+
221+
222+
class MinImageInput(MathsInput):
223+
224+
dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True,
225+
argstr="-%smin", position=4,
226+
desc="dimension to min across")
227+
228+
229+
class MinImage(MathsCommand):
230+
"""Use fslmaths to generate a minimum image across a given dimension.
231+
232+
"""
233+
input_spec = MinImageInput
234+
_suffix = "_min"
235+
236+
237+
class MedianImageInput(MathsInput):
238+
239+
dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True,
240+
argstr="-%smedian", position=4,
241+
desc="dimension to median across")
242+
243+
244+
class MedianImage(MathsCommand):
245+
"""Use fslmaths to generate a median image across a given dimension.
246+
247+
"""
248+
input_spec = MedianImageInput
249+
_suffix = "_median"
250+
251+
252+
class AR1ImageInput(MathsInput):
253+
254+
dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True,
255+
argstr="-%sar1", position=4,
256+
desc=("dimension to find AR(1) coefficient"
257+
"across"))
258+
259+
260+
class AR1Image(MathsCommand):
261+
"""Use fslmaths to generate an AR1 coefficient image across a
262+
given dimension. (Should use -odt float and probably demean first)
263+
264+
"""
265+
input_spec = AR1ImageInput
266+
_suffix = "_ar1"
267+
268+
177269
class IsotropicSmoothInput(MathsInput):
178270

179271
fwhm = traits.Float(mandatory=True, xor=["sigma"],

0 commit comments

Comments
 (0)