Пример #1
0
def p300(guessletter):
    global learningperiod
    datasize = len(sampledata[0])
    timestep = (sampledata[0][-1] - sampledata[0][0]) / datasize
    beg250 = int(0.25 / timestep)
    end450 = int(0.45 / timestep)
    beg600 = int(0.60 / timestep)
    end700 = int(0.70 / timestep)
    targetmean = np.mean(sampledata[1][beg250:end450])
    baselinemean = np.mean(sampledata[1][beg600:end700])
    newdatapoint = abs(float(targetmean - baselinemean))
    if learningperiod > 0:
        text0 = "still learning..." + str(learningperiod)
        game.writetk(text0)
        pdata.append(newdatapoint)
        learningperiod -= 1
    elif learningperiod == 0:
        pdata.append(newdatapoint)
        learningperiod -= 1
    else:
        if newdatapoint > (np.mean(pdata) + np.std(pdata)):
            game.addlinetk("We guessed right! You had a significant evoked response!")
            game.writeletter(guessletter)
            game.addlinetk("Now think of a new letter...")
            tm.sleep(5)
        else:
            pdata.append(newdatapoint)
            game.addlinetk("Nope... doesnt look like it was. Were still learning!")
            game.addlinetk("Keep thinking of that letter!")
            tm.sleep(5)
    return pdata
Пример #2
0
    mng.window.state("zoomed")
    ax1, ax2, ax3, ax4, ax5 = setupgrid()
    setupallaxes()
    fig1.tight_layout()
    plt.draw()
    learningperiod = 15
    while 1:
        try:
            lettertoprint = None
            if learningperiod < 0:
                game.writetk("Think of a letter (anything from A -> G)")
                lettertoprint = guessnewletter()
                tm.sleep(5)
                game.inlinetk("Was it... ")
                tm.sleep(1)
                learningperiod0 = lettertoprint * 5 + "???? Lets see..."
                game.addlinetk(learningperiod0)
            sampledata = data()
            adjustaxistimes()
            l13 = setupdatalines()
            fft1, fft2, fft3 = setupfftline()
            l46 = plotfft()
            pdata = p300(lettertoprint)
            results = PCAanalysis()
            l7 = setuppcaaxis()
            fig1.tight_layout()
            plt.draw()
            cleanupdata()
        except:
            continue