neu_mark.tables¶
The table model: elements and relationships as DataFrames.
Coordinates are always named columns (z, y, x, to_z, …). DVID stores
positions as [x, y, z], the suite holds zyx in memory and precomputed stores xyz, and
a mix-up mirrors positions through the z=x diagonal with no error. Named columns cannot be
transposed silently; positions_zyx() and positions_xyz() are the only places
an (N, 3) array is built from a table, and the caller states the order.
A DVID relationship points at a coordinate, not a body ({"Rel": "PostSynTo", "To":
[x, y, z]}); the partner body is found by joining that coordinate against the fetched
elements, so it resolves only when both ends’ bodies were fetched. match_rate()
reports how much resolved: a low rate means the body list is too small, and otherwise
looks like a sparse connectome. Relationships are kept one row each, unmodified, and
connections() derives the de-duplicated synapse view, using both directions since
each is anchored on the body list at one end only.
Attributes¶
Functions¶
|
Per body, the share of its synapses in each neuropil, as columns a rule can read. |
|
Per body and kind, how many synapses fall in each ROI. Long form, lossless. |
|
Concatenate per-body |
|
The tables for a WHOLE instance, whose |
|
The oriented, de-duplicated synapse view over the raw relationship table. |
|
One body's |
|
Bring per-element columns onto a connections table as |
|
|
|
How much of the connectivity the body list actually resolved. |
|
|
|
|
|
|
|
Fill |
Module Contents¶
- neu_mark.tables.body_neuropil_fractions(points: pandas.DataFrame, *, top_level: Mapping[str, str] | None = None, kind_column: str = 'kind') pandas.DataFrame¶
Per body, the share of its synapses in each neuropil, as columns a rule can read.
synapse_neuropilsis{"pre": {roi: share}, "post": {...}, "all": {...}}, each share out of all that body’s synapses of that side, so a side’s shares sum to at most 1 and the rest lies in no ROI. Withtop_level({roi: top-level neuropil}) asynapse_neuropils_topcolumn groups the same counts by top-level neuropil. Each inner dict runs largest share first.
- neu_mark.tables.body_roi_counts(points: pandas.DataFrame, *, kind_column: str = 'kind') pandas.DataFrame¶
Per body and kind, how many synapses fall in each ROI. Long form, lossless.
A group-by over
points, in the shape a tagging rule wants: where a neuron’s outputs sit often identifies it.
- neu_mark.tables.combine(frames: Iterable[tuple[pandas.DataFrame, pandas.DataFrame]]) tuple[pandas.DataFrame, pandas.DataFrame]¶
Concatenate per-body
(points, rels)pairs and resolve partner bodies.
- neu_mark.tables.complete_tables(points: pandas.DataFrame, rels: pandas.DataFrame) dict[str, Any]¶
The tables for a WHOLE instance, whose
pointscarry a looked-upbody.Each relationship’s own body comes from its element and its partner’s by the usual position join, which resolves for every partner because every element was fetched. In
connections, body 0 (background) becomes null, so no line is indexed under body 0.
- neu_mark.tables.connections(rels: pandas.DataFrame) pandas.DataFrame¶
The oriented, de-duplicated synapse view over the raw relationship table.
One row per distinct
(tbar, psd)coordinate pair, whichever direction it was seen from. Columnspre_z/pre_y/pre_x,post_z/post_y/post_x,pre_body,post_body.Both relationship directions are used, then de-duplicated. Non-synaptic relationships are ignored here and stay in the raw table.
- neu_mark.tables.elements_to_frames(elements: Sequence[Mapping[str, Any]], body: int) tuple[pandas.DataFrame, pandas.DataFrame]¶
One body’s
/labelresponse -> (points, relationships).Elements have
Pos,Kind,Tags,PropandRels; everyPropkey becomes a column. (neuclease.load_elements_as_dataframedrops the element’s body.)
- neu_mark.tables.enrich_connections(conns: pandas.DataFrame, points: pandas.DataFrame, columns: Sequence[str] = ('conf',)) pandas.DataFrame¶
Bring per-element columns onto a connections table as
pre_<col>/post_<col>.Joined from
pointson the coordinate (confidence, ROI, …). A value for a partner that was not fetched stays NaN rather than 0, which would claim zero confidence; NaN also fails shader comparisons, so aconf < thresholdfilter keeps such lines.
- neu_mark.tables.keyvalues_to_frame(values: Mapping[str, Any]) pandas.DataFrame¶
{body_key: json}from a keyvalue instance -> one row per body.Records are ragged, so columns are the union of keys, with missing fields null.
instanceis the neuron’s name (CAm(L)), not a DVID data instance; the name is kept to match neuclease and neuprint. The raw record is kept in ajsoncolumn.
- neu_mark.tables.match_rate(conns: pandas.DataFrame) dict[str, Any]¶
How much of the connectivity the body list actually resolved.
A low fraction looks the same as a sparse connectome once the tables are written.
- neu_mark.tables.position_index(points: pandas.DataFrame) pandas.Series¶
(z, y, x) -> bodyfor every fetched element.Raises if two elements share a position, which would make the partner join ambiguous.
- neu_mark.tables.positions_xyz(df: pandas.DataFrame, prefix: str = '') numpy.ndarray¶
(N, 3)array of positions in xyz order, as DVID and precomputed store them.
- neu_mark.tables.positions_zyx(df: pandas.DataFrame, prefix: str = '') numpy.ndarray¶
(N, 3)array of positions in zyx order.With
positions_xyz(), the only place named coordinate columns become an array.
- neu_mark.tables.resolve_partner_bodies(points: pandas.DataFrame, rels: pandas.DataFrame) pandas.DataFrame¶
Fill
to_bodyby joining each relationship’s target againstpoints.NAwhere the target was not fetched. NullableUInt64, never float, which would round large body ids.
- neu_mark.tables.AXES = ('z', 'y', 'x')¶
- neu_mark.tables.BODY_DTYPE¶
- neu_mark.tables.COORD_DTYPE¶
- neu_mark.tables.DVID_AXES = ('x', 'y', 'z')¶
- neu_mark.tables.NO_BODY = 0¶
- neu_mark.tables.SYNAPTIC_RELS¶