neu_eval.tables

Writing results out, and reading a reviewed disagreement table back in.

Metrics go to parquet, which round-trips nullable integer columns. The disagreement table goes to csv, because a reviewer edits its verdict column. Spreadsheets parse long integers as float64 and round 19-digit body ids, so ids are written as text and pair_key is the join key on the way back in.

pandas and pyarrow (neu-eval[report]) are imported inside functions, so import neu_eval does not load them.

Attributes

Functions

annotation_csv(rows, path, *[, labels]) → str

The located rows as a point list neu-glance annotate --points can read.

per_label_frame(c)

Per-label VOI contributions and sizes, one row per label on each side.

read_disagreements(path) → tuple[list[dict], dict[str, str]]

(rows, verdicts) from a csv written by write_disagreements().

shape_csvs(rows, out_dir, prefix, *[, labels, ...]) → dict[str, dict[str, str]]

The located shapes as the CSVs neu-glance annotate reads, one set per kind.

write_disagreements(rows, path, *[, labels, verdicts]) → str

The ranked disagreements as csv, with a verdict column to fill in.

write_summary(rows, path) → str

One parquet file of metric rows. Accepts a single row or many.

write_table(frame, path) → str

A DataFrame to parquet, matching neu_morpho.measure.tables.write_table.

Module Contents

neu_eval.tables.annotation_csv(rows: Iterable[Mapping], path: str | pathlib.Path, *, labels: Sequence[str] = ('gt', 'seg')) → str

The located rows as a point list neu-glance annotate --points can read.

Columns z, y, x (required by neu-glance), description, segments. Coordinates are nm, so the command needs --nm and a frame (--volume or --voxel-size). segments holds both ids of the pair; only the one in the linked segmentation layer is found, which is harmless.

They become local annotations, which, unlike a precomputed annotation source, are listed in neuroglancer’s Annotations tab, so the worst-first list can be stepped with [ and ].

neu_eval.tables.per_label_frame(c: neu_eval.overlap.Contingency)

Per-label VOI contributions and sizes, one row per label on each side.

One long frame with a side column.

neu_eval.tables.read_disagreements(path: str | pathlib.Path) → tuple[list[dict], dict[str, str]]

(rows, verdicts) from a csv written by write_disagreements().

verdicts maps pair_key to the verdict text, ready for neu_eval.adjudicate.apply(). Rows come back as strings; numeric columns in a hand-edited file are not re-parsed.

neu_eval.tables.shape_csvs(rows: Iterable[Mapping], out_dir: str | pathlib.Path, prefix: str, *, labels: Sequence[str] = ('gt', 'seg'), relationships: Sequence[str] = ()) → dict[str, dict[str, str]]

The located shapes as the CSVs neu-glance annotate reads, one set per kind.

Returns {"merges": {"lines": path, "points": path}, "splits": {"ellipsoids": ...}, "tangles": {"lines": ..., "ellipsoids": ...}}, only for files with rows, so each kind becomes its own toggleable layer.

Coordinates are nm (use annotate --nm). Each row has a segments:<name> column per entry of relationships, holding the ids neu_eval.disagree.sample_ids() found at the shape’s anchors, for annotate --link <name>=<layer>. An empty one is written empty, not left out, because the viewer matches id lists by position. A row with no seam is written as a point, so every row gets an annotation.

neu_eval.tables.write_disagreements(rows: Iterable[Mapping], path: str | pathlib.Path, *, labels: Sequence[str] = ('gt', 'seg'), verdicts: Mapping[str, str] | None = None) → str

The ranked disagreements as csv, with a verdict column to fill in.

Uses the stdlib csv module, so it needs no optional extra. verdicts pre-fills the column, so re-running a comparison keeps an existing review. Also writes a .README.txt legend beside it for the reviewer.

neu_eval.tables.write_summary(rows: Mapping | Sequence[Mapping], path: str | pathlib.Path) → str

One parquet file of metric rows. Accepts a single row or many.

neu_eval.tables.write_table(frame, path: str | pathlib.Path) → str

A DataFrame to parquet, matching neu_morpho.measure.tables.write_table.

neu_eval.tables.SHAPE_OF