brain_deer.warp

Headless deformation-field mathematics.

This package is the compute core for interactive warp refinement: turning a sparse set of user-authored source -> target correspondences into a dense displacement field, and composing that field with an existing one.

COORDINATE CONVENTION

All arrays, affines and points in this package are RAS millimetres. Conversion to and from LPS – the on-disk convention of ANTs/ITK and of Slicer markups JSON – happens ONLY in brain_deer.warp.io. Callers never see LPS.

Beware the mixed-frame trap: nibabel normalises img.affine to RAS+ on read, but treats the three displacement components of an ANTs warp as opaque scalar data and does not flip them. A naively-loaded ANTs field therefore has an RAS grid and LPS vectors, with nothing to warn you; the result is a warp mirrored in x and y, which on near-symmetric data looks almost right.

FIELD SEMANTICS

A field defines the point map phi(x) = x + sample(d, x). It carries no notion of “forward”, “inverse”, “template” or “native”: those are the caller’s labels for which file went where, and live in the command layer, not here. Nothing in this package imports Qt or VTK – not even function-locally – so the logic stays unit-testable without a display.

Submodules