Hi
I have been trying to use psychopy coder to create and run a random dot kinetogram (RDK) experiment. The basic structure of my experiment is as follows:
Fixation (300 ms)
DotStim stimuli (400 ms)
Feedback screen (300 ms)
text screen with self-initiated keypress to begin next trial (self-paced ITI)
I am calling keyboard.getKeys() for every frame the dotStim is drawn to allow responses while the stimulus is displayed and then if the keypress does not happen in the 400 ms duration of stim display, i switch to wait keys with a maxWait of 1.0 secs to allow the participant to respond while there’s a blank screen.
The issue I am tackling is that in the very small interval when the stim disappears and the blank screen appears, the keypresses are not being recorded. I am using the ‘for frame in range()’ method to draw the stimuli for optimal timing and i am not sure what’s the issue here?
I would like to know:
- If someone has faced a similar issue with using such experiment setups where responses are recorded from the milisecond the stimuli appears and can record after the stim disappears.
- Is this an issue with switching from getKeys to waitKeys considering the latter freezes the frame until there’s a response.
My system details are:
MacOS Catalina 10.15.7
PsychoPy v2021.2.3
the code i am using:
#drawing a blank screen for 300 ms, set to ur frames
#18 frames for 60 Hz screens i.e. 300 ms[stim_duration]/16.67 ms[of every frame]
for frame in range (1, 19):
fixation.draw()
task_window.flip()
#24 frames for 60 Hz screens i.e. 400 ms[stim_duration]/16.67 ms[of every frame]
#reset keyboard clock and start the time again to take response keys
kb.clock.reset()
for frame in range (1, 25):
dots1.draw()
trial_keys = kb.getKeys(keyList = ['left', 'right', 'escape'])
if (trial_keys != []) :
temp_keys.append(trial_keys[0].name)
temp_RT.append(trial_keys[0].rt)
flag = 1
break
task_window.flip()
if flag != 1:
task_window.flip()
wait_keys = kb.waitKeys(maxWait = 1.0, keyList = ['left', 'right', 'escape'])
if (wait_keys != None) :
#print(wait_keys)
temp_keys.append(wait_keys[0].name)
temp_RT.append(wait_keys[0].rt)
flag = 2 #means the subject went beyond the 400 ms to make a response
else:
flag = -1
temp_keys.append(flag)
#for escaping from the experiment or continuing
if temp_keys != []:
if temp_keys[0] == 'escape':
core.quit()
elif flag == 1 or flag == 2:
keydata.append(temp_keys[0])
thisKey = temp_keys[0] #this variable is for accuracy comparison
rtdata.append(temp_RT[0])
elif flag == -1 :
keydata.append(flag)
thisKey = None
rtdata.append(flag)
#add if statements for when the direction and keypress is a match or not
if (direction == 180.0 and thisKey == 'left') or (direction == 0.0 and thisKey == 'right'):
#drawing feedback screen for 300 ms
for frame in range (1, 19):
correct_feedback.draw()
task_window.flip()
var_p = 1
accuracy.append(var_p)
elif (direction == 180.0 and thisKey == 'right') or (direction == 0.0 and thisKey == 'left'):
#drawing error feedback
for frame in range (1, 19):
incorrect_feedback.draw()
task_window.flip()
var_p = 0
accuracy.append(var_p)
else:
missed = flag
accuracy.append(missed)