neu_mark.annotations¶
Encoding neuroglancer_annotations_v1 LINE annotations.
One annotation per synaptic connection, a line from the T-bar to the PSD, as published
synapse sources do. A shader can still draw either endpoint alone
(setLineWidth(0.0); setEndpointMarkerSize(pre, 0.0) shows only T-bars).
Byte layout, little-endian, checked against a published male-CNS source. Per annotation:
geometry (for LINE, two float32 xyz triples), then properties in descending size
(4-, 2-, then 1-byte), then zero padding to 4 bytes. The single-annotation (by_id)
encoding then adds, per relationship, a uint32 count and that many uint64 ids; the
multi-annotation encoding instead starts with a uint64 count and ends with all the ids.
Property order matters: a reader infers offsets from the declared order, and a file
written in any other order parses into misaligned values with no error, so
sort_properties() fixes it. Properties cannot be uint64; full body ids go in
relationships, with a truncated uint32 copy as a property if a shader needs one.
Attributes¶
Functions¶
|
The annotation source's |
|
Invert |
|
Invert |
|
The multiple-annotation encoding: a spatial cell, or one relationship's annotations. |
|
The single-annotation encoding, for the |
|
A property whose integer values index |
|
Bytes per annotation in a group: geometry + properties + padding to 4 bytes. |
|
Properties in the order the format requires: descending size, the caller's order |
Module Contents¶
- neu_mark.annotations.build_info(*, lower_bound: Sequence[float], upper_bound: Sequence[float], voxel_size_xyz: Sequence[float], annotation_type: str = LINE, properties: Sequence[Mapping[str, Any]] = (), relationships: Sequence[Mapping[str, Any]] = (), by_id: Mapping[str, Any] | None = None, spatial: Sequence[Mapping[str, Any]] = ()) dict[str, Any]¶
The annotation source’s
info.Every member is required (
relationshipsandspatialmay be empty).dimensionsis written x, y, z, matching the stored geometry, in metres (8 nm is8e-9).
- neu_mark.annotations.decode_group(raw: bytes, *, annotation_type: str = LINE, properties: Sequence[Mapping[str, Any]] = ()) dict[str, Any]¶
Invert
encode_group(). Returns{"ids", "geometry", "values"}.Used to check a written source against the table it came from.
- neu_mark.annotations.decode_single(raw: bytes, *, annotation_type: str = LINE, properties: Sequence[Mapping[str, Any]] = (), n_relationships: int = 0) dict[str, Any]¶
Invert
encode_single(). Returns{"geometry", "values", "relationships"}.
- neu_mark.annotations.encode_group(geometry: numpy.ndarray, ids: Sequence[int], *, annotation_type: str = LINE, properties: Sequence[Mapping[str, Any]] = (), values: Mapping[str, Any] | None = None) bytes¶
The multiple-annotation encoding: a spatial cell, or one relationship’s annotations.
geometryis(n, floats)in xyz, fromneu_mark.tables.positions_xyz(). Relationship ids are not part of this encoding; seeencode_single().
- neu_mark.annotations.encode_single(geometry: Sequence[float], *, annotation_type: str = LINE, properties: Sequence[Mapping[str, Any]] = (), values: Mapping[str, Any] | None = None, relationships: Sequence[Sequence[int]] = ()) bytes¶
The single-annotation encoding, for the
by_idindex.relationshipsis one sequence of segment ids per declared relationship, in the declared order.
- neu_mark.annotations.enum_property(prop_id: str, labels: Sequence[str], *, dtype: str = 'int16', description: str | None = None) dict[str, Any]¶
A property whose integer values index
labels.By convention index 0 means “none” (
<unspecified>), so a shader can test for it.
- neu_mark.annotations.record_size(annotation_type: str, properties: Sequence[Mapping[str, Any]]) int¶
Bytes per annotation in a group: geometry + properties + padding to 4 bytes.
- neu_mark.annotations.sort_properties(properties: Sequence[Mapping[str, Any]]) list[dict[str, Any]]¶
Properties in the order the format requires: descending size, the caller’s order kept within a size.
- neu_mark.annotations.AT_TYPE = 'neuroglancer_annotations_v1'¶
- neu_mark.annotations.GEOMETRY_FLOATS¶
- neu_mark.annotations.LINE = 'line'¶
- neu_mark.annotations.POINT = 'point'¶
- neu_mark.annotations.PROPERTY_TYPES: dict[str, tuple[int, str]]¶