Skip to content

Commit b9c75fb

Browse files
authored
Merge pull request #2079 from nipy/revert-2070-ants/registration_masks
Revert "ENH: Enable per-stage masking in ants.Registration"
2 parents 3d930e8 + e813102 commit b9c75fb

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

nipype/interfaces/ants/registration.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,12 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
219219
usedefault=True, desc='image dimension (2 or 3)')
220220
fixed_image = InputMultiPath(File(exists=True), mandatory=True,
221221
desc='image to apply transformation to (generally a coregistered functional)')
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 '
225-
'(Use "NULL" to omit a mask at a given stage)')
222+
fixed_image_mask = File(argstr='%s', exists=True,
223+
desc='mask used to limit metric sampling region of the fixed image')
226224
moving_image = InputMultiPath(File(exists=True), mandatory=True,
227225
desc='image to apply transformation to (generally a coregistered functional)')
228-
moving_image_mask = InputMultiPath(
229-
traits.Either('NULL', File(exists=True)),
230-
desc='mask used to limit metric sampling region of the moving image '
231-
'(Use "NULL" to omit a mask at a given stage)')
226+
moving_image_mask = File(requires=['fixed_image_mask'],
227+
exists=True, desc='mask used to limit metric sampling region of the moving image')
232228

233229
save_state = File(argstr='--save-state %s', exists=False,
234230
desc='Filename for saving the internal restorable state of the registration')
@@ -787,20 +783,6 @@ def _format_registration(self):
787783
if isdefined(self.inputs.restrict_deformation):
788784
retval.append('--restrict-deformation %s' %
789785
self._format_xarray(self.inputs.restrict_deformation[ii]))
790-
if any((isdefined(self.inputs.fixed_image_mask),
791-
isdefined(self.inputs.moving_image_mask))):
792-
if isdefined(self.inputs.fixed_image_mask):
793-
fixed_masks = filename_to_list(self.inputs.fixed_image_mask)
794-
fixed_mask = fixed_mask[ii if len(fixed_masks) > 1 else 0]
795-
else:
796-
fixed_mask = 'NULL'
797-
798-
if isdefined(self.inputs.moving_image_mask):
799-
moving_masks = filename_to_list(self.inputs.moving_image_mask)
800-
moving_mask = moving_mask[ii if len(moving_masks) > 1 else 0]
801-
else:
802-
moving_mask = 'NULL'
803-
retval.append('--masks [ %s, %s ]' % (fixed_mask, moving_mask))
804786
return " ".join(retval)
805787

806788
def _get_outputfilenames(self, inverse=False):
@@ -845,7 +827,13 @@ def _format_winsorize_image_intensities(self):
845827
self.inputs.winsorize_upper_quantile)
846828

847829
def _format_arg(self, opt, spec, val):
848-
if opt == 'transforms':
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':
849837
return self._format_registration()
850838
elif opt == 'initial_moving_transform':
851839
do_invert_transform = self.inputs.invert_initial_moving_transform \

nipype/interfaces/ants/tests/test_auto_Registration.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def test_Registration_inputs():
2323
),
2424
fixed_image=dict(mandatory=True,
2525
),
26-
fixed_image_mask=dict(),
26+
fixed_image_mask=dict(argstr='%s',
27+
),
2728
float=dict(argstr='--float %d',
2829
),
2930
ignore_exception=dict(nohash=True,
@@ -57,7 +58,8 @@ def test_Registration_inputs():
5758
metric_weight_stage_trait=dict(),
5859
moving_image=dict(mandatory=True,
5960
),
60-
moving_image_mask=dict(),
61+
moving_image_mask=dict(requires=['fixed_image_mask'],
62+
),
6163
num_threads=dict(nohash=True,
6264
usedefault=True,
6365
),

0 commit comments

Comments
 (0)