Skip to content

Latest commit

 

History

History
100 lines (73 loc) · 4.14 KB

examples.rst

File metadata and controls

100 lines (73 loc) · 4.14 KB

Examples

Fast analysis with :pyneurom

Here we load a neuron and obtain some information from it:

>>> import neurom as nm
>>> nrn = nm.load_neuron('some/data/path/morph_file.swc')
>>> ap_seg_len = nm.get('segment_lengths', nrn, neurite_type=nm.APICAL_DENDRITE)
>>> ax_sec_len = nm.get('section_lengths', nrn, neurite_type=nm.AXON)

Morphology visualization with the :pyneurom.viewer module

Here we visualize a neuronal morphology:

>>> # Initialize nrn as above
>>> from neurom import viewer
>>> fig, ax = viewer.draw(nrn)
>>> fig.show()
>>> fig, ax = viewer.draw(nrn, mode='3d') # valid modes '2d', '3d', 'dendrogram'
>>> fig.show()

Advanced iterator-based feature extraction example

These slightly more complex examples illustrate what can be done with the neurom module's various generic iterators and simple morphometric functions.

The idea here is that there is a great deal of flexibility to build new analyses based on some limited number of orthogonal iterator and morphometric components that can be combined in many ways. Users with some knowledge of python and neurom can easily implement code to obtain new morphometrics.

All of the examples in the previous sections can be implemented in a similar way to those presented here.

../../examples/neuron_iteration_analysis.py

Getting Log Information

neurom emits many logging statements during the course of its functioning. They are emitted in the neurom namespace, and can thus be filtered based on this. An example of setting up a handler is:

>>> import logging
>>> # setup which namespace will be examined, and at what level
>>> # in this case we only want messages from 'neurom' and all messages
>>> # (ie: DEBUG, INFO, etc)
>>> logger = logging.getLogger('neurom')
>>> logger.setLevel(logging.DEBUG)
>>> # setup where the output will be saved, in this case the console
>>> sh = logging.StreamHandler()
>>> logger.addHandler(sh)

For more information on logging, it is recommended to read the official Python logging HOWTOs: Python 2 and Python 3.