@@ -446,7 +446,7 @@ class Registration(ANTSCommand):
446
446
>>> reg5.inputs.sampling_strategy = ['Random', None] # use default strategy in second stage
447
447
>>> reg5.inputs.sampling_percentage = [0.05, [0.05, 0.10]]
448
448
>>> 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[ 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'
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'
450
450
"""
451
451
DEF_SAMPLING_STRATEGY = 'None'
452
452
"""The default sampling strategy argument."""
@@ -466,14 +466,12 @@ def _formatMetric(self, index):
466
466
----------
467
467
index: the stage index
468
468
"""
469
- # The common fixed image.
470
- fixed = self .inputs .fixed_image [0 ]
471
- # The common moving image.
472
- moving = self .inputs .moving_image [0 ]
473
469
# The metric name input for the current stage.
474
470
name_input = self .inputs .metric [index ]
475
471
# The stage-specific input dictionary.
476
472
stage_inputs = dict (
473
+ fixed_image = self .inputs .fixed_image [0 ],
474
+ moving_image = self .inputs .moving_image [0 ],
477
475
metric = name_input ,
478
476
weight = self .inputs .metric_weight [index ],
479
477
radius_or_bins = self .inputs .radius_or_number_of_bins [index ],
@@ -502,16 +500,32 @@ def _formatMetric(self, index):
502
500
# dict-comprehension only works with python 2.7 and up
503
501
#specs = [{k: v[i] for k, v in items} for i in indexes]
504
502
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 )
505
517
else :
506
518
specs = [stage_inputs ]
507
519
508
520
# Format the --metric command line metric arguments, one per
509
521
# specification.
510
- return [self ._formatMetricArgument (fixed , moving , ** spec ) for spec in specs ]
522
+ return [self ._formatMetricArgument (** spec ) for spec in specs ]
511
523
512
- def _formatMetricArgument (self , fixed , moving , ** kwargs ):
524
+ def _formatMetricArgument (self , ** kwargs ):
513
525
retval = '%s[ %s, %s, %g, %d' % (kwargs ['metric' ],
514
- fixed , moving , kwargs ['weight' ],
526
+ kwargs ['fixed_image' ],
527
+ kwargs ['moving_image' ],
528
+ kwargs ['weight' ],
515
529
kwargs ['radius_or_bins' ])
516
530
517
531
# The optional sampling strategy.
0 commit comments