Don't Repeat Identity Consecutively

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2023.2.3
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?:

In my Builder experiment I have a loop in which the conditions variable is set to $selected_set. $selected_set denotes one of three possible Excel files which had been randomly selected when initialising the experiment in a previous routine (i.e. participants can be allocated to one of 3 different blocks of trials).

In my experiment, I want to play videos to participants. Therefore, in each spreadsheet, the column “target” links to an mp4 filename (e.g. M1A1-N.mp4) which is then called by the Movie file variable of the movie component:

The spreadsheet also contains additional information about each video in other columns. For example, the column named “Identity” specifies the identity of the target (e.g. M1). In my stimuli, I have 12 different identities across 108 trials (9 trials per identity). An example of one of the spreadsheets is attached and screenshotted below:

Block 1 Videos.xlsx (24.0 KB)

What code could I use to allow me to ensure that the same identity (e.g. M1) is never presented twice in a row? I presume that this would need to go in a code component within the routine in which the mp4 files are presented, which is called “face_video_presentation”.

What did you try to make it work?:

Nothing yet. ChatGPT suggested an option but it doesn’t look like it understood properly.

Have a look at my Randomisation without repetition and Complex randomisation online demos

Thank you so much for these resources! However, I’m still unsure about how these examples can be applied to my experiment given that the conditions file is selected by a code component rather than specifically within the conditions variable of the loop? I am unsure about how to index into the “identity” column of the spreadsheet such that I can manipulate it so that no two identities are the same?