

# from import Keyboardįrom psychopy.iohub import launchHubServer In most studies, including all those from Builder, this isn't an issue because the screen refresh interval gives time for all the events to be processed.įrom re import Clock, quit, waitįrom psychopy.visual import Window, GratingStim, TextStim Maybe you could confirm that the above solutions work for you and then we can close this issue. If you simply create an iohub client at the top of your script (before creating the keyboard object) then this will be used in preference to PTB for the keyboard IoHub seems better at getting events even in a tight loop and has nearly the same performance (certainly polling in a separate process and time-stamping there). switch to ioHub for keyboard instead of the PTB keyboard.Possibly just a microsecond would suffice even add something like time.sleep(0.001) to your while True loop to give a millisecond to the CPU for housekeeping.

I think either of the following options will fix that: I think this is caused by checking the keyboard in too "tight" a loop - you're calling getKeys so rapidly that the OS isn't able to do anything else (including some of the housekeeping required to do the keyboard polling behind the scenes). to_csv( 'testData.csv', mode = 'a', index = False, header = False)
#Psychopy drawing a stimulus based on if statement trial#
rt # end response window break # write trial info to results file conditions. name # RT at the last keypress # conditions.loc = trialClock.getTime() conditions. # key at the last keypress # conditions.loc = keys conditions. # start endless/large response window while True: #trialClock.getTime() 0: # iterate over trials for idx in range( 1, 51): # wait for button press to start the experiment print( " \nPress the space bar to start the block \n")īreak # print info print( " \nStarting block " + str( i) + " \n") # add column for response key conditions = 'NA' # add column for RTs conditions = 'NA' # show text text. # loop through the blocks for i in range( 1, 2 + 1): Text = 'Press the space bar to start the block') # create visual stimuli grating = GratingStim( win = mywin, mask = 'circle', size = 3, pos =, sf = 3)įixation = GratingStim( win = mywin, size = 0.2, pos =, sf = 0, rgb = - 1) # create a window mywin = Window(, monitor = "testMonitor", units = "deg") keyboard import Keyboard from psychopy import event import pandas as pd # intialize timer trialClock = Clock() visual import Window, GratingStim, TextStim from psychopy. core import Clock, quit, wait from psychopy.
