NeuroMorphoMeasurement#

class braincell.io.NeuroMorphoMeasurement(neuron_id, surface=None, volume=None, soma_surface=None, n_stems=None, n_bifs=None, n_branch=None, width=None, height=None, depth=None, diameter=None, length=None, euclidean_distance=None, path_distance=None, branch_order=None, contraction=None, fragmentation=None, partition_asymmetry=None, pk_classic=None, bif_ampl_local=None, bif_ampl_remote=None, extras=<factory>, raw=<factory>)[source]#

Typed view over a NeuroMorpho.Org morphometry record.

All quantitative fields are bare floats using the units documented by NeuroMorpho.Org: lengths in micrometres (μm), surfaces in square micrometres (μm²), volumes in cubic micrometres (μm³), angles in degrees. Missing fields are None rather than NaN.

The dataclass only promotes the fields that NeuroMorpho.Org returns most consistently. Less common fields remain available through extras and the get() accessor.

Parameters:
  • neuron_id (int) – NeuroMorpho.Org numeric id this measurement belongs to.

  • surface (float | None) – Total neuritic surface area (μm²).

  • volume (float | None) – Total neuritic volume (μm³).

  • soma_surface (float | None) – Soma surface area (μm²).

  • n_stems (int | None) – Number of stems leaving the soma.

  • n_bifs (int | None) – Number of bifurcations.

  • n_branch (int | None) – Number of branches (excluding soma).

  • width (float | None) – Bounding-box width (μm).

  • height (float | None) – Bounding-box height (μm).

  • depth (float | None) – Bounding-box depth (μm).

  • diameter (float | None) – Average branch diameter (μm).

  • length (float | None) – Total neuritic length (μm).

  • euclidean_distance (float | None) – Maximum Euclidean distance from soma (μm).

  • path_distance (float | None) – Maximum path distance from soma (μm).

  • branch_order (int | None) – Maximum branch order.

  • contraction (float | None) – Average branch contraction.

  • fragmentation (int | None) – Average compartment count per branch.

  • partition_asymmetry (float | None)

  • pk_classic (float | None)

  • bif_ampl_local (float | None)

  • bif_ampl_remote (float | None)

  • extras (Mapping[str, Any]) – Long-tail measurement keys not promoted to dataclass fields.

  • raw (Mapping[str, Any]) – Read-only view of the upstream JSON payload (with the original upstream key spellings preserved). Useful when callers want to forward the unmodified upstream record or compare against documentation.

Examples

>>> meas = NeuroMorphoMeasurement.from_payload(
...     {"neuron_id": 10047, "n_stems": 1.0, "length": 123.4}
... )
>>> meas.n_stems, meas.length
(1, 123.4)
>>> meas.get("custom_field", "missing")
'missing'
as_dict()[source]#

Return a flat dict view including extras keys.

Returns:

All promoted attributes plus the contents of extras, with attribute values taking precedence on key collisions.

Return type:

dict[str, Any]

classmethod from_payload(payload)[source]#

Build a NeuroMorphoMeasurement from a JSON payload.

Missing keys map to None. Unrecognized keys are stashed in extras.

Parameters:

payload (Mapping[str, Any]) – JSON object returned by /api/morphometry/id/<id>.

Return type:

NeuroMorphoMeasurement

get(key, default=None)[source]#

Look up a measurement value by attribute or extras key.

Promoted attributes are tried first; otherwise the lookup falls through to extras. Returns default when neither contains the key.

Parameters:
Return type:

Any