Create constraints for randomization based on sequence of trials

Hello,

I am trying to design a simple task-switching experiment. In my design I have three tasks: a shape discrimination task (herein task A), a color discrimination task (task B) and an orientation discrimination task (task C). On each trial participants are presented with 1 of 6 possible stimuli. The stimuli are colored geometrical shapes presented at different orientation: therefore, each task can be performed on each stimulus.
I am interested in sequential effects of task switching. Therefore I want to compare task sequences in which a task repeat after an initial switch (e.g. ABA) with sequences in which the task always changes (e.g. CBA). So for instance, let’s say that on the first trial I ask participants to perform task A, then B, then C, then B…and so on… I end up with a ABC sequence followed by a BCB sequence. The last trial of the sequence (3rd and 4th trials of the experiment in this example), will be referred to as a repeat trial or switch trial according to the identity of the 2 previous trials.

When creating my experiment I would like to apply several randomization constraints:

  1. the task should never repeat in two consecutive trials
  2. each task must be present the same number of times in each block
  3. each stimulus must be present the same number of times for each task
  4. the repetition sequences (e.g. ABA) and the switch sequences (e.g. CBA) must be present for the same number of times for each task, and for each stimulus
  5. stimuli should never repeat in a sequence (i.e. stimuli must never repeat in the next 2 trials).

I have no clue on how I can do this: I have tried to assign a number to each stimulus(6)Xsequence(2)Xtask(3) element, and then shuffle it using a brute force approach (repeat the random shuffle until there is no repetition of any number). The problem with it is that it is too demanding for psychopy.

Any suggestions?

Hi @thewall79, to help with your task randomisation, you can use the following structure

image

This nested loop structure allows the outer loop nRepController to control the presentation of your inner loops loopA and loopB. The presentation of the inner loops is controlled by setting the nReps to 0 (skip routine) or 1 (present routine 1 time). The nRepController has a conditions file with columns for feeding values in to the inner loops e.g., nRepsA and nRepsB which each contain values of either 0 or 1 depending on whether you want that routine displayed for that iteration. Each row in the nRepController conditions file thus presents only 1 of your tasks, so if you want both tasks displayed, you would have 2 rows. Each inner loop dialog should be opened, and in each loop, set the nRep value to the nRep value from the nRepController conditions file i.e., set loopA nreps to nRepsA. The order of the tasks (or inner loops and routines) is controlled by the outer loop, selecting either random or sequential for respective order.

Example of nRepController conditions file: nRepControls.xlsx (7.8 KB)