neuron_morphology.morphology

Module Contents

Classes

Morphology
class neuron_morphology.morphology.Morphology(nodes, node_id_cb, parent_id_cb)

Bases: allensdk.core.simple_tree.SimpleTree

__len__(self)
validate(self, strict=False)
Validate the neuron morphology in
[bits, radius, resample, type, structure]
children_of(self, node)
parent_of(self, node)
get_children_of_node_by_types(self, node, node_types)
get_children(self, node, node_types=None)
node_by_id(self, node_id)
get_soma(self)

Return one soma node labeled with SOMA If the input SWC file does not have any node labeled with SOMA, it will return None

Parameters:
morphology: Morphology object
Returns:
Soma node object
get_root(self)

Return the first found root node If the input SWC file does not have any root node, it will return None

Parameters:
morphology: Morphology object
Returns:
Root node object
get_roots(self)
get_root_id(self)
get_roots_for_nodes(self, nodes)
get_roots_for_analysis(self, root=None, node_types=None)

Returns a list of all trees to be analyzed, based on the supplied root. These trees are the list of all children of the root, if root is not None, and the root node of all trees in the morphology if root is None.

Parameters:
morphology: Morphology object
root: dict
This is the node from which to count branches under. When root=None,
all separate trees in the morphology are returned.
node_types: list (AXON, BASAL_DENDRITE, APICAL_DENDRITE)
Type to restrict search to
Returns:
Array of Node objects
get_number_of_trees(self, nodes=None)
get_tree_list(self)
get_root_for_tree(self, tree_number)
get_node_by_types(self, node_types=None)
has_type(self, node_type)
get_non_soma_nodes(self)
get_max_id(self)
is_soma_child(self, node)
get_segment_list(self, node_types=None)
_build_segment(self, end_node)
is_node_at_beginning_of_segment(self, node)
is_node_at_end_of_segment(self, node)
get_segment_length(self, segment)
get_branch_order_for_node(self, node)
get_branch_order_for_segment(self, segment)
_create_compartment_dictionary(self)
get_compartments(self, nodes=None, node_types=None)
get_compartment_for_node(self, node, node_types=None)
get_compartment_length(self, compartment)
get_compartment_surface_area(self, compartment: Sequence[Dict])

Calculate the surface area of a single compartment. Treats the compartment as a circular conic frustum and calculates its lateral surface area. This is:

pi * (r_1 + r_2) * sqrt( (r_2 - r_1) ** 2 + L ** 2 )
Parameters:
compartment : two-long sequence. Each element is a node and must have

3d position data (“x”, “y”, “z”) and a “radius”

Returns:
The surface area of the sides of the compartment
get_compartment_volume(self, compartment: Sequence[Dict])

Calculate the volume of a single compartment. Treats the compartment as a circular conic frustum and calculates its volume as:

pi * L * (r_1 ** 2 + r_1 * r_2 + r_2 ** 2) / 3
Parameters:
compartment : two-long sequence. Each element is a node and must have

3d position data (“x”, “y”, “z”) and a “radius”

Returns:
The volume of the compartment
get_compartment_midpoint(self, compartment)
get_leaf_nodes(self, node_types=None)
get_branching_nodes(self, node_types=None)
clone(self)
build_intermediate_nodes(self, make_intermediates_cb, set_parent_id_cb)
_insert_between(self, new_node, parent_id, child_id, set_parent_id_cb)
_make_and_insert_intermediate(self, make_intermediates_cb, set_parent_id_cb, child)
breadth_first_traversal(self, visit, neighbor_cb=None, start_id=None)

Apply a function to each node of a connected graph in breadth-first order

Parameters:
visit : callable

Will be applied to each node. Signature must be visit(node). Return is ignored.

neighbor_cb : callable, optional

Will be used during traversal to find the next nodes to be visited. Signature must be neighbor_cb(node id) -> list of node_ids. Defaults to self.child_ids.

start_id : hashable, optional

Begin the traversal from this node. Defaults to self.get_root_id().

Notes

assumes rooted, acyclic

depth_first_traversal(self, visit, neighbor_cb=None, start_id=None)

Apply a function to each node of a connected graph in depth-first order

Parameters:
visit : callable

Will be applied to each node. Signature must be visit(node). Return is ignored.

neighbor_cb : callable, optional

Will be used during traversal to find the next nodes to be visited. Signature must be neighbor_cb(node_id) -> list of node_ids. Defaults to self.child_ids.

start_id : hashable, optional

Begin the traversal from this node. Defaults to self.get_root_id().

Notes

assumes rooted, acyclic

swap_nodes_edges(self, merge_cb=None, parent_id_cb=None, make_root_cb=None, start_id=None)

Build a new tree whose nodes are the edges of this tree and vice-versa

Parameters:
merge_cb : callable, optional
parent_id_cb : callable, optional
make_root_cb : callable, optional
start_id : hashable, optional

Notes

assumes rooted, acyclic

_get_edge_and_merge(self, merge_cb, new_nodes, node)

Used by swap_nodes_edges

static _get_node_attributes(attributes, nodes)
get_dimensions(self, node_types=None)
static euclidean_distance(node1, node2)
static midpoint(node1, node2)