def test_neuron(): soma = neuron.make_soma(SOMA_A_PTS) nrn = neuron.Neuron(soma, ['foo', 'bar']) nt.assert_equal(nrn.soma.center, (11, 22, 33)) nt.assert_equal(nrn.neurites, ['foo', 'bar']) nt.assert_equal(nrn.name, 'Neuron') nrn = neuron.Neuron(soma, ['foo', 'bar'], 'test') nt.assert_equal(nrn.name, 'test')
def test_bounding_box(): soma = neuron.make_soma([[0, 0, 0, 1, 1, 1, -1]]) nrn = neuron.Neuron(soma, [TREE]) ref1 = ((-1, -1, -1), (4.0, 6.0, 3.0)) for a, b in izip(nrn.bounding_box(), ref1): nt.assert_true(np.allclose(a, b)) soma = neuron.make_soma(SOMA_A_PTS) nrn = neuron.Neuron(soma, [TREE]) ref2 = ((-33, -22, -11), (55, 66, 77)) for a, b in izip(nrn.bounding_box(), ref2): nt.assert_true(np.allclose(a, b))
def test_i_neurites_filter(): soma = neuron.make_soma(SOMA_A_PTS) nrn = neuron.Neuron(soma, ['foo', 'bar', 'baz']) ref = 'barbaz' for i, j in izip(ref, nrn.i_neurites(iter, tree_filter=lambda s: s.startswith('b'))): nt.assert_equal(i, j)
def test_i_neurites_chains(): soma = neuron.make_soma(SOMA_A_PTS) nrn = neuron.Neuron(soma, ['foo', 'bar', 'baz']) s = 'foobarbaz' for i, j in izip(s, nrn.i_neurites(iter)): nt.assert_equal(i, j)
rd = load_data(filename) init_seg_ids = get_initial_segment_ids(rd) trees = [make_tree(rd, sg) for sg in init_seg_ids] soma = neuron.make_soma([rd.get_row(si) for si in get_soma_ids(rd)]) for tr in trees: for p in point_iter(tree.ipreorder(tr)): print p print 'Initial segment IDs:', init_seg_ids nrn = neuron.Neuron(soma, trees) print 'Neuron soma raw data', [r for r in nrn.soma.iter()] print 'Neuron soma points', [as_point(p) for p in nrn.soma.iter()] print 'Neuron tree init points, types' for tt in nrn.neurites: print tt.value[COLS.ID], tt.value[COLS.TYPE] print 'Making neuron 2' nrn2 = make_neuron(rd) print 'Neuron 2 soma points', [r for r in nrn2.soma.iter()] print 'Neuron 2 soma points', [as_point(p) for p in nrn2.soma.iter()] print 'Neuron 2 tree init points, types' for tt in nrn2.neurites: print tt.value[COLS.ID], tt.value[COLS.TYPE]