MorphologyData#

class braintools.visualize.morphology.MorphologyData(branches, root_index=0, children=None, name=None)[source]#

A tree of BranchData, the input of every morphology plot.

Parameters:
  • branches (tuple[BranchData, ...]) – All branches; branches[i].index must equal i.

  • root_index (int) – Index of the root branch (default 0).

  • children (tuple[tuple[int, ...], ...] | None) – Child indices of each branch, in drawing order. Layouts place children in this order. None (default) derives it from parent_index in index order.

  • name (str | None) – Display name, used as a default panel title.

Raises:

ValueError – If the indices are not 0..n-1, a parent does not exist, the branches do not form one tree rooted at root_index, or children disagrees with parent_index.

See also

as_morphology_data

Accepts this type or an object implementing __morphology_data__().

Examples

>>> import brainunit as u
>>> from braintools.visualize.morphology import BranchData, MorphologyData
>>> soma = BranchData(
...     index=0, name="soma", type="soma", parent_index=None,
...     parent_x=None, child_x=None, lengths=[10.0] * u.um,
...     radii_proximal=[5.0] * u.um, radii_distal=[5.0] * u.um,
... )
>>> dend = BranchData(
...     index=1, name="dend", type="basal_dendrite", parent_index=0,
...     parent_x=1.0, child_x=0.0, lengths=[20.0, 20.0] * u.um,
...     radii_proximal=[2.0, 1.5] * u.um, radii_distal=[1.5, 1.0] * u.um,
... )
>>> data = MorphologyData(branches=(soma, dend))
>>> data.children
((1,), ())
>>> data.has_full_point_geometry
False
property has_full_point_geometry: bool#

Whether every branch carries 3-D points (needed by 3-D and projected plots).

property n_branches: int#

Number of branches.

property structure_key: Hashable[source]#

Hashable snapshot of the geometry and topology, computed once.

Two instances with equal geometry (rounded to 1e-6 um) and equal child order share a key; LayoutCache uses it.