An open-source, high-precision visual stimulation platform designed for visual neuroscience, sensory physiology, and human psychophysics. The system delivers temporally agile, multi-chromatic optical stimulation (e.g., Green for M-cones/rods and UV for S-cones, or custom multi-spectral arrays) with sub-millisecond precision.
LEDstim_antiphase_2hz.MOV
Example stimulus: 2 Hz antiphase (Green / UV) sinusoidal flicker.
- High-Resolution Temporal Modulation: 16-bit Phase-Correct carrier PWM (~7.68–10 kHz) combined with hardware-interrupt pacing (Timer3 CTC ISR) eliminates visible digital stepping and software loop jitter.
- Rich Stimulus Battery: Native microsecond-timed generation of sinusoidal flickers, Gaussian white noise (with Central Limit Theorem PRNG), contrast-switching adaptation sequences, exponential frequency chirps, and stepped luminance pulses.
-
Quantitative Radiometric Calibration: End-to-end MATLAB calibration pipeline mapping raw duty cycles to linearized lookup tables (LUTs) and calculating exact photoreceptor isomerisation rates (
$R^*/\text{photoreceptor/s}$ ). - Flexible Form Factors: Supports both 200mm full-field panel enclosures (with magnetic diffusion clamping) and miniature wearable mounts for Pupil Labs Neon eye-tracking glasses.
- Reactive Experiment Orchestration: Full integration with Bonsai for closed-loop, state-dependent, adaptive psychometric staircase, and LabStreamingLayer (LSL) multi-modal recording.
graph LR
subgraph Host Software
Bonsai[Bonsai Reactive Workflows]
LSL[LabStreamingLayer / LabRecorder]
MATLAB[MATLAB Calibration Suite]
end
subgraph Microcontroller Firmware
MCU[Arduino Leonardo / Teensy 4.1]
T1[Timer1: 16-bit PWM]
T3[Timer3: CTC Interrupt Pacing]
LUT[PROGMEM Gamma LUT]
end
subgraph Hardware & Optics
Driver[Multi-Channel Driver Stage]
LEDs[Dual-Channel LED Arrays]
Enclosure[Magnetic Diffusion Enclosure / Glasses]
Sensors[Photodiode / Power Meter / Eye Tracker]
end
Bonsai -- Serial ASCII (115200) --> MCU
MATLAB -. Offline Calibration .-> LUT
MCU --> T1 & T3
T3 --> LUT --> T1
T1 --> Driver --> LEDs --> Enclosure
Enclosure -. Optical Feedback .-> Sensors
Sensors --> LSL
- Open
ArduinoCode/StimulusControlViaSerial_Leonardo_v8/StimulusControlViaSerial_Leonardo_v8.inoin the Arduino IDE. - Select Arduino Leonardo as your board and choose the corresponding COM port.
- Click Upload.
- Connect your LED driver to the designated MCU pins (PWM: Pins 9 & 10; Indicators: Pins 4 & 5).
- Open the Serial Monitor at
115200baud. - Send a test sinusoidal flicker:
(Runs a 3-second, 2 Hz antiphase flicker on Channels A and B at 80% contrast).
s, 3000, 2.0, 0.0, 0.5, 0.8, 0.8
Open Bonsai and load one of the pre-built visual stimulation workflows from BonsaiCode/ (e.g., LEDstimulation_normal.bonsai or ManualMethodOfAdjustment.bonsai).
Comprehensive guides, schematics, and technical specifications are available in the docs/ directory:
├── ArduinoCode/ # Microcontroller firmware (Leonardo v8, DDS, Teensy 4.1, IMU)
├── BonsaiCode/ # Main Bonsai visual reactive workflows & stimulus CSVs
├── BonsaiForHumanExperiments/ # Dedicated human psychophysics Bonsai workflows
├── Calibration/ # MATLAB scripts for radiometry, gamma LUTs & opsin calculations
├── Hardware/ # CAD files (.stp, .stl, .ipt), KiCad PCB designs & driver schematics
│ ├── Enclosure/ # Baseplate CAD & 3D printed magnetic diffusion clamps
│ ├── glasses/ # Pupil Labs Neon glasses boom arm & miniature diffuser
│ ├── LED_board/ # KiCad dual-channel LED array PCB
│ └── LED_board_humans/ # KiCad 3-colour LED array PCB (WIP redesign with layout improvements)
├── HumanExpAnalysis/ # MATLAB scripts for IMU movement and behavioural analysis
├── LabRecorderFiles/ # Multi-modal LabStreamingLayer (LSL) recording configurations
└── docs/ # Modular technical documentation
Developed for scientific research applications. If you use this platform in your research, please cite this repository.