Adapted from the Stanford VISTA lab's vistadisp/toon_ret retinotopy code.
Questions/comments: sakbiyik@stanford.edu
Retinotopy stimulus for pRF mapping: a bar sweeps through 8 directions across the visual field, filled with randomly-selected colorful cartoons.
Subject's task: fixate and press a button when the fixation dot changes color. The visual angle covered isn't fixed, since it depends on stimSize together with each display's calibration (see "Display setup" below), so the same code can present a small or wide aperture depending on what the screen/distance can actually support.
- In MATLAB:
cdinto this folder, runret. - A parameter window opens, pre-filled with defaults. The only thing you normally need to set is Display calibration (pick the display you're actually using, e.g.
CNIProjector). Click Go. - Enter Subject ID and Run number at the MATLAB prompt.
- A list of input devices prints, then you're asked which device number is the subject's button box. This matters: trigger detection listens on every device (safe, since the trigger is a specific keycode), but button responses only come from whatever device you pick here. If you skip this and the experimenter types on the laptop mid-run, that keystroke would otherwise be recorded as a subject response.
- Screen opens and shows a welcome message. Press space when you and the subject are ready. This step exists because hitting scan on our scanner starts a prescan period that sends its own trigger pulses; the code only starts listening for the real trigger after you press space, so those prescan pulses can't accidentally start the experiment early. If your scanner doesn't send trigger pulses during its own prescan, you likely don't need this particular safeguard. Once space is pressed, matlab waits for the actual scanner trigger (or a keypress, if "No trigger" was selected) to begin. Press
qat any time to abort early; data collected so far is still saved.
- 8 bars with blanks: a bar sweeps across the screen in 8 directions (with a blank/rest period after every 2 sweeps)
- Aperture: 24° diameter (12° radius) by default, set by
stimSizeinexperiment/retCreateDefaultGUIParams.mand capped by how much of that a given screen can physically show at its calibrated distance. - One run = 204 s (3.4 min): 12 s prescan/baseline plus 192 s of bar sweeps, at TR = 2 s (102 TRs total). This must match your actual scanner acquisition length. The default version of this script has a dummy countdown period of 8 seconds on top of this.
Each display needs a folder in displays/<Name>/displayParams.m with values measured directly, not estimated:
numPixels: the real drawable canvas (confirm via an actualScreen('OpenWindow'))dimensions: physical screen width × height in cm, measured with a ruler at the display surface.distance: eye-to-screen distance in cm. For a mirror/projector setup, measure the full eye→mirror→screen path.
Get any of these wrong and the stimulus is the wrong size or shape on screen. There's no way to detect this from the data afterward, so it's worth double-checking before a real session.
Each run saves to data/<subjectID>_<timestamp>_run<NN>.mat, including:
params,stimulus,t0,scanTiming,timing,quitProgresponse: per-frame button presses (keyCode/secs) and actual flip timestamps (flip/missed), from the button box only (see device selection above)score: overall fixation-task percentagefixationEvents: one entry per fixation-color change (either direction), with whether it was detected and the response latency if so. Use this instead of re-deriving change events fromstimulus.fixSeqby hand for any custom scoring/analysis.stimulus.imageNames: whichpicNN.jpg(or'blank') was shown at each image slot; combine withstimulus.seq(imageNames{seq(t)}) to get what the subject saw at framet. Cartoons are chosen randomly per run with no fixed seed.
toon_prfRun.m needs a matching pair of files for the actual display/session used:
stimuli/8bars_images_<Display>.matandstimuli/8bars_params_<Display>.mat(generate offline viamakeImages.m, or regenerate to match whateverstimSize/display was actually used).params.fliprotate(intoon_prfRun.m) must match how that specific images/params pair was generated:- Up/down (2nd element): our generator saves images "right side up" for on-screen display, which vistasoft's analysis grid reads upside-down unless
fliprotate(2) = 1. - Left/right (1st element): only relevant if there's a mirror in the optical path (e.g.
CNIProjector) that isn't compensated for in real time (displayParams.m'sflipLR).makeImages.malready bakes the flip into8bars_images_CNIProjector.matfor this reason, sofliprotate(1)should stay0for that display. - In short:
fliprotate = [0, 1, 0]for anything generated by this codebase'sCNIProjectorfiles as they currently stand.
- Up/down (2nd element): our generator saves images "right side up" for on-screen display, which vistasoft's analysis grid reads upside-down unless
toon_init.m'sclip/keepmust match your real acquisition (frames to drop from the start / frames to keep). For 102 volumes at TR=2s with a 12s prescan, that'sclip=6, keep=96.
