@@ -219,12 +219,14 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
219
219
usedefault = True , desc = 'image dimension (2 or 3)' )
220
220
fixed_image = InputMultiPath (File (exists = True ), mandatory = True ,
221
221
desc = 'image to apply transformation to (generally a coregistered functional)' )
222
- fixed_image_mask = File (argstr = '%s' , exists = True ,
223
- desc = 'mask used to limit metric sampling region of the fixed image' )
222
+ fixed_image_mask = InputMultiPath (
223
+ traits .Either ('NULL' , File (exists = True )),
224
+ desc = 'mask used to limit metric sampling region of the fixed image' )
224
225
moving_image = InputMultiPath (File (exists = True ), mandatory = True ,
225
226
desc = 'image to apply transformation to (generally a coregistered functional)' )
226
- moving_image_mask = File (requires = ['fixed_image_mask' ],
227
- exists = True , desc = 'mask used to limit metric sampling region of the moving image' )
227
+ moving_image_mask = InputMultiPath (
228
+ traits .Either ('NULL' , File (exists = True )),
229
+ desc = 'mask used to limit metric sampling region of the moving image' )
228
230
229
231
save_state = File (argstr = '--save-state %s' , exists = False ,
230
232
desc = 'Filename for saving the internal restorable state of the registration' )
@@ -783,6 +785,20 @@ def _format_registration(self):
783
785
if isdefined (self .inputs .restrict_deformation ):
784
786
retval .append ('--restrict-deformation %s' %
785
787
self ._format_xarray (self .inputs .restrict_deformation [ii ]))
788
+ if any ((isdefined (self .inputs .fixed_image_mask ),
789
+ isdefined (self .inputs .moving_image_mask ))):
790
+ if isdefined (self .inputs .fixed_image_mask ):
791
+ fixed_masks = filename_to_list (self .inputs .fixed_image_mask )
792
+ fixed_mask = fixed_mask [ii if len (fixed_masks ) > 1 else 0 ]
793
+ else :
794
+ fixed_mask = 'NULL'
795
+
796
+ if isdefined (self .inputs .moving_image_mask ):
797
+ moving_masks = filename_to_list (self .inputs .moving_image_mask )
798
+ moving_mask = moving_mask [ii if len (moving_masks ) > 1 else 0 ]
799
+ else :
800
+ moving_mask = 'NULL'
801
+ retval .append ('--masks [ %s, %s ]' % (fixed_mask , moving_mask ]))
786
802
return " " .join (retval )
787
803
788
804
def _get_outputfilenames (self , inverse = False ):
@@ -827,13 +843,7 @@ def _format_winsorize_image_intensities(self):
827
843
self .inputs .winsorize_upper_quantile )
828
844
829
845
def _format_arg (self , opt , spec , val ):
830
- if opt == 'fixed_image_mask' :
831
- if isdefined (self .inputs .moving_image_mask ):
832
- return '--masks [ %s, %s ]' % (self .inputs .fixed_image_mask ,
833
- self .inputs .moving_image_mask )
834
- else :
835
- return '--masks %s' % self .inputs .fixed_image_mask
836
- elif opt == 'transforms' :
846
+ if opt == 'transforms' :
837
847
return self ._format_registration ()
838
848
elif opt == 'initial_moving_transform' :
839
849
do_invert_transform = self .inputs .invert_initial_moving_transform \
0 commit comments