Skip to content

Commit 94b7262

Browse files
author
bpinsard
committed
Merge branch 'master' into bug/afni
* master: added maths.MaxImage examples test maths.MaxImage for fslmaths -Tmax option add maths.MaxImage for fslmaths -Tmax option fix: change type of loops,speedup and between loops so its compatible with changes in the nipy code
2 parents 52175f1 + d323b92 commit 94b7262

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

nipype/interfaces/fsl/maths.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,28 @@ class MeanImage(MathsCommand):
117117
input_spec = MeanImageInput
118118
_suffix = "_mean"
119119

120+
class MaxImageInput(MathsInput):
121+
122+
dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True, argstr="-%smax", position=4,
123+
desc="dimension to max across")
124+
125+
126+
class MaxImage(MathsCommand):
127+
"""Use fslmaths to generate a max image across a given dimension.
128+
129+
Examples
130+
--------
131+
from nipype.interfaces.fsl.maths import MaxImage
132+
maxer = MaxImage()
133+
maxer.inputs.in_file = "functional.nii"
134+
maxer.dimension = "T"
135+
maths.cmdline
136+
fslmaths functional.nii -Tmax functional_max.nii
137+
138+
"""
139+
input_spec = MaxImageInput
140+
_suffix = "_max"
141+
120142

121143
class IsotropicSmoothInput(MathsInput):
122144

nipype/interfaces/fsl/tests/test_maths.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,32 @@ def test_meanimage():
169169
# Clean up our mess
170170
clean_directory(testdir, origdir, ftype)
171171

172+
@skipif(no_fsl)
173+
def test_maximage():
174+
files, testdir, origdir, ftype = create_files_in_directory()
175+
176+
# Get the command
177+
maxer = fsl.MaxImage(in_file="a.nii",out_file="b.nii")
178+
179+
# Test the underlying command
180+
yield assert_equal, maxer.cmd, "fslmaths"
181+
182+
# Test the defualt opstring
183+
yield assert_equal, maxer.cmdline, "fslmaths a.nii -Tmax b.nii"
184+
185+
# Test the other dimensions
186+
cmdline = "fslmaths a.nii -%smax b.nii"
187+
for dim in ["X","Y","Z","T"]:
188+
maxer.inputs.dimension=dim
189+
yield assert_equal, maxer.cmdline, cmdline%dim
190+
191+
# Test the auto naming
192+
maxer = fsl.MaxImage(in_file="a.nii")
193+
yield assert_equal, maxer.cmdline, "fslmaths a.nii -Tmax %s"%os.path.join(testdir, "a_max.nii")
194+
195+
# Clean up our mess
196+
clean_directory(testdir, origdir, ftype)
197+
172198
@skipif(no_fsl)
173199
def test_smooth():
174200
files, testdir, origdir, ftype = create_files_in_directory()

nipype/interfaces/nipy/preprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ def _run_interface(self, runtime):
156156
time_interp=self.inputs.time_interp,
157157
start=self.inputs.start)
158158

159-
R.estimate(loops=self.inputs.loops,
160-
between_loops=self.inputs.between_loops,
161-
speedup=self.inputs.speedup)
159+
R.estimate(loops=list(self.inputs.loops),
160+
between_loops=list(self.inputs.between_loops),
161+
speedup=list(self.inputs.speedup))
162162

163163
corr_run = R.resample()
164164
self._out_file_path = []

0 commit comments

Comments
 (0)