mr2.algorithms.image_registration.correlation_registration

mr2.algorithms.image_registration.correlation_registration(fixed: Tensor, moving: Tensor, *, mask: Tensor | None = None, smooth_mask_sigma: float = 1.5, search_mask: Tensor | None = None) → SpatialDimension[Tensor][source]

Estimate a 2D or 3D shift using FFT-based normalized cross-correlation.

Parameters:
  • fixed (Tensor) – Fixed image with shape (*batch, channels, z, y, x).

  • moving (Tensor) – Moving image with shape (*batch, channels, z, y, x). Complex-valued inputs are registered phase-sensitively; pass magnitude images to ignore phase.

  • mask (Tensor | None, default: None) – Optional mask/weight tensor. Outside values are suppressed in both fixed and moving. The mask is smoothed before it is applied.

  • smooth_mask_sigma (float, default: 1.5) – Standard deviation of Gaussian mask smoothing in voxel units.

  • search_mask (Tensor | None, default: None) – Optional boolean mask restricting the allowed shifts in shift space with shape (*batch, 1, z-shift, y-shift, x-shift). This mask is defined in shift space with zero shift at the center. Values outside the dimensions of the mask are treated as false / forbidden. Example: torch.ones(1,1,10,10,10) would allow shifts in the range [-5, 4] in each dimension.

Returns:

Estimated voxel shift to apply to moving to align it to fixed. For 2D inputs (z == 1), the returned z-shift is zero.