BranchData#

class braintools.visualize.morphology.BranchData(index, name, type, parent_index, parent_x, child_x, lengths, radii_proximal, radii_distal, points_proximal=None, points_distal=None)[source]#

Geometry and attachment of one unbranched section of a morphology.

A branch is a chain of n_seg frusta (segments). Segment k runs from radius radii_proximal[k] to radii_distal[k] over lengths[k].

Parameters:
  • index (int) – Position of this branch in MorphologyData.branches.

  • name (str) – Branch name, unique within the morphology. Unlike index, it is the identifier that survives edits of the source morphology.

  • type (str) – Branch type, such as "soma", "axon", "basal_dendrite", "apical_dendrite". Selects the colour of the branch.

  • parent_index (int | None) – Index of the parent branch, None for the root.

  • parent_x (float | None) – Normalised position [0, 1] on the parent where this branch is attached; None for the root.

  • child_x (float | None) – Normalised position [0, 1] on this branch that touches the parent; None for the root.

  • lengths (Quantity) – Segment lengths, shape (n_seg,), a length unit.

  • radii_proximal (Quantity) – Segment end radii, shape (n_seg,), a length unit.

  • radii_distal (Quantity) – Segment end radii, shape (n_seg,), a length unit.

  • points_proximal (Quantity | None) – Segment end points, shape (n_seg, 3), a length unit. Both or neither must be given; without them only the automatic 2-D layouts are available.

  • points_distal (Quantity | None) – Segment end points, shape (n_seg, 3), a length unit. Both or neither must be given; without them only the automatic 2-D layouts are available.

Raises:
  • TypeError – If a geometry field is not a Quantity with a length unit.

  • ValueError – If the geometry arrays disagree in shape or are empty.

Examples

>>> import brainunit as u
>>> from braintools.visualize.morphology import BranchData
>>> 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,
... )
>>> soma.n_segments
1
>>> soma.length
Quantity(10., "um")
property has_points: bool#

Whether the branch carries 3-D point geometry.

property length: Quantity#

Total path length of the branch.

property n_segments: int#

Number of segments.