When setting the image of ImageStim: pracImage the argument: is neither an image nor a video" }

URL of experiment: GNG_Experiment [PsychoPy]

Description of the problem: When trying to run the experiment I run into the error message: “when setting the image of ImageStim: pracImage the argument: is neither an image nor a video” }"

I have an image time called pracImage, which is looking for $pracTarget (set every repeat).

This decision comes from code at the start of the experiment. I have pasted the JS code below (via auto-JS):

pracRows = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14]];
util.shuffle(pracRows);
pracRows = pracRows[0];
pracTarget = [];
pracText1 = [];
pracText2 = [];
pracText3 = [];
if ((pracRows === [0, 1, 2, 3, 4])) {
    pracTarget = "Circle.png";
    pracText1 = "TRIANGLES";
    pracText2 = "SQUARES";
    pracText3 = "CIRCLES";
} else {
    if ((pracRows === [5, 6, 7, 8, 9])) {
        pracTarget = "Square.jpg";
        pracText1 = "TRIANGLES";
        pracText2 = "CIRCLES";
        pracText3 = "SQUARES";
    } else {
        if ((pracRows === [10, 11, 12, 13, 14])) {
            pracTarget = "Triangle.png";
            pracText1 = "SQUARES";
            pracText2 = "CIRCLES";
            pracText3 = "TRIANGLES";
        }
    }
}

This works fine locally, but not online. I tried to open the console to have a look but it is not showing me where in my JS code it’s going wrong, only where it’s pulling the error message from.

Might there be an issue with pracRows? Try printing the value to the console.

The console log states “Array (5)” , does this mean instead of it storing [1,2,3,4,5] etc, it’s instead storing type and length? Or is this how it should appear with JS?

Did not spot the collapsible arrow. It says

0: 5
1: 6
2: 7
3: 8
4: 9
length: 5

I’m concerned that you might always be getting the else condition. An alternative would be just to check the first entry, e.g.

if ((pracRows[0] === 0)) {
1 Like

You were correct, I tested it a few times and it was only displaying the “else”.

Changing to check the first item in the array has fixed the issue