MorphoEdge

Contents

MorphoEdge#

class braincell.morph.MorphoEdge(parent, child, parent_x, child_x=0.0)[source]#

A directed edge between two morphology branches.

MorphoEdge is a frozen dataclass representing a parent-child connection in a Morpho tree. It records which branches are connected and where on each branch the attachment occurs.

Edges are typically obtained via Morpho.edges rather than constructed directly.

Parameters:
  • parent (MorphoBranch) – The parent branch in the connection.

  • child (MorphoBranch) – The child branch in the connection.

  • parent_x (float) – Attachment point on the parent branch. One of 0 (proximal), 0.5 (midpoint, soma only), or 1 (distal).

  • child_x (float) – Attachment point on the child branch. One of 0 (proximal) or 1 (distal). Default is 0.

See also

Morpho.edges

Retrieve all edges in a morphology.

Morpho.attach

Attach a child branch to a parent.

Examples

>>> import brainunit as u
>>> from braincell import Branch, Morphology
>>> soma = Branch.from_lengths(
...     lengths=[20.0] * u.um,
...     radii=[10.0, 10.0] * u.um,
...     type="soma",
... )
>>> dend = Branch.from_lengths(
...     lengths=[50.0] * u.um,
...     radii=[2.0, 1.0] * u.um,
...     type="dendrite",
... )
>>> morph = Morphology.from_root(soma, name="soma")
>>> morph.soma.dend = dend
>>> edges = morph.edges
>>> len(edges)
1
>>> edges[0].parent.name
'soma'
>>> edges[0].child.name
'dend'