Randomization of stimulus sequence within participants.
Hi there!
I am new to OpenSesame but I have some experience with using code. I want to set up an experiment that goes as such:
I have a pool of 5 stimuli.
In each trial, I want 3 of those stimuli to be presented.
I want all possible combinations of stimuli to be presented in each run of the experiment. However, in each trial, I want OpenSesame to show the stimuli in random order. So, every participant will see all possible combinations of stimuli, but between participants the combinations should be presented in random order.
Anyone has any idea of how I could do that or at least point me to a direction of search?
Thank you very much in advance, I would appreciate any help!☺️

Comments
Hi @amoupsou,
Not sure I understand your description. "I want all possible combinations of stimuli to be presented in each run of the experiment. However, in each trial, I want OpenSesame to show the stimuli in random order". If you present each combination in a random order, you won't be presentng every combination...
Are you trying to say that you want all possible of three stimuli among a fixed list of five presented to each participant, but that the order of these three stimuli should be random?
Best,
Fabrice.
Hi @Fab , thank you very much for taking the time.
You got it right, it is exactly what I mean!
Hi @amoupsou,
In that case, the solution is fairly simple:
(1) Create a loop and populate it with all the sub-selection of 3 stimuli from your set of 5. One sub-selection of 3 stimuli per row.
Set your loop to run the rows in a random order. Each stimulus should be in its own column (that you for example call "stim1, "stim2" stim3")
(2) to ensure that the stimuli are presented within each trial in a random order, use the shuffle_horiz function in the script of the loop: https://osdoc.cogsci.nl/4.0/manual/structure/loop/#shuffle_horiz. IN the example I set above, you'd have to add the following to the loop's script:
shuffle_horiz stim1 stim3This method will ensure that all combinations of 3 stmuli from your set of 5 is presented once, in a random order, and that the 3 elements inside each combination are presented randomly for each participant.
Hope this helps,
Fabrice.
Hi @Fab , thank you very much for taking the time.
I designed the experimental loop with a loop item. After it, I have entered the sketchpad items that will present each stimulus. I wonder though, if I need to enter a script, should I enter it before the first sketchpad?
Thank you very much for helping out!
Hi @amoupsou,
It all depends what you want that script to achieve. But if you're talking about the loop's script, you need to access the loop's script, not adding a Python script object anywhere.
To access the loop's script, simply go here:
You'll then see the loop's script. Simply add your
shuffle_horizinstruction there.Hope this helps,
Fabrice.
Hi,
I wonder though, if I need to enter a script, should I enter it before the first sketchpad?
Is this question independent of your previous question? The solution that @Fab described does not require an inline_script item. You have to directly write the combinations into the loop table (`experimental loop`) and add the
shuffle_horizto the script of theexperimentalloopscript. You can find it by clicking on the little icon with the two sliders in the top right corner:and select `view script` there. Once there, you can copy the command in there, and save it.
Does this make sense?
Eduard
edit: Guess Fab was quicker ;)
@Fab @eduard thank you both very much, it worked!