Skip to content

Commit 092125d

Browse files
committed
Merge pull request #534 from beOn/whichFix
Fix for #533 - use of write_which and closes #531
2 parents ef9122e + d74069e commit 092125d

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

nipype/interfaces/spm/preprocess.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ class RealignInputSpec(SPMCommandInputSpec):
129129
wrap = traits.List(traits.Int(), minlen=3, maxlen=3,
130130
field='eoptions.wrap',
131131
desc='Check if interpolation should wrap in [x,y,z]')
132-
write_which = traits.Tuple(traits.Int, traits.Int, field='roptions.which',
132+
write_which = traits.List(traits.Int, traits.Int, field='roptions.which',
133+
minlen=2, maxlen=2,
133134
desc='determines which images to reslice')
134135
write_interp = traits.Range(low=0, high=7, field='roptions.interp',
135136
desc='degree of b-spline used for interpolation')
@@ -187,6 +188,8 @@ def _parse_inputs(self):
187188

188189
def _list_outputs(self):
189190
outputs = self._outputs().get()
191+
resliced_all = self.inputs.write_which[0] > 0
192+
resliced_mean = self.inputs.write_which[1] > 0
190193
if isdefined(self.inputs.in_files):
191194
outputs['realignment_parameters'] = []
192195
for imgf in self.inputs.in_files:
@@ -206,16 +209,19 @@ def _list_outputs(self):
206209
else:
207210
first_image = self.inputs.in_files[0]
208211

209-
outputs['mean_image'] = fname_presuffix(first_image, prefix='mean')
210-
outputs['realigned_files'] = []
211-
for imgf in filename_to_list(self.inputs.in_files):
212-
realigned_run = []
213-
if isinstance(imgf,list):
214-
for inner_imgf in filename_to_list(imgf):
215-
realigned_run.append(fname_presuffix(inner_imgf, prefix=self.inputs.out_prefix))
216-
else:
217-
realigned_run = fname_presuffix(imgf, prefix=self.inputs.out_prefix)
218-
outputs['realigned_files'].append(realigned_run)
212+
if resliced_mean:
213+
outputs['mean_image'] = fname_presuffix(first_image, prefix='mean')
214+
215+
if resliced_all:
216+
outputs['realigned_files'] = []
217+
for imgf in filename_to_list(self.inputs.in_files):
218+
realigned_run = []
219+
if isinstance(imgf,list):
220+
for inner_imgf in filename_to_list(imgf):
221+
realigned_run.append(fname_presuffix(inner_imgf, prefix=self.inputs.out_prefix))
222+
else:
223+
realigned_run = fname_presuffix(imgf, prefix=self.inputs.out_prefix)
224+
outputs['realigned_files'].append(realigned_run)
219225
return outputs
220226

221227

0 commit comments

Comments
 (0)