Hi @wakecarter, you seem to know a lot about using resources in an online experiment. I would really appreciate if you could take a look at my problem below.
I basically run an experiment that download at least 2000 videos my 2000 videos are located in 20 different subfolders which are located in 2 different folders. for instance, depending on the trial my participants are in it will show stimuli from different folders.
I have three different variables that keep track of which folder and subfolder. The first one is id_group that stays constant (Stimuli/anger_male_/) second is id_groups(1 & 2) and third is stim_block (from 0 to 9) which can give something like this:
id_group = 1 & stimblock = 0 then the output:
Stimuli/anger_male_0 which contains 50 videos from 0 to 49.
The idea here is to download only the resources I need right before the trial starts to prevent any buffer problems or to have my participants wait forever while downloading the 2000 videos.
So I thought of coding something like this:
id_group_temp = (id_group + id_group0);
var path_block = id_group_temp + stim_block.toString();
var resourcePaths = [
{'name': path_block + '/test_trial_sample_0000.mp4', 'path': path_block + '/test_trial_sample_0000.mp4'},
{'name': path_block + '/test_trial_sample_0001.mp4', 'path': path_block + '/test_trial_sample_0001.mp4'},
// ... all the way up to ...
{'name': path_block + '/test_trial_sample_0049.mp4', 'path': path_block + '/test_trial_sample_0049.mp4'},
{'name': path_block + '/test_trial_anti_sample_0000.mp4', 'path': path_block + '/test_trial_anti_sample_0000.mp4'},
// ... all the way up to ...
{'name': path_block + '/test_trial_anti_sample_0049.mp4', 'path': path_block + '/test_trial_anti_sample_0049.mp4'}
];
psychoJS.downloadResources(resourcePaths);
I basically put this piece of code in the routing right before my trial loops start, in the same routine where the id_group variable gets assigned.
But nothing is being downloaded. Any idea on what I could be doing wrong?
Use the filename without the path in the experiment components or (for local compatibility) put the filename with the path as the name in the list of dictionaries.
downloadResources was used in an earlier version. What version are you using?
Could you please clarify what you mean here, please?
“ Use the filename without the path in the experiment components or (for local compatibility) put the filename with the path as the name in the list of dictionaries.” I’m not quite sure to understand what the first part mean? Where should I put the path name then, for online compatibility?
Also, I’m using the latest version. You are right I should change it to
Also, I thought of implementing this code in the routine right before the trial_loop starts. Do you think this is the right place to put this code snippet?
Here you are putting the path in the name and path fields. This is probably the best option, because it means that your experiment will look for the files in the same place when running locally as online. I think maybe I’ll simplify my crib sheet to encourage people to just use the full path both times.
I would recommend putting the code snippet in Begin Routine of your first routine, so that the resources can be downloading while the participant is reading the instructions.
I understand the rationale here. The way the experiment is defined right now is that all participants read the instructions and then they get assign to their respective block (id_group_temp). Would you recommend to put the instructions in the same routine as id_group_temp which should also contain the resource code snippet?
The only reason I’m asking is because in order for the resource to be downloaded from the proper folders id_group_temp has to be assigned first.
Given that the instructions do not depend on which block they are assigned to, as every participant will complete the exact same task(just different stimuli will be provided). We thought it was easier to just put the instructions at the beginning.
Would you recommend that we change this? Or should I use another option to have them wait until the resources are being downloaded?
Since you are using code, you shouldn’t add the resources to Experiment Settings / Online since that will download all of them. In similar circumstances, I have added the resources for the practice trials there.
Also – it may be important to note that the resource that appears first in your list will be downloaded first, so you may want to ensure that the download order is the same as the presentation order.
Given that my instructions are split into two routines and that change_id_folder is the routine where id_group_temp is being assigned, where do you think I should implement the code for the resources to be downloaded so that it’s being downloaded in the background of displaying the instructions? Please note that trial_2 routine is where the stimuli are being presented to the participants.
I went ahead and tried implementing the code per your instruction, however, I’m getting this error
I think the reason might be that I clicked on the spacebar to go to the following routine, and maybe the resources haven’t been downloaded, yet. Could that be possible? If yes, how do I prevent anyone from going to the next routine until all the resources have been downloaded?
The thing is the next resource available can be any of my 50 stimuli as this is randomly assigned from the excel condition file. So, I’m not sure which one will be next.
I have followed all the steps from this post
But, I keep getting the same errors. Any help would be appreciated. I’m losing hope…
Originally, when all the resources for the experiment were being downloaded at the beginning(~2000 videos), it wouldn’t take a very long time (5-7 min). But, some browsers (i.e., chrome) wouldn’t load any of them, it would just crashed. Firefox would load some of them but not all of them. Hence, why I wanted to dynamically download only necessary resources. I think it we’re having some buffer problem. So maybe there is an easier fix here…
For some reason nothing happens when I implemented the above code, any suggestions @thomas_pronk ?
Upon checking my code, the stimuli array is correctly populated with my stimuli paths, everything works well. Except this line of code:
and it was working great back in December. Now it breaks and gives the error in the photo. Do you know if something changed with pavlovia in the last few months to make this not work anymore?