Example #1
0
def test_make_tree_postaction():
    def post_action(t):
        t.foo = 'bar'

    rd = RAW_DATA[0]
    seg_ids = utils.get_initial_segment_ids(rd)
    trees = [utils.make_tree(rd, root_id=seg_id, post_action=post_action)
             for seg_id in seg_ids]
    for t in trees:
        nt.ok_(hasattr(t, 'foo') and t.foo == 'bar')
Example #2
0
def point_iter(iterator):
    '''Transform tree iterator into a point iterator

    Args:
        iterator: tree iterator for a tree holding raw data rows.
    '''
    return imap(as_point, tree.val_iter(iterator))


if __name__ == '__main__':

    filename = 'test_data/swc/Neuron.swc'

    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()]
Example #3
0
def point_iter(iterator):
    '''Transform tree iterator into a point iterator

    Args:
        iterator: tree iterator for a tree holding raw data rows.
    '''
    return imap(as_point, tree.val_iter(iterator))


if __name__ == '__main__':

    filename = 'test_data/swc/Neuron.swc'

    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)):
            LOG.debug(p)

    LOG.info('Initial segment IDs: %s', init_seg_ids)

    nrn = neuron.Neuron(soma, trees)

    LOG.info('Neuron soma raw data % s', [r for r in nrn.soma.iter()])
    LOG.info('Neuron soma points %s', [as_point(p)
Example #4
0
def test_get_initial_segment_ids():
    for i, d in enumerate(RAW_DATA):
        nt.ok_(utils.get_initial_segment_ids(d) == INIT_IDS[i])
Example #5
0
def test_make_tree():
    rd = RAW_DATA[0]
    seg_ids = utils.get_initial_segment_ids(rd)
    trees = [utils.make_tree(rd, seg_id) for seg_id in seg_ids]
    nt.ok_(len(trees) == len(INIT_IDS[0]))
    _check_trees(trees)