Skip to content

Revert "ENH: Enable per-stage masking in ants.Registration" #2079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions nipype/interfaces/ants/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,12 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
usedefault=True, desc='image dimension (2 or 3)')
fixed_image = InputMultiPath(File(exists=True), mandatory=True,
desc='image to apply transformation to (generally a coregistered functional)')
fixed_image_mask = InputMultiPath(
traits.Either('NULL', File(exists=True)),
desc='mask used to limit metric sampling region of the fixed image '
'(Use "NULL" to omit a mask at a given stage)')
fixed_image_mask = File(argstr='%s', exists=True,
desc='mask used to limit metric sampling region of the fixed image')
moving_image = InputMultiPath(File(exists=True), mandatory=True,
desc='image to apply transformation to (generally a coregistered functional)')
moving_image_mask = InputMultiPath(
traits.Either('NULL', File(exists=True)),
desc='mask used to limit metric sampling region of the moving image '
'(Use "NULL" to omit a mask at a given stage)')
moving_image_mask = File(requires=['fixed_image_mask'],
exists=True, desc='mask used to limit metric sampling region of the moving image')

save_state = File(argstr='--save-state %s', exists=False,
desc='Filename for saving the internal restorable state of the registration')
Expand Down Expand Up @@ -787,20 +783,6 @@ def _format_registration(self):
if isdefined(self.inputs.restrict_deformation):
retval.append('--restrict-deformation %s' %
self._format_xarray(self.inputs.restrict_deformation[ii]))
if any((isdefined(self.inputs.fixed_image_mask),
isdefined(self.inputs.moving_image_mask))):
if isdefined(self.inputs.fixed_image_mask):
fixed_masks = filename_to_list(self.inputs.fixed_image_mask)
fixed_mask = fixed_mask[ii if len(fixed_masks) > 1 else 0]
else:
fixed_mask = 'NULL'

if isdefined(self.inputs.moving_image_mask):
moving_masks = filename_to_list(self.inputs.moving_image_mask)
moving_mask = moving_mask[ii if len(moving_masks) > 1 else 0]
else:
moving_mask = 'NULL'
retval.append('--masks [ %s, %s ]' % (fixed_mask, moving_mask))
return " ".join(retval)

def _get_outputfilenames(self, inverse=False):
Expand Down Expand Up @@ -845,7 +827,13 @@ def _format_winsorize_image_intensities(self):
self.inputs.winsorize_upper_quantile)

def _format_arg(self, opt, spec, val):
if opt == 'transforms':
if opt == 'fixed_image_mask':
if isdefined(self.inputs.moving_image_mask):
return '--masks [ %s, %s ]' % (self.inputs.fixed_image_mask,
self.inputs.moving_image_mask)
else:
return '--masks %s' % self.inputs.fixed_image_mask
elif opt == 'transforms':
return self._format_registration()
elif opt == 'initial_moving_transform':
do_invert_transform = self.inputs.invert_initial_moving_transform \
Expand Down
6 changes: 4 additions & 2 deletions nipype/interfaces/ants/tests/test_auto_Registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def test_Registration_inputs():
),
fixed_image=dict(mandatory=True,
),
fixed_image_mask=dict(),
fixed_image_mask=dict(argstr='%s',
),
float=dict(argstr='--float %d',
),
ignore_exception=dict(nohash=True,
Expand Down Expand Up @@ -57,7 +58,8 @@ def test_Registration_inputs():
metric_weight_stage_trait=dict(),
moving_image=dict(mandatory=True,
),
moving_image_mask=dict(),
moving_image_mask=dict(requires=['fixed_image_mask'],
),
num_threads=dict(nohash=True,
usedefault=True,
),
Expand Down