nifreeze.registration.ants module

Using ANTs for image registration.

nifreeze.registration.ants.generate_command(fixed_path: str | Path, moving_path: str | Path, fixedmask_path: str | Path | list[str] | None = None, movingmask_path: str | Path | list[str] | None = None, init_affine: str | Path | None = None, default: str = 'b0-to-b0_level0', **kwargs: dict) str[source]

Generate an ANTs’ command line.

Parameters:
  • fixed_path (os.pathlike) – Path to the fixed image.

  • moving_path (os.pathlike) – Path to the moving image.

  • fixedmask_path (os.pathlike or list, optional) – Path to the fixed image mask.

  • movingmask_path (os.pathlike or list, optional) – Path to the moving image mask.

  • init_affine (os.pathlike, optional) – Initial affine transformation.

  • default (str, optional) – Default settings configuration.

  • **kwargs (dict) – Additional parameters for ANTs registration.

Returns:

The ANTs registration command line string.

Return type:

str

Examples

>>> generate_command(
...     fixed_path=repodata / 'fileA.nii.gz',
...     moving_path=repodata / 'fileB.nii.gz',
... )  
'antsRegistration --collapse-output-transforms 1 --dimensionality 3     --initialize-transforms-per-stage 0 --interpolation Linear --output transform     --transform Rigid[ 12.0 ]     --metric GC[ .../fileA.nii.gz,         .../fileB.nii.gz,         1, 3, Random, 0.4 ]     --convergence [ 20, 1e-06, 4 ] --smoothing-sigmas 2.71vox --shrink-factors 3     --use-histogram-matching 1     --transform Rigid[ 1.96 ]     --metric GC[ .../fileA.nii.gz,         .../fileB.nii.gz,         1, 4, Random, 0.18 ]     --convergence [ 10, 1e-07, 2 ] --smoothing-sigmas 0.0vox --shrink-factors 2     --use-histogram-matching 1     -v --winsorize-image-intensities [ 0.063, 0.991 ]     --write-composite-transform 0'
>>> generate_command(
...     fixed_path=repodata / 'fileA.nii.gz',
...     moving_path=repodata / 'fileB.nii.gz',
...     default="dwi-to-b0_level0",
... )  
'antsRegistration --collapse-output-transforms 1 --dimensionality 3     --initialize-transforms-per-stage 0 --interpolation Linear --output transform     --transform Rigid[ 0.01 ] --metric Mattes[         .../fileA.nii.gz,         .../fileB.nii.gz,         1, 32, Regular, 0.2     ] --convergence [ 100x50, 1e-05, 10 ] --smoothing-sigmas 2.0x0.0vox     --shrink-factors 2x1 --use-histogram-matching 1 --transform Rigid[ 0.001 ]     --metric Mattes[         .../fileA.nii.gz,         .../fileB.nii.gz,         1, 32, Random, 0.1     ] --convergence [ 25, 1e-06, 2 ] --smoothing-sigmas 0.0vox --shrink-factors 1     --use-histogram-matching 1 -v --winsorize-image-intensities [ 0.0001, 0.9998 ]     --write-composite-transform 0'
>>> generate_command(
...     fixed_path=repodata / 'fileA.nii.gz',
...     moving_path=repodata / 'fileB.nii.gz',
...     fixedmask_path=repodata / 'maskA.nii.gz',
...     default="dwi-to-b0_level0",
... )  
'antsRegistration --collapse-output-transforms 1 --dimensionality 3     --initialize-transforms-per-stage 0 --interpolation Linear --output transform     --transform Rigid[ 0.01 ] --metric Mattes[         .../fileA.nii.gz,         .../fileB.nii.gz,         1, 32, Regular, 0.2 ]     --convergence [ 100x50, 1e-05, 10 ] --smoothing-sigmas 2.0x0.0vox --shrink-factors 2x1     --use-histogram-matching 1 --masks [         .../maskA.nii.gz, NULL ]     --transform Rigid[ 0.001 ] --metric Mattes[         .../fileA.nii.gz,         .../fileB.nii.gz,         1, 32, Random, 0.1 ]     --convergence [ 25, 1e-06, 2 ] --smoothing-sigmas 0.0vox --shrink-factors 1     --use-histogram-matching 1 --masks [         .../maskA.nii.gz, NULL ]     -v --winsorize-image-intensities [ 0.0001, 0.9998 ]  --write-composite-transform 0'
>>> generate_command(
...     fixed_path=repodata / 'fileA.nii.gz',
...     moving_path=repodata / 'fileB.nii.gz',
...     default="dwi-to-b0_level0",
... )  
'antsRegistration --collapse-output-transforms 1 --dimensionality 3     --initialize-transforms-per-stage 0 --interpolation Linear --output transform     --transform Rigid[ 0.01 ] --metric Mattes[         .../fileA.nii.gz,         .../fileB.nii.gz,         1, 32, Regular, 0.2     ] --convergence [ 100x50, 1e-05, 10 ] --smoothing-sigmas 2.0x0.0vox     --shrink-factors 2x1 --use-histogram-matching 1 --transform Rigid[ 0.001 ]     --metric Mattes[         .../fileA.nii.gz,         .../fileB.nii.gz,         1, 32, Random, 0.1     ] --convergence [ 25, 1e-06, 2 ] --smoothing-sigmas 0.0vox --shrink-factors 1     --use-histogram-matching 1 -v --winsorize-image-intensities [ 0.0001, 0.9998 ]     --write-composite-transform 0'
>>> generate_command(
...     fixed_path=repodata / 'fileA.nii.gz',
...     moving_path=repodata / 'fileB.nii.gz',
...     fixedmask_path=[repodata / 'maskA.nii.gz'],
...     default="dwi-to-b0_level0",
... )  
'antsRegistration --collapse-output-transforms 1 --dimensionality 3     --initialize-transforms-per-stage 0 --interpolation Linear --output transform     --transform Rigid[ 0.01 ] --metric Mattes[         .../fileA.nii.gz,         .../fileB.nii.gz,         1, 32, Regular, 0.2 ]     --convergence [ 100x50, 1e-05, 10 ] --smoothing-sigmas 2.0x0.0vox --shrink-factors 2x1     --use-histogram-matching 1 --masks [ NULL, NULL ]     --transform Rigid[ 0.001 ] --metric Mattes[         .../fileA.nii.gz,         .../fileB.nii.gz,         1, 32, Random, 0.1 ]     --convergence [ 25, 1e-06, 2 ] --smoothing-sigmas 0.0vox --shrink-factors 1     --use-histogram-matching 1 --masks [         .../maskA.nii.gz, NULL ]     -v --winsorize-image-intensities [ 0.0001, 0.9998 ]  --write-composite-transform 0'