| Reference | Downloads | Github

Experiment involves using images as masks

URL of experiment:

Description of the problem: I have created an experiment in PsychoPy and it runs well, but when I tried to pilot it online I got this error:

when setting the image of ImageStim: image_test
when getting the value of resource: color
unknown resource

I color images by using them as masks. I was wondering is it possible to run it online when I’m using this function? Thank you.

“Unknown resource” has cropped up a lot on the forum (worth using search first). It usually indicates that your stimuli and/or conditions files haven’t uploaded (e…g because the file name is define by some code and PsychoPy couldn’t pre-compute it. Try checking the html/resources folder to see if all the necessary files are there.

But, in future, do please search before asking, and also add the URL of your experiment (code or running) so we can check it directly

Hi @jon ,

Thanks for the reply. I’ve checked the resource folder and all the necessary files are there. Sorry I didn’t describe my problem clearly.

This is a memory test. For each image, participants will need to do an old new judgment. If they recognize an image, they’ll need to do some further memory tests, such as the color of the image. The error appears in the color routine in which I’m using images as masks and using a slider for participants to change the color of each image.

It might be more straightforward if you could have a look at the code. Thank you so much in advance.

To be more specific

var colortestComponents;
function colortestRoutineBegin() {
  //------Prepare to start Routine 'colortest'-------
  t = 0;
  colortestClock.reset(); // clock
  frameN = -1;
  // update component parameters for each repeat
  image_test.color = [1, 0, 1]
  keycontinue.keys = undefined;
  keycontinue.rt = undefined;

The line in bold got an error. This line is corresponding to the following settings in PsychoPy:

I have no idea what went wrong. Any suggestions would be appreciated!

Any updates on this issue? Run into this error again:

Unfortunately we encountered the following error:
when setting the image of ImageStim: image_nt
when getting the value of resource: color
unknown resource
Try to run the experiment again. If the error persists, contact the experiment designer.

Any help will be greatly appreciated!

URL of experiment:

The code shows that you are attempting to set the image to the literal value 'color'

Presumably you want to refer to a variable of that name, so prefix it with $

Thanks Michael! Then I encountered this error: color is not defined.

The image value ‘color’ is defined in the advanced tab-color which refers to a variable from xlsx. It runs great locally. I guess the connection between the image value ‘color’ and the color in the advanced tab is lost online.

Try changing the name of the variable to something less likely to be used by JavaScript as a special term. If that helps, please let me know so I can add it to the list of words to avoid in my crib sheet.

Thanks wakecarter. I think the ‘color’ on the left will refer to the color on the right (or maybe I’m wrong). I don’t know what ‘color’ should be replaced of. The names of my own variables should be fine.

You’re doing something this an image component that I’ve never seen before. image normally has the name of the image file to be shown. It might be what’s happening is the locally color gets interpreted as None but online that gets changed to null instead of undefined.

Is there any documentation which suggests that you can type “color” in the image field?

I learned this in the book ‘building experiments in PsychoPy’, in section 3.7 Using Masks.

Cool. However, that working locally doesn’t necessarily mean that the method will work online. I know that there have been some issues with the mask parameter so it wouldn’t surprise me. You could try replacing the image with a flat color rectangle, possibly a transparent png, but I’m out of my area of expertise here.

Thank you so much for your time! :grinning: