Ejemplo n.º 1
0
    def i_neurites(self, iterator_type, mapping=None, tree_filter=None):
        '''Returns a mapped iterator to all the neuron's neurites

        Provides access to all the elements of all the neurites
        in one iteration sequence.

        Parameters:
            iterator_type: type of the iteration (segment, section, triplet...)
            mapping: optional function to apply to the iterator's target.
            tree_filter: optional top level filter on properties of neurite tree objects.
        '''
        return tr.i_chain(self.neurites, iterator_type, mapping, tree_filter)
Ejemplo n.º 2
0
    def bounding_box(self):
        '''Return 3D bounding box of a neuron

        Returns:
            2D numpy array of [[min_x, min_y, min_z], [max_x, max_y, max_z]]
        '''

        # Get the bounding coordinates of the neurites
        nmin_xyz, nmax_xyz = (np.array([np.inf, np.inf, np.inf]),
                              np.array([np.NINF, np.NINF, np.NINF]))

        for p in tr.i_chain(self.neurites, tr.ipreorder, lambda p: p):
            nmin_xyz = np.minimum(p[:COLS.R], nmin_xyz)
            nmax_xyz = np.maximum(p[:COLS.R], nmax_xyz)

        # Get the bounding coordinates of the soma
        smin_xyz = np.array(self.soma.center) - self.soma.radius

        smax_xyz = np.array(self.soma.center) + self.soma.radius

        return np.array([np.minimum(smin_xyz, nmin_xyz),
                         np.maximum(smax_xyz, nmax_xyz)])