FireANTs Registration
RegisterImagesFireants provides GPU-accelerated rigid, affine, and
deformable image registration using the FireANTs backend.
Class Reference
- class monai_physio.RegisterImagesFireants(log_level=20)[source]
Bases:
RegisterImagesBaseFireANTs-based image registration implementation.
This class extends RegisterImagesBase to provide rigid, affine, and deformable image registration on the GPU using FireANTs. FireANTs transforms are expressed in physical (LPS) coordinates as
y = A x + tfrom the fixed to the moving image, which is the ITKfixed_to_moving_transformdirectly.- number_of_iterations
List of iterations per level (e.g. [40, 20, 10]). Level
iofnruns at downsampling factor2 ** (n - 1 - i).
- transform_type
‘Deformable’, ‘Affine’, or ‘Rigid’
- metric
‘CC’ (-> cc), ‘Mattes’ (-> mi), or ‘MeanSquares’ (-> mse)
- scales
Optional explicit downsampling factor per level (coarse to fine); when None they follow from
number_of_iterations.
- init_affine
Source of the deformable stage’s initial transform: ‘Affine’ (FireANTs affine registration) or ‘Identity’ (none).
- deformable_options
Keyword arguments forwarded to FireANTs’
GreedyRegistration(seeset_deformable_options).
- set_number_of_iterations(number_of_iterations)[source]
Set the number of iterations per resolution level.
- set_transform_type(transform_type)[source]
Set the type of transform: Deformable, Affine, or Rigid.
- configure_for_heart_ct()[source]
Apply the tuned deformable settings for cardiac 4D CT.
Values from experiments/Registration-Fireants_vs_Greedy/results/REPORT.md: deformable-only (identity initial transform) CC registration.
- Return type:
- configure_for_lung_ct()[source]
Apply the tuned deformable settings for lung 4D CT.
Values from experiments/Registration-Fireants_vs_Greedy/results/REPORT.md: deformable-only (identity initial transform) CC registration at coarser scales than the heart.
- Return type:
- registration_method(moving_image, moving_mask=None, moving_labelmap=None, moving_image_pre=None)[source]
Register moving image to fixed image using FireANTs.
Returns a dict with “fixed_to_moving_transform”, “moving_to_fixed_transform”, and “loss”. As with the other image-registration backends, fixed_to_moving_transform warps the moving image onto the fixed grid and moving_to_fixed_transform warps the fixed image onto the moving grid; point and landmark warps use the opposite transform from image warps (see docs/developer/transform_conventions).
- Raises:
ValueError – If the fixed image is not set.
NotImplementedError – For
moving_labelmaporfixed_labelmap, which FireANTs cannot use as a similarity term. Masks are used through the FireANTs masked loss; a mask on only one image is paired with an all-ones mask on the other.
- Return type:
Basic Registration
import itk
from monai_physio import RegisterImagesFireants
fixed = itk.imread("reference.mha")
moving = itk.imread("moving.mha")
registrar = RegisterImagesFireants()
registrar.set_modality("ct")
registrar.set_fixed_image(fixed)
result = registrar.register(moving)
fixed_to_moving_transform = result["fixed_to_moving_transform"]
moving_to_fixed_transform = result["moving_to_fixed_transform"]
registered = registrar.get_registered_image()
Installation Note
RegisterImagesFireants requires the fireants package, which is not
installed by default. Install it without its dependencies, so that it does not
replace the CUDA build of PyTorch already in the environment:
pip install fireants --no-deps