psychopy.org | Reference | Downloads | Github

event.waitKeys timeStamped not working

timing

#1

Hi!

I ran into problems using event.waitKeys method. When I set the timeStamped attribute to True, it does not return anything and just leaves it blank.

Here’s my code:

from psychopy import visual, event, core
import sys

win = visual.Window(
    size=[400, 400],
    fullscr=False,
    allowStencil=True,
    color=[-1, -1, -1],
    units='pix'
)

fixation = visual.ShapeStim(
    win=win,
    vertices=((0, -20), (0, 20), (0, 0), (-20, 0), (20, 0)),
    lineWidth=2,
    closeShape=False,
    lineColor="white",
    units='pix',
)

fixation.draw()
win.flip()

clock = core.Clock()
clock.reset()
response = event.waitKeys(timeStamped=True)
time = clock.getTime()
print time, response

win.close()
sys.exit()

And here’s what I would get:

0.868468999863 [('i',)]

Still, if I set the attribute to clock, I would normally get something like this:

0.868468999863 [('i', -1.8378880023956299)]

which is also abnormal and beyond me. Does anyone here know what is wrong?


#2

try:

response = event.waitKeys(timeStamped = clock, clearEvents = True)

#3

Thanks for the reply. But that does not work. My PsychoPy says no atttribute ‘clearEvents’ for waitKeys.

I tried:

event.clearEvents()
response = event.waitKeys(timeStamped=clock)

but it does not work either.


#4

Your code (in your first post) works fine for me (1.85.3, Linux):

with timeStamped=True: 0.605473041534 [('i', 1.588170051574707)]
with timeStamped=clock: 0.762838840485 [('i', 0.7627718448638916)]

What is your psychopy version and OS?


#5

Like @djmannion, your code works fine for me too (1.85.4, Mac).

You do seem to have hit on a weird bug with this though:

TypeError: waitKeys() got an unexpected keyword argument 'clearEvents' 

I can replicate that as well. That isn’t the cause of your issues, but is really strange.


#6

That’s new in 1.85.4 I think - I don’t have that argument in 1.85.3. Though that doesn’t explain why you are getting the error on 1.85.4.


#7

Ahh, I was looking in the source code for my developer installation but was actually running the code on the 1.85.4 Standalone. The clearEvents parameter must still be upstream only and not yet released. Unfortunately; the online API documents are ahead of the released version.


#8

I am running psychopy 1.85.4 on macOS. Still not sure how this bug can be fixed. Workaround is possible, though, given that what I need is just the response time.

Anyway, thanks for replying!