Exemple #1
0
def select():

    spec = Collate(*Collate.from_log(path))

    sel = Select(spec, float_keys=['cortex_density', 'retina_density'])

    data = np.random.rand(9)
    selection = (sel.retina_density > 3.0) & (sel.cortex_density > 5)

    assert set(sel[selection].tid) == set([5, 8])
    assert repr(sel.select(selection, data)) == repr(data[selection])

    list_data = [None, 3, False, object, 3.4, '32', np.int64, unicode, lambda x: x]
    list_selection = [True, True, False, True] + [False]*5
    assert repr(sel.select(list_selection, list_data)) == repr([None, 3,object])
    new_sel = Select(sel.tolist(selection), float_keys=['cortex_density', 'retina_density'])
    return new_sel
Exemple #2
0
def pytable_save(collation):

    loader = PILImageLoader(['.png'], transform = lambda im: im.rotate(180))
    (images, metadata, imlabels) = collation.extract_files(loader, 'ColKey','ColKeyLabels')

    sel = Select(collation, 
                   float_keys=['cortex_density', 'retina_density'], 
                   int_keys=['time', 'activity'],
                   visible_keys = ['cortex_density', 'retina_density', 'activity', 'ColKeyLabels'])

    condition = (sel.retina_density > 3.0)
    image_sel, iminfo_sel, imlabel_sel =  sel.select(condition, images, metadata, imlabels)

    with PyTableUtils('utils-test.h5', 'util_test', 'Testing purposes', title='Title') as pytable:
        pytable.declare_group('images', 'Storing images')
        pytable.declare_group('selector', 'The Select object')

        for (ims, iminfos, labels) in zip(image_sel, iminfo_sel, imlabel_sel):
            for (im, label, iminfo) in zip(ims, labels, iminfos):
                pytable.store_array('images', np.array(im), label, iminfo=iminfo)
        
        pytable.store_selector('selector', sel.subselector(condition), 'subselector')