def iter_neurites(self, iterator_type, mapping=None, neurite_type=TreeType.all): '''Iterate over collection of neurites applying iterator_type Parameters: iterator_type: Type of iterator with which to perform the iteration.\ (e.g. isegment, isection, i_section_path_length) mapping: mapping function to be applied to the target of iteration.\ (e.g. segment_length). Must be compatible with the iterator_type. neurite_type: TreeType object. Neurites of incompatible type are\ filtered out. Returns: Iterator of mapped iteration targets. Example: Get the total volume of all neurites in the cell and the total\ length or neurites from their segments. >>> from neurom import ezy >>> from neurom.analysis import morphmath as mm >>> from neurom.core import tree as tr >>> nrn = ezy.load_neuron('test_data/swc/Neuron.swc') >>> v = sum(nrn.iter_neurites(tr.isegment, mm.segment_volume)) >>> tl = sum(nrn.iter_neurites(tr.isegment, mm.segment_length))) ''' return self.i_neurites(iterator_type, mapping, tree_filter=lambda t: checkTreeType(neurite_type, t.type))
def _n_sections_per_neurite(self, **kwargs): '''Get an iterable with the number of sections for a given neurite type''' neurite_type = kwargs.get('neurite_type', TreeType.all) return self._iterable_type( [n_sections(n) for n in self.neurites if checkTreeType(neurite_type, n.type)] )
def _n_neurites(self, **kwargs): '''Get the number of neurites of a given type in a neuron''' neurite_type = kwargs.get('neurite_type', TreeType.all) return sum(1 for n in self.neurites if checkTreeType(neurite_type, n.type))
def get_n_neurites(self, neurite_type=TreeType.all): '''Get the number of neurites of a given type in a neuron''' return sum(1 for n in self.neurites if checkTreeType(neurite_type, n.type))
def _n_sections(self, **kwargs): '''Get the number of sections of a given type''' neurite_type = kwargs.get('neurite_type', TreeType.all) return sum(n_sections(t) for t in self.neurites if checkTreeType(neurite_type, t.type))
def get_n_sections(self, neurite_type=TreeType.all): '''Get the number of sections of a given type''' return sum(n_sections(t) for t in self.neurites if checkTreeType(neurite_type, t.type))
def get_n_sections_per_neurite(self, neurite_type=TreeType.all): '''Get an iterable with the number of sections for a given neurite type''' return self._iterable_type( [n_sections(n) for n in self.neurites if checkTreeType(neurite_type, n.type)] )
def get_trunk_lengths(self, neurite_type=TreeType.all): '''Get the trunk lengths of a given type in a neuron''' return self._iterable_type( [trunk_length(t) for t in self.neurites if checkTreeType(neurite_type, t.type)] )
def get_trunk_lengths(self, neurite_type=TreeType.all): '''Get the trunk lengths of a given type in a neuron''' return self._iterable_type([ trunk_length(t) for t in self.neurites if checkTreeType(neurite_type, t.type) ])
def get_n_neurites(self, neurite_type=TreeType.all): '''Get the number of neurites of a given type in a neuron''' return sum(1 for n in self.neurites if checkTreeType(neurite_type, n.type))
def get_n_sections_per_neurite(self, neurite_type=TreeType.all): '''Get an iterable with the number of sections for a given neurite type''' return self._iterable_type([ n_sections(n) for n in self.neurites if checkTreeType(neurite_type, n.type) ])
def get_n_sections(self, neurite_type=TreeType.all): '''Get the number of sections of a given type''' return sum( n_sections(t) for t in self.neurites if checkTreeType(neurite_type, t.type))