Skip to content

rules

Experiments Surveys & forms

rules holds block-selection expressions that run once at experiment start and rewrite the initial trial order: randomly keep a subset of the blocks defined by the block column, optionally shuffling the kept blocks’ order. Use it for “show each participant k of N counterbalanced blocks” designs. Exactly two expressions are recognized: block.sample(...) and block.select(...). Anything else is silently ignored.

Put a single expression in one cell, for example block.sample(A, B, C, 2) to keep 2 of the blocks A, B, C in random order.

block.sample(<blockId>, <blockId>[, <blockId>...], <count>)
block.select(<blockId>, <blockId>[, <blockId>...], <count>)
  • List at least one block identifier, then the count as the final argument.
  • Identifiers may contain letters, digits and underscores only; spaces around the commas are fine.
  • The count must be a plain whole number (no sign, no decimals).
  • The cell may sit on any row; a rule applies to the whole experiment, not just its own row. Every non-empty rules cell is collected in row order and applied in that order.
ExpressionEffect
block.sample(b1,...,bN, k)Randomly pick k distinct entries from the listed identifiers without replacement. Trials of listed-but-unpicked blocks are removed; the picked blocks are re-inserted, in the random order they were sampled, into the position slots the picked blocks occupied; trials whose block value is not listed are untouched. Net effect: keep k of the listed blocks AND shuffle their relative order.
block.select(b1,...,bN, k)Randomly pick k of the listed identifiers, keep their trials in the original file order, and remove trials of the other listed blocks; unlisted trials untouched. Net effect: keep k of the listed blocks WITHOUT reordering.
anything elseSilently ignored; the trial order is left unchanged.

If the column is absent, or every rules cell is left blank, the trial order is simply left as-is. Empty and whitespace-only cells are skipped; only cells containing an expression have any effect.

  • block: supplies the identifiers a rule refers to; matching against each trial’s block value is exact and case-sensitive.
  • Ordering: rules run on the initial file order, before random/randomBlock shuffling and before randomPick. The kept trials then go through the normal randomization.
  • repeat / wildcards: rules are collected after rows are expanded, so a rule sitting on a row with repeat=3 is collected and executed 3 times (see Tips & gotchas).
  • Results: the rules cell value is written into the raw results CSV like any other recognized column.

Show 2 of 3 blocks in random order:

typestimFormatblockrulesstim1presTime
test.jpgAblock.sample(A, B, C, 2)a11000
test.jpgAa21000
test.jpgBb11000
test.jpgBb21000
test.jpgCc11000
test.jpgCc21000

Result: exactly two of A/B/C survive, their block order is random, each block’s internal trial order is preserved (until random/randomBlock apply).

Show 1 of 2 blocks, keeping file order (no shuffle):

typestimFormatblockrulesstim1
test.jpgversion1block.select(version1, version2, 1)v1_1
test.jpgversion1v1_2
test.jpgversion2v2_1
test.jpgversion2v2_2
  • All failure modes are silent: a bad function name, a malformed argument list, an identifier with characters other than letters, digits or underscores, or a count with a sign or decimal point all make the rule do nothing, with no warning.
  • If one cell somehow contains both a block.sample(...) and a block.select(...) expression, only the block.select one applies.
  • A count larger than the number of listed identifiers behaves the same as a count equal to the number listed: every listed block is kept (and block.sample still shuffles their order).
  • Do not list the same identifier twice: a duplicate can be picked twice, wasting a pick, and you end up with fewer distinct blocks than the count.
  • There is no pick:2 syntax; the two block.* forms above are the only ones.

rules appears in these worked recipes:

  • Pick a subset of blocks: Give each participant a random two of three self-contained tasks, each opening with its own instructions screen.