Greedy Registration

RegisterImagesGreedy provides fast CPU-based deformable image registration using the PICSL Greedy backend.

Class Reference

class physiomotion4d.RegisterImagesGreedy(log_level=20)[source]

Bases: RegisterImagesBase

Greedy-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 ImageTools

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”)

__init__(log_level=20)[source]

Initialize the Greedy image registration class.

Parameters:

log_level (int | str) – Logging level (default: logging.INFO)

set_number_of_iterations(number_of_iterations)[source]

Set the number of iterations per resolution level.

Parameters:

number_of_iterations (list[int]) – List of iterations (e.g. [40, 20, 10]).

Return type:

None

set_transform_type(transform_type)[source]

Set the type of transform: Deformable, Affine, or Rigid.

Parameters:

transform_type (str) – ‘Deformable’, ‘Affine’, or ‘Rigid’.

Return type:

None

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.

Parameters:

metric (str) – ‘CC’, ‘Mattes’, or ‘MeanSquares’.

Return type:

None

registration_method(moving_image, moving_mask=None, moving_labelmap=None, moving_image_pre=None, initial_forward_transform=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. Composes with initial_forward_transform when provided.

Return type:

dict[str, Union[Transform, float]]

Basic Registration

import itk

from physiomotion4d 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)

forward_transform = result["forward_transform"]
inverse_transform = result["inverse_transform"]
registered = registrar.get_registered_image()

Installation Note

RegisterImagesGreedy requires the picsl-greedy package, which is not installed by default:

pip install picsl-greedy

See Also