예제 #1
0
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')
예제 #2
0
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)
예제 #3
0
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))
예제 #4
0
def test_load_trees_invalid_id_sequence_raises():
    utils.load_trees(INVALID_ID_SEQUENCE_FILE);
예제 #5
0
def test_load_trees_no_soma():

    trees = utils.load_trees(NO_SOMA_FILE)
    nt.eq_(len(trees), 1)