示例#1
0
文件: paper.py 项目: gic888/gdblocks
def evalSystem(m, ens=False, bl=True, cid=0):
    if not type(m[0]) in [tuple, list]:
        nd = int((-5 + np.sqrt(25 + 8 * len(m))) / 2)
        m = (m[:nd], m[nd:2 * nd], m[2 * nd:])
    if bl:
        stim = gwn.getstim('bl')
    else:
        stim = gwn.getstim('raw')
    evts = acell.gmatchCell(stim, m[0], m[1], m[2], cid)
    if not ens:
        return evts
    else:
        return ece(stim, evts)
示例#2
0
文件: ga.py 项目: gic888/gdblocks
 def __init__(self, pars):
     self.compress = pars['compress']
     self.clevel = pars['clevel']
     self.doc = gwn.getstim('doc', pars['slen'])
     self.snn = self.doc.find(timeseries_t, True)
     self.ac = acell.acell()
     self.cm = acell.compare()
     self.nd = pars['nd']
     Model.__init__(self, pars)
示例#3
0
文件: paper.py 项目: gic888/gdblocks
def stacnbackFig(m1, stac=.8):
    stim = gwn.getstim('bl')
    uc = ucse(stim)
    rc = evalSystem(m1, True, cid=0)
    iss = istac.istacspace(rc, uc, stac)['vecs']
    plt.figure(3)
    plt.clf()
    _prow(rc, None, 0)
    rc1 = np.dot(iss.transpose(), rc)
    _prow(rc1, None, 1)
    rc2 = np.dot(iss, rc1)
    _prow(rc2, None, 2)
    f = plt.figure(3)
    f.subplots_adjust(left=.04, right=.99, bottom=.05, top=.99, wspace=.05, hspace=.05)
    f.canvas.draw()
示例#4
0
文件: paper.py 项目: gic888/gdblocks
def llFig(m1, m2, compress='istac', clevel=.85):
    if istac:
        n = 2
    else:
        n = 1
    stim = gwn.getstim('bl')
    evts1 = evalSystem(m1, cid=0)
    evts2 = evalSystem(m2, cid=1)
    ll = compare(stim, evts1, evts2, compress='no')
    f = plt.figure(2)
    plt.clf()
    plt.subplot(1, n, 1)
    _llplt(ll)
    if istac:
        ll = compare(stim, evts1, evts2, compress=compress, clevel=clevel, report=report)
        plt.subplot(1, n, 2)
        _llplt(ll)
    f.subplots_adjust(left=.05, right=.98, bottom=.1, top=.98, wspace=.05)
    f.canvas.draw()
示例#5
0
文件: paper2.py 项目: gic888/gdblocks
def runSystems(stimuli=STIMS_BAND_OL, systems=(M200_FO,), stimlength=800, length=60, lead=40,
               label="A", date="", comments="", edet=(1.0, .01)):
    '''
    stimuli is a list of "band" parameter tuples. Systems is a list of
    (off, mean, cov) test system parameter tuples. "l" is a stimulus length.
    Constructs each stimulus in the stimulus list, and passes it to each
    system.
    '''
    if not date:
        date = time.strftime("%m%d%y")
    s = gd.Doc()
    s['label'] = 'iSTACe' + date + label
    s['comments'] = comments
    s['samplerate'] = 1000.0
    s['stimlength'] = stimlength
    s['enslength'] = length
    s['enslead'] = lead
    s['eventgenerator'] = 'peakdet'
    for i, b in enumerate(stimuli):
        sn = "s%i" % i
        s[sn + '._'] = gwn.getstim('bl', stimlength, b)
        s[sn + '.band'] = b
        un = "u%i" % i
        s[un + '._'] = ucse(s[sn + '._'], 10000, length)
    for i, p in enumerate(systems):
        mn = "m%i" % i
        off, mu, sig = p
        d = {'mu': mu, 'off': off, 'sigma': sig, 'cid': i, 'ejit': edet[0], 'ethresh': edet[1]}
        s.set(mn, d)
        for j in range(len(stimuli)):
            en = "e%i_%i" % (i, j)
            sn = "s%i" % j
            d['outpath'] = en
            d['stimpath'] = "->" + sn
            s = s.fuse(acell(s, d)[0])
            s[en + '.stim'] = {'_link': sn}
            s[en + '.sys'] = {'_link': mn}
            rn = "r%i_%i" % (i, j)
            s[rn + '._'] = ece(s[sn + '._'], s[en + '._'], length, lead)
            s[rn + '.stim'] = {'_link': sn}
            s[rn + '.sys'] = {'_link': mn}
    return s
示例#6
0
文件: paper.py 项目: gic888/gdblocks
def bigFig(m1, m2, compress='istac', clevel=.85):
    stim = gwn.getstim('bl')
    uc = ucse(stim)
    rcse = evalSystem(m1, True, cid=0)
    rcse2 = evalSystem(m2, True, cid=1)
    rc = eqrc((rcse, rcse2))
    iss = DRMODES[compress](rc, uc, clevel)
    report('Using %i components' % iss.shape[0])
    plt.figure(3)
    plt.clf()
    ll = lltest(rcse, rcse2)
    _prow(rcse, rcse2, 0, 3, True, ll)
    rc1 = np.dot(iss, rcse)
    rc2 = np.dot(iss, rcse2)
    ll = lltest(rc1, rc2)
    _prow(rc1, rc2, 1, 3, True, ll)
    rcb1 = np.dot(iss.transpose(), rc1)
    rcb2 = np.dot(iss.transpose(), rc2)
    #ll = lltest(rcb1, rcb2)
    _prow(rcb1, rcb2, 2, 3, True, ll)
    f = plt.figure(3)
    f.subplots_adjust(left=.04, right=.99, bottom=.05, top=.99, wspace=.05, hspace=.05)
    f.canvas.draw()
示例#7
0
    def run(self, doc, pars, out, messages):
        paths = dict([(n, doc[pars[n]]) for n in ['stim1', 'stim2', 'evts1', 'evts2']])
        ll = self.callWith(comp2s, paths, pars)
        c12 = (ll[0, 0, 0] - ll[0, 1, 0]) / (ll[0, 0, 1] + ll[0, 1, 1])
        c21 = (ll[1, 1, 0] - ll[1, 0, 0]) / (ll[1, 0, 1] + ll[1, 1, 1])
        out[pars['outpath']] = min(c12, c21)
        out[pars['outpath'] + '.raw'] = ll


compare2 = Compare2s()

if __name__ == "__main__":
    import gwn

    s = gwn.getstim().fuse(gwn.getstim(band=(1, 400)))
    s['m1.outpath'] = 'evts1'
    s['m1.stimpath'] = 'stim5_150'
    d, r = acell(s, 'm1')
    for st in r:
        print(st)
    s['m2.outpath'] = 'evts2'
    s['m2.stimpath'] = 'stim1_400'
    d2, r = acell(s, 'm2')
    for st in r:
        print(st)
    d = d.fuse(d2)
    d['stim1'] = s['stim5_150']
    d['stim2'] = s['stim1_400']
    cmo = {'evts1': 'evts1', 'evts2': 'evts2', 'stim1': 'stim1', 'stim2': 'stim2'}
    print d['evts1']
示例#8
0
文件: acell.py 项目: gic888/gdblocks
    def run(self, doc, pars, out, messages):
        paths = dict([(n, doc[pars[n]]) for n in ['evts1', 'evts2', 'stim']])
        ll = self.callWith(iscmp, paths, pars)
        c12 = (ll[0, 0, 0] - ll[0, 1, 0]) / (ll[0, 0, 1] + ll[0, 1, 1])
        c21 = (ll[1, 1, 0] - ll[1, 0, 0]) / (ll[1, 0, 1] + ll[1, 1, 1])
        out[pars['outpath']] = min(c12, c21)
        messages.append('ll values %s' % (str(ll[..., 0]),))


compare = Compare()

if __name__ == "__main__":
    import gwn

    s = gwn.getstim()
    s['model.off'] = (9, 5, 1)
    s['model.mu'] = (.2, -.5, 1)
    s['model.sigma'] = (.3, -1, 1, .2, -1, .1)
    s['model.cid'] = 0
    s['model.outpath'] = 'events'
    s['model.stimpath'] = 'stim5_150'
    #print(ac.test(s, 'model'))
    d, r = acell(s, 'model')
    for st in r:
        print(st)
    s['model2.off'] = (5, 3, 1)
    s['model2.mu'] = (.2, -.5, 1)
    s['model2.sigma'] = (.3, -1, 1, .2, -1, .1)
    s['model2.cid'] = 0
    s['model2.outpath'] = 'events2'