neu_draw.sources

The only module that reads data; everything else takes arrays.

Reads meshes and skeletons from a neuroglancer-precomputed volume, resolves a pyramid level to a Frame, and turns a synapse table into point arrays.

Subdirectory names come from the volume’s own info, never assumed: they vary (one volume declares {"mesh": "mesh", "skeletons": "skeleton"}), and a wrong guess reads back as every body having no skeleton. A level’s voxel size comes from the metadata, never 2 ** level. Meshes and skeletons are stored in nm and need no frame.

Attributes

Exceptions

MissingSubresource

The volume's info declares no meshes or no skeletons.

Functions

body_mesh(volume, body_id, *[, lod, cache, name, ...]) → Optional[neu_lib.Mesh]

One body's mesh at one LOD, or None if the volume holds none for it.

body_meshes(volume, body_ids, *[, cache, names, ...]) → dict[int, neu_lib.Mesh]

Meshes for many bodies, fetched concurrently. Missing bodies are omitted.

body_skeleton(volume, body_id, *[, cache, name, ...]) → Optional[neu_lib.Skeleton]

One body's skeleton, or None if the volume holds none for it.

body_skeletons(volume, body_ids, *[, cache, names, ...]) → dict[int, neu_lib.Skeleton]

Skeletons for many bodies, fetched concurrently. Missing bodies are omitted.

points_from_table(table, *[, frame, columns, prefix]) → numpy.ndarray

An (N, 3) zyx nm array from a table with named coordinate columns.

scales(volume, *[, refresh]) → list

Every pyramid level, finest first, each with its own voxel size

subresource_dir(volume, kind[, info]) → str

The subdirectory holding kind ("mesh" or "skeletons"), from info.

synapse_points(table, *[, frame, kind_column, ...]) → dict[str, numpy.ndarray]

Split a synapse table by kind into {kind: (N, 3) zyx nm}.

volume_frame(volume[, level]) → neu_lib.Frame

The Frame (voxel size and origin) of one pyramid level, from the

volume_info(volume) → dict

The volume's own info, as a dict.

Module Contents

exception neu_draw.sources.MissingSubresource

Bases: RuntimeError

The volume’s info declares no meshes or no skeletons.

Initialize self. See help(type(self)) for accurate signature.

neu_draw.sources.body_mesh(volume: str, body_id: int, *, lod: int | None = None, cache: Any = None, name: str | None = None, mesh_dir: str | None = None, info: Mapping | None = None) → neu_lib.Mesh | None

One body’s mesh at one LOD, or None if the volume holds none for it.

lod defaults to the coarsest present, the cheapest to draw; pass 0 for full detail.

neu_draw.sources.body_meshes(volume: str, body_ids: Iterable[int], *, cache: Any = None, names: Mapping[int, str] | None = None, threads: int = DEFAULT_THREADS, skip_missing: bool = True, **kwargs) → dict[int, neu_lib.Mesh]

Meshes for many bodies, fetched concurrently. Missing bodies are omitted.

skip_missing covers only bodies the volume does not hold. A volume declaring no meshes, or storing them in a format the reader cannot decode, raises either way.

neu_draw.sources.body_skeleton(volume: str, body_id: int, *, cache: Any = None, name: str | None = None, skeleton_dir: str | None = None, info: Mapping | None = None, require_radii: bool = True) → neu_lib.Skeleton | None

One body’s skeleton, or None if the volume holds none for it.

require_radii=False accepts a source that publishes centrelines only, with every radius the -1 sentinel (FlyEM’s male-CNS does).

neu_draw.sources.body_skeletons(volume: str, body_ids: Iterable[int], *, cache: Any = None, names: Mapping[int, str] | None = None, threads: int = DEFAULT_THREADS, skip_missing: bool = True, **kwargs) → dict[int, neu_lib.Skeleton]

Skeletons for many bodies, fetched concurrently. Missing bodies are omitted.

skip_missing covers only bodies the volume does not hold. A volume declaring no skeletons, or storing them in a format the reader cannot decode, raises either way.

neu_draw.sources.points_from_table(table: Any, *, frame: neu_lib.Frame | None = None, columns: Sequence[str] = ('z', 'y', 'x'), prefix: str = '') → numpy.ndarray

An (N, 3) zyx nm array from a table with named coordinate columns.

columns are read in the order given, so the default yields zyx from neu-mark’s tables. Pass frame when the table holds voxel indices (DVID’s do) rather than nm. Columns are looked up by name, never by position, so the axis order is explicit.

neu_draw.sources.scales(volume: str, *, refresh: bool = False) → list

Every pyramid level, finest first, each with its own voxel size (neu_vol.read_scales). Memoized; refresh=True re-reads.

neu_draw.sources.subresource_dir(volume: str, kind: str, info: Mapping | None = None) → str

The subdirectory holding kind ("mesh" or "skeletons"), from info.

Raises rather than guessing, since a wrong name would read back as every body having no mesh.

neu_draw.sources.synapse_points(table: Any, *, frame: neu_lib.Frame | None = None, kind_column: str = 'kind', columns: Sequence[str] = ('z', 'y', 'x'), prefix: str = '') → dict[str, numpy.ndarray]

Split a synapse table by kind into {kind: (N, 3) zyx nm}.

Keys are the column’s values (DVID’s are PreSyn and PostSyn). A table with no kind column becomes a single "points" entry.

neu_draw.sources.volume_frame(volume: str, level: int = 0) → neu_lib.Frame

The Frame (voxel size and origin) of one pyramid level, from the volume’s metadata.

neu_draw.sources.volume_info(volume: str) → dict

The volume’s own info, as a dict.

neu_draw.sources.DEFAULT_THREADS = 8