Exemplo n.º 1
0
def i_segment_meander_angle(tree):
    '''Return an iterator to a tree meander angle

    The meander angle is defined as the angle between to adjacent  segments.
    Applies neurom.morphmath.angle_3points to triplets of
    '''

    return tr.imap_val(lambda t: mm.angle_3points(t[1], t[0], t[2]), tr.itriplet(tree))
Exemplo n.º 2
0
def i_segment_meander_angle(tree):
    '''Return an iterator to a tree meander angle

    The meander angle is defined as the angle between to adjacent  segments.
    Applies neurom.morphmath.angle_3points to triplets of
    '''

    return tr.imap_val(lambda t: mm.angle_3points(t[1], t[0], t[2]),
                       tr.itriplet(tree))
Exemplo n.º 3
0
def trunk_section_length(tree):
    '''Length of the initial tree section

    Returns:
        Length of first section of tree or 0 if single point tree
    '''
    try:
        _it = tr.imap_val(mm.section_length, tr.isection(tree))
        return _it.next()
    except StopIteration:
        return 0.0
Exemplo n.º 4
0
def i_segment_radial_dist(pos, tree):
    '''Return an iterator of radial distances of tree segments to a given point

    The radial distance is the euclidian distance between the mid-point of
    the segment and the point in question.

    Parameters:
        pos: origin to which disrances are measured. It must have at least 3
        components. The first 3 components are (x, y, z).

        tree: tree of raw data rows.

    '''
    return tr.imap_val(lambda s: mm.segment_radial_dist(s, pos), tr.isegment(tree))
Exemplo n.º 5
0
def i_segment_radial_dist(pos, tree):
    '''Return an iterator of radial distances of tree segments to a given point

    The radial distance is the euclidian distance between the mid-point of
    the segment and the point in question.

    Parameters:
        pos: origin to which disrances are measured. It must have at least 3
        components. The first 3 components are (x, y, z).

        tree: tree of raw data rows.

    '''
    return tr.imap_val(lambda s: mm.segment_radial_dist(s, pos),
                       tr.isegment(tree))
Exemplo n.º 6
0
def i_section_radial_dist(tree, pos=None, use_start_point=False):
    '''Return an iterator of radial distances of tree sections to a given point

    The radial distance is the euclidian distance between the either the
    end-point or rhe start point of the section and the point in question.

    Parameters:
        tree: tree object
        pos: origin to which distances are measured. It must have at least 3\
            components. The first 3 components are (x, y, z).\
            (default tree origin)

        use_start_point: If true, calculate distance from section start point,\
            else from end-point (default, False)

    '''
    pos = tree.value if pos is None else pos
    sec_idx = 0 if use_start_point else -1
    return tr.imap_val(lambda s: mm.point_dist(s[sec_idx], pos), tr.isection(tree))
Exemplo n.º 7
0
def i_section_radial_dist(tree, pos=None, use_start_point=False):
    '''Return an iterator of radial distances of tree sections to a given point

    The radial distance is the euclidian distance between the either the
    end-point or rhe start point of the section and the point in question.

    Parameters:
        tree: tree object
        pos: origin to which distances are measured. It must have at least 3\
            components. The first 3 components are (x, y, z).\
            (default tree origin)

        use_start_point: If true, calculate distance from section start point,\
            else from end-point (default, False)

    '''
    pos = tree.value if pos is None else pos
    sec_idx = 0 if use_start_point else -1
    return tr.imap_val(lambda s: mm.point_dist(s[sec_idx], pos),
                       tr.isection(tree))
Exemplo n.º 8
0
def i_segment_area(tree):
    ''' return an iterator of tree segment areas
    '''
    return tr.imap_val(mm.segment_area, tr.isegment(tree))
Exemplo n.º 9
0
def i_segment_volume(tree):
    ''' return an iterator of tree segment volumes
    '''
    return tr.imap_val(mm.segment_volume, tr.isegment(tree))
Exemplo n.º 10
0
def i_segment_radius(tree):
    ''' return an iterator of tree segment radii
    '''
    return tr.imap_val(mm.segment_radius, tr.isegment(tree))
Exemplo n.º 11
0
def i_segment_length(tree):
    ''' return an iterator of tree segment lengths
    '''
    return tr.imap_val(mm.segment_length, tr.isegment(tree))
Exemplo n.º 12
0
def path_length(tree):
    '''Get the path length from a sub-tree to the root node'''
    return np.sum(s for s in tr.imap_val(mm.segment_length,
                                         tr.isegment(tree, tr.iupstream)))
Exemplo n.º 13
0
def i_segment_area(tree):
    ''' return an iterator of tree segment areas
    '''
    return tr.imap_val(mm.segment_area, tr.isegment(tree))
Exemplo n.º 14
0
def i_segment_volume(tree):
    ''' return an iterator of tree segment volumes
    '''
    return tr.imap_val(mm.segment_volume, tr.isegment(tree))
Exemplo n.º 15
0
def i_segment_radius(tree):
    ''' return an iterator of tree segment radii
    '''
    return tr.imap_val(mm.segment_radius, tr.isegment(tree))
Exemplo n.º 16
0
def i_segment_length(tree):
    ''' return an iterator of tree segment lengths
    '''
    return tr.imap_val(mm.segment_length, tr.isegment(tree))
Exemplo n.º 17
0
def path_length(tree):
    '''Get the path length from a sub-tree to the root node'''
    return np.sum(s for s in
                  tr.imap_val(mm.segment_length, tr.isegment(tree, tr.iupstream)))
Exemplo n.º 18
0
def i_section_length(tree):
    """
    Return an iterator of tree section lengths
    """
    return tr.imap_val(mm.section_length, tr.isection(tree))
Exemplo n.º 19
0
def i_section_length(tree):
    """
    Return an iterator of tree section lengths
    """
    return tr.imap_val(mm.section_length, tr.isection(tree))