Exemplo n.º 1
0
def retina_reduce(info, activity_retina, collation):
    collation.insert_columns(retina_activity=activity_retina)
    s = Select(collation)
    s.view(int_keys=['time'], 
           float_keys=['retina_density', 'cortex_density', 'V1_activity', 'retina_activity'])

    condition = (s.retina_density > 2.0) & (s.time == 1)
    result = np.mean(s[condition].retina_activity)
    print "Average std. of retina activity vs cortex density for retina density of 2.0 (@time=1): %f" % result
    return collation
Exemplo n.º 2
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
Exemplo n.º 3
0
def V1_reduce(info, activity_V1, accumulator):
    import pylab
    collation = Collate(*info, V1_activity=activity_V1)
    s = Select(collation)
    s.view(float_keys=['time', 'retina_density', 'cortex_density', 'V1_activity'])
    
    condition = (s.cortex_density > 0.5) & (s.retina_density == 2.0)
    pylab.plot(s[condition].V1_activity, s[condition].cortex_density)
    pylab.title('Mean activity (cortex) against cortex density at time = 1.0 for retina density=2')

    [root_directory, _] = info
    figure_path = os.path.join(root_directory, 'cluster_figures')
    try: os.mkdir(figure_path)
    except :pass
    pylab.savefig(os.path.join(figure_path, 'rd2_mean_activity.png'))
    print "Saved figure rd2_mean_activity.png in folder cluster_figures"
    return collation
Exemplo n.º 4
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')