Skip to content

Commit 07ec0cc

Browse files
committed
Revert "BUG: Registration interface failed multi-modal"
1 parent 747640b commit 07ec0cc

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

CHANGES

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Next release
22
============
33

4-
* BUG: ANTs Registration interface failed with multi-modal inputs
5-
(https://github.com/nipy/nipype/pull/1176) (https://github.com/nipy/nipype/issues/1175)
64
* FIX: Bug in XFibres5 (https://github.com/nipy/nipype/pull/1168)
75
* ENH: Attempt to use hard links for data sink.
86
(https://github.com/nipy/nipype/pull/1161)

nipype/interfaces/ants/registration.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ class Registration(ANTSCommand):
446446
>>> reg5.inputs.sampling_strategy = ['Random', None] # use default strategy in second stage
447447
>>> reg5.inputs.sampling_percentage = [0.05, [0.05, 0.10]]
448448
>>> reg5.cmdline
449-
'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --initial-moving-transform [ trans.mat, 1 ] --initialize-transforms-per-stage 0 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --restore-state trans.mat --save-state trans.mat --transform Affine[ 2.0 ] --metric CC[ fixed1.nii, moving1.nii, 1, 4, Random, 0.05 ] --convergence [ 1500x200, 1e-08, 20 ] --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --transform SyN[ 0.25, 3.0, 0.0 ] --metric CC[ fixed1.nii, moving1.nii, 0.5, 32, None, 0.05 ] --metric Mattes[ fixed2.nii, moving2.nii, 0.5, 32, None, 0.1 ] --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1'
449+
'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --initial-moving-transform [ trans.mat, 1 ] --initialize-transforms-per-stage 0 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --restore-state trans.mat --save-state trans.mat --transform Affine[ 2.0 ] --metric CC[ fixed1.nii, moving1.nii, 1, 4, Random, 0.05 ] --convergence [ 1500x200, 1e-08, 20 ] --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --transform SyN[ 0.25, 3.0, 0.0 ] --metric CC[ fixed1.nii, moving1.nii, 0.5, 32, None, 0.05 ] --metric Mattes[ fixed1.nii, moving1.nii, 0.5, 32, None, 0.1 ] --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1'
450450
"""
451451
DEF_SAMPLING_STRATEGY = 'None'
452452
"""The default sampling strategy argument."""
@@ -466,12 +466,14 @@ def _formatMetric(self, index):
466466
----------
467467
index: the stage index
468468
"""
469+
# The common fixed image.
470+
fixed = self.inputs.fixed_image[0]
471+
# The common moving image.
472+
moving = self.inputs.moving_image[0]
469473
# The metric name input for the current stage.
470474
name_input = self.inputs.metric[index]
471475
# The stage-specific input dictionary.
472476
stage_inputs = dict(
473-
fixed_image=self.inputs.fixed_image[0],
474-
moving_image=self.inputs.moving_image[0],
475477
metric=name_input,
476478
weight=self.inputs.metric_weight[index],
477479
radius_or_bins=self.inputs.radius_or_number_of_bins[index],
@@ -500,32 +502,16 @@ def _formatMetric(self, index):
500502
# dict-comprehension only works with python 2.7 and up
501503
#specs = [{k: v[i] for k, v in items} for i in indexes]
502504
specs = [dict([(k, v[i]) for k, v in items]) for i in indexes]
503-
specs = list()
504-
for i in indexes:
505-
temp = dict([(k, v[i]) for k, v in items])
506-
if i > len( self.inputs.fixed_image ):
507-
temp["fixed_image"] = self.inputs.fixed_image[0]
508-
else:
509-
temp["fixed_image"] = self.inputs.fixed_image[i]
510-
511-
if i > len( self.inputs.moving_image ):
512-
temp["moving_image"] = self.inputs.moving_image[0]
513-
else:
514-
temp["moving_image"] = self.inputs.moving_image[i]
515-
516-
specs.append( temp )
517505
else:
518506
specs = [stage_inputs]
519507

520508
# Format the --metric command line metric arguments, one per
521509
# specification.
522-
return [self._formatMetricArgument(**spec) for spec in specs]
510+
return [self._formatMetricArgument(fixed, moving, **spec) for spec in specs]
523511

524-
def _formatMetricArgument(self, **kwargs):
512+
def _formatMetricArgument(self, fixed, moving, **kwargs):
525513
retval = '%s[ %s, %s, %g, %d' % (kwargs['metric'],
526-
kwargs['fixed_image'],
527-
kwargs['moving_image'],
528-
kwargs['weight'],
514+
fixed, moving, kwargs['weight'],
529515
kwargs['radius_or_bins'])
530516

531517
# The optional sampling strategy.

0 commit comments

Comments
 (0)