Experiment example (Psychtoolbox): Houses vs faces localizer

Description

A passive visual category localizer for the KIT MEG system with two stimulus classes:

  • faces (20 unique images);

  • houses (20 unique images).

It is the face and house part of the Arabic language localizer, without the Arabic word and nonword trials. The images, timing, fades, triggers, launcher, output format and safety behaviour are the same as in that task; this page lists what is specific to the houses-vs-faces version. The participant looks at the centre of the screen; there are no targets, decisions or response-box events.

Code: experiments/psychtoolbox/houses_vs_faces (start with main.m).

Presentation sequence

After the operator presses SPACE, 0.25 s of trigger-free warm-up frames are followed by the run-start pulse (KIT 228) and a 2 s baseline with a grey fixation cross on black. Each trial then shows one 255 x 255 px image in a centred 500 x 500 px square for 1 s, followed by 1 s of black with the fixation cross.

  • Every image fades in and out with a 0.25 s raised-cosine ramp (30 frames at 120 Hz) while the fixation cross cross-fades the other way. The trigger is on the first (faint) fade frame; the 1 s image duration runs from that frame to the first fully blank frame, fades included. When epoching, remember the image reaches full contrast one fade length after the trigger.

  • Instruction and end texts fade in and out; the window closes on black.

  • Trials are scheduled on a fixed grid from the run-start frame, so timing errors do not accumulate. Timing is measured and logged but never stops a run.

Conditions and randomization

Every image appears once in each pass (40 images per pass), with a separate random order per pass and these constraints:

  • no condition more than three times in a row, including across the pass boundary;

  • the last image of one pass is never the first image of the next.

With the default 2 passes the run has 80 presentations (40 faces, 40 houses, the same number per condition as the Arabic localizer) and lasts 2 min 42 s (0.25 s warm-up + 2 s baseline + 80 x 2 s). Use more passes in the launcher (up to 8) for more trials per run.

Triggers

Single-channel DataPixx pixel mode. Faces and houses keep the same KIT channels and RGB codes as in the Arabic localizer, so both tasks share event IDs. The mapping is defined once in houses_vs_faces_trigger_map.m.

Event

KIT channel

MNE channel

Pixel RGB

When

face

226

MISC 003

[64 0 0]

First fade frame of a face

house

227

MISC 004

[0 1 0]

First fade frame of a house

run_start

228

MISC 005

[0 4 0]

Start of the 2 s baseline

off

none

none

[0 0 0]

Every other frame

Each pulse lasts one 120 Hz refresh (8.33 ms). A completed default run therefore contains 40 pulses on 226, 40 on 227 and one on 228. Pixel mode is enabled only after SPACE and disabled before the end text. Channels 226, 227 and 228 must be wired on the KIT.

Running the experiment

cd experiments/psychtoolbox/houses_vs_faces
main              % opens the launcher (production preset selected)

The launcher has the same layout as the other MEG experiments:

  • Subject, Session, Run: BIDS labels; the run number is set to the next free run, and a run whose files already exist cannot be started.

  • Preset: production (DataPixx, full screen, 120 Hz), full rehearsal (no DataPixx), debug (windowed, 16 images, visible 50 px trigger patch) or visual preview (MATLAB figure, no Psychtoolbox).

  • Run parameters: passes (1 to 8), image duration, blank duration and fade in/out, each with its allowed range.

  • Planned run: the run length, recomputed whenever a value changes, the number of faces and houses with their KIT channels, and the fade length.

  • Checks: what is wrong with the current values; Start stays disabled until every value is valid, and a production start asks for confirmation that the KIT recording is running.

  • Preview stimuli shows one face and one house.

Operator keys: SPACE starts, ESC or Q stops at once and saves the partial data.

Scripted launch and validation:

spec = struct('subject', 'P01', 'session', '01', 'mode', 'debug');
spec.params = struct('nPasses', 1);   % optional overrides
main(spec)                            % run = next free run

main('P01')                   % production, session 01, next free run
main('validate')              % headless asset/schedule/limits self-test

Saved data

The same BIDS layout as the Arabic localizer, with task label housesvsfaces. Production writes to data/; the other presets write to data_rehearsal/ (both Git-ignored):

data/
  dataset_description.json, README
  stimuli/faces/, houses/                   (copied on the first run)
  sub-P01/ses-01/meg/sub-P01_ses-01_task-housesvsfaces_run-01_events.tsv
  sub-P01/ses-01/meg/sub-P01_ses-01_task-housesvsfaces_run-01_events.json
  sub-P01/ses-01/beh/sub-P01_ses-01_task-housesvsfaces_run-01_beh.tsv
  sourcedata/sub-P01/ses-01/beh/<base>_desc-snapshot_beh.mat
  sourcedata/sub-P01/ses-01/beh/<base>_desc-matlabconsole_log.txt
  sourcedata/sub-P01/ses-01/beh/<base>_desc-{initialized,autosave,abort,crash}_*

events.tsv has one row per trigger (run_start, then one face or house row per image shown), with onset and sample left empty / n/a for preprocessing to fill from the recorded triggers, value equal to the KIT channel, and "TriggerMode": "single_channel" in events.json. See the Arabic localizer page for the full column descriptions.

Files

File

Role

main.m

Launcher, run loop, drawing, DataPixx and cleanup.

houses_vs_faces_config.m

Presets, default run parameters and their limits.

houses_vs_faces_check_params.m

Parameter checks and planned run length.

houses_vs_faces_trigger_map.m

Condition names, KIT channels and RGB codes.

build_houses_vs_faces_schedule.m

Constrained randomized passes.

build_houses_vs_faces_events.m, write_houses_vs_faces_events.m

events.tsv table and events.json sidecar.

houses_vs_faces_bids_*.m, houses_vs_faces_next_run.m, houses_vs_faces_format_duration.m

BIDS labels, paths, dataset files, next free run, run-length text.

validate_houses_vs_faces_manifest.m

Checks the 40-image manifest (20 per condition) and every image file.

stimuli/

stimulus_manifest.csv and the face and house images (copied from the Arabic localizer).

self_test.m

Headless test suite (main('validate')).