| Reference | Downloads | Github

Randomise stimuli without repeating presentation in Pavlovia


I am programming a psychological experiment.
In every trial, participants will read a scenario. Next, they will evaluate a set of stimuli which is a combination of a face photo and an answer for the scenario.

Scenarios are 20 sets.
And there are 4 conditions for the set of stimuli. (Happy face-Happy sound, Neutral face-Happy sound, Happy face-Neutral sound, Neutral face-Neutral sound)

Therefore, All trials are 80. (Scenario 20 * Condition 4)

The point is I need to randomize scenario order without repeating stimuli twice in a row.
My problem is that the “random trials” must NOT include consecutive presentations of scenarios.
For example, scenario 1(Happy f-Happy v) → scenario 1(Happy f-Neural v)
Or scenario 1 - 3 - 5 - 6 - 7- 8 - 3 - 4 - 4 - 5 - 10

However, I am very new to psychopy/coding and am not sure of how to do this.
Plus, It’s impossible to move ‘shuffle code in python’ to Pavlovia.
Is anyone able to please help guide me in generating a code that will constrain the randomization process?


I use shuffle in Pavlovia in most of my experiments.

Would it be okay to have something like:

thisCondition = conditions.pop() # takes the last item
if len(conditions) == 0: 
     conditions = fullConditions # reset conditions
     shuffle(conditions) # and shuffle
     while conditions[-1] == thisCondtion: # until the last item isn't the current item