psychopy.org | Reference | Downloads | Github

Unknown resource error: Pavlovia not reading list index of images

URL of experiment: https://gitlab.pavlovia.org/DASLab/social_5800

Description of the problem: I am trying to create a task where participants are given conditional correct feedback with the presentation of one of three images. I have created a list of the images in the Begin Experiment tab, shuffle the list in Begin Routine, and based on some feedback logic, set the opacity of the image to either 1 or 0. This runs totally fine in PsychoPy, but I get an unknown resource error in Pavlovia

Screen Shot 2020-06-19 at 10.09.00 AM

Here is my JS code:

#Begin experiment
Reward = [0, 1];
imgList = ["Stimuli/Star.jpg", "Stimuli/Wow.jpg", "Stimuli/Wonderful.jpg"];

#Begin routine
util.shuffle(imgList);

if (m_v.corr == 1) {
    Reward = 1;
    rewardCounter += 1;
    psychoJS.experiment.addData("RewardCounter", rewardCounter);
} 
else {
    Reward = 0;
}


if (m_v.keys == null || rewardCounter > 40 || Reward == 0) {
    social_reward.opacity = 0.0;
    psychoJS.experiment.addData("Did_Reward", 0);
    psychoJS.experiment.addData("Big_Reward", 0);
    psychoJS.experiment.addData("Lil_Reward", 0);
} 
else if (Reward == 1 && m_v.keys == "m" && MV == "m" && Math.random() > 0.25) {
        social_reward.opacity = 1.0;
        psychoJS.experiment.addData("Did_Reward", 1);
        psychoJS.experiment.addData("Big_Reward", 0);
        psychoJS.experiment.addData("Lil_Reward", 1);
} 
else if (Reward == 1 && m_v.keys == "v" && MV == "v" && Math.random() > 0.75) {
            social_reward.opacity = 1.0;
            psychoJS.experiment.addData("Did_Reward", 1);
            psychoJS.experiment.addData("Big_Reward", 1);
            psychoJS.experiment.addData("Lil_Reward", 0);
} 
else {
    social_reward.opacity = 0.0;
    psychoJS.experiment.addData("Did_Reward", 0);
    psychoJS.experiment.addData("Big_Reward", 0);
    psychoJS.experiment.addData("Lil_Reward", 0);
}

And here is what I have my image properties set to:

The images weren’t uploaded to the resource folder when I committed this file the first time, so I copy and saved them from my original Stimuli folder. Unfortunately I still get this error.

Thanks!

Is your code component above or below your image component?

You can add print(var) (which translates to console.log(var); ) to check the value of a variable var at a particular point.

I would check imgList[0] just before the error

My code component is below the image.

I have the trial and feedback components in different routines, so I placed

print(imgList[0])

in the Begin Routine tab. I’m unfamiliar with the print function and did not see any changes to the task or any way to check the value of the variable. I must be missing something, apologies for the simple question

I’m on my phone. Please search the forum for crib sheet to find a link. You need the JS equivalent of print which will go to the console (see crib sheet)

Sorry I should have clarified, the auto->JS function translated it to console.log (imgList[0]) and I’m still unable to check the status of the variable.

Why? Did you look at the console?

Ah I understand now. I checked the console in the “Info” tab, and it looks like one of the three images that is supposed to appear is set as the variable. Here is a screenshot for reference (the image is called “Stimuli/Star.jpg”):

and here is a screenshot of the same error in the console:

It looks like there’s an issue with the mask setting (under advanced). I know that mask can be an issue so try removing anything from that box.

I left the mask box blank and set it to every repeat, but still no luck :frowning:. I took a look at the JS script and it looks like the image is undefined in the Initialize Components part of the code, which might be the cause of the error? Like I said earlier, the image list is placed under the image but I have it in the “Begin Experiment” tab. I’m a little confused because of the mask error coming up, if it was a problem with the image being undefined shouldn’t that be indicated in the error?

I tried deleting the experiment on Pavlovia and re-uploading it with no success, but here is the new study URL: https://gitlab.pavlovia.org/DASLab/social_5800

Thanks so much for keeping up with this thread and answering my questions!

Just wanted to post here again to see if anyone else has had a similar issue. I removed the mask field from all my images in my study with no luck. I have also set mask to “constant” but have tried changing it to “set every repeat” and “set every frame”.

This appeared to be a browser issue! I was working in Incognito mode while I was received these errors, and when I ran it in regular Chrome I achieved the desired outcome.