AttributeError for conditional result images?

I’ll start by saying I have little experience with psychopy as a psychologist. But, I am trying to get a task from a colleague to work and I have been struggling with a multitude of errors, the most recent one being: AttributeError: Couldn’t make sense of requested image.

This task has the participant collecting berries. Once the berry is presented, they need to repeatedly press the spacebar to collect the berry, so I need the resulting image to either be one of “collected” or “not collected” if they didn’t press the spacebar. My colleague had the same static image as her result image and it would automatically be replaced once the code ran depending on how the participant responded, but for me, it just keeps showing me the same berry being collected (the same static image). I tried to replace the result image with a variable that I defined in the routine but now I get the above mentioned error. I’m not sure what is going on. Should I not be defining a variable for this?

I have tried looking on this forum and on others for solutions but as I am a newbie, I am unsure how to implement them and some have not worked for my issue. I keep getting the same error.

OS (Windows):
PsychoPy version 2025 1.1

I truly appreciate any insight or help on this issue! I have been trying to figure this out for a long time!

Hello @Katastrophe

What does your code look like?

Best wishes Jens

You might have used a variable name twice.

Specifically, you might be using one of your spreadsheet column names for something else.

This is where I think the issue is. I need the image to change depending on whether the participant collected the berry or not. I don’t think this is the way to do it, but I’m not sure what to change.

And then, I initially was having trouble with this part of the code:

I wasn’t sure if I had to define ResultImage before this part of the routine so I tried that, but I keep getting the same error.

Thank you so much!

I checked my column names and I haven’t noticed anything that is already defined in the code. I didn’t change anything from how I got it from my colleague except for the paths to the berry images, so all column names and the code has remained the same.

You have an image component called ResultImage
You have an image filename variable called ResultImage

ResultImage = ResultImage. One of these names need to change.

Your image component is set to update each repeat. You are also updating the image filename in End Routine. Are you setting ResultImage.setAutoDraw(True) in the following routine? This could work, but normally it would make sense to have a separate feedback image component in the next routine and set it to show filename Collected or Not_Collected via a variable, e.g. feedbackImage

This also makes sense! I ended up being able to talk to my colleague about it and they had me delete a piece of code in the Begin experiment part and it is running smoothly now. They had coded it in a 2022 version and I’m using 2025.1.1. Don’t know if that made a difference.