Avoiding client download of multiple condition files from which one per P is selected

URL of experiment: https://pavlovia.org/rgart/ld_js

Description of the problem: I have target binary sequences constructed to have particular sequential properties. I have had each sequence in a separate file, from which one file is randomly selected per participant and neatly used to sequentially assign the target items per trial. That works well enough online as via python.

Trouble is, there are over 100 such files, and separate ones again for practice and buffer trials. When run online (and given how I’ve translated the python to JS), all of these files get downloaded via the browser, which can take a few minutes. To avoid that, I’ve tried rewriting to have only one file for formal trials, another for practice, etc., with the candidate sequences now each filling a column. These few files download quite quickly. So now I make a random selection of column. But this creates the problem of how to assign this column for trial handling in the same way as previously; when setting this as a separate conditions file. So a column is headed with a number, I randomly select one of these numbers, but now I need to assign that as column as a variable that is then used to set the items trial-by-trial.

I’ve left the script in this state, somewhat broken, in trying to do that. I’m no longer confident that more investigation in going down this route is going to get me out of this problem. Perhaps someone can suggest a more intelligent way of doing this altogether–perhaps identical to the standard (?) way of setting a conditions file by variable, while keeping these candidate files outside of the downloaded resources or otherwise, to avoid the big download?

Thank you for any assistance you can provide.I suppose this question might generalise to questions others might have about selecting a sample of images per P from a large pool, etc…

I don’t think there is a way to achieve what you’re asking for. JavaScript only runs on the participant’s computer so, by the time it runs, we’ve had to decide which files to send.
At present the decision of which files to send is the first thing to be done. Potentially we’ll change that but it will take some thinking about how to handle it

Thank you. I gather it’s not possible to make the decision about which file to send, and then pick it out from a folder sitting above where the script is, seeing these contents are uploaded as well to pavlovia (when “syncing”), but (it seems) not automatically downloaded by client. Well, tried it: “unknown resource”. Found information about server-side javascript (in trying to find out how to get a list of files in folder), but too many unknowns. Will think about an alternative to selecting participant conditions from a pool of possibilities sitting on the server, as if on the desktop. All fun. Thanks for your feedback.

If you’re using the html folder for outputting the experiment then it duplicates the blocks/conditions files into a resources folder but only the ones that it can detect as being needed. If you’re selecting that files using code then PsychoPy can’t auto-detect it. Easiest thing then is to copy your conditions file into the html/resources folder and it should be automatically downloaded to the users’ machine ready for selection

Thank you, I appreciate that. The challenge I had was to avoid all the 100+ files in the resources folder being automatically downloaded to the user’s machine, as soon as the page loads, because this takes some minutes. I gather that’s not possible, and I’ll try not to sample conditions from a large pool.

A neat idea about how to handle this after all from @wakecarter’s code components sheet: Just name the files with respect to some given experiment variable per participant and use psychoJS.downloadResources to selectively get them; rather than adding them all upfront in settings as resources:

1 Like