def test_load_trees_postaction(): def post_action(t): t.foo = 'bar' filepath = os.path.join(SWC_PATH, 'Neuron.swc') trees = utils.load_trees(filepath, tree_action=post_action) nt.eq_(len(trees), 4) # sanity check for t in trees: nt.ok_(hasattr(t, 'foo') and t.foo == 'bar')
def test_load_neuron_disconnected_components(): filepath = DISCONNECTED_POINTS_FILE trees = utils.load_trees(filepath) nt.eq_(len(trees), 8) # tree ID - number of points map ref_ids_pts = {4: 1, 215: 1, 426: 1, 637: 1, 6: 209, 217: 209, 428: 209, 639: 209} ids_pts = {} for t in trees: ids_pts[t.value[COLS.ID]] = pts.count(t) nt.eq_(ref_ids_pts, ids_pts)
def test_load_neuron_disconnected_components(): filepath = os.path.join(SWC_PATH, 'Neuron_disconnected_components.swc') trees = utils.load_trees(filepath) nt.eq_(len(trees), 8) # tree ID - number of points map ref_ids_pts = {4: 1, 215: 1, 426: 1, 637: 1, 6: 209, 217: 209, 428: 209, 639: 209} ids_pts = {} for t in trees: ids_pts[t.value[COLS.ID]] = pts.count(t) nt.eq_(ref_ids_pts, ids_pts)
def test_load_trees_good_neuron(): '''Check trees in good neuron are the same as trees from loaded neuron''' filepath = os.path.join(SWC_PATH, 'Neuron.swc') nrn = utils.load_neuron(filepath) trees = utils.load_trees(filepath) nt.eq_(len(nrn.neurites), 4) nt.eq_(len(nrn.neurites), len(trees)) nrn2 = MockNeuron(trees) @pts.point_function(as_tree=False) def elem(point): return point # Check data are the same in tree collection and neuron's neurites for a, b in izip(iter_neurites(nrn, elem), iter_neurites(nrn2, elem)): nt.ok_(np.all(a == b))
def test_load_trees_invalid_id_sequence_raises(): utils.load_trees(INVALID_ID_SEQUENCE_FILE);
def test_load_trees_no_soma(): trees = utils.load_trees(NO_SOMA_FILE) nt.eq_(len(trees), 1)
pass stylize(ax, cell.name, feature) return fig if __name__ == "__main__": import numpy as np import os args = parse_args() nrns = [] for j, neuronFile in enumerate(get_morph_files(args.datapath)): _name = os.path.splitext(os.path.split(neuronFile)[-1])[0] nrn = None try: soma = make_soma([np.array([11, 22, 33, 44, 1, 1, -1])]) trees = load_trees(neuronFile) cn = coreNeuron(soma, trees, name=_name) nrn = ezyNeuron(cn) except IDSequenceError: pass for i, _feature in enumerate(args.features): f = plot_feature(_feature, nrn) figname = "{0}_{1}_{2}.eps".format(i, j, _name) f.savefig(os.path.join(args.odir, figname)) pl.close(f)