brain_deer.surface.tracts¶
White-matter tract loading and tract scene building.
Loads streamlines from TRK/TCK (via nibabel, if available) or accepts in-memory
lists of (P,3) arrays, and builds a TractLayer.
Optional per-point scalars (tractometry, e.g. FA along the tract) drive colouring.
Streamline I/O depends on nibabel’s streamlines API; the scene builder itself is headless and works on plain arrays, so it is unit-testable without any tract file.
Functions¶
|
Load streamlines from a TRK/TCK file as a list of (P,3) mm arrays (RAS+). |
|
Randomly keep at most |
|
Build a scene from streamlines, optionally coloured by per-point scalars. |
Module Contents¶
- brain_deer.surface.tracts.load_streamlines(path: str) list[numpy.ndarray]¶
Load streamlines from a TRK/TCK file as a list of (P,3) mm arrays (RAS+).
- brain_deer.surface.tracts.subsample(streamlines: Sequence[numpy.ndarray], max_streamlines: int, *, seed: int = 0, scalars: Sequence[numpy.ndarray] | None = None) tuple[list[numpy.ndarray], list[numpy.ndarray] | None]¶
Randomly keep at most
max_streamlines(for responsive interaction).
- brain_deer.surface.tracts.build_tracts_scene(streamlines: Sequence[numpy.ndarray], *, scalars: Sequence[numpy.ndarray] | None = None, color: tuple[float, float, float] = (0.9, 0.55, 0.1), cmap: str = 'fa', vminmax: Sequence[float] | None = None, radius: float = 0.4, max_streamlines: int = 0, threshold: float | None = None, opacity: float = 1.0, views: Sequence[str] | None = None, background: tuple[float, float, float] = (1.0, 1.0, 1.0), colorbar: bool = True, colorbar_title: str = '', force_solid: bool = False, source_name: str | None = None) brain_deer.surface.scene_model.SceneModel¶
Build a scene from streamlines, optionally coloured by per-point scalars.