Reset time in each frame (Self-paced Reading Task)

Hi, in my experiment, I need to analize the reading time of each frame. However, every time it changes the frame, it is adding the time of the previous read frame to the next one (it’s summing the time). It is only reseting the time when the participant finishes the entire routine which is in a loop. That’s the code I’m using:

Begin Routine:

#clear the buffer
event.clearEvents()
#event.clearKeys()
#event.clearEvents(“keyboard”)
event.globalKeys.clear()

#parse our stimulus
words = target.split(" ")

#create individual word stimuli
wordPos = 0
stimulus = words[wordPos]

#create a clock
clock = core.Clock()

Each Frame:

#listen for keys
thisKeys = event.getKeys()
n = len(thisKeys)
i = 0

#update stim on spacebar press
while n > i:
if thisKeys[i] == “esc”:
core.quit()
break
elif thisKeys[i] == “space”:
thisExp.addData(“readingRT”, clock.getTime())
thisExp.addData(“wordPos”, wordPos)
thisExp.addData(“word”, words[wordPos])
thisExp.addData(“sentPos”, sentPos)
thisExp.addData(“keypress”, theseKeys[i])
thisExp.nextEntry()

    wordPos = wordPos + 1
    if wordPos == len(words):
        sentPos = sentPos + 1
        continueRoutine = False
        break
    stimulus = words[wordPos]
    break
else:
    break  

I’d be really grateful if anyone can help me.
Thanks.

clock.reset() next to thisExp.nextEntry() ?

1 Like

It worked. Thank you so much!!!