psychopy.org | Reference | Downloads | Github

Correct/incorrect feedback using images

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2021.2.0
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:
Hey guys, I am super new to PsychoPy and I am just seeking some information to help get me started on my experiment for my thesis. In my task I want my participants to be shown an equation e.g. 4 + 4 = 8 and then either press “4” or “6” to denote that the equation is correct or not. If the participant gets the answer correct I want to display a happy face selected out of a pool of faces I have in an excel-folder. If the participant gets the answer wrong I want to display a disgusted face. Currently, the only thing that I have been able to achieve is getting the equations to display by defining the variable $equations and linking that to an excel file with the equations as well as recording whether they responded correctly with 4 or 6. Any advice on where to go from here?



Equations.xlsx (9.4 KB)

Hello,

First, you should define the correct answer and the image path in every row cause Psychopy reads the rows one by one.
Equations.xlsx (9.7 KB)

Then, go to key_resp component > Data > Store correct > add: $corr_response (the variable name the same as the new excel file above)

Then, add a new routine (HappyImage) within the same loop with the MainTask routine. Add an image component with path $Happy_Faces
Then add a custom code component. Write under Begin Routine (or Each Frame?):

if (key_resp.corr == 0):
    continueRoutine = False #will skip this routine if the answer is incorrect

Then add another routine repeat the same for the disgust. Add a routine in the same loop and add image and code components.

untitled.psyexp (5.8 KB)

Someone can correct me if I am mistaken.
Bests

Thank you for this it has helped me out very much as it almost works perfectly! However, I am running into a problem where if it displays a happy face (indicating the answer was right) then it is followed with a disgusted face as soon as the duration of the happy face ends (this does not happen the other way round e.g. getting the question wrong only displays a disgusted face). I think this might be because the custom code only finishes the happy face routine and the happy face routine is followed by the disgusted face routine, but the disgusted face routine is at the end of the loop (if you look at the routines in the image it will make more sense.) Is there any way to fix this e.g. ending the entire loop instead of just the routine?

Please check dm. I corrected there

In disgust face routine > custom code > begin routine:

if (key_resp.corr == 1):
    continueRoutine = False

This should work in Begin Routine. In Each Frame, you might see one frame of the disgust face.

1 Like