:mod:`neuron_morphology.morphology` =================================== .. py:module:: neuron_morphology.morphology Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: neuron_morphology.morphology.Morphology .. py:class:: Morphology(nodes, node_id_cb, parent_id_cb) Bases: :class:`allensdk.core.simple_tree.SimpleTree` .. method:: __len__(self) .. method:: validate(self, strict=False) Validate the neuron morphology in [bits, radius, resample, type, structure] .. !! processed by numpydoc !! .. method:: children_of(self, node) .. method:: parent_of(self, node) .. method:: get_children_of_node_by_types(self, node, node_types) .. method:: get_children(self, node, node_types=None) .. method:: node_by_id(self, node_id) .. method:: 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 .. .. !! processed by numpydoc !! .. method:: 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 .. .. !! processed by numpydoc !! .. method:: get_roots(self) .. method:: get_root_id(self) .. method:: get_roots_for_nodes(self, nodes) .. method:: 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 .. .. !! processed by numpydoc !! .. method:: get_number_of_trees(self, nodes=None) .. method:: get_tree_list(self) .. method:: get_root_for_tree(self, tree_number) .. method:: get_node_by_types(self, node_types=None) .. method:: has_type(self, node_type) .. method:: get_non_soma_nodes(self) .. method:: get_max_id(self) .. method:: is_soma_child(self, node) .. method:: get_segment_list(self, node_types=None) .. method:: _build_segment(self, end_node) .. method:: is_node_at_beginning_of_segment(self, node) .. method:: is_node_at_end_of_segment(self, node) .. method:: get_segment_length(self, segment) .. method:: get_branch_order_for_node(self, node) .. method:: get_branch_order_for_segment(self, segment) .. method:: _create_compartment_dictionary(self) .. method:: get_compartments(self, nodes=None, node_types=None) .. method:: get_compartment_for_node(self, node, node_types=None) .. method:: get_compartment_length(self, compartment) .. method:: 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 .. .. !! processed by numpydoc !! .. method:: 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 .. .. !! processed by numpydoc !! .. method:: get_compartment_midpoint(self, compartment) .. method:: get_leaf_nodes(self, node_types=None) .. method:: get_branching_nodes(self, node_types=None) .. method:: clone(self) .. method:: build_intermediate_nodes(self, make_intermediates_cb, set_parent_id_cb) .. method:: _insert_between(self, new_node, parent_id, child_id, set_parent_id_cb) .. method:: _make_and_insert_intermediate(self, make_intermediates_cb, set_parent_id_cb, child) .. method:: 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(). .. rubric:: Notes assumes rooted, acyclic .. !! processed by numpydoc !! .. method:: 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(). .. rubric:: Notes assumes rooted, acyclic .. !! processed by numpydoc !! .. method:: 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 .. .. rubric:: Notes assumes rooted, acyclic .. !! processed by numpydoc !! .. method:: _get_edge_and_merge(self, merge_cb, new_nodes, node) Used by swap_nodes_edges .. !! processed by numpydoc !! .. staticmethod:: _get_node_attributes(attributes, nodes) .. method:: get_dimensions(self, node_types=None) .. staticmethod:: euclidean_distance(node1, node2) .. staticmethod:: midpoint(node1, node2)