Randomizing stimlus to display only a subset of a larger overall list

Hi all, I’m trying to run a memory experiment on pavlovia where, in a first trial, participants are presented with 5 random images, and are then asked, in a subsequent larger trial, to identify any image they recognize. I have a list of 24 images but only want to display 5 at random for the first trial. I do not want the same 5 images for all participants, but rather I want to display 5 random images from the original list of 24 - giving each participant a slightly different combination.
I was able to make this work in the builder using code components (main component attached), however, in order to do so, I used the python modules ‘random’ and ‘xlrd’. This is problematic because I can no longer link my experiment online.

Is there any way I can do achieve this using javascript, or anything transferable to pavlovia?

Any help would be much appreciated, thank you.


What I do is shuffle a list and then use the first few elements.

Have a look at my crib sheet (see pinned post in the online category) for how to define shuffle and use code_JS

1 Like