I am using a combination of the coder and builder and seem to be having an issue with collecting response times to key presses. I am relatively unfamiliar with coding. I'm still in the testing stage of the experiment and it isn't in it's final form yet. Briefly, the experiment is supposed to present a list of words in a random order, participants get instructions for a recognition test for the words, and then see the list presented again while pressing y or n for having seen the previous words.
I have 3 routines, in order: trial, recallinstructions, and recallwords. Trial and Recallwords have a one iteration loop around them. studylista is a list that contains 4 words that I entered under the beginexperiment tab in the coder under the trial routine. For recallwords in the begin routine tab, I have in the coder:
studylista = ['balls','dingy','bear','shoe'];
import random
random.shuffle(studylista)
studylista
import time
for i in studylista:
text.setText(i) # Prepare stim
text.pos = (0, 0)
text.draw() # Draw to buffer
win.flip() # Display on monitor
response = event.getKeys(timeStamped=True)
time.sleep(5.0)
For the same recallwords routine I also have a key response item in the builder set to store last key. The program works correctly in the sense that everything is displayed. It does not print out a csv file that includes responses during the above for loop, but it does give this in a text file. I also want to have the response time from the onset of the word presented in the for loop to when the participant presses a key recorded in a file somewhere, which I believed timestamped would take care of. Thanks.
Edited to add the requested information about studylista.
Your existing code breaks Builder's drawing cycle: Builder fundamentally operates on a continuous cycle that updates stimuli, collects keypresses and so on, at the same rate as the screen refreshes (e.g. 60 Hz). So any code you put in a code component (unless it is being executed in the periods at the start or end of the experiment) must be able to fit within a single screen refresh period (e.g. < 16.7 ms). So pausing for 5 seconds will cause Builder all sorts of problems.
Also you are re-shuffling the list on every iteration, which means you will probably get duplicate word presentation/some words missing. So this should occur only once. You are also collecting keypresses in code, which will conflict with the graphical keyboard component, and need to be explicitly saved in the data.
So don't fight Builder, but let it do most of the hard work for you. Specify a text stimulus that lasts for 5 seconds, and only use a keyboard component to collect responses (which will then be automatically saved in your data file).
This allows you to then just have this minimalist code:
# what iteration is this? (0 through 3)
wordNumber = yourLoopName.thisN # insert the actual loop name here
# only on the first iteration, shuffle the words:
if wordNumber == 0:
shuffle(studylista)
# on each iteration, get current word and update the stimulus with it:
yourTextStimulus.setText(studylista[wordNumber])