Dear community,
I am currently programming my first experiment which you can see below. The participant should react as fast as possible to the words displayed and I want to record the reaction time between displaying the word to the participant reacting by pressing the space key. I already tried several things but so far, it only records the time without setting it back after each trial. I believe it should work with clearEvents, but hasn’t worked so far, so I would be very grateful for any help!
from psychopy.visual import Window, TextStim, RatingScale
from psychopy.core import wait, Clock
from psychopy.event import waitKeys, getKeys, clearEvents
import random
wordlist = [‘murder’, ‘death’, ‘raped’, ‘fight’, ‘drown’, ‘wound’, ‘lynch’, ‘choke’, ‘angel’, ‘sugar’, ‘dream’, ‘ocean’, ‘green’, ‘music’, ‘marry’, ‘sleep’]
my_win = Window( [800, 500], color=‘black’)
welcome_text = TextStim ( my_win, text = “Welcome to this psychological experiment. Your task is to respond to a word which is presented by pressing the ‘space’ key as fast as possible.” )
cross_1 = TextStim ( my_win, text = ‘+’ )
welcome_text.draw()
my_win.flip()
waitKeys( keyList = [‘space’] )
for words in wordlist:
task_1 = TextStim ( my_win, text = random.choice(wordlist))
cross_1.draw()
my_win.flip()
wait( 2 )
task_1.draw()
my_win.flip()
response = waitKeys(timeStamped = True, clearEvents = True)
scale_1 = RatingScale ( my_win, scale = "How do you rate the valence of this word?", labels = ("positive", "negative"), marker = "slider", mouseOnly = True )
while scale_1.noResponse:
scale_1.draw()
my_win.flip()
rating = scale_1.getRating()
print(rating, response)
end_text = TextStim ( my_win, text = “Thank you for participating in this experiment! This is a valuable contribution to the scientific community.” )
end_text.draw()
my_win.flip()
wait(10)