Greedy Registration
RegisterImagesGreedy provides fast CPU-based deformable image registration
using the PICSL Greedy backend.
Class Reference
- class monai_physio.RegisterImagesGreedy(log_level=20)[source]
Bases:
RegisterImagesBaseGreedy-based deformable image registration implementation.
This class extends RegisterImagesBase to provide deformable image registration using the PICSL Greedy algorithm. Greedy is a fast CPU-based tool for 2D/3D medical image registration, supporting rigid, affine, and deformable (NCC/SSD) registration.
Greedy-specific features: - Rigid and affine registration (-a -dof 6 or 12) - Deformable registration with multi-resolution (-n, -s) - Metrics: NMI, NCC, SSD (mapped from CC, Mattes, MeanSquares) - Optional mask support (-gm fixed, -mm moving when both provided) - SimpleITK in-memory interface via ProcessImages
Inherits from RegisterImagesBase: - Fixed and moving image management - Binary mask processing with optional dilation - Modality-specific parameter configuration - Standardized registration interface
- number_of_iterations
List of iterations per level (e.g. [40, 20, 10])
- transform_type
‘Deformable’, ‘Affine’, or ‘Rigid’
- metric
‘CC’ (→NCC), ‘Mattes’ (→NMI), or ‘MeanSquares’ (→SSD)
- deformable_smoothing
Smoothing sigmas for deformable (e.g. “2.0vox 0.5vox”) (set via set_deformable_smoothing)
- use_stationary_velocity
Whether the deformable stage optimizes a stationary velocity field (Greedy’s -sv) (set via set_stationary_velocity)
- set_stationary_velocity(use_stationary_velocity)[source]
Set whether deformable registration optimizes a velocity field (-sv).
Greedy then exponentiates a stationary velocity field into its warp rather than optimizing the warp directly. That alone does not keep the warp from folding: with the default warp smoothing of 0.5 voxel the exponentiated warp still folds. Pair it with more warp smoothing, via
set_deformable_smoothing(), when the warp must stay invertible.
- set_deformable_smoothing(gradient_sigma='2.0vox', warp_sigma='0.5vox')[source]
Set the deformable stage’s two smoothing sigmas (Greedy’s -s).
The warp sigma is the regularization that keeps the warp from folding. Points carried through a folded warp, such as a tetrahedral mesh’s nodes, invert the elements the fold covers;
"1.0vox"or more avoids that where the default"0.5vox"does not.
- 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.
- set_metric(metric)[source]
Set the similarity metric (CC→NCC, Mattes→NMI, MeanSquares→SSD).
This metric is used for both affine and deformable registration stages. Greedy recommends NCC or SSD for deformable registration; NMI works well for affine but is less suited to deformable.
- registration_method(moving_image, moving_mask=None, moving_labelmap=None, moving_image_pre=None)[source]
Register moving image to fixed image using Greedy.
Converts ITK images to SimpleITK, runs Greedy (affine and/or deformable), then converts outputs back to ITK transforms.
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).
Basic Registration
import itk
from monai_physio import RegisterImagesGreedy
fixed = itk.imread("reference.mha")
moving = itk.imread("moving.mha")
registrar = RegisterImagesGreedy()
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
RegisterImagesGreedy requires the picsl-greedy package, which is not
installed by default:
pip install picsl-greedy