Example #1
0
def get_data(tf=65, trials=5, snr=0.5, mean_correct=False, save=False):
    # inits
    db = MunkSession()
    id_ana_mu = 1284
    # get relevant info for analysis item
    q = db.query(
        """
    SELECT a.expid, a.tetrode
    FROM analysis a
    WHERE a.id = %d
    """
        % id_ana_mu
    )  # L014 tet7 mua
    id_exp = q[0][0]
    id_tet = q[0][1]
    trial_ids = db.get_trial_range_exp(id_exp, trlidx=(0, trials), include_error_trials=False)
    id_mu = db.get_units_for_analysis(id_ana_mu)[0]
    ndet = TimeSeriesCovE(tf_max=tf, nc=4)
    data = {}
    align_at = int(tf / 4)

    print "loading data trials.."
    for id_trl in trial_ids:
        trial_data = None
        try:
            trial_data = db.get_tetrode_data(id_trl, id_tet)
            if mean_correct is True:
                trial_data -= trial_data.mean(axis=0)
            data[id_trl] = trial_data
            print "\tprocessed %s" % db.get_fname_for_id(id_trl)
        except Exception, e:
            raise RuntimeError("error processing %s\n%s" % (db.get_fname_for_id(id_trl), e))
        finally:
Example #2
0
def main2():
    from spikedb import MunkSession

    EXP = 'L011'
    TNR = 7

    DB = MunkSession()
    ampl = AmplitudeHistogram(ampl_range=(-100.0, 100.0, 1.0),
                              ampl_noise=(-8.0, 8.0),
                              nchan=4,
                              bin_size=300000,
                              bin_hist=2500)

    id_exp = DB.get_exp_id(EXP)
    id_blks = [DB.get_block_id(EXP, '%s' % b)
               for b in ['a']]  #, 'b', 'c', 'd', 'e']]
    id_tet = DB.get_tetrode_id(id_exp, TNR)
    tlist = []
    for id_blk in id_blks:
        tlist.extend(DB.get_trial_range(id_blk))

    for tid in tlist:
        print 'Processing: %s ..' % DB.get_fname_for_id(tid),
        ampl.append_data_all(DB.get_tetrode_data(tid, id_tet))
        ampl.force_new_bin()
        print 'done.'
    print 'done. Computing AmplHist...'

    DB.close()

    print
    print 'plotting event loop..',
    ampl.plot_ampl_hist()
    print 'done!'

    return ampl
def main2():
    from spikedb import MunkSession

    EXP = 'L011'
    TNR = 7

    DB = MunkSession()
    ampl = AmplitudeHistogram(ampl_range=(-100.0, 100.0, 1.0),
        ampl_noise=(-8.0, 8.0),
        nchan=4,
        bin_size=300000,
        bin_hist=2500)

    id_exp = DB.get_exp_id(EXP)
    id_blks = [DB.get_block_id(EXP, '%s' % b) for b in
    ['a']]#, 'b', 'c', 'd', 'e']]
    id_tet = DB.get_tetrode_id(id_exp, TNR)
    tlist = []
    for id_blk in id_blks:
        tlist.extend(DB.get_trial_range(id_blk))

    for tid in tlist:
        print 'Processing: %s ..' % DB.get_fname_for_id(tid),
        ampl.append_data_all(DB.get_tetrode_data(tid, id_tet))
        ampl.force_new_bin()
        print 'done.'
    print 'done. Computing AmplHist...'

    DB.close()

    print
    print 'plotting event loop..',
    ampl.plot_ampl_hist()
    print 'done!'

    return ampl