psychopy.org | Reference | Downloads | Github

Dynamic image stimuli paths on Pavlovia

URL of experiment: https://pavlovia.org/lcdlab/center-spatial

Description of the problem:
Hello! I made a memory task that I want to run on Pavlovia. In order to randomize images, I load in a list of numbers, then shuffle it in the beginning. I was loading in a csv file but since that doesn’t translate to JS very well I went with this instead. From the shuffled list, I pull ‘triplets’ of images. To set these images I use the following code:

triplet1 = ((“images/” + encodingPics[eTrials][0]) + “.png”);
triplet2 = ((“images/” + encodingPics[eTrials][1]) + “.png”); (and so on)

When I try to run this on pavlovia, I get the following error:

  • when setting the image of ImageStim: Triplet1
  • when getting the value of resource: images/OBJ_32.png
  • unknown resource

If anyone knows how I may fix this I’d appreciate it!

Check my crib sheet to see how I’ve successfully made custom image sets available. Search the forum for crib sheet to find the link

Thank you! I’m sorry but I am new to this and want to check a couple things if that’s okay! I believe you are referring to the ‘download resources’ part in the crib sheet. Do you think it is feasible to download all of the images in the experiment file (105 images) in the beginning, then pull from them with the code I had above? I’m worried that with every iteration it might take a long time to download the images

You are getting unknown resource because only mask.png is in the html/resources folder, because the others are only defined in code.

If you want to load all images because everyone will see all of them then I’d try copying them to your local html/resources folder and then refer to them without the images/ folder reference. Actually if you copy them to html/resources/images and then sync you probably don’t need to change your code at all.

Downloading resources during the experiment happens in the background so you have to make sure there’s no risk of asking for an image before it’s ready

1 Like