neuron_morphology.morphology module¶
-
class
neuron_morphology.morphology.Morphology(nodes, node_id_cb, parent_id_cb)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectMethods
__call__(self, \*args, \*\*kw)Call self as a function. breadth_first_traversal(self, visit[, …])Apply a function to each node of a connected graph in breadth-first order depth_first_traversal(self, visit[, …])Apply a function to each node of a connected graph in depth-first order get_compartment_surface_area(self, compartment)Calculate the surface area of a single compartment. get_compartment_volume(self, compartment)Calculate the volume of a single compartment. get_root(self)Return the first found root node If the input SWC file does not have any root node, it will return None get_roots_for_analysis(self[, root, node_types])Returns a list of all trees to be analyzed, based on the supplied root. 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 swap_nodes_edges(self[, merge_cb, …])Build a new tree whose nodes are the edges of this tree and vice-versa validate(self[, strict])Validate the neuron morphology in build_intermediate_nodes children_of clone euclidean_distance get_branch_order_for_node get_branch_order_for_segment get_branching_nodes get_children get_children_of_node_by_types get_compartment_for_node get_compartment_length get_compartment_midpoint get_compartments get_dimensions get_leaf_nodes get_max_id get_node_by_types get_non_soma_nodes get_number_of_trees get_root_for_tree get_root_id get_roots get_roots_for_nodes get_segment_length get_segment_list get_tree_list has_type is_node_at_beginning_of_segment is_node_at_end_of_segment is_soma_child midpoint node_by_id parent_of -
breadth_first_traversal(self, visit, neighbor_cb=None, start_id=None)[source]¶ 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)[source]¶ 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
-
get_compartment_surface_area(self, compartment: Sequence[Dict]) → float[source]¶ 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]) → float[source]¶ 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) / 3Parameters: - 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_root(self)[source]¶ 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_for_analysis(self, root=None, node_types=None)[source]¶ 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_soma(self)[source]¶ 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
-
swap_nodes_edges(self, merge_cb=None, parent_id_cb=None, make_root_cb=None, start_id=None)[source]¶ 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
-