@@ -129,7 +129,8 @@ class RealignInputSpec(SPMCommandInputSpec):
129
129
wrap = traits .List (traits .Int (), minlen = 3 , maxlen = 3 ,
130
130
field = 'eoptions.wrap' ,
131
131
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 ,
133
134
desc = 'determines which images to reslice' )
134
135
write_interp = traits .Range (low = 0 , high = 7 , field = 'roptions.interp' ,
135
136
desc = 'degree of b-spline used for interpolation' )
@@ -187,6 +188,8 @@ def _parse_inputs(self):
187
188
188
189
def _list_outputs (self ):
189
190
outputs = self ._outputs ().get ()
191
+ resliced_all = self .inputs .write_which [0 ] > 0
192
+ resliced_mean = self .inputs .write_which [1 ] > 0
190
193
if isdefined (self .inputs .in_files ):
191
194
outputs ['realignment_parameters' ] = []
192
195
for imgf in self .inputs .in_files :
@@ -206,16 +209,19 @@ def _list_outputs(self):
206
209
else :
207
210
first_image = self .inputs .in_files [0 ]
208
211
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 )
219
225
return outputs
220
226
221
227
0 commit comments