Morphologies module¶
- class bsb.morphologies.Branch(*args, labels=None)[source]¶
A vector based representation of a series of point in space. Can be a root or connected to a parent branch. Can be a terminal branch or have multiple children.
- attach_child(branch)[source]¶
Attach a branch as a child to this branch.
- Parameters
branch (
Branch
) – Child branch
- property children¶
Collection of the child branches of this branch.
- Returns
list of
Branches
- Return type
list
- detach_child(branch)[source]¶
Remove a branch as a child from this branch.
- Parameters
branch (
Branch
) – Child branch
- label(*labels)[source]¶
Add labels to every point on the branch. See
label_points
to label individual points.- Parameters
labels (str) – Label(s) for the branch.
- label_points(label, mask)[source]¶
Add labels to specific points on the branch. See
label
to label the entire branch.- Parameters
label (str) – Label to apply to the points.
mask (np.ndarray(dtype=bool, shape=(branch_size,))) – Boolean mask equal in size to the branch that determines which points get labelled.
- property points¶
Return the vectors of this branch as a matrix.
- property size¶
Returns the amount of points on this branch
- Returns
Number of points on the branch.
- Return type
int
- property terminal¶
Returns whether this branch is terminal or has children.
- Returns
True if this branch has no children, False otherwise.
- Return type
bool
- class bsb.morphologies.Compartment(start, end, radius, id=None, labels=None, parent=None, section_id=None, morphology=None)[source]¶
Compartments are line segments with a radius. They can be constructed from the points on a
Branch
or by concatenating the results of a depth-first iteration of the branches of aMorphology
.
- class bsb.morphologies.Morphology(roots)[source]¶
A multicompartmental spatial representation of a cell based on connected 3D compartments.
- Todo
Uncouple from the MorphologyRepository and merge with TrueMorphology.
- property branches¶
Return a depth-first flattened array of all branches.
- flatten(vectors=None, matrix=False, labels=None)[source]¶
Return the flattened vectors of the morphology
- Parameters
vectors (list of str) – List of vectors to return such as [‘x’, ‘y’, ‘z’] to get the positional vectors.
- Returns
Tuple of the vectors in the given order, if matrix is True a matrix composed of the vectors is returned instead.
- Return type
tuple of ndarrays (matrix=False) or matrix (matrix=True)
- get_branches(labels=None)[source]¶
Return a depth-first flattened array of all or the selected branches.
- Parameters
labels (list) – Names of the labels to select.
- Returns
List of all branches or all branches with any of the labels when given
- Return type
list