![]() 050- win.monitorFramePeriod * 0.75 # most of one frame period left Prime_txt.frameNStart = frameN # exact frame indexįrameRemains = 0.0 +. # keep track of start time/frame for later If t >= 0.0 and prime_txt.status = NOT_STARTED: While continueRoutine and routineTimer.getTime() > 0:įrameN = frameN + 1 # number of completed frames (so 0 is the first frame) # keep track of which components have finished # update component parameters for each repeat I’m checking if timing of each of the routines above is fine, but I’m facing some weird results.įor one of my routines (the prime), my code says the following: # -Prepare to start Routine "prime". Many keyboards have an inherent 10-30 ms latency anyway, so you can't get rid of all latency.In my code for a masked priming experiment, I have 4 routines: if up to +16ms error in RT recording matters), use the iohub module. If you want to get real asynchronous polling of the keyboard state (i.e. In this "frame-locked loop" the key response is therefore discretized to frame intervals. Note that event.getKeys() records the time this line was executed, not the time that the key was pressed. I've used core.Clock() to assess the time here, but your win.logOnFlip() is just as good. Win.flip() # inner loop is timed to this, as long as the rest of the code in here doesn't take longer than a frame. If keepLooping: # do not show bitmap2 if a key was pressed on bitmap1 While keepLooping: # continue until breakįor thisBitmap in : # alternate between images So to switch between two imagesStims ( bitmap1 and bitmap2) until there is a response: clock = core.Clock() # to assess timing So looping over win.flip() will give you exactly one frame per loop. Yes, there is a better way! The standard solution exploits the fact that win.flip() halts code execution until the next monitor update. Win.saveFrameIntervals(filename+'.log', clear=True) Print keys, rt #show resp and rt on screen Keys = event.getKeys(keyList=) #record resp Win.logOnFlip(msg='frame=%i' %frameN, level=logging.DEBUG) #record the time of win.flip() in the log file # Initialize clock to register response time Keys = event.getKeys(keyList=)īitmap1 = visual.ImageStim(win, 'Mondrians/Mask_1.bmp', size=scrsize)īitmap2 = visual.ImageStim(win, 'Mondrians/Mask_2.bmp', size=scrsize) Keys = event.getKeys(keyList=) #allow only space and escape keys #win = visual.Window(, fullscr=True, allowGUI=False, waitBlanking=True) Win = visual.Window(size=scrsize, color='white', units='pix', fullscr=False) (logging.WARNING) # outputs to the screen, not a file LogFile = logging.LogFile(filename+'.log', level=logging.DEBUG) _thisDir = os.path.dirname(os.path.abspath(_file_))ĭlg = gui.DlgFromDict(dictionary=exp_info, title=exp_name)įilename = _thisDir + os.sep + 'data/%s_%s_%s' %(exp_info, exp_name, exp_info) # Ensure that relative paths start from the same directory as this script Here my code: import os # for file/folder operationsįrom psychopy import visual, event, core, gui, data, logging I would be very grateful if you could give me some tips on how to achieve (and verify) presentation of each image for 6 frames. The function core.wait() only takes time in seconds, and not in frames, correct? I am verifying it by writing the frame of each flip to the log file with win.logOnFlip()īut I believe I could be way more precise I only knew how to define the duration of the image in terms of frames. I sort of got it right by using core.wait(.084) after win.flip() - on a 60Hz screen that gives approximately 100ms. I have some experience in Matlab, but am very new to PsychoPy.įor now I would like to continuously switch between two images until there is a keyboard response.Įach image should stay on the screen exactly for 100ms, and I want to be able to verify that this is the case (e.g.
0 Comments
Leave a Reply. |