neu_glance.layers¶
Local annotation layers: authored from coordinates, or from a volume’s occupancy boxes.
Pure: plain data in, plain data out, no store access. The occupancy analysis itself is
neu_vol.ops.occupancy.labeled_regions.
Local annotations, carried inline in the state, appear in the viewer’s Annotations tab,
where they can be clicked through and stepped with [ / ]. A precomputed annotation
source renders but lists nothing there (its frontend class iterates as empty), so it suits
sets too large to carry inline (neu_glance.sources), and a local layer suits a
subset to step through.
Coordinates are zyx throughout and flipped to xyz only in build_annotation(); a
wrong flip gives a valid annotation in the wrong place.
Attributes¶
Functions¶
|
The occupancy layer: one annotation per region of |
|
One annotation object, zyx in and xyz out. |
|
The layer envelope for inline ( |
|
|
|
The position tuples of a record, skipping any that are extents (zyx). |
|
Rows of a CSV as annotation records: |
|
Every relationship the records name, in first-seen order. |
|
|
|
Multiply every coordinate of every record by |
Module Contents¶
- neu_glance.layers.boxes_layer(regions: list[dict], dims: dict, *, name: str = 'regions', color: str = '#ffee00', kind: str = 'box', label: str = 'r') dict¶
The occupancy layer: one annotation per region of
labeled_regions.regionsare zyx{"lo", "hi"}. (neu_glance.sources.annotation_layer()is the unrelated layer for a precomputed annotation source.)
- neu_glance.layers.build_annotation(record: dict, ident: str, relationships: Sequence[str] | None = None) dict¶
One annotation object, zyx in and xyz out.
A box’s corners are sorted per axis, since a reversed pair renders as nothing; a line’s order is its direction and is kept.
relationshipsis the layer’s declared order, andsegmentsgets one id list per relationship in that order: neuroglancer matches them by position, not name. Without it, only the default relationship is written.
- neu_glance.layers.local_layer(annotations: list[dict], dims: dict, *, name: str = 'annotations', color: str = '#ffee00', links: dict[str, str] | None = None) dict¶
The layer envelope for inline (
local://annotations) annotations.linksmaps each relationship name to the segmentation layer it refers to. Without it the segment ids are stored but inert: neuroglancer does not know which layer they belong to. Its order must match therelationshipsgiven tobuild_annotation().
- neu_glance.layers.output_dimensions(voxel_size_zyx, units: str | None) tuple[dict, str | None]¶
{"x": [scale, "m"], ...}for the layer, and a warning if units are unknown.Declared on the layer, so it can be pasted into any state of the same volume.
- neu_glance.layers.positions(record: dict)¶
The position tuples of a record, skipping any that are extents (zyx).
- neu_glance.layers.read_annotation_csv(text: str, kind: str, *, source: str = '<csv>') list[dict]¶
Rows of a CSV as annotation records:
{"kind", "coords", id?, ...}.coordsis one zyx tuple per geometry field ofkind(one for a point, two for a box), in the file’s units;rescale()converts them. Columns are found by name, not position, and unknown columns are ignored.
- neu_glance.layers.record_relationships(records: Sequence[dict]) list[str]¶
Every relationship the records name, in first-seen order.
segmentsstands for the plain column.
- neu_glance.layers.render(obj: Any) str¶
json.dumpswith each annotation kept on a single line.For pasting into neuroglancer’s JSON editor, where a person reads it.
- neu_glance.layers.rescale(records: list[dict], factor_zyx: Sequence[float]) list[dict]¶
Multiply every coordinate of every record by
factor_zyx(per axis).Covers voxels at another level to level-0 voxels, and nm to level-0 voxels. Radii scale like positions.
- neu_glance.layers.ANNOTATION_TYPES = ('point', 'line', 'axis_aligned_bounding_box', 'ellipsoid', 'polyline')¶
- neu_glance.layers.CSV_COLUMNS: dict[str, tuple[tuple[str, ...], ...]]¶
- neu_glance.layers.DEFAULT_RELATIONSHIP = 'segments'¶
- neu_glance.layers.KINDS: dict[str, tuple[str, tuple[str, ...]]]¶
- neu_glance.layers.OPTIONAL_COLUMNS = ('id', 'description', 'segments')¶
- neu_glance.layers.POSITION_GROUPS¶
- neu_glance.layers.RELATIONSHIP_PREFIX = 'segments:'¶