| Reference | Downloads | Github

Feedback on the same routine

Hi everyone!

I have started to use Psychopy during this week and I have created an experiment in which a randomized set of images and songs are presented to the subject. In each set of image+sound the subject has to answer if that “context” is true or false (there is only one true context that predicts a memory task). I made that with the keyboard component and following the instructions from the stroop demo to create a feedback response and it worked!

However, I will really need to get the feedback be presented together with its corresponding image and sound. When I copy the code command on the same routine, I cannot make it work right because it always gives me the feedback taking into account the last answer of the subject and not the current one.

As I am not expert writing in code, I do not know how to create a new code to make a feedback that can be presented at the end of the same routine (with the image and the sound in the background).
I will really appreciate hints to solve this problem!


Hi Jessica,

don’t be afraid to split your trial into multiple routines. i.e. in the first routine, present the stimuli and collect the keyboard response (set to force the end of the routine). Then in the next routine, present the image stimulus again, along with the feedback stimulus. They will all be set to appear at time zero, so from the subject’s point of view, there has been no visible disruption to the image stimulus. Both routines occur within the same iteration of the loop, so there should be no longer be any issue with showing the feedback based on the value from the previous iteration.

Hi Michael,

Thank you for your response.

Something that made me feel confused about how to program the feedback together with the corresponding images was that I made a routine with images and sound in a random order.

Finally, I could solve this trouble by putting $ImageFile in the Image Box into the feedback routine and surprisingly the program runs the same image that ran in the last routine so, as you said, there is no visible disruption to the image stimulus from the subject’s point of view.

Thank you very much for your help!


The key concept here is that routines do not equal trials. Every routine within a loop has access to the same row of information from the conditions file. The information only updates (i.e. goes to the next row of the file) on the next iteration of the loop.


Thank you for your clear response.

Now the program is running correctly and the feedback is presented together with its corresponding image.

It would be also great if I could also keep the audio file playing during the feedback. Is there any chance to tell the program not to start again the music when the feedback routine starts and just keep playing it?

Thank you very much!


As above, Builder operates so that all stimuli need to be completed before a routine can end. So to get around that, you’ll need to create a sound object in code (ie delete your current sound component: you’ll be replacing it with a snippet of custom code). Builder won’t know about this sound, as it isn’t specified as a Builder component, so it will happily play across the boundaries of routines.

Insert a Code Component from the component panel into the routine where the sound should start playing. In the “begin experiment” tab of the code component window, put something like this to instantiate an empty sound object:

audio = sound.Sound()

Then in the “begin routine” tab, put something like this to associate it with the sound file for this trial and to start it:


If needed, you might have to manually stop the sound playing in the last routine so that it doesn’t leak over into the next trial. Insert a new code component on that routine, and in its “end routine” tab, put: