Creating feedback--green border around correctly selected image

OS (e.g. Win10): macOS High Sierra
PsychoPy version (e.g. 1.84.x): 1.90.1
Standard Standalone? (y/n) If not then what?: builder

What are you trying to achieve?:

I am currently designing a miniature natural Turkish language learning paradigm assessing knowledge of Turkish morphology and noun cases. I have searched previous posts that align with this issue but have been unable to find one so I figured I would post my questions here!

During trials in the second block, participants hear a short dialogue between a male and female speaker which consists of a male asking a very short question (“to where is the goat going”?) and an answer spoken by a female (e.g. “to the airplane [object]”). Simultaneously, two side by side pictures are presented to the participant (one consists of a goat going towards an airplane, and the other consists of a goat going towards a stove for example). Then, the participant is required to press the corresponding key that matches the image that represents the female answer (in this case, it would be the image that depicts the goat going towards the airplane). The participant presses the left or right arrow key using a keyResp that is in accordance with the $correctAns variable in my conditions file (attached here). The correct image could therefore be presented on the left or righthand side of the screen. The incorrect image is presented on the opposite side of the screen.

I have this part totally figured out and is part of the “DialogueB2” routine displayed in the image below.

What I am having trouble with is the 3rd routine (called FeedbackB2) which is the feedback part. Here, the participant is given feedback based on their answer. At the top of the next screen, the participant sees ‘correct’ in green if they select the appropriate picture and they see ‘oops! That was wrong’ if they select the wrong picture. This is included in a code component at the beginning of the routine and works fine:

if DialogueB2_keyResp.corr:
    msg = "Correct!"
    msgColor = "green"
else:
    msg = "Oops! That was wrong"
    msgColor = "red"

Under the written feedback, I want the participant to see the same exact pictures side by side that they saw in the second component (DialogueB2) except I want a green border/rectangle to surround the CORRECT picture and no border to surround the incorrect picture (this is important as I want to minimize cognitive load by keeping the same pictures as they saw in the second component). Simultaneously, the participant will hear the same female answer as they did in the DialogueB2 component. The participant will see a green border over the correct image no matter if they got it correct or not.

So far, I have designed the third component (see image of ‘FeedbackB2’ component below) and I have inserted the same images from the DialogueB2 component and placed polygon stimuli over them (this is in accordance from a previous post: Provide feedback by highlighting answer).

I am having trouble designing a code that would allow me to place a green polygon border over the correct image only. Right now, I have two polygon components (one for each image) but the more I think about it, the more I am think that I only need one polygon with a position (the size of polygon always remains the same and is the size of the image) that is dependent on the correct image for that particular trial. The way I have it now in the builder and code component makes it looks like this:

This is accompanied by the following code component that is also placed at the beginning of the routine:

if DialogueB2_keyResp.corr:
    border_colour = 'green'

With that said, obviously this code is missing something that makes it conditional depending on if the left or right picture was the correct picture.

I hope this makes sense. Please let me know if you would like me to insert the entire script output or if you have any other questions!

As a note: this is a draft of the experiment and the final experiment will include many more stimuli!

Thank you for taking the time to read my post–I know it is long! I am new to psychopy but am really enjoying it! I love the fact that i get to learn Python along the way as well. I look forward to hearing from you soon.

-Maya
conditionTestRunTrainingBlock2_v2.xlsx (8.8 KB)

Hi Maya, this sounds like a nice study.

I’m assuming you have a variable called something like correct_answer in your conditions file, which has values of either 'left' or 'right' that you use to determine whether the response was correct or not.

Insert two green polygon stimuli around where the left and right picture stimuli would go.

Control which one is visible on any given trial by putting an expression like this in the opacity field of the left one: (True = 1 = visible, False = 0 = invisible):

correct_answer == 'left'

and this for the right one:

correct_answer == 'right'

Hi Michael,

That worked! Awesome!

I knew it had something to do with opacity …this makes so much sense. I am excited to expand this experiment in PsychoPy.

All the best,
Maya

1 Like