brain_deer.warp.apply

Headless orchestration of applying a refinement session to a normalization.

This is the pure, importable core behind the warpdrive_apply_corrections command: read a session’s control points, solve the correction field on a coarse grid over the forward warp, and compose it into corrected forward/inverse warps.

It lives in brain_deer.warp (not brain_deer.commands) so external hosts – notably Lead-Lizard – can drive the exact same orchestration without pulling in the command registry. It raises WarpApplyError; the command wrapper translates that into the registry’s CommandError.

Exceptions

WarpApplyError

A refinement-apply orchestration failure (bad inputs, empty session).

Functions

apply_corrections(→ dict)

Apply a WarpDrive session's corrections to a pair of ANTs warps.

harden_corrections(→ dict)

Bake corrections into the subject's warps and harden the session points.

Module Contents

exception brain_deer.warp.apply.WarpApplyError

Bases: ValueError

A refinement-apply orchestration failure (bad inputs, empty session).

brain_deer.warp.apply.apply_corrections(session_dir: str, forward_warp: str, inverse_warp: str, out_dir: str, *, spacing: float = 2.0, stiffness: float = 0.1) → dict

Apply a WarpDrive session’s corrections to a pair of ANTs warps.

Reads source.json/target.json from session_dir, solves the correction on a coarse grid over forward_warp, and writes corrected forward and inverse warps into out_dir (never overwriting the inputs).

brain_deer.warp.apply.harden_corrections(session_dir: str, forward_warp: str, inverse_warp: str, *, spacing: float = 2.0, stiffness: float = 0.1, backup: bool = True) → dict

Bake corrections into the subject’s warps and harden the session points.

Unlike apply_corrections(), this overwrites forward_warp / inverse_warp (optionally keeping *.bak copies) and rewrites the session’s source.json/target.json so every point becomes a fixed anchor (source == target). Reload then holds anatomy in place rather than re-applying the same moves.