Image needs to appear conditionally but is always shown

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

OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 1.84.x): 2022.2.4
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:
I have a n-back task running. In this task participants get feedback on their performance. The textual feedback is working, however the images are always shown (and not conditionally).

What did you try to make it work?:

Because of code that is setting the % n-back, it is not possible to load the image in the Excel file. Instead, I tried to directly load the png into the image and set the conditions.

What specifically went wrong when you tried that?:

However this is not working, the feedback is always shown. What am I doing wrong?

Include pasted full error message if possible. “That didn’t work” is not enough information.

Used code to set conditions (when to show feedback), please note the text is shown correctly, but the images are shown always:
begin experiment:
msg= ‘’
score = 0
begin routine:
if type == 1 and response == 2:
msg = “Korrekt”
image = image_2
score = 1

elif type == 2 and response == 2:
msg = “Inkorrekt”
imagein = image_3
score = 2

elif type == 1 and response == 1:
msg = “Sie sollten auf die Leertaste gedrückt haben!”
imagein = image_3
score = 3

else:
msg = “”
score = 4
image = “”
imagein = “”

end routine: thisExp.addData(‘score’, score)


Hello

The component image_2 presents the image image.png on each repeat. This needs to be a variable to show different images.

Best wishes Jens

1 Like

Dear Jens, many thanks for your response. I tried to do this by defining a variable and requesting the .png in the code (see below in the pictures). However although I can see the correct folder is found, the picture cannot be found…
OSError: Couldn’t find image ; check path? (tried: C:\Users\3385507\OneDrive - Universiteit Utrecht\Desktop\N-back for remind)
################ Experiment ended with exit code 1 [pid:11456] #################

Best wishes, Sanne




Hello

Where are image.png and imagein.png stored relative to the experiment?

BTW, you should set an image for the else-part of your if-else construction.

I attach a little demo that show two different pictures based on trial-number. The images are in a folder called stimul

SetPicture.psyexp (11.5 KB)


Best wishes Jens

1 Like

Dear Jens, thanks! Something seems to be working now I added an image to the else part. However I don’t want to show an image under the else part… first I thought I could handle this by only writing: currentimage = " "
But that doesn’t work… How could I solve this?
When I have this correct I can test whether the images are also shown correctly (but they seem so).
Best wishes, Sanne

Hello

Add a picture in the same color as the background color, a transparent picture just a pixel large or skip the rest of the routine.

e.g.

continueRoutine = False

Best wishes Jens

Thanks!