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