Skip to content

Side-by-side comparison

Show two images left and right of centre and let the participant click their choice, scored correctly whichever side the target lands on.

Two-alternative forced choice with images: the participant sees a pair and clicks the one matching some criterion. The naive layout, two stimuli in the default centred row, works but leaves the target on a predictable side, and scoring by screen position breaks the moment you shuffle. This setup positions the pair explicitly, randomises which side the target appears on, and scores by stimulus identity so the shuffle never touches the scoring. Reach for buttons instead when the choice is a judgement about a single stimulus rather than a click on one of two.

typecontentstimFormatstim1stim2stimPosstimOptionskeybutton1
instructionsTwo photos appear side by side. Click the one taken during the day.NEXT
test.jpgday1night1-250 0;250 0randomstim1
test.jpgday2night2-250 0;250 0randomstim1
test.jpgday3night3-250 0;250 0randomstim1
test.jpgday4night4-250 0;250 0randomstim1

Each test row loads two images: stim1 is always the daytime target, stim2 the night-time foil, with the .jpg extension supplied by stimFormat.

stimPos places them: one segment per stimulus, semicolon-separated, each an X Y pixel offset from the canvas centre. -250 0 puts the first display slot 250 px left of centre, 250 0 puts the second 250 px right. On image trials the offsets scale with the participant’s screen size, so the arrangement holds across devices. Always start the cell with a real position: a leading empty segment leaves the first stimulus in the automatic layout, uncentred against its positioned partner.

stimOptions: random shuffles which stimulus occupies each positioned slot. Positions belong to the slots, not the stimuli, so the layout stays put while the target lands left or right at random on every presentation. The order actually shown is saved per trial in the stimOrder_actual results column.

Clicking is the response without any column asking for it: on test trials with both keyboard and button1 empty, the images themselves become clickable. A click records the stimulus number as the response and ends the trial; the clicked file’s name is saved separately as responseText but is not used for scoring.

key: stim1 is what makes the shuffle safe. A stimulus-based key follows the stimulus through stimOptions: random, so clicking the daytime photo scores correct (correct = 1) wherever it appears. Scoring by position (key: 1) would instead mark “clicked whatever was loaded first”, which is exactly the bug this recipe avoids.

With no presTime, both photos stay up until the click, and the response window opens when they appear, so RT is time from pair onset to choice.

  • Add a deadline with responseWindow set to 3000; no click within 3 s records timeout and auto-advances.
  • Limit exposure with presTime set to 1500; the pair disappears after 1.5 s while clicks stay open, separating perception from decision.
  • Widen the gap by increasing the offsets in stimPos, or stack the pair vertically with 0 -200;0 200.
  • Jitter the exact positions per presentation with intervals in stimPos, for example -300_-200 0;200_300 0; the resolved offsets are saved in stimPos_actual.