psychopy.org | Reference | Downloads | Github

Images not showing up on the first run

URL of experiment: https://pavlovia.org/renato/img_loop

Description of the problem:
Hello everyone! I have this issue where my images don’t show during the first run in a loop. From the second run onwards it’s all good, but somehow, Pavlovia fails to display (maybe load) these images during the first trial. This is also reoccurring problem for me since it has happened in multiple experiments so any help is greatly appreciated. This also only happens on Pavlovia, builder works just fine.
This is a warning message I get in console:
log4javascript.min.js:1 WARN unknown | setting the image of ImageStim: im_prac_guess with argument: undefined.

Providing a link to a minimal demonstration of this going wrong would help enormously so we can see under what circumstances this is a problem

I mean, on the whole this is not an issue, so the question is what’s different about your study

Ok, I think I’ve now set the experiment on ‘public’ and posted the link. On the first screen there should be an image on the right hand side of the screen that enables to to continue. As I said, this is not visible on the first run, but if you click on it(or try couple of times to find it), you will be able to proceed.
Update: This is the warning message I get:

log4javascript.min.js:1 WARN unknown | the Pixi.js representation of this stimulus is undefined.

Thanks!!

hi Pavle,

Um, that isn’t a “minimal working example” of the problem, that’s your full study with a lot of code included. :stuck_out_tongue:

The idea is to cut out the stuff that’s irrelevant so the problem, and only the problem, is left. At that point we can focus just on the issue

thanks

Hi @jon!
Thank you for your response. You can now access a short study that shows this problem by clicking on the URL. In the meantime, I was able to figure out that this problem only happens when I set the image value to “set every frame”, whereas if I use “set every repeat” this does not happen. Nonetheless, since in my original experiments I use these images in combination with mouse hover effect, I need them to refresh every frame. Thanks!

Has anyone been able to look at this yet? I really don’t see any workaround…
Thanks!

This issue still hasn’t been resolved in the newest psychoPy version, so I will provide my workaround here.
I created a variable isFirstRun in the “begin experiment” tab of the first routine in the loop:
isFirstRun = 0
For each routine in the loop, I created a custom code component and under the “every frame” tab, I put

if isFirstRun == 0:
    continueRoutine = False

In the “end routine” tab of the last routine in the loop, I put:

if isFirstRun == 0:
    isFirstRun = 1

Therefore, the program will go through one iteration of the loop without actually displaying anything. On the second and all subsequent iterations, the images will be displayed properly and all routines will execute normally since the value of isFirstRun is now set to 1.
Tip:
If you have some other code in the same loop with if conditions, make sure to add and isFirstRun != 0 as an additional condition so that nothing gets executed during the “skip” iteration and all your variables stay unchanged until the second iteration. So, the code like below (before the workaround):

for i in range (len(array)):
    x = array[i]

will now become

if isFirstRun != 0:
    for i in range (len(array)):
        x = array[i]

and the code

if y == len(array):
    z += 1

will become

if y == len(array) and isFirstRun != 0:
    z += 1

Pro tip:
In python, if isFirstRun == 0 can be written as if isFirstRun, while if isFirstRun != 0 can be written as if not isFirstRun.

Good luck!

Hi Pavle, this is a very neat solution! I also had the same problem, and I believe it has been flagged to be fixed by the team.

Thomas Pronk published a solution here that also fixes the problem.

Basically, all you need to do is write: componentName.setImage(this_image) in your begin routine tab.