psychopy.org | Reference | Downloads | Github

Creating expt with feedback based on subject's response

**Win10
**PsychoPy version v2021.2.0
**Anaconda

Hi everyone, I’m very new to PsychoPy. I’m trying to create an experiment which can provide a different picture feedback to every trial depending on the response the subject has made. For example, if the subject chooses A in Trial 1, a picture feedback “Trial1_A” should appear and if the subject chooses B, a picture feedback “Trial1_B” should appear. The feedback pictures for every trial are different. There is a total of 35 trials.

Moreover, I created a simple experiment without the feedback part. However, the laptop screen turns dark when the experiment ends. It’s like screen brightness has been reduced to minimum. And cue?

Many thanks!

There’s two ways to do this:
One is the same as in the “branched experiment” demo, essentially you create a routine with different images in, make a loop around each and set the nReps attribute of these loops to 1 or 0 according to the participants’ response.

However, as the only thing you’re varying is the image, it may actually be cleaner to just set the image according to response. I would make a Variable :variable: component with a value like this:

{'a': "path/to/image1.png", 'b': "path/to/image2.png"}

And then set the value of the image to “set every repeat” and be myVariableName[response] (where myVariableName is whatever you called your variable component and response is either a or b according to participants’ response)

Thank you so much for the reply!
Since the two feedback images for each trial is different, I tried to use the Code component instead of using the Variable component.

if resp.keys == ‘a’:
feedback_image = feedback_a
else:
feedback_image = feedback_b

And then in the Image component, the value of Image is $feedback_image. I do have an excel file specifying the feedback_a and feedback_b images for each trial.
Do you think this will work?