def trunk_vectors(nrn, neurite_type=NeuriteType.all): """Calculates the vectors between all the trunks of the neuron and the soma center.""" neurite_filter = is_type(neurite_type) nrns = neuron_population(nrn) return np.array([morphmath.vector(s.root_node.points[0], n.soma.center) for n in nrns for s in n.neurites if neurite_filter(s)])
def _elevation(section, soma): """Elevation of a section.""" vector = morphmath.vector(section[0], soma.center) norm_vector = np.linalg.norm(vector) if norm_vector >= np.finfo(type(norm_vector)).eps: return np.arcsin(vector[COLS.Y] / norm_vector) raise ValueError("Norm of vector between soma center and section is almost zero.")
def _elevation(section, soma): '''Elevation of a section''' vector = mm.vector(section[0], soma.center) norm_vector = np.linalg.norm(vector) if norm_vector >= np.finfo(type(norm_vector)).eps: return np.arcsin(vector[COLS.Y] / norm_vector) else: raise ValueError("Norm of vector between soma center and section is almost zero.")
def test_vector(): vec1 = (12.0, 3, 6.0) vec2 = (14.0, 1.0, 6.0) vec = mm.vector(vec1, vec2) assert np.all(vec == (-2.0, 2.0, 0.0))
def _azimuth(section, soma): """Azimuth of a section.""" vector = morphmath.vector(section[0], soma.center) return np.arctan2(vector[COLS.Z], vector[COLS.X])
def test_vector(): vec1 = (12.0, 3, 6.0) vec2 = (14.0, 1.0, 6.0) vec = mm.vector(vec1,vec2) nt.ok_(np.all(vec ==(-2.0, 2.0, 0.0)))
def trunk_origin_direction(tree, soma): '''Vector of trunk origin direction defined as (initial tree point - soma center) of the tree. ''' return mm.vector(tree.value, soma.center)
def _azimuth(section, soma): '''Azimuth of a section''' vector = mm.vector(section[0], soma.center) return np.arctan2(vector[COLS.Z], vector[COLS.X])