Example #1
0
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]))
Example #2
0
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]))
Example #3
0
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)
    ]
Example #4
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]))
Example #5
0
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])
Example #6
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]))
Example #7
0
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)
Example #8
0
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)
Example #9
0
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)
Example #10
0
 def length(self):
     """Return the path length of this section."""
     return morphmath.section_length(self.points)
Example #11
0
 def _seclen(sec, **kwargs):
     """get section length of `sec`"""
     return morphmath.section_length(sec.points, **kwargs)
Example #12
0
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)]
Example #13
0
def _section_length(section):
    """Get section length of `section`."""
    return morphmath.section_length(section.points)
Example #14
0
 def sec_len(sec):
     """Return the length of a section."""
     return mm.section_length(sec.points)
Example #15
0
def length(section):
    '''Return the length of a section'''
    return mm.section_length(section)
Example #16
0
def sec_len(sec):
    '''Return the length of a section'''
    return mm.section_length(sec.points)
Example #17
0
 def length(self):
     '''Return the path length of this section.'''
     return morphmath.section_length(self.points)
Example #18
0
 def length(self):
     '''Return the path length of this section.'''
     return morphmath.section_length(self.points)
Example #19
0
 def _seclen(sec, **kwargs):
     '''get section length of `sec`'''
     return morphmath.section_length(sec.points, **kwargs)
Example #20
0
def _section_length(section):
    '''get section length of `section`'''
    return morphmath.section_length(section.points)
Example #21
0
def section_path_length(section):
    '''Path length from section to root'''
    return sum(mm.section_length(s.points) for s in section.iupstream())
Example #22
0
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)