def test_trunk_origin_elevation(): t = Tree((1, 0, 0, 2)) s = make_soma([[0, 0, 0, 4]]) nt.assert_equal(mtr.trunk_origin_elevation(t, s), 0.0) t = Tree((0, 1, 0, 2)) nt.assert_equal(mtr.trunk_origin_elevation(t, s), np.pi/2) t = Tree((0, -1, 0, 2)) nt.assert_equal(mtr.trunk_origin_elevation(t, s), -np.pi/2) t = Tree((0, 0, 0, 2)) try: mtr.trunk_origin_elevation(t, s) nt.ok_(False) except ValueError: nt.ok_(True)
padding = padding * (_max - _min) return _min - padding, _max + padding # Neurite types of interest NEURITES_ = (ezy.TreeType.axon, ezy.TreeType.apical_dendrite, ezy.TreeType.basal_dendrite,) # map feature names to functors that get us arrays of that # feature, for a given tree type GET_NEURITE_FEATURE = { 'trunk_origin_azimuth': lambda nrn, typ: [mt.trunk_origin_azimuth(n, nrn.soma) for n in nrn.neurites if n.type == typ], 'trunk_origin_elevation': lambda nrn, typ: [mt.trunk_origin_elevation(n, nrn.soma) for n in nrn.neurites if n.type == typ], 'segment_length': lambda n, typ: n.get_segment_lengths(typ), 'section_length': lambda n, typ: n.get_section_lengths(typ), } # For now we use all the features in the map FEATURES = GET_NEURITE_FEATURE.keys() def load_neurite_features(filepath): '''Unpack relevant data into megadict''' stuff = defaultdict(lambda: defaultdict(list)) nrns = ezy.load_neurons(filepath) # unpack data into arrays for nrn in nrns: