def test_i_segment_meander_angles(): T = NEURON_TREE ref = [math.pi * a for a in (1.0, 1.0, 1.0, 0.5, 0.5, 1.0, 1.0, 1.0, 0.5)] for i, m in enumerate(i_segment_meander_angle(T)): nt.assert_almost_equal(m, ref[i])
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. '''Calculate inter-segment angles''' import logging import numpy as np from neurom.core.dataformat import COLS from neurom.io.readers import load_data from neurom.io.utils import make_neuron from neurom.analysis.morphtree import i_segment_meander_angle # root level logger. This would be a top level application logger. logging.basicConfig() LOG = logging.getLogger() LOG.setLevel(logging.DEBUG) fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') LOG.handlers[0].setFormatter(fmt) if __name__ == '__main__': filename = 'test_data/swc/Neuron.swc' rd = load_data(filename) nrn = make_neuron(rd) for tt in nrn.neurites: print 'Tree ID: {0}, type: {1}'.format(tt.value[COLS.ID], tt.value[COLS.TYPE]) for a in i_segment_meander_angle(tt): LOG.debug('Angle %f', a) if np.isnan(a): LOG.warn('Found NaN angle. Check for zero length segments!')
'''Calculate inter-segment angles''' import logging import numpy as np from neurom.core.dataformat import COLS from neurom.io.readers import load_data from neurom.io.utils import make_neuron from neurom.analysis.morphtree import i_segment_meander_angle # root level logger. This would be a top level application logger. logging.basicConfig() LOG = logging.getLogger() LOG.setLevel(logging.DEBUG) fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') LOG.handlers[0].setFormatter(fmt) if __name__ == '__main__': filename = 'test_data/swc/Neuron.swc' rd = load_data(filename) nrn = make_neuron(rd) for tt in nrn.neurites: print 'Tree ID: {0}, type: {1}'.format(tt.value[COLS.ID], tt.value[COLS.TYPE]) for a in i_segment_meander_angle(tt): LOG.debug('Angle %f', a) if np.isnan(a): LOG.warn('Found NaN angle. Check for zero length segments!')