def test_get_section_path_distances(self):
        _close(_nrt.section_path_lengths(self.sec_nrn.neurites[0]),
               get('section_path_distances', self.ref_nrn.neurites[0]))

        _close(_nrt.section_path_lengths(self.sec_nrn), get('section_path_distances', self.ref_nrn))
        for t in NeuriteType:
            _close(_nrt.section_path_lengths(self.sec_nrn, neurite_type=t),
                   get('section_path_distances', self.ref_nrn, neurite_type=t))

        pl = [_sec.section_path_length(s) for s in i_chain2(self.sec_nrn_trees)]
        _close(pl, get('section_path_distances', self.ref_nrn))
    def test_get_remote_bifurcation_angles(self):
        _close(_nrt.remote_bifurcation_angles(self.sec_nrn.neurites[0]),
               get('remote_bifurcation_angles', self.ref_nrn.neurites[0]))

        _close(_nrt.remote_bifurcation_angles(self.sec_nrn),
               get('remote_bifurcation_angles', self.ref_nrn))

        for t in NeuriteType:
            _close(_nrt.remote_bifurcation_angles(self.sec_nrn, neurite_type=t),
                   get('remote_bifurcation_angles', self.ref_nrn, neurite_type=t))

        ba = [_bf.remote_bifurcation_angle(b)
              for b in i_chain2(self.sec_nrn_trees, iterator_type=Tree.ibifurcation_point)]

        _close(ba, get('remote_bifurcation_angles', self.ref_nrn))
Example #3
0
def iter_neurites(obj, mapfun=None, filt=None):
    """Iterator to a neurite, neuron or neuron population

    Applies optional neurite filter and element mapping functions.

    Example:
        Get the lengths of sections in a neuron and a population

        >>> from neurom import sections as sec
        >>> neuron_lengths = [l for l in iter_neurites(nrn, sec.length)]
        >>> population_lengths = [l for l in iter_neurites(pop, sec.length)]
        >>> neurite = nrn.neurites[0]
        >>> tree_lengths = [l for l in iter_neurites(neurite, sec.length)]

    """
    #  TODO: optimize case of single neurite and move code to neurom.core.tree
    neurites = [obj] if isinstance(obj, Tree) else (obj.neurites if hasattr(obj, "neurites") else obj)
    iter_type = None if mapfun is None else mapfun.iter_type

    return i_chain2(neurites, iter_type, mapfun, filt)