def test_section_tortuosity(): sec_a = load_neuron(StringIO(u""" ((CellBody) (0 0 0 2)) ((Dendrite) (0 0 0 2) (1 0 0 2) (2 0 0 2) (3 0 0 2))"""), reader='asc').sections[SECTION_ID] sec_b = load_neuron(StringIO(u""" ((CellBody) (0 0 0 2)) ((Dendrite) (0 0 0 2) (1 0 0 2) (1 2 0 2) (0 2 0 2))"""), reader='asc').sections[SECTION_ID] assert _sf.section_tortuosity(sec_a) == 1.0 assert _sf.section_tortuosity(sec_b) == 4.0 / 2.0 for s in _nf.iter_sections(NRN): assert (_sf.section_tortuosity(s) == mmth.section_length(s.points) / mmth.point_dist(s.points[0], s.points[-1]))
def test_section_tortuosity(): sec_a = load_neuron(StringIO(u""" ((CellBody) (0 0 0 2)) ((Dendrite) (0 0 0 2) (1 0 0 2) (2 0 0 2) (3 0 0 2))"""), reader='asc').sections[1] sec_b = load_neuron(StringIO(u""" ((CellBody) (0 0 0 2)) ((Dendrite) (0 0 0 2) (1 0 0 2) (1 2 0 2) (0 2 0 2))"""), reader='asc').sections[1] nt.eq_(_sf.section_tortuosity(sec_a), 1.0) nt.eq_(_sf.section_tortuosity(sec_b), 4.0 / 2.0) for s in _nf.iter_sections(NRN): nt.eq_( _sf.section_tortuosity(s), mmth.section_length(s.points) / mmth.point_dist(s.points[0], s.points[-1]))
def trunk_section_lengths(nrn, neurite_type=NeuriteType.all): """List of lengths of trunk sections of neurites in a neuron.""" neurite_filter = is_type(neurite_type) return [ morphmath.section_length(s.root_node.points) for s in nrn.neurites if neurite_filter(s) ]
def test_section_tortuosity(): sec_a = Section([(0, 0, 0), (1, 0, 0), (2, 0, 0), (3, 0, 0)]) sec_b = Section([(0, 0, 0), (1, 0, 0), (1, 2, 0), (0, 2, 0)]) nt.eq_(_sf.section_tortuosity(sec_a), 1.0) nt.eq_(_sf.section_tortuosity(sec_b), 4.0 / 2.0) for s in _nf.iter_sections(NRN): nt.eq_(_sf.section_tortuosity(s), mmth.section_length(s.points) / mmth.point_dist(s.points[0], s.points[-1]))
def section_tortuosity(section): '''Tortuosity of a section The tortuosity is defined as the ratio of the path length of a section and the euclidian distnce between its end points. The path length is the sum of distances between consecutive points. If the section contains less than 2 points, the value 1 is returned. ''' pts = section.points return 1 if len(pts) < 2 else mm.section_length(pts) / mm.point_dist(pts[-1], pts[0])
def test_section_tortuosity(): sec_a = Section([(0, 0, 0), (1, 0, 0), (2, 0, 0), (3, 0, 0)]) sec_b = Section([(0, 0, 0), (1, 0, 0), (1, 2, 0), (0, 2, 0)]) nt.eq_(_sf.section_tortuosity(sec_a), 1.0) nt.eq_(_sf.section_tortuosity(sec_b), 4.0 / 2.0) for s in _nf.iter_sections(NRN): nt.eq_( _sf.section_tortuosity(s), mmth.section_length(s.points) / mmth.point_dist(s.points[0], s.points[-1]))
def has_all_nonzero_section_lengths(neuron, threshold=0.0): '''Check presence of neuron sections with length not above threshold Arguments: neuron: Neuron object whose segments will be tested threshold: value above which a section length is considered to be non-zero Return: status and list of ids bad sections ''' bad_ids = [s.id for s in _nf.iter_sections(neuron.neurites) if section_length(s.points) <= threshold] return CheckResult(len(bad_ids) == 0, bad_ids)
def has_all_nonzero_section_lengths(neuron, threshold=0.0): '''Check presence of neuron sections with length not above threshold Arguments: neuron(Neuron): The neuron object to test threshold(float): value above which a section length is considered to be non-zero Returns: CheckResult with result including list of ids bad sections ''' bad_ids = [s.id for s in _nf.iter_sections(neuron.neurites) if section_length(s.points) <= threshold] return CheckResult(len(bad_ids) == 0, bad_ids)
def has_all_nonzero_section_lengths(neuron, threshold=0.0): '''Check presence of neuron sections with length not above threshold Arguments: neuron(Neuron): The neuron object to test threshold(float): value above which a section length is considered to be non-zero Returns: CheckResult with result including list of ids of bad sections ''' bad_ids = [s.id for s in _nf.iter_sections(neuron.neurites) if section_length(s.points) <= threshold] return CheckResult(len(bad_ids) == 0, bad_ids)
def length(self): """Return the path length of this section.""" return morphmath.section_length(self.points)
def _seclen(sec, **kwargs): """get section length of `sec`""" return morphmath.section_length(sec.points, **kwargs)
def trunk_section_lengths(nrn, neurite_type=NeuriteType.all): '''list of lengths of trunk sections of neurites in a neuron''' neurite_filter = is_type(neurite_type) return [mm.section_length(s.root_node.points) for s in nrn.neurites if neurite_filter(s)]
def _section_length(section): """Get section length of `section`.""" return morphmath.section_length(section.points)
def sec_len(sec): """Return the length of a section.""" return mm.section_length(sec.points)
def length(section): '''Return the length of a section''' return mm.section_length(section)
def sec_len(sec): '''Return the length of a section''' return mm.section_length(sec.points)
def length(self): '''Return the path length of this section.''' return morphmath.section_length(self.points)
def _seclen(sec, **kwargs): '''get section length of `sec`''' return morphmath.section_length(sec.points, **kwargs)
def _section_length(section): '''get section length of `section`''' return morphmath.section_length(section.points)
def section_path_length(section): '''Path length from section to root''' return sum(mm.section_length(s.points) for s in section.iupstream())