Problem with preloading images with jsPsych/JATOS on server (Mindprobe)
Hi guys,
I'm sorry if I ask something really stupid, but I have no clue of how to work with servers. I've got my code on my local JATOS, and preloading images in jsPsych works alright, but when I import the experiment on the JATOS server, I get an error message:
"Error loading file: https://jatos.mindprobe.eu/publix/[file path/file name].png
File did not begin loading. Check that file path is correct and reachable by the browser, and that loading is not blocked by cross-origin resource sharing (CORS) errors."
If I inactivate the preloading part of the code, images are displayed alright in the trials, but as it is a reaction time experiment I would prefer preloading them to prevent any issues with slow internet connections etc.
My code in short is the following:
// initialize jsPsych var jsPsych = initJsPsych({ on_finish: () => jatos.endStudy(jsPsych.data.get().json()) }); // create timeline var timeline = []; // define array of images to preload, e.g. var images = [ 'img1.png', 'img2.png', 'img3.png' ]; // preload images var preload = { type: jsPsychPreload, images: images, show_detailed_errors: true, message: 'Please wait.' }; timeline.push(preload); // here comes the code of the experiment proper // start experiment jatos.onLoad(function () { jsPsych.run(timeline) })
I imagine it has to do with access to cache? As far as I understood, there are default specifications of temp file locations that should work alright, but apparently I need to change something here. Or maybe it is something else and, again, sorry if this is a really stupid question.
I really would appreciate your help on this topic! Thank you so much in advance for any hint!
Comments
Hi,
Preloading of images should work the same way as normal loading. But maybe jsPsych does something with the URL path it uses to open the file. Where are those image files stored? What is the file structure of your experiment?
Best
K
Hi,
Thank you so much for answering! First, I stored the image files in separate folders called "stimuli" and "practice_imgs", then I tried out putting them all directly in the experiment folder in study_assets_root. It was all the same in the two cases: images load in the experiment, but preloading fails. In the code, I use relative paths.
In the attached pictures you can see the error message with the file path in the online experiment and the folder content in the experiment folder in study_assets_root on my computer. The different html-files are the different components of the experiment.
Best, Ines
Hi Ines,
Your file structure and the relative path you are using seem to be fine. But I could have a closer look if you agree. Can you share your study with me? The easiest would be to add user 'admin' as a member of your study. But if your study contains sensitive data you can also export it and send me a stripped-down version of it.
Best,
K
Great, thank you very much! I have just added you. The error occurs with the second component.
You develop your study on Windows, aren't you? Windows isn't very strict with letters and capitalization. But Mindprobe-JATOS runs on Linux and there it is. Your filename spelling must be precisely the same in your file system and the code.
I changed
coffee_s1.JPG -> coffee_s1.jpg
andcoffee_s2.JPG -> coffee_s2.jpg
and then the second component worked with me. But to be sure I'd recommend to check all other filenames too.Best,
Kristian
Hi Kristian,
thank you so much! Yes, I am working on Windows. I always looked for errors in the code, and therefore I also searched the wrong questions to find the answer elsewhere in forums.... Now it works alright. Many thanks!!
Best,
Ines