brainhops._ext.invfield
Functions:
inverse
Invert a displacement field.
The grid of the field is treated as a mesh in which each simplex defines an affine transform, following Ashburner, Andersson and Friston, "High-Dimensional Image Registration Using Symmetric Priors", NeuroImage, 1999 (in 2D, https://www.fil.ion.ucl.ac.uk/spm/doc/papers/john_high_dim.pdf), and "Image Registration Using a Symmetric Prior - in Three Dimensions", Human Brain Mapping, 2000 (in 3D, https://pmc.ncbi.nlm.nih.gov/articles/PMC6871943/pdf/HBM-9-212.pdf).
Only the displacements at the nodes of the grid are used. They define a piecewise-affine map, with one affine transform per simplex of the mesh, which is inverted exactly. A field that is meant to be interpolated with higher-degree splines 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.
The inversion runs with the package of the field, NumPy or CuPy, so that a field on a GPU is inverted on the GPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
ndarray or ndarray
|
Displacements in voxels, with shape |
required |
Returns:
| Type | Description |
|---|---|
ndarray or ndarray
|
The inverse field, with the same shape and package as |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the field is neither two- nor three-dimensional. |