brain_deer.warp.io¶
The LPS <-> RAS boundary, and all warp/correction disk I/O.
This is the only module in brain_deer.warp that touches LPS. Everything
it returns is RAS millimetres; everything it writes is in the on-disk convention
of the format (LPS for ANTs fields and Slicer markups).
Two independent flips, both involutions (F @ F == I):
points / affines –
diag(-1, -1, 1)on the xy world coordinates.displacement vectors – the same sign flip on the three components.
nibabel normalises img.affine to RAS+ on read but leaves the displacement
components untouched, so a naively-loaded ANTs field is RAS-grid / LPS-vectors
with nothing to warn you. Loading here fixes the vectors; the affine is already
RAS from nibabel.
Functions¶
|
Flip |
Load an ANTs-style displacement field as an RAS-mm |
|
|
Write an RAS-mm field to an ANTs-style LPS displacement NIfTI. |
|
Read a WarpDrive session's |
|
Write a correction set back out as paired Slicer markups (LPS on disk). |
Module Contents¶
- brain_deer.warp.io.lps_to_ras_points(points_lps: FloatArray) FloatArray¶
Flip
(N,3)points between LPS and RAS (self-inverse).
- brain_deer.warp.io.read_displacement_field(path: str | pathlib.Path) brain_deer.warp.field.DeformationField¶
Load an ANTs-style displacement field as an RAS-mm
DeformationField.Handles both
(I,J,K,3)and ANTs’ 5-D(I,J,K,1,3)layout, and flips the LPS vector components to RAS. The grid affine is taken from nibabel, which has already normalised it to RAS+.
- brain_deer.warp.io.write_displacement_field(field: brain_deer.warp.field.DeformationField, path: str | pathlib.Path, *, ants_5d: bool = True) None¶
Write an RAS-mm field to an ANTs-style LPS displacement NIfTI.
ants_5dwrites the(I,J,K,1,3)layout ANTs and Lead-DBS expect.
- brain_deer.warp.io.read_correction_set(source_json: str | pathlib.Path, target_json: str | pathlib.Path) brain_deer.warp.corrections.CorrectionSet¶
Read a WarpDrive session’s
source/targetmarkups into RAS mm.The two files are paired by position: control point
iofsourceis the origin, and control pointioftargetis where it should go.
- brain_deer.warp.io.write_correction_set(cs: brain_deer.warp.corrections.CorrectionSet, source_json: str | pathlib.Path, target_json: str | pathlib.Path) None¶
Write a correction set back out as paired Slicer markups (LPS on disk).