Deal with condition files on psychojs/pavlovia

Thank you so much! I finally got it to work, but also I struggled a bit so I figured I should share my journey here for other people’s reference. I created a routine called ‘loadResource’ in the very beginning and added the code psychoJS._serverManager.prepareResources in the begin Routine part. I have two kinds of resources to load: condition files and some images. Right off the bat the condition files work just fine, however, the images just wouldn’t work. I have a line: example_image.setImage(im) to updated the image for each page of instruction. Even though psychoJS.serverManager.getResource shows the images are loaded, just like the conditions files, example_image.setImage just keeps giving me errors. I tried loading the images at various places in the code, with no success. Then I came to the conclusion that the images can only be loaded at PsychJS.start, in which case setImage works without a problem. Now in the final version, I load all the images as usual (thankfully I use the same images for everyone and thus it doesn’t depend on subject ID), then use psychoJS._serverManager.prepareResources to load the condition files later in the loadResources routine. While this works fine for the current experiment I am designing, I think it would be worth looking into why doesn’t setImage work when images are load through psychoJS._serverManager.prepareResources whereas condition_files can be loaded without bug.

1 Like