class_docstr: ANTs Registration command for registration of images
  
  `antsRegistration <http://stnava.github.io/ANTs/>`_ registers a ``moving_image`` to a ``fixed_image``,
  using a predefined (sequence of) cost function(s) and transformation operations.
  The cost function is defined using one or more 'metrics', specifically
  local cross-correlation (``CC``), Mean Squares (``MeanSquares``), Demons (``Demons``),
  global correlation (``GC``), or Mutual Information (``Mattes`` or ``MI``).
  
  ANTS can use both linear (``Translation``, ``Rigid``, ``Affine``, ``CompositeAffine``,
  or ``Translation``) and non-linear transformations (``BSpline``, ``GaussianDisplacementField``,
  ``TimeVaryingVelocityField``, ``TimeVaryingBSplineVelocityField``, ``SyN``, ``BSplineSyN``,
  ``Exponential``, or ``BSplineExponential``). Usually, registration is done in multiple
  *stages*. For example first an Affine, then a Rigid, and ultimately a non-linear
  (Syn)-transformation.
  
  antsRegistration can be initialized using one or more transforms from moving_image
  to fixed_image with the ``initial_moving_transform``-input. For example, when you
  already have a warpfield that corrects for geometrical distortions in an EPI (functional) image,
  that you want to apply before an Affine registration to a structural image.
  You could put this transform into 'intial_moving_transform'.
  
  The Registration-interface can output the resulting transform(s) that map moving_image to
  fixed_image in a single file as a ``composite_transform`` (if ``write_composite_transform``
  is set to ``True``), or a list of transforms as ``forwards_transforms``. It can also output
  inverse transforms (from ``fixed_image`` to ``moving_image``) in a similar fashion using
  ``inverse_composite_transform``. Note that the order of ``forward_transforms`` is in 'natural'
  order: the first element should be applied first, the last element should be applied last.
  
  Note, however, that ANTS tools always apply lists of transformations in reverse order (the last
  transformation in the list is applied first). Therefore, if the output forward_transforms
  is a list, one can not directly feed it into, for example, ``ants.ApplyTransforms``. To
  make ``ants.ApplyTransforms`` apply the transformations in the same order as ``ants.Registration``,
  you have to provide the list of transformations in reverse order from ``forward_transforms``.
  ``reverse_forward_transforms`` outputs ``forward_transforms`` in reverse order and can be used for
  this purpose. Note also that, because ``composite_transform`` is always a single file, this
  output is preferred for  most use-cases.
  
  More information can be found in the `ANTS
  manual <https://sourceforge.net/projects/advants/files/Documentation/ants.pdf/download>`_.
  
  See below for some useful examples.
  
  Examples
  --------
  
  Set up a Registration node with some default settings. This Node registers
  'fixed1.nii' to 'moving1.nii' by first fitting a linear 'Affine' transformation, and
  then a non-linear 'SyN' transformation, both using the Mutual Information-cost
  metric.
  
  The registration is initialized by first applying the (linear) transform
  trans.mat.
  
  >>> import copy, pprint
  >>> from nipype.interfaces.ants import Registration
  >>> reg = Registration()
  >>> reg.inputs.fixed_image = 'fixed1.nii'
  >>> reg.inputs.moving_image = 'moving1.nii'
  >>> reg.inputs.output_transform_prefix = "output_"
  >>> reg.inputs.initial_moving_transform = 'trans.mat'
  >>> reg.inputs.transforms = ['Affine', 'SyN']
  >>> reg.inputs.transform_parameters = [(2.0,), (0.25, 3.0, 0.0)]
  >>> reg.inputs.number_of_iterations = [[1500, 200], [100, 50, 30]]
  >>> reg.inputs.dimension = 3
  >>> reg.inputs.write_composite_transform = True
  >>> reg.inputs.collapse_output_transforms = False
  >>> reg.inputs.initialize_transforms_per_stage = False
  >>> reg.inputs.metric = ['Mattes']*2
  >>> reg.inputs.metric_weight = [1]*2 # Default (value ignored currently by ANTs)
  >>> reg.inputs.radius_or_number_of_bins = [32]*2
  >>> reg.inputs.sampling_strategy = ['Random', None]
  >>> reg.inputs.sampling_percentage = [0.05, None]
  >>> reg.inputs.convergence_threshold = [1.e-8, 1.e-9]
  >>> reg.inputs.convergence_window_size = [20]*2
  >>> reg.inputs.smoothing_sigmas = [[1,0], [2,1,0]]
  >>> reg.inputs.sigma_units = ['vox'] * 2
  >>> reg.inputs.shrink_factors = [[2,1], [3,2,1]]
  >>> reg.inputs.use_estimate_learning_rate_once = [True, True]
  >>> reg.inputs.use_histogram_matching = [True, True] # This is the default
  >>> reg.inputs.output_warped_image = 'output_warped_image.nii.gz'
  >>> reg.cmdline
  'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --initial-moving-transform [ trans.mat, 0 ] --initialize-transforms-per-stage 0 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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'
  >>> reg.run()  # doctest: +SKIP
  
  Same as reg1, but first invert the initial transform ('trans.mat') before applying it.
  
  >>> reg.inputs.invert_initial_moving_transform = True
  >>> reg1 = copy.deepcopy(reg)
  >>> reg1.inputs.winsorize_lower_quantile = 0.025
  >>> reg1.cmdline
  '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 ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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.025, 1.0 ]  --write-composite-transform 1'
  >>> reg1.run()  # doctest: +SKIP
  
  Clip extremely high intensity data points using winsorize_upper_quantile. All data points
  higher than the 0.975 quantile are set to the value of the 0.975 quantile.
  
  >>> reg2 = copy.deepcopy(reg)
  >>> reg2.inputs.winsorize_upper_quantile = 0.975
  >>> reg2.cmdline
  '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 ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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, 0.975 ]  --write-composite-transform 1'
  
  Clip extremely low intensity data points using winsorize_lower_quantile. All data points
  lower than the 0.025 quantile are set to the original value at the 0.025 quantile.
  
  
  >>> reg3 = copy.deepcopy(reg)
  >>> reg3.inputs.winsorize_lower_quantile = 0.025
  >>> reg3.inputs.winsorize_upper_quantile = 0.975
  >>> reg3.cmdline
  '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 ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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.025, 0.975 ]  --write-composite-transform 1'
  
  Use float instead of double for computations (saves memory usage)
  
  >>> reg3a = copy.deepcopy(reg)
  >>> reg3a.inputs.float = True
  >>> reg3a.cmdline
  'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --float 1 --initial-moving-transform [ trans.mat, 1 ] --initialize-transforms-per-stage 0 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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'
  
  Force to use double instead of float for computations (more precision and memory usage).
  
  >>> reg3b = copy.deepcopy(reg)
  >>> reg3b.inputs.float = False
  >>> reg3b.cmdline
  'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --float 0 --initial-moving-transform [ trans.mat, 1 ] --initialize-transforms-per-stage 0 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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'
  
  'collapse_output_transforms' can be used to put all transformation in a single 'composite_transform'-
  file. Note that forward_transforms will now be an empty list.
  
  >>> # Test collapse transforms flag
  >>> reg4 = copy.deepcopy(reg)
  >>> reg4.inputs.save_state = 'trans.mat'
  >>> reg4.inputs.restore_state = 'trans.mat'
  >>> reg4.inputs.initialize_transforms_per_stage = True
  >>> reg4.inputs.collapse_output_transforms = True
  >>> outputs = reg4._list_outputs()
  >>> pprint.pprint(outputs)  # doctest: +ELLIPSIS,
  {'composite_transform': '...data/output_Composite.h5',
   'elapsed_time': <undefined>,
   'forward_invert_flags': [],
   'forward_transforms': [],
   'inverse_composite_transform': '...data/output_InverseComposite.h5',
   'inverse_warped_image': <undefined>,
   'metric_value': <undefined>,
   'reverse_forward_invert_flags': [],
   'reverse_forward_transforms': [],
   'reverse_invert_flags': [],
   'reverse_transforms': [],
   'save_state': '...data/trans.mat',
   'warped_image': '...data/output_warped_image.nii.gz'}
  >>> reg4.cmdline
  'antsRegistration --collapse-output-transforms 1 --dimensionality 3 --initial-moving-transform [ trans.mat, 1 ] --initialize-transforms-per-stage 1 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --restore-state trans.mat --save-state trans.mat --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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'
  
  
  >>> # Test collapse transforms flag
  >>> reg4b = copy.deepcopy(reg4)
  >>> reg4b.inputs.write_composite_transform = False
  >>> outputs = reg4b._list_outputs()
  >>> pprint.pprint(outputs)  # doctest: +ELLIPSIS,
  {'composite_transform': <undefined>,
   'elapsed_time': <undefined>,
   'forward_invert_flags': [False, False],
   'forward_transforms': ['...data/output_0GenericAffine.mat',
   '...data/output_1Warp.nii.gz'],
   'inverse_composite_transform': <undefined>,
   'inverse_warped_image': <undefined>,
   'metric_value': <undefined>,
   'reverse_forward_invert_flags': [False, False],
   'reverse_forward_transforms': ['...data/output_1Warp.nii.gz',
   '...data/output_0GenericAffine.mat'],
   'reverse_invert_flags': [True, False],
   'reverse_transforms': ['...data/output_0GenericAffine.mat',     '...data/output_1InverseWarp.nii.gz'],
   'save_state': '...data/trans.mat',
   'warped_image': '...data/output_warped_image.nii.gz'}
  >>> reg4b.aggregate_outputs()  # doctest: +SKIP
  >>> reg4b.cmdline
  'antsRegistration --collapse-output-transforms 1 --dimensionality 3 --initial-moving-transform [ trans.mat, 1 ] --initialize-transforms-per-stage 1 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --restore-state trans.mat --save-state trans.mat --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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 0'
  
  One can use multiple similarity metrics in a single registration stage.The Node below first
  performs a linear registration using only the Mutual Information ('Mattes')-metric.
  In a second stage, it performs a non-linear registration ('Syn') using both a
  Mutual Information and a local cross-correlation ('CC')-metric. Both metrics are weighted
  equally ('metric_weight' is .5 for both). The Mutual Information- metric uses 32 bins.
  The local cross-correlations (correlations between every voxel's neighborhoods) is computed
  with a radius of 4.
  
  >>> # Test multiple metrics per stage
  >>> reg5 = copy.deepcopy(reg)
  >>> reg5.inputs.fixed_image = 'fixed1.nii'
  >>> reg5.inputs.moving_image = 'moving1.nii'
  >>> reg5.inputs.metric = ['Mattes', ['Mattes', 'CC']]
  >>> reg5.inputs.metric_weight = [1, [.5,.5]]
  >>> reg5.inputs.radius_or_number_of_bins = [32, [32, 4] ]
  >>> reg5.inputs.sampling_strategy = ['Random', None] # use default strategy in second stage
  >>> reg5.inputs.sampling_percentage = [0.05, [0.05, 0.10]]
  >>> reg5.cmdline
  '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 ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 0.5, 32, None, 0.05 ] --metric CC[ fixed1.nii, moving1.nii, 0.5, 4, 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'
  
  ANTS Registration can also use multiple modalities to perform the registration. Here it is assumed
  that fixed1.nii and fixed2.nii are in the same space, and so are moving1.nii and
  moving2.nii. First, a linear registration is performed matching fixed1.nii to moving1.nii,
  then a non-linear registration is performed to match fixed2.nii to moving2.nii, starting from
  the transformation of the first step.
  
  >>> # Test multiple inputS
  >>> reg6 = copy.deepcopy(reg5)
  >>> reg6.inputs.fixed_image = ['fixed1.nii', 'fixed2.nii']
  >>> reg6.inputs.moving_image = ['moving1.nii', 'moving2.nii']
  >>> reg6.cmdline
  '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 ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 0.5, 32, None, 0.05 ] --metric CC[ fixed2.nii, moving2.nii, 0.5, 4, 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'
  
  Different methods can be used for the interpolation when applying transformations.
  
  >>> # Test Interpolation Parameters (BSpline)
  >>> reg7a = copy.deepcopy(reg)
  >>> reg7a.inputs.interpolation = 'BSpline'
  >>> reg7a.inputs.interpolation_parameters = (3,)
  >>> reg7a.cmdline
  'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --initial-moving-transform [ trans.mat, 1 ] --initialize-transforms-per-stage 0 --interpolation BSpline[ 3 ] --output [ output_, output_warped_image.nii.gz ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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'
  
  >>> # Test Interpolation Parameters (MultiLabel/Gaussian)
  >>> reg7b = copy.deepcopy(reg)
  >>> reg7b.inputs.interpolation = 'Gaussian'
  >>> reg7b.inputs.interpolation_parameters = (1.0, 1.0)
  >>> reg7b.cmdline
  'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --initial-moving-transform [ trans.mat, 1 ] --initialize-transforms-per-stage 0 --interpolation Gaussian[ 1.0, 1.0 ] --output [ output_, output_warped_image.nii.gz ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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'
  
  BSplineSyN non-linear registration with custom parameters.
  
  >>> # Test Extended Transform Parameters
  >>> reg8 = copy.deepcopy(reg)
  >>> reg8.inputs.transforms = ['Affine', 'BSplineSyN']
  >>> reg8.inputs.transform_parameters = [(2.0,), (0.25, 26, 0, 3)]
  >>> reg8.cmdline
  '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 ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 BSplineSyN[ 0.25, 26, 0, 3 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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'
  
  Mask the fixed image in the second stage of the registration (but not the first).
  
  >>> # Test masking
  >>> reg9 = copy.deepcopy(reg)
  >>> reg9.inputs.fixed_image_masks = ['NULL', 'fixed1.nii']
  >>> reg9.cmdline
  '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 ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 --masks [ NULL, NULL ] --transform SyN[ 0.25, 3.0, 0.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --masks [ fixed1.nii, NULL ] --winsorize-image-intensities [ 0.0, 1.0 ]  --write-composite-transform 1'
  
  Here we use both a warpfield and a linear transformation, before registration commences.  Note that
  the first transformation that needs to be applied ('ants_Warp.nii.gz') is last in the list of
  'initial_moving_transform'.
  
  >>> # Test initialization with multiple transforms matrices (e.g., unwarp and affine transform)
  >>> reg10 = copy.deepcopy(reg)
  >>> reg10.inputs.initial_moving_transform = ['func_to_struct.mat', 'ants_Warp.nii.gz']
  >>> reg10.inputs.invert_initial_moving_transform = [False, False]
  >>> reg10.cmdline
  'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --initial-moving-transform [ func_to_struct.mat, 0 ] [ ants_Warp.nii.gz, 0 ] --initialize-transforms-per-stage 0 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, 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 Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --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'
class_docstr_tok: ["ANTs","Registration","command","for","registration","of","images","`","antsRegistration","<","http",":","\/\/stnava.github.io\/ANTs\/",">","`","_","registers","a","``","moving_image","``","to","a","``","fixed_image","``",",","using","a","predefined","(","sequence","of",")","cost","function","(","s",")","and","transformation","operations",".","The","cost","function","is","defined","using","one","or","more","'metrics","'",",","specifically","local","cross-correlation","(","``","CC","``",")",",","Mean","Squares","(","``","MeanSquares","``",")",",","Demons","(","``","Demons","``",")",",","global","correlation","(","``","GC","``",")",",","or","Mutual","Information","(","``","Mattes","``","or","``","MI","``",")",".","ANTS","can","use","both","linear","(","``","Translation","``",",","``","Rigid","``",",","``","Affine","``",",","``","CompositeAffine","``",",","or","``","Translation","``",")","and","non-linear","transformations","(","``","BSpline","``",",","``","GaussianDisplacementField","``",",","``","TimeVaryingVelocityField","``",",","``","TimeVaryingBSplineVelocityField","``",",","``","SyN","``",",","``","BSplineSyN","``",",","``","Exponential","``",",","or","``","BSplineExponential","``",")",".","Usually",",","registration","is","done","in","multiple","*","stages","*",".","For","example","first","an","Affine",",","then","a","Rigid",",","and","ultimately","a","non-linear","(","Syn",")","-transformation",".","antsRegistration","can","be","initialized","using","one","or","more","transforms","from","moving_image","to","fixed_image","with","the","``","initial_moving_transform","``","-input",".","For","example",",","when","you","already","have","a","warpfield","that","corrects","for","geometrical","distortions","in","an","EPI","(","functional",")","image",",","that","you","want","to","apply","before","an","Affine","registration","to","a","structural","image",".","You","could","put","this","transform","into","'intial_moving_transform","'",".","The","Registration-interface","can","output","the","resulting","transform","(","s",")","that","map","moving_image","to","fixed_image","in","a","single","file","as","a","``","composite_transform","``","(","if","``","write_composite_transform","``","is","set","to","``","True","``",")",",","or","a","list","of","transforms","as","``","forwards_transforms","``",".","It","can","also","output","inverse","transforms","(","from","``","fixed_image","``","to","``","moving_image","``",")","in","a","similar","fashion","using","``","inverse_composite_transform","``",".","Note","that","the","order","of","``","forward_transforms","``","is","in","'natural'","order",":","the","first","element","should","be","applied","first",",","the","last","element","should","be","applied","last",".","Note",",","however",",","that","ANTS","tools","always","apply","lists","of","transformations","in","reverse","order","(","the","last","transformation","in","the","list","is","applied","first",")",".","Therefore",",","if","the","output","forward_transforms","is","a","list",",","one","can","not","directly","feed","it","into",",","for","example",",","``","ants.ApplyTransforms","``",".","To","make","``","ants.ApplyTransforms","``","apply","the","transformations","in","the","same","order","as","``","ants.Registration","``",",","you","have","to","provide","the","list","of","transformations","in","reverse","order","from","``","forward_transforms","``",".","``","reverse_forward_transforms","``","outputs","``","forward_transforms","``","in","reverse","order","and","can","be","used","for","this","purpose",".","Note","also","that",",","because","``","composite_transform","``","is","always","a","single","file",",","this","output","is","preferred","for","most","use-cases",".","More","information","can","be","found","in","the","`","ANTS","manual","<","https",":","\/\/sourceforge.net\/projects\/advants\/files\/Documentation\/ants.pdf\/download",">","`","_",".","See","below","for","some","useful","examples",".","Examples","--","--","--","--","Set","up","a","Registration","node","with","some","default","settings",".","This","Node","registers","'fixed1.nii","'","to","'moving1.nii","'","by","first","fitting","a","linear","'Affine","'","transformation",",","and","then","a","non-linear","'SyN","'","transformation",",","both","using","the","Mutual","Information-cost","metric",".","The","registration","is","initialized","by","first","applying","the","(","linear",")","transform","trans.mat",".",">",">",">","import","copy",",","pprint",">",">",">","from","nipype.interfaces.ants","import","Registration",">",">",">","reg","=","Registration","(",")",">",">",">","reg.inputs.fixed_image","=","'fixed1.nii'",">",">",">","reg.inputs.moving_image","=","'moving1.nii'",">",">",">","reg.inputs.output_transform_prefix","=","``","output_","''",">",">",">","reg.inputs.initial_moving_transform","=","'trans.mat'",">",">",">","reg.inputs.transforms","=","[","'Affine","'",",","'SyN","'","]",">",">",">","reg.inputs.transform_parameters","=","[","(","2.0",",",")",",","(","0.25",",","3.0",",","0.0",")","]",">",">",">","reg.inputs.number_of_iterations","=","[","[","1500",",","200","]",",","[","100",",","50",",","30","]","]",">",">",">","reg.inputs.dimension","=","3",">",">",">","reg.inputs.write_composite_transform","=","True",">",">",">","reg.inputs.collapse_output_transforms","=","False",">",">",">","reg.inputs.initialize_transforms_per_stage","=","False",">",">",">","reg.inputs.metric","=","[","'Mattes","'","]","*","2",">",">",">","reg.inputs.metric_weight","=","[","1","]","*","2","#","Default","(","value","ignored","currently","by","ANTs",")",">",">",">","reg.inputs.radius_or_number_of_bins","=","[","32","]","*","2",">",">",">","reg.inputs.sampling_strategy","=","[","'Random","'",",","None","]",">",">",">","reg.inputs.sampling_percentage","=","[","0.05",",","None","]",">",">",">","reg.inputs.convergence_threshold","=","[","1.e-8",",","1.e-9","]",">",">",">","reg.inputs.convergence_window_size","=","[","20","]","*","2",">",">",">","reg.inputs.smoothing_sigmas","=","[","[","1,0","]",",","[","2,1,0","]","]",">",">",">","reg.inputs.sigma_units","=","[","'vox","'","]","*","2",">",">",">","reg.inputs.shrink_factors","=","[","[","2,1","]",",","[","3,2,1","]","]",">",">",">","reg.inputs.use_estimate_learning_rate_once","=","[","True",",","True","]",">",">",">","reg.inputs.use_histogram_matching","=","[","True",",","True","]","#","This","is","the","default",">",">",">","reg.inputs.output_warped_image","=","'output_warped_image.nii.gz'",">",">",">","reg.cmdline","'antsRegistration","--","collapse-output-transforms","0","--","dimensionality","3","--","initial-moving-transform","[","trans.mat",",","0","]","--","initialize-transforms-per-stage","0","--","interpolation","Linear","--","output","[","output_",",","output_warped_image.nii.gz","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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'",">",">",">","reg.run","(",")","#","doctest",":","+SKIP","Same","as","reg1",",","but","first","invert","the","initial","transform","(","'trans.mat","'",")","before","applying","it",".",">",">",">","reg.inputs.invert_initial_moving_transform","=","True",">",">",">","reg1","=","copy.deepcopy","(","reg",")",">",">",">","reg1.inputs.winsorize_lower_quantile","=","0.025",">",">",">","reg1.cmdline","'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","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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.025",",","1.0","]","--","write-composite-transform","1'",">",">",">","reg1.run","(",")","#","doctest",":","+SKIP","Clip","extremely","high","intensity","data","points","using","winsorize_upper_quantile",".","All","data","points","higher","than","the","0.975","quantile","are","set","to","the","value","of","the","0.975","quantile",".",">",">",">","reg2","=","copy.deepcopy","(","reg",")",">",">",">","reg2.inputs.winsorize_upper_quantile","=","0.975",">",">",">","reg2.cmdline","'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","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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",",","0.975","]","--","write-composite-transform","1'","Clip","extremely","low","intensity","data","points","using","winsorize_lower_quantile",".","All","data","points","lower","than","the","0.025","quantile","are","set","to","the","original","value","at","the","0.025","quantile",".",">",">",">","reg3","=","copy.deepcopy","(","reg",")",">",">",">","reg3.inputs.winsorize_lower_quantile","=","0.025",">",">",">","reg3.inputs.winsorize_upper_quantile","=","0.975",">",">",">","reg3.cmdline","'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","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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.025",",","0.975","]","--","write-composite-transform","1'","Use","float","instead","of","double","for","computations","(","saves","memory","usage",")",">",">",">","reg3a","=","copy.deepcopy","(","reg",")",">",">",">","reg3a.inputs.float","=","True",">",">",">","reg3a.cmdline","'antsRegistration","--","collapse-output-transforms","0","--","dimensionality","3","--","float","1","--","initial-moving-transform","[","trans.mat",",","1","]","--","initialize-transforms-per-stage","0","--","interpolation","Linear","--","output","[","output_",",","output_warped_image.nii.gz","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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'","Force","to","use","double","instead","of","float","for","computations","(","more","precision","and","memory","usage",")",".",">",">",">","reg3b","=","copy.deepcopy","(","reg",")",">",">",">","reg3b.inputs.float","=","False",">",">",">","reg3b.cmdline","'antsRegistration","--","collapse-output-transforms","0","--","dimensionality","3","--","float","0","--","initial-moving-transform","[","trans.mat",",","1","]","--","initialize-transforms-per-stage","0","--","interpolation","Linear","--","output","[","output_",",","output_warped_image.nii.gz","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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'","'collapse_output_transforms","'","can","be","used","to","put","all","transformation","in","a","single","'composite_transform'-","file",".","Note","that","forward_transforms","will","now","be","an","empty","list",".",">",">",">","#","Test","collapse","transforms","flag",">",">",">","reg4","=","copy.deepcopy","(","reg",")",">",">",">","reg4.inputs.save_state","=","'trans.mat'",">",">",">","reg4.inputs.restore_state","=","'trans.mat'",">",">",">","reg4.inputs.initialize_transforms_per_stage","=","True",">",">",">","reg4.inputs.collapse_output_transforms","=","True",">",">",">","outputs","=","reg4._list_outputs","(",")",">",">",">","pprint.pprint","(","outputs",")","#","doctest",":","+ELLIPSIS",",","{","'composite_transform","'",":","'","...","data\/output_Composite.h5","'",",","'elapsed_time","'",":","<","undefined",">",",","'forward_invert_flags","'",":","[","]",",","'forward_transforms","'",":","[","]",",","'inverse_composite_transform","'",":","'","...","data\/output_InverseComposite.h5","'",",","'inverse_warped_image","'",":","<","undefined",">",",","'metric_value","'",":","<","undefined",">",",","'reverse_forward_invert_flags","'",":","[","]",",","'reverse_forward_transforms","'",":","[","]",",","'reverse_invert_flags","'",":","[","]",",","'reverse_transforms","'",":","[","]",",","'save_state","'",":","'","...","data\/trans.mat","'",",","'warped_image","'",":","'","...","data\/output_warped_image.nii.gz","'","}",">",">",">","reg4.cmdline","'antsRegistration","--","collapse-output-transforms","1","--","dimensionality","3","--","initial-moving-transform","[","trans.mat",",","1","]","--","initialize-transforms-per-stage","1","--","interpolation","Linear","--","output","[","output_",",","output_warped_image.nii.gz","]","--","restore-state","trans.mat","--","save-state","trans.mat","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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'",">",">",">","#","Test","collapse","transforms","flag",">",">",">","reg4b","=","copy.deepcopy","(","reg4",")",">",">",">","reg4b.inputs.write_composite_transform","=","False",">",">",">","outputs","=","reg4b._list_outputs","(",")",">",">",">","pprint.pprint","(","outputs",")","#","doctest",":","+ELLIPSIS",",","{","'composite_transform","'",":","<","undefined",">",",","'elapsed_time","'",":","<","undefined",">",",","'forward_invert_flags","'",":","[","False",",","False","]",",","'forward_transforms","'",":","[","'","...","data\/output_0GenericAffine.mat","'",",","'","...","data\/output_1Warp.nii.gz","'","]",",","'inverse_composite_transform","'",":","<","undefined",">",",","'inverse_warped_image","'",":","<","undefined",">",",","'metric_value","'",":","<","undefined",">",",","'reverse_forward_invert_flags","'",":","[","False",",","False","]",",","'reverse_forward_transforms","'",":","[","'","...","data\/output_1Warp.nii.gz","'",",","'","...","data\/output_0GenericAffine.mat","'","]",",","'reverse_invert_flags","'",":","[","True",",","False","]",",","'reverse_transforms","'",":","[","'","...","data\/output_0GenericAffine.mat","'",",","'","...","data\/output_1InverseWarp.nii.gz","'","]",",","'save_state","'",":","'","...","data\/trans.mat","'",",","'warped_image","'",":","'","...","data\/output_warped_image.nii.gz","'","}",">",">",">","reg4b.aggregate_outputs","(",")","#","doctest",":","+SKIP",">",">",">","reg4b.cmdline","'antsRegistration","--","collapse-output-transforms","1","--","dimensionality","3","--","initial-moving-transform","[","trans.mat",",","1","]","--","initialize-transforms-per-stage","1","--","interpolation","Linear","--","output","[","output_",",","output_warped_image.nii.gz","]","--","restore-state","trans.mat","--","save-state","trans.mat","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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","0'","One","can","use","multiple","similarity","metrics","in","a","single","registration","stage.The","Node","below","first","performs","a","linear","registration","using","only","the","Mutual","Information","(","'Mattes","'",")","-metric",".","In","a","second","stage",",","it","performs","a","non-linear","registration","(","'Syn","'",")","using","both","a","Mutual","Information","and","a","local","cross-correlation","(","'CC","'",")","-metric",".","Both","metrics","are","weighted","equally","(","'metric_weight","'","is",".5","for","both",")",".","The","Mutual","Information-","metric","uses","32","bins",".","The","local","cross-correlations","(","correlations","between","every","voxel","'s","neighborhoods",")","is","computed","with","a","radius","of","4",".",">",">",">","#","Test","multiple","metrics","per","stage",">",">",">","reg5","=","copy.deepcopy","(","reg",")",">",">",">","reg5.inputs.fixed_image","=","'fixed1.nii'",">",">",">","reg5.inputs.moving_image","=","'moving1.nii'",">",">",">","reg5.inputs.metric","=","[","'Mattes","'",",","[","'Mattes","'",",","'CC","'","]","]",">",">",">","reg5.inputs.metric_weight","=","[","1",",","[",".5",",",".5","]","]",">",">",">","reg5.inputs.radius_or_number_of_bins","=","[","32",",","[","32",",","4","]","]",">",">",">","reg5.inputs.sampling_strategy","=","[","'Random","'",",","None","]","#","use","default","strategy","in","second","stage",">",">",">","reg5.inputs.sampling_percentage","=","[","0.05",",","[","0.05",",","0.10","]","]",">",">",">","reg5.cmdline","'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","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","0.5",",","32",",","None",",","0.05","]","--","metric","CC","[","fixed1.nii",",","moving1.nii",",","0.5",",","4",",","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'","ANTS","Registration","can","also","use","multiple","modalities","to","perform","the","registration",".","Here","it","is","assumed","that","fixed1.nii","and","fixed2.nii","are","in","the","same","space",",","and","so","are","moving1.nii","and","moving2.nii",".","First",",","a","linear","registration","is","performed","matching","fixed1.nii","to","moving1.nii",",","then","a","non-linear","registration","is","performed","to","match","fixed2.nii","to","moving2.nii",",","starting","from","the","transformation","of","the","first","step",".",">",">",">","#","Test","multiple","inputS",">",">",">","reg6","=","copy.deepcopy","(","reg5",")",">",">",">","reg6.inputs.fixed_image","=","[","'fixed1.nii","'",",","'fixed2.nii","'","]",">",">",">","reg6.inputs.moving_image","=","[","'moving1.nii","'",",","'moving2.nii","'","]",">",">",">","reg6.cmdline","'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","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","0.5",",","32",",","None",",","0.05","]","--","metric","CC","[","fixed2.nii",",","moving2.nii",",","0.5",",","4",",","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'","Different","methods","can","be","used","for","the","interpolation","when","applying","transformations",".",">",">",">","#","Test","Interpolation","Parameters","(","BSpline",")",">",">",">","reg7a","=","copy.deepcopy","(","reg",")",">",">",">","reg7a.inputs.interpolation","=","'BSpline'",">",">",">","reg7a.inputs.interpolation_parameters","=","(","3",",",")",">",">",">","reg7a.cmdline","'antsRegistration","--","collapse-output-transforms","0","--","dimensionality","3","--","initial-moving-transform","[","trans.mat",",","1","]","--","initialize-transforms-per-stage","0","--","interpolation","BSpline","[","3","]","--","output","[","output_",",","output_warped_image.nii.gz","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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'",">",">",">","#","Test","Interpolation","Parameters","(","MultiLabel\/Gaussian",")",">",">",">","reg7b","=","copy.deepcopy","(","reg",")",">",">",">","reg7b.inputs.interpolation","=","'Gaussian'",">",">",">","reg7b.inputs.interpolation_parameters","=","(","1.0",",","1.0",")",">",">",">","reg7b.cmdline","'antsRegistration","--","collapse-output-transforms","0","--","dimensionality","3","--","initial-moving-transform","[","trans.mat",",","1","]","--","initialize-transforms-per-stage","0","--","interpolation","Gaussian","[","1.0",",","1.0","]","--","output","[","output_",",","output_warped_image.nii.gz","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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'","BSplineSyN","non-linear","registration","with","custom","parameters",".",">",">",">","#","Test","Extended","Transform","Parameters",">",">",">","reg8","=","copy.deepcopy","(","reg",")",">",">",">","reg8.inputs.transforms","=","[","'Affine","'",",","'BSplineSyN","'","]",">",">",">","reg8.inputs.transform_parameters","=","[","(","2.0",",",")",",","(","0.25",",","26",",","0",",","3",")","]",">",">",">","reg8.cmdline","'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","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","BSplineSyN","[","0.25",",","26",",","0",",","3","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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'","Mask","the","fixed","image","in","the","second","stage","of","the","registration","(","but","not","the","first",")",".",">",">",">","#","Test","masking",">",">",">","reg9","=","copy.deepcopy","(","reg",")",">",">",">","reg9.inputs.fixed_image_masks","=","[","'NULL","'",",","'fixed1.nii","'","]",">",">",">","reg9.cmdline","'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","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","--","masks","[","NULL",",","NULL","]","--","transform","SyN","[","0.25",",","3.0",",","0.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","convergence","[","100x50x30",",","1e-09",",","20","]","--","smoothing-sigmas","2.0x1.0x0.0vox","--","shrink-factors","3x2x1","--","use-estimate-learning-rate-once","1","--","use-histogram-matching","1","--","masks","[","fixed1.nii",",","NULL","]","--","winsorize-image-intensities","[","0.0",",","1.0","]","--","write-composite-transform","1'","Here","we","use","both","a","warpfield","and","a","linear","transformation",",","before","registration","commences",".","Note","that","the","first","transformation","that","needs","to","be","applied","(","'ants_Warp.nii.gz","'",")","is","last","in","the","list","of","'initial_moving_transform","'",".",">",">",">","#","Test","initialization","with","multiple","transforms","matrices","(","e.g.",",","unwarp","and","affine","transform",")",">",">",">","reg10","=","copy.deepcopy","(","reg",")",">",">",">","reg10.inputs.initial_moving_transform","=","[","'func_to_struct.mat","'",",","'ants_Warp.nii.gz","'","]",">",">",">","reg10.inputs.invert_initial_moving_transform","=","[","False",",","False","]",">",">",">","reg10.cmdline","'antsRegistration","--","collapse-output-transforms","0","--","dimensionality","3","--","initial-moving-transform","[","func_to_struct.mat",",","0","]","[","ants_Warp.nii.gz",",","0","]","--","initialize-transforms-per-stage","0","--","interpolation","Linear","--","output","[","output_",",","output_warped_image.nii.gz","]","--","transform","Affine","[","2.0","]","--","metric","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32",",","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","Mattes","[","fixed1.nii",",","moving1.nii",",","1",",","32","]","--","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","'"]
code: def _format_transform(self, index):
      retval = []
      retval.append("%s[ " % self.inputs.transforms[index])
      parameters = ", ".join(
          [
              str(element)
              for element in self.inputs.transform_parameters[index]
          ]
      )
      retval.append("%s" % parameters)
      retval.append(" ]")
      return "".join(retval)
  
imports: import os
  from ...utils.filemanip import ensure_list
  from ..base import TraitedSpec, File, Str, traits, InputMultiPath, isdefined
  from .base import ANTSCommand, ANTSCommandInputSpec, LOCAL_DEFAULT_NUMBER_OF_THREADS
label_desc: Use image node_id 5 for calling the Registration obj's underlying member method code with example usage: obj._format_transform(index) and returns: str