@@ -120,7 +120,8 @@ class RealignInputSpec(SPMCommandInputSpec):
120
120
desc = 'gaussian smoothing kernel width' )
121
121
separation = traits .Range (low = 0.0 , field = 'eoptions.sep' ,
122
122
desc = 'sampling separation in mm' )
123
- register_to_mean = traits .Bool (field = 'eoptions.rtm' ,
123
+ register_to_mean = traits .Bool (True , field = 'eoptions.rtm' ,
124
+ mandatory = True , usedefault = True ,
124
125
desc = 'Indicate whether realignment is done to the mean image' )
125
126
weight_img = File (exists = True , field = 'eoptions.weight' ,
126
127
desc = 'filename of weighting image' )
@@ -213,14 +214,26 @@ def _list_outputs(self):
213
214
outputs ['mean_image' ] = fname_presuffix (first_image , prefix = 'mean' )
214
215
215
216
if resliced_all :
217
+ reg_to_mean = self .inputs .register_to_mean
216
218
outputs ['realigned_files' ] = []
217
- for imgf in filename_to_list (self .inputs .in_files ):
219
+ for idx , imgf in enumerate ( filename_to_list (self .inputs .in_files ) ):
218
220
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 ))
221
+ if isinstance (imgf , list ):
222
+ for i , inner_imgf in enumerate (filename_to_list (imgf )):
223
+ newfile = fname_presuffix (inner_imgf ,
224
+ prefix = self .inputs .out_prefix )
225
+ if os .path .exists (newfile ):
226
+ realigned_run .append (newfile )
227
+ continue
228
+ if idx == 0 and i == 0 and not reg_to_mean and \
229
+ func_is_3d (inner_imgf ):
230
+ realigned_run .append (fname_presuffix (inner_imgf ,
231
+ prefix = '' ))
222
232
else :
223
- realigned_run = fname_presuffix (imgf , prefix = self .inputs .out_prefix )
233
+ realigned_run = fname_presuffix (imgf ,
234
+ prefix = self .inputs .out_prefix )
235
+ if idx == 0 and not reg_to_mean and func_is_3d (imgf ):
236
+ realigned_run = fname_presuffix (imgf , prefix = '' )
224
237
outputs ['realigned_files' ].append (realigned_run )
225
238
return outputs
226
239
0 commit comments