brain_deer.plugins.warpdrive.geometry

Geometry helpers for WarpDrive tools (plane rings, contours, path resample).

Pure numpy (+ optional nibabel); no Qt. Used by Draw / ShrinkExpand tools and tests.

Functions

plane_basis(→ tuple[FloatArray, FloatArray])

Return (plane_normal, in_plane_u) unit vectors for a slice view.

resample_path(→ list[WorldPoint])

Polyline resampled at approximately step_mm spacing (keeps endpoints).

shrink_expand_ring(→ tuple[list[WorldPoint], ...)

Build source/target rings in the slice plane (Slicer ShrinkExpand parity).

label_slice_contour(→ FloatArray)

Boundary voxels of a label mask on one slice, as RAS mm points (N,3).

nearest_points_on_cloud(→ FloatArray)

For each query, the closest point in cloud (brute force; contours are small).

match_path_counts(→ tuple[list[WorldPoint], ...)

Resample the longer path so both have the same point count (min length ≥ 2).

best_cloud_for_seed(→ FloatArray)

Pick the contour cloud whose nearest point is closest to seed.

Module Contents

brain_deer.plugins.warpdrive.geometry.plane_basis(view_name: str) → tuple[FloatArray, FloatArray]

Return (plane_normal, in_plane_u) unit vectors for a slice view.

brain_deer.plugins.warpdrive.geometry.resample_path(path: Sequence[WorldPoint], step_mm: float) → list[WorldPoint]

Polyline resampled at approximately step_mm spacing (keeps endpoints).

brain_deer.plugins.warpdrive.geometry.shrink_expand_ring(center: WorldPoint, view_name: str, radius_mm: float, amount_pct: float, *, mode: str = 'Shrink', n_angles: int = 12) → tuple[list[WorldPoint], list[WorldPoint]]

Build source/target rings in the slice plane (Slicer ShrinkExpand parity).

amount_pct is 5–95. Shrink pulls the outer ring inward; Expand pushes out. Returns (source_points, target_points) each of length n_angles.

brain_deer.plugins.warpdrive.geometry.label_slice_contour(data: FloatArray, affine: FloatArray, slice_axis: int, slice_index: int, *, label: int | None = None) → FloatArray

Boundary voxels of a label mask on one slice, as RAS mm points (N,3).

brain_deer.plugins.warpdrive.geometry.nearest_points_on_cloud(queries: FloatArray, cloud: FloatArray) → FloatArray

For each query, the closest point in cloud (brute force; contours are small).

brain_deer.plugins.warpdrive.geometry.match_path_counts(source: Sequence[WorldPoint], target: Sequence[WorldPoint]) → tuple[list[WorldPoint], list[WorldPoint]]

Resample the longer path so both have the same point count (min length ≥ 2).

brain_deer.plugins.warpdrive.geometry.best_cloud_for_seed(seed: WorldPoint, clouds: Iterable[FloatArray]) → FloatArray

Pick the contour cloud whose nearest point is closest to seed.