OS: Ubuntu 16.4
PsychoPy version: 1.85.3
Standard Standalone? (y/n) If not then what?: Should have all dependencies installed?
What are you trying to achieve?:
My experiment loops over trials which are audio files of blocks of a narrative. After each file has played there is a pause until the subject decides to begin listening to the next part of the narrative. The subject’s task is to give a response (by pressing space, but it doesn’t really matter how, could be a mouse click as well) based on subjective cues in the narrative (there are no correct answers). I would like to give a quick visual feedback (eg a cross on the screen) a couple seconds long when the subject gives a response, just so they know that their response has been registered. The time of the response should be saved relative to the time of the audio file, and the trial should continue regardless of responses until the the audio file has been fully played.
Here is a picture of the experiment WITHOUT any feedback (seems to work):
What did you try to make it work?: I’ve looked at the stroop demo as well as http://www.psychopy.org/recipes/builderFeedback.html, among other examples. The last thing I’ve tried doing is using the code component in builder. I’ve tried making the feedback show up on the screen after a space bar press by adding the feedback code both within the narrative trial and as a separate trial but within the same loop. I’ve also tried inserting the code within different places (eg each frame) within the code component.
What specifically went wrong when you tried that?:
What seems to happen is that either the feedback doesn’t show up at all, it shows up immediately at the beginning of the trial, or the responses register but the feedback shows up when the trial has ended rather than immediately.
Hi @emsti. Rather than use the keyboard component, you could remove it and use the event module in a code component. In the code component we define a text stim called ‘text’ which draws your cross, and create conditions for its presentation which will not end the trial. In the relevant tabs add:
Begin Routine
text = visual.TextStim(win=win, name='text', text='+',height=0.3)
startTime = None
Each Frame
keys = event.getKeys()
for key in keys:
if 'q' in key:
core.quit() # quit key
elif 'space' in key and startTime is None:
startTime = t # time to start presentation
if startTime is not None:
if startTime+2 >= t: # present for 2 seconds from key detection
text.draw()
Hi @dvbridges, thanks for your help! The code works, but I forgot to specify that multiple responses are expected to be given within a trial. At the moment the code will only give feedback on the first response. How can I modify the code to give feedback repeatedly?
Ok, just to clarify, your participants will respond multiple times during a single 5 second recording? If so, and each visual feedback lasts 2 seconds, it seems there is little time for giving feedback for more than 2 responses.However, if this is your design, you could do the following:
Begin Routine
text = visual.TextStim(win=win, name='text', text='+',height=0.3)
startTime = None
RTs = [] # Create new list for holding RTs
Each Frame
keys = event.getKeys()
for key in keys:
if 'q' in key:
core.quit() # quit key
elif 'space' in key:
RTs.append(t)
startTime = t
if startTime is not None:
if startTime+2 >= t: # present for 2 seconds from key detection
text.draw()
End routine
for idx, rt in enumerate(RTs):
thisExp.addData("RT{}".format(idx), rt) # Add an RT column to data file for each RT
Thank you so much for your help, the experiment works now! The trials are actually several minutes long, I’ve just cut them short for testing the experiment :).