Hello,
I have five images appearing on the screen and I want to signal to the participant which one they have clicked.
The participant will select one image via mouse click and I want the one they choose (regardless of whether or not it is the correct choice) to either appear less opaque or have a border surrounding it (I don’t really mind which way as long as participants get confirmation that they have clicked on an image).
Also, I am unsure how to tell PsychoPy to code responses as either ‘correct’ or ‘incorrect’. I don’t care which image they chose I just want to know if they chose the right one or not. Currently, I have a ‘correct image’ column set up in my excel file but I was not sure how to continue.
Thanks in advance!
Hi @leorelizur, for the first requirement, you can use the isPressedIn
function see docs. You would use it like this to change your image stim:
if mouse.isPressedIn(YOUR_IMAGE_1):
YOUR_IMAGE_1.opacity = .4 # where opacity changes makes your image less opaque
elif mouse.isPressedIn(YOUR_IMAGE_2):
YOUR_IMAGE_2.opacity = .4
#...etc
For correct responses, you could compare your correct image
variable to the image clicked (btw, I would remove the spaces from your variables, this will cause problems). E.g.,:
if mouse.isPressedIn(YOUR_IMAGE_1):
YOUR_IMAGE_1.opacity =
if YOUR_IMAGE_1.image == correctImage:
correctResponse = 1 # You will want to define your correctResponse variable at the beginning of the trial
When I have tried using this code like you mentioned, the image that is pressed remains at a lower opacity on all subsequent trials. I have a loop of images going and whenever an image is pressed the next image in that position remains at opacity 0.4. Is there a way to reset the opacity to 1 for the next trial?