Dear Psychopy users,
I am getting some negative reaction times which seem to be related to very early key presses, I obtained them by pressing repeatedly in order to simulate accidental early key presses. The issue shows up on Windows (10) with last standalone version of Psychopy (I tested the same code on Ubuntu with Psychopy 2020.2.10 and I could not reproduce the issue). I am probably missing something here, I have not collected reaction times with Psychopy for a while and I would like to understand whether the problem is in my code (quite likely) or there is something else there. Here it is a toy example of the code that gives the same issue:
from psychopy import visual, core
from psychopy.hardware import keyboard
import numpy as np
stim_duration = np.repeat([1.5, 2, 2.5, 3, 3.5], 5)
win = visual.Window([800,600])
stim = visual.TextStim(win)
clock = core.Clock()
timer = core.CountdownTimer()
kb = keyboard.Keyboard()
for trial, dur in enumerate(stim_duration):
rt = {"trial": trial, "rt": []}
stim.text = f"trial {trial}"
timer.add(dur)
kb.clock.reset()
while timer.getTime() > 0:
keys = kb.getKeys(['left', 'right'])
stim.draw()
win.flip()
if keys:
resp = keys[0].rt
rt["rt"].append(resp)
print(rt)
I would be glad if someone could give me any suggestions.
Thanks a lot