neu_morpho.measure.tables¶
Turn a measure DB into tidy tables, for cohort selection and comparison.
The notebook-facing half of measure: DataFrame in, DataFrame out, no printing or
plotting. pandas and pyarrow (neu-morpho[measure]) are imported inside functions.
Variants: all is the whole body, minus_nucleus removes the nucleus,
minus_soma_nucleus the whole cell body. Which matches depends on the other cohort:
removing a compartment from one side that is present on the other is a silent bias.
Attributes¶
Functions¶
|
One row per column: each cohort's statistic and the ratio between them. |
|
One row per body, with volume, cable, per-compartment volume and the variants. |
|
Wide table of every inline property across one or more properties sources. |
|
Log-spaced histogram as a DataFrame, with under/overflow rows. |
|
Join properties onto a bodies table, keeping boolean columns BOOLEAN. |
|
Percentile table for |
|
Write parquet, which unlike csv round-trips a nullable integer column. |
Module Contents¶
- neu_morpho.measure.tables.compare(left, right, columns: Sequence[str], *, labels: Sequence[str] = ('left', 'right'), statistic: str = 'median')¶
One row per column: each cohort’s statistic and the ratio between them.
The ratio is of the statistics: the cohorts are unpaired.
- neu_morpho.measure.tables.load_bodies(db_path: str, *, voxel_nm: float = 32.0, dataset: str | None = None, compartments: Mapping[int, str] | None = None)¶
One row per body, with volume, cable, per-compartment volume and the variants.
Opens the DB read-only, so it is safe against a run in flight. Bodies with no voxel count were never measured and are dropped.
- neu_morpho.measure.tables.load_segment_properties(base: str, *sources: str)¶
Wide table of every inline property across one or more properties sources.
tagsbecome a boolean column per bare tag and, fornamespace:valuetags, one column per namespace. A namespace with several values for one body keeps the first, and the whole tuple goes in<namespace>_all.
- neu_morpho.measure.tables.log_histogram(df, column: str, *, lo: float, hi: float, nbins: int = 48, weight: str | None = None)¶
Log-spaced histogram as a DataFrame, with under/overflow rows.
The catch-alls keep the weight total exact; a fat overflow row means the range is wrong.
- neu_morpho.measure.tables.merge_properties(bodies, props, *, how: str = 'left')¶
Join properties onto a bodies table, keeping boolean columns BOOLEAN.
Use this rather than
bodies.merge(props, on='body_id'). A plain merge widens aboolcolumn toobjectwhere a body has no properties row, and~on that column is arithmetic (~Trueis-2), so~col.fillna(False)silently masks nothing. A body with no properties row getsFalsefor every flag.
- neu_morpho.measure.tables.summarize(df, columns: Sequence[str], *, by: str | None = None, quantiles: Sequence[float] = (0.1, 0.5, 0.9))¶
Percentile table for
columns, optionally grouped by a column.Percentiles rather than mean and sd: these distributions are heavy-tailed.
- neu_morpho.measure.tables.write_table(df, path: str) str¶
Write parquet, which unlike csv round-trips a nullable integer column.
- neu_morpho.measure.tables.DEFAULT_COMPARTMENTS¶
- neu_morpho.measure.tables.VARIANTS¶