neu_glance.sources¶
Layers built from something on a store: a volume, or a precomputed annotation source.
The only module in this package that reads a store, so neu_glance.state and
neu_glance.layers stay pure and work for locally served sources that have no store.
Two choices here fail silently if made wrong:
The source scheme (
precomputed://orzarr://) comes fromdetect_backend(), not from the path.Volume or annotation source. Both are
precomputed://with aninfoat the root, and an annotation layer pointed at a volume loads and draws nothing. Only the@typetells them apart, soread_annotation_info()checks it.
Attributes¶
Exceptions¶
A named volume or annotation source could not be used as a layer source. |
Functions¶
|
One annotation layer for a precomputed annotation source, plus its frame. |
|
|
|
Level-0 voxel size in nm, zyx, from the source's |
|
The |
|
The precomputed volume a state's layer reads, as a location: the |
|
The |
|
Everything a volume's |
|
|
|
Segment ids for |
|
|
|
|
|
The subset of |
|
Segment ids matching a tag and/or label query. |
|
|
|
One layer for |
Module Contents¶
- exception neu_glance.sources.SourceProblem¶
Bases:
RuntimeErrorA named volume or annotation source could not be used as a layer source.
Initialize self. See help(type(self)) for accurate signature.
- neu_glance.sources.annotation_layer(source: str, *, name: str | None = None, shader: str | None = None, linked_segmentation: str | None = None, filter_by_segmentation: bool = True, filter_relationships: Sequence[str] | None = None, controls: Mapping[str, Any] | None = None, info: Mapping[str, Any] | None = None) tuple[dict, dict]¶
One annotation layer for a precomputed annotation source, plus its frame.
linked_segmentationnames a segmentation layer in the same state. Without it the source’srelationshipsindex does nothing: neuroglancer only uses a relationship once it is bound to a layer whose selected segments it can read, and otherwise draws every annotation.Every relationship is bound;
filter_relationshipschooses which ones restrict the view, e.g. onlybody_prefor the selected body’s outputs. Each can be toggled in the layer’s Annotations tab.
- neu_glance.sources.annotation_source_extent(info: Mapping[str, Any]) tuple[tuple, tuple] | None¶
(extent_zyx, offset_zyx)from an annotation source’s declared bounds.Lets an annotations-only link open framed on its data, as
volume_extent()does for a volume.
- neu_glance.sources.annotation_source_voxel_size(info: Mapping[str, Any]) tuple | None¶
Level-0 voxel size in nm, zyx, from the source’s
dimensions.dimensionsis{axis: [scale, unit]}in SI units (metres). None if absent or not in metres.
- neu_glance.sources.end_layers(source: str, *, linked_segmentation: str, shader: str | None = None, info: Mapping[str, Any] | None = None) list[dict]¶
The
presynandpostsynlayers of a synapse source (END_LAYERS).A layer filtered on both relationships draws both ends of every synapse touching the selected bodies, so the partners’ ends come too; these show only the ends that lie on the selected bodies.
- neu_glance.sources.layer_volume(layer: Mapping[str, Any]) str | None¶
The precomputed volume a state’s layer reads, as a location: the
sourcewithout neuroglancer’s scheme (precomputed://s3://b/vors3://b/v|neuroglancer-precomputed:->s3://b/v).Nonefor any other kind of source.
- neu_glance.sources.read_annotation_info(source: str) dict¶
The
infoof a precomputed annotation source, refusing anything else.
- neu_glance.sources.read_segment_properties(volume: str, *, info: Mapping[str, Any] | None = None) dict¶
Everything a volume’s
segment_propertiescarries, in ONE read.Returns
{"ids", "labels", "tags", "numbers", "vocabulary"}: ids as strings, labels parallel to them, tags resolved from indices to strings, and each numeric property under its own name. Pass the result toselect_segments()to query it without re-reading. Properties are paired with ids by position, so a length mismatch raises.
- neu_glance.sources.segment_boxes(volume: str, segment_ids: Sequence[Any], *, lod: int | None = None, mesh_dir: str | None = None, threads: int = 8, skip_missing: bool = True) dict[str, tuple[tuple, tuple]]¶
{segment_id: (lo_zyx, hi_zyx)}in nanometres, from each segment’s mesh.For
neu_glance.movie.animate.Timeline.frame_on(). Bounds come from the mesh rather than a coarse level of the segmentation, where a thin arbor can shrink or vanish and the box would be wrong.lod=Nonereads the coarsest level of detail, which is small and bounds the object just as well. Sharded sources and a source’s owntransformare handled, so the result is in nm.skip_missingdrops a segment with no mesh; a structurally broken source still raises.
- neu_glance.sources.segment_ids(volume: str, names: Sequence[str], *, info: Mapping[str, Any] | None = None) list[str]¶
Segment ids for
names, in order. Raises on a name the source does not carry.A mistyped name raises (with close matches suggested) rather than being dropped. Labels are not unique in this format, so a name matching several segments also raises.
- neu_glance.sources.segment_labels(volume: str, *, info: Mapping[str, Any] | None = None) dict[str, str]¶
{segment_id: label}from a volume’ssegment_propertiessubresource.Lets code name segments (
"LAL(L)") rather than ids. The format pairs ids and values by position, so arrays of different lengths raise rather than mislabel segments.
- neu_glance.sources.segment_tags(volume: str, *, info: Mapping[str, Any] | None = None) dict[str, tuple]¶
{segment_id: (tag, ...)}, tags resolved from their vocabulary indices.
- neu_glance.sources.segments_with_meshes(volume: str, segment_ids: Sequence[Any], *, mesh_dir: str | None = None, threads: int = 32) list[str]¶
The subset of
segment_idswhose meshes are actually in the store, in order.One segment with no mesh hangs a render indefinitely. Neuroglancer waits for its mesh chunk forever, so the viewer never reports ready and the capture stalls at
N-1 / N chunks.segment_propertieslists every segment, including unmeshed ones, so filter a set through this before rendering it.One existence check per body (cheap for unsharded meshes). A sharded source has no per-body object to check, so every id is returned unchecked.
- neu_glance.sources.select_segments(volume: str, *, tags: Sequence[str] | None = None, any_tags: Sequence[str] | None = None, without: Sequence[str] | None = None, label: str | None = None, limit: int | None = None, order_by: str | None = 'voxels', properties: Mapping | None = None) list[str]¶
Segment ids matching a tag and/or label query.
tags: all must be present;any_tags: at least one must be;without: none may be (e.g.fragment,truncated);label: a regular expression, searched (not anchored) in the label.
Conditions combine with “and”, so
tags=["side:L"], label=r"^KC"is left-side KCs. No match returns an empty list; an unknown tag raises.limitkeeps the largest byorder_by(voxels);order_by=Nonekeeps the source’s order. Sets can be very large (thousands of bodies), so check the count before rendering.
- neu_glance.sources.volume_extent(volume: str, fmt: str) tuple[tuple, tuple] | None¶
(extent_zyx, offset_zyx)in level-0 voxels, or None if not determinable.Precomputed answers from the root
info; zarr opens the level-0 array once.
- neu_glance.sources.volume_layer(volume: str, *, kind: str | None = None, name: str | None = None, segments: Sequence[int] | None = None, opacity: float | None = None, bounds: bool = False) tuple[dict, dict]¶
One layer for
volume, plus what its metadata says about the frame.kind("image"or"segmentation") overrides what the volume records; without it the recorded kind decides, defaulting to image.boundsdraws the volume’s bounding box, which neuroglancer shows by default.
- neu_glance.sources.ANNOTATION_TYPE = 'neuroglancer_annotations_v1'¶
- neu_glance.sources.END_LAYERS¶