OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 1.84.x): 2020.2.3
I’m working on a self-paced reading task where I’m presenting sentences one word at a time and participants press ‘space’ to see the next word. I want to get the response times for each time ‘space’ is pressed for each word in the sentence. Right now, the response times are additive for each sentence, so by the last word in the sentence, the response time appears to be several seconds long. I’m very new to PsychoPy and have very limited Python experience and I’ve tried to apply some solutions from a few other posts (like this one and this one) but haven’t been able to figure it out yet. In my custom code component in the builder here’s what I have (a colleague helped with this):
Begin Routine
# Clear the buffer
event.clearEvents()
# Parse stimulus
words = sentence.split(' ')
#Create individual word stimuli
sentPos = 0
stimulus = words[sentPos]
# Create a clock
clock = core.Clock()
# Update stimulusDisplay before drawing to the screen
stimulusDisplay.setText(stimulus)
Each Frame
theseKeys = event.getKeys()
n = len(theseKeys)
i = 0
# Update stimulus on spacebar press
while n > i:
if theseKeys[i] == "esc":
core.quit()
break
elif theseKeys[i] == "space":
thisExp.addData("readingRT", clock.getTime())
thisExp.addData("sentPos", sentPos)
thisExp.addData("keypress", theseKeys[i])
thisExp.nextEntry()
sentPos = sentPos + 1
if sentPos == len(words):
continueRoutine = False
break
stimulus = words[sentPos]
i = i + 1
Does anyone know how I can get the response times relative to each word that’s presented, not relative to the first word in the sentence)? I’ve included an example of the data output in case I’m not being clear. Thanks so much in advance!
Psychopy_test_stimuli.csv (762 Bytes) self-pacedDemo.psyexp (22.6 KB) test01_slef-pacedDemo_2020_Sep_25_1625.csv (26.0 KB)