nifreeze.registration.utils module¶
Utilities to aid in performing and evaluating image registration.
This module provides functions to compute displacements of image coordinates under a transformation, useful for assessing the accuracy of image registration processes.
- nifreeze.registration.utils.RADIUS = 50.0¶
Typical radius (in mm) of a sphere mimicking the size of a typical human brain.
- nifreeze.registration.utils.compute_fd_from_motion(motion_parameters: ndarray, radius: float = 50.0) ndarray [source]¶
Compute framewise displacement (FD) from motion parameters.
Each row in the motion parameters represents one frame, and columns represent each coordinate axis
x
, y`, andz
. Translation parameters are followed by rotation parameters column-wise.- Parameters:
motion_parameters (
numpy.ndarray
) – Motion parameters.radius (
float
, optional) – Radius (in mm) of a sphere mimicking the size of a typical human brain.
- Returns:
The framewise displacement (FD) as the sum of absolute differences between consecutive frames.
- Return type:
- nifreeze.registration.utils.compute_fd_from_transform(img: nibabel.spatialimages.SpatialImage, test_xfm: nitransforms.base.TransformBase, radius: float = 50.0) float [source]¶
Compute the framewise displacement (FD) for a given transformation.
- Parameters:
img (
SpatialImage
) – The reference image. Used to extract the center coordinates.test_xfm (
TransformBase
) – The transformation to test. Applied to coordinates around the image center.radius (
float
, optional) – The radius (in mm) of the spherical neighborhood around the center of the image.
- Returns:
The average framewise displacement (FD) for the test transformation.
- Return type:
- nifreeze.registration.utils.displacements_within_mask(mask_img: nb.spatialimages.SpatialImage, test_xfm: nt.base.TransformBase, reference_xfm: nt.base.TransformBase | None = None) np.ndarray [source]¶
Compute the distance between voxel coordinates mapped through two transforms.
- Parameters:
mask_img (
SpatialImage
) – A mask image that defines the region of interest. Voxel coordinates within the mask are transformed.test_xfm (
TransformBase
) – The transformation to test. This transformation is applied to the voxel coordinates.reference_xfm (
TransformBase
, optional) – A reference transformation to compare with. IfNone
, the identity transformation is assumed (no transformation).
- Returns:
An array of displacements (in mm) for each voxel within the mask.
- Return type: