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. https://gitlab.pavlovia.org/xiaotong/next-day-test

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]
  slider.reset()
  **image_test.setImage('color');**
  image_test.setMask(Test_ImageItem);
  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: https://run.pavlovia.org/xiaotong/dt_a/html

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.
5

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:

Hi @Xiaotong, @wakecarter ,
I am a beginner on PsychoPy and I can’t seem to find the way to set up the duration of a mask.
Can anyone of you be of help?
Thanking you in advance

Mask in this thread is, about having an image with transparent sections which can then be coloured. Are you thinking about a mask that disrupts the iconic memory of an image? If so, then you should set up your mask image as a separate image component (or use a code component to set the image of the image component to a mask after the desired duration.

Yes, much like this sort of paradigm.

As you can see on the screenshots I enclosed, I can set the duration for the visual (image) stimulus on the ‘Basic’ tab, but cannot seem to change anything about the duration of the mask on the ‘Texture’ tab.

Capture d’écran 2023-01-17 à 09.21.50
Capture d’écran 2023-01-17 à 09.22.05

So why can’t you present the mask as a separate image component?

A duration of 0.012 seconds is unlikely to work. Try 1 frame instead and set the start of the mask image as frame 2 (or possibly frame 1 – I’m not sure which)

That’s what I ended up doing. Thanks very much for the help!