Pseudo randomisation with multiple constraints

Hi all,

I’m creating a mental rotation task with 96 trials, presented in 2 blocks of 48 trials. The stimuli consist of images displaying two 3D objects. There are 48 ‘same trials’ (where the two objects are the same) and 48 ‘different trials’ (where the object on the right is a pseudo-mirror image of the object on the left). The object on the right is rotated at one of four different angular disparities: 0 degrees, 50 degrees, 100 degrees, and 150 degrees. Participants respond by pressing ‘b’ if they believe the two objects are the same or ‘n’ if they believe the two objects are different.

Trial order needs to be randomised within these 3 constraints:

  1. Each block needs to contain 24 same trials and 24 different trials
  2. The four angular disparities must occur equally often within each block (i.e. 12 presentations of each angular disparity per block)
  3. No more than 3 consecutive same/different trials can occur

I have attached the excel file containing the images and all the conditions. I know I will need to add code components to my Builder task, but I’m new to using PsychoPy so I have no idea where to begin. Any help is much appreciated!

experimental_stimuli.xlsx (10.9 KB)