The argument is not an image error

URL of experiment: Pavlovia

Description of the problem: Dear all, I created a program that shows images on the screen.

I put the images (png format) in a folder named “Ideogr” in the resources folder, and the files get synchronized and downloaded.

If I set the filename in the object GUI like this:

everything seems to work fine.

If instead I code the filename in a variable, and then call it like this:

I get the following error:

Pressing F12 in the browser reveals this error message:

FATAL unknown | {“origin”:“ImageStim.setImage”,“context”:“when setting the image of ImageStim: image1”,“error”:“the argument: Ideogr/nonTUP.png is not an image” }"}

Which I find a bit puzzling because the path to the file seems to be exactly the same, but in the second case it´s not found.

Has anybody encountered this before? from the previous reports I saw the problem was usually missing files or wrong path definitions, but as far as I can tell here it´s not the case.

Thanks a lot,

Matteo

1 Like

Dear all, it took me a while but I sort of managed to solve the issue. The only solution I found was to create a mock trial at the beginning of the experiments that has all the images shown each called by its own name (with 0 opacity to avoid them actually showing). After that they seem to be available to be called through the variable definition.

1 Like

I had a very similar problem, slightly different error message.
The images would not load in, despite the images folder being present in the gitlab directory, the error was something like “image.png is not a resource”. Having tried many other fixes for the issue (changing backslashes to forward slashes, recreating a new directory and pavlovia experiment, etc, the above fix is the only thing that worked.

Hi @valsecchimat,

Can you please show how you did this?

Hi, I literally had a trial at the end of the experiment where I showed all the stimuli calling them by name

image

I’m getting this and cannot for the life of me understand why. I considered it being due to \ instead of /, filenames starting with numbers, resources not added via the Online tab, the conditions file itself being broken/corrupted (and so creating it afresh), but it just seems that pavlovia/js is reading all cells of a row from the conditions.xlsx file as one… :frowning:

Also, I note from visual/ImageStim.js that this error is due to the image not now being an actual HTMLImageElement… I don’t know what that is though!

Any assistance would be greatly appreciated.

@PsyTechMMU it’s hard to know what’s happened without seeing your variables and any code components (maybe you have something that changes the values of your variable or loads them outside the loop)

Regarding the original issue about resources not being found, this is caused by the fact that the PsychoJS script needs to decide which files to fetch from the pavlovia server. It shouldn’t fetch them all (your participant doesn’t want all the other participants’ data files) but it needs to fetch the ones that you’ll be presenting. When you give the complete filename (as in the first dialog and as in your final solution) then PsychoPy can work out what files to download and express them in the script. When you specify the same filename using code (like THESTIMS[1]) then PsychoPy can’t deduce in advance what to deliver to the participant’s browser so the resource doesn’t exist. The way to handle this is using the ExperimentSettings>Online>AdditionalResources to explicitly list files that you’ll need that PsychoPy couldn’t automagically guess.

But I think the most recent post by @PsyTechMMU is something else, and for that we probably need to see the project files

Somehow you are setting the image of leftImage to a list instead of a single file at a time. Perhaps you are missing [0]

Many thanks for responding, Jon. And apologies for not even linking to the experiment. It’s this one: Pavlovia (GitLab Id: #204560), running (or not) here: symbolLearning [PsychoPy]
Please ignore the text formatting (unless that’s somehow the issue).

Based on the loading bar after launching the experiment, it appears the stimuli/resources are being loaded, but then the conditions.xlsx is being read “wrong”. Perhaps due to @wakecarter’s suggestion (thank you - though I’m not 100% on what you mean and don’t know how to fix it). Also, this error still happens after explicitly adding all resources via ExperimentSettings>Online>AdditionalResources.

Please could you upload your conditions file here?

conditions.xlsx (20.2 KB)

This is one generated new from within PsychoPy, but I have also tried (re)creating new xlsx and csv files (and checked for blank columns/rows etc), all still with the error.

Thanks in advance.

The main thing that looks odd is the comments.

However, last time I mentioned comments it wasn’t the issue and in your case there aren’t extra rows.

What do you mean by “generated new from within PsychoPy”?

Please could you show a screenshot of how to set the image for leftStimulus?

They’re part of the PsychoPy-generated template (accessed by clicking the new button beside the conditions file location in the loop dialog).
Also, the “argument is not an image” error occurs with all other versions I’ve tried (fresh xlsx and csv).

As for the leftStimulus image component:

Just to confirm/clarify, this works as expected via PsychoPy/offline.

The good news is that I can replicate the issue - the bad news is that I have now idea why it would be an issue! :wink:

We’ll need Alain for this one. Most conditions files are working fine and I can’t see what’s different about this one. I’ve also converted it to a csv file (which doesn’t have any issue with comments and is certainly correctly formatted) and that fails in the same way.

We’ll get back to you
Jon

1 Like

Cheers, Jon! That puts my insanity at ease for a while at least. :blush:

And I’m the same: I’ve been using other experiments/examples with conditions files (and ones more complicated) that are working fine.

Also, I wasn’t convinced it was the issue, but I also tried using .bmp and .jpg files (separately) for the stimuli too, but that didn’t seem to make any difference either. Just thought I’d mention it as another thing it doesn’t appear to be!

I couldn’t see any issues with the code or spreadsheet either.

I can’t see why stimulusR and stimulusL would be a problem, but you could try it with different column names.

Thanks, wakecarter, your help is much appreciated. I had tried that previously and have just tried it again but to no avail.

As mentioned above (referring to visual/ImageStim.js), it seems to me that, even though the stimuli/resources are being loaded, they’re not being “converted” or encoded/decoded or interpreted correctly for some reason. The “for some reason” being the stumper, of course.

Anyway, hopefully this can be fixed or worked around at least! :grin:

I don’t think that’s the issue.

The issue is that all three columns of the spreadsheet are being used for the image file name as if the contents of all three columns was in the first column. That’s never going to be a valid image file.

Yeah, this is definitely what seems to be happening. And because of this (and it not being a valid image file), it’s throwing this error. So weird it’s happening with this and not others though.

@jon Dare I ask if there might be a workaround (or even a fix!) in sight for this? :blush: