MIR.models.registration_utils

Model-level registration utilities (transformers and geometry).

Functions

ensemble_average(fields, field_types[, ...])

Ensemble average of displacement fields or SVFs. :param fields: list of displacement fields, each (*vol, ndims) :param field_types: parallel list, 'svf' or 'disp' :param weights: list of floats or None (defaults to equal) :param nb_steps: number of integration steps for VecInt :param iters: number of iterations for fit_warp_to_svf.

ensure_svf(field, field_type[, nb_steps, iters])

field: numpy or torch, shape (*vol, ndims) field_type: 'svf' (already velocity) | 'disp' (plain displacement) Returns v as numpy, shape (*vol, ndims)

fit_warp_to_svf(warp_t[, nb_steps, iters, ...])

Fit a stationary‑velocity field v so that exp(v) ≈ given displacement field. Parameters mirror the original TF implementation. warp shape: (*vol_shape, ndims) (numpy array or torch tensor) Returns: v as a numpy array of same shape.

fit_warp_to_svf_fast(warp_t[, nb_steps, ...])

Fast approximation to fit_warp_to_svf using coarse-to-fine fitting.

invert_warp_via_velocity(warp[, nb_steps, iters])

Approximate inverse by: fit v, then integrate ‑v.

jacobian_determinant(disp)

Compute the Jacobian determinant of a displacement field. disp: (B, C, *vol_shape) tensor with C = spatial dims (2 or 3) Returns detJ: (B, 1, *vol_shape).

Classes

AffineTransformer(*args, **kwargs)

3-D Affine Transformer :param mode: interpolation mode, 'bilinear' or 'nearest'

SpatialTransformer(*args, **kwargs)

N-D Spatial Transformer Obtained from https://github.com/voxelmorph/voxelmorph :param size: spatial size of the input tensor :param mode: interpolation mode, 'bilinear' or 'nearest'

VecInt(*args, **kwargs)

Integrates a vector field via scaling and squaring.