Image stimulus shows up blank online

https://run.pavlovia.org/emdeschacht/keyboardtest

Hi there, I have include the URL and gitlab repository of the experiment above. I hope this works.

The experiment works perfectly when i run it on PsychoPy, but I have a problem on Pavlovia.
The issue I am having is that when it tries to draw my image stimulus, nothing comes up. I originally had the resource not found error, so I followed the advice from other forum posts and put my image resources in the additional resources section in builder. This solved the error problem, but the images simply do not come up.

They are drawn from a piece of code in which i have:
listOfImages =[img1.jpg, img2.jpg] which continues for 50 stimuli names.

the image component is $listOfImages[idx]
where idx = util.randint(0, 50);
(this is JS)

I have then coded it to randomly select one of these images as a start image and then participants use the left and right arrow keys to scroll through the images. Once they find their target image they press space and it should move to the next trial.


this screenshot is what it looks like in Pavlovia


this screenshot is what it looks like in PsychoPy (and how it should look in Pavlovia).

I am not getting any error messages but there is clearly something going wrong.
Please help!

Just to verify that your code works properly, could you insert console.log(listOfImages[idx]) in your code at a point where this value would be used and have a look in the console which value is printed?

hi there! thanks for the help,
I’m not exactly sure if this is what you mean, but when I open the console in pavlovia these are the messages that come up. Any idea how to fix them?

I’ve just added your suggested code component under begin routine on the JS side and this is the console after doing that.

Ok, that looks like your code does indeed return a stimulus name, that’s a good start :smiley: But all the warnings showing up before you even print the stimulus name make me think that your image component gets initiated before the code that should give it its stimulus even runs. Did you make sure that the code runs before the image is displayed? Is the code in a routine before the routine with the Image? Or is it in the same routine? Is it the uppermost component in the routine view in the builder?

I’ve tried both. I just moved the code component back up to the top and still get the same warnings

The only difference is the image it is pulling, which makes sense because its a random start image each time.
The code is in the same routine as the image. This is what my builder looks like. The testtext routine is just there so I can see if I can advance routines (which I can with the spacebar press).

side note: I think the failed to load resource is from the initialising/loading screen. I believe my institution logo would normally be there, which isn’t a problem for me, it’s not related to my code!

Could you make the experiment public, so I can have a look?

Should be available now, let me know if you can’t access it

I think what you need to do is change the image from being “set every frame” to being “set every repeat”. This way the first image is properly presented. Then, you can use image.setImage(listOfImages[idx]) in the “Every frame” code tab to change the image if some conditions are met (i.e., if some key is pressed). Hope that helps!

ahhh thank you!! this worked, you’re a lifesaver. Much appreciated :partying_face: