Skip to content

brainhops._ext.invfield

Functions:

inverse

inverse(field: ndarray) -> ndarray

Compute the inverse of a displacement field by interpreting it as a mesh, where each cell defines an affine transform.

This is the method described in: "High-Dimensional Image Registration Using Symmetric Priors" Ashburner, Andersson & Friston. NeuroImage (1999). https://www.fil.ion.ucl.ac.uk/spm/doc/papers/john_high_dim.pdf for the 2D version, and in: "Image Registration Using a Symmetric Prior — in Three Dimensions" Ashburner, Andersson & Friston. Human Brain Mapping (2000). https://pmc.ncbi.nlm.nih.gov/articles/PMC6871943/pdf/HBM-9-212.pdf for the 3D version.

Parameters:

Name Type Description Default
field ndarray

The displacement field to invert (displacements are in voxels). Should be of shape (Nx, Ny, Nz, 3) or (Nx, Ny, 2). The last dimension should contain the displacements along each axis, in the same order (i.e. [x, y, z] or [x, y]).

required

Returns:

Type Description
ndarray

The inverse displacement field, of the same shape as the input.

Notes

Only the displacements at the grid nodes are used. They define a piecewise-affine map (one affine transform per simplex of the mesh), and it is that map which is inverted, exactly. A field meant to be interpolated with splines of a higher degree is therefore inverted as its piecewise-linear interpolant: the result is approximate between nodes, and more so near the border, where the mesh is clipped by the field of view.