Skip to content

Trial Sequencing

The trialOrder column controls which trials a participant receives and in what order. It replaces ad hoc combinations of the legacy random and randomPick columns with one small language that covers constrained randomisation, sampling, ordered selection, structured shuffles, and reusable orders. Everything runs per participant, and the editor checks every instruction as you type, so an impossible design is caught while you build it, never in front of a participant.

Write a program on one row of a group, and the bare group number on the group’s other rows:

trialOrder = 1: shuffle; maxRun 2 condition
trialOrder = 1
trialOrder = 1

All rows sharing the number form the group. Rows with an empty cell, 0, or na never move. Each numbered group runs its own program independently.

Every word answers one of two questions:

  • Selection, which trials appear: sample, select, groupSample, groupSelect
  • Ordering, where they go: shuffle, the constraints (maxRun, noRepeat, alternate, gap, balance, pattern, first, last, follows, notFollows), structure (groupShuffle, shuffleWithin), and reuse (saveOrder, useOrder)

The selection words always choose at random; they differ only in how the survivors are presented. This table is the heart of the system:

specwhich trials are chosenrest of the grouppresentation
shuffleall stayrandom
sample 5random 5 from the groupdroppedrandom
sample 5 difficultyrandom 5 per value of difficultynon-selected droppedrandom
sample 5 difficulty easyrandom 5 among easy onlyall non-easy trials stayrandom
select ... (same three forms)same choice rules as samplesamefile order
groupSample 2 pair2 random whole unitsother units droppedunit order random, inside each unit file order
groupSelect 2 pair2 random whole unitsother units droppedeverything file order
groupShuffle pairall stayunit order random, inside each unit file order

A memory aid: sample shuffles what it keeps, select keeps your order. The same pair exists at the block level (block.sample and block.select) with the same meanings.

Constraint words describe which random orders are acceptable, so they need randomness to constrain. Add shuffle, or use sample or groupSample, whose meaning already includes it:

trialOrder = 1: shuffle; maxRun 2 condition
trialOrder = 1: sample 10 difficulty; maxRun 1 difficulty
constraintmeaning
maxRun 2 conditionnever more than 2 consecutive trials sharing a condition value
noRepeat itemthe same value never appears twice in a row
alternate difficultystrict alternation between the values
gap 2 4 item2 to 4 other trials sit between two appearances of the same value (gap 2 item means at least 2, no upper limit)
first 2 category fillerthe group opens with 2 filler trials
last 1 category targetthe group closes with a target trial
balance 4 difficultyevery window of 4 trials holds each value in proportion to its share
pattern phase stim stim questionpositions tile a fixed skeleton; * is a free slot
follows category prime category targetevery prime is immediately followed by a target
notFollows condition con condition inca con trial is never immediately followed by an inc trial

first and last also work without any shuffle, pinning trials to the edges of an otherwise file-ordered group.

  • groupShuffle unit moves trials sharing a unit value as one chunk; chunks shuffle, the order inside each stays as in your file. Ideal for yoked pairs (a prime always directly before its own target).
  • shuffleWithin unit is the mirror image: chunks stay put, trials shuffle inside them.
  • saveOrder name remembers a group’s realised order; useOrder name in a later group of the same size replays the same relative order. Ideal for study and test phases that must share a sequence.

Join two columns with * and each combination counts as one condition:

trialOrder = 1: sample 1 valence*arousal
trialOrder = 1: shuffle; maxRun 1 valence*arousal

The first keeps one trial per cell of the design; the second stops the exact combination repeating back to back. Crossing works in sample, select, groupSample, groupSelect, maxRun, noRepeat, and balance.

  • One program per group, on any single row of the group.
  • Structure words cannot combine with constraints, and select/groupSelect cannot combine with anything that would reorder their file-order promise. The editor names any offending pair.
  • A group spanning several randomBlock values, trial types, or timer sections applies its program inside each part separately.
  • The legacy random column keeps working in old experiments but cannot mix with trialOrder in one file. Convert a legacy group 1 to 1: shuffle. Replace randomPick N with sample N.