Python control system for laser scanning photostimulation (LSPS) experiments on in vitro brain
slice preparations. The system steers a laser across a configurable grid of stimulation sites using
galvanometer scanning mirrors, triggers electrophysiology recording sweeps via a Molecular Devices
DigiData digitizer, captures a tissue image at the end of each run, and saves all data to a
.npz file for analysis in Python. A PySide6 GUI provides a live camera feed with a real-time
stimulation-grid overlay and experiment controls.
PC (Python / PySide6)
│
│ USB serial — 115,200 baud
│
Arduino Uno
├── I2C 0x62 ──► MCP4725 DAC ──► X Galvo Mirror ─┐
├── I2C 0x63 ──► MCP4725 DAC ──► Y Galvo Mirror ─┘ (laser positioning)
│
├── Digital pin 16 ──────────────────────────────► DigiData "Start Sweep" trigger
└── Digital pin 17 ◄────────────────────────────── DigiData "Recording Done"
PC (OpenCV)
│
└── USB / frame-grabber ────────────────────────► Camera (e.g. Dage-MTI IR-1000)
The Arduino positions the laser by writing 12-bit DAC values to two Adafruit MCP4725 boards over I2C. A rising-then-falling edge on pin 16 triggers a DigiData recording sweep; the Arduino polls pin 17 and waits for the DigiData to signal completion before moving to the next site.
Install the package and launch the GUI:
uv sync
uv run lspsuv sync --group devThis installs all runtime dependencies plus the dev tools (pytest, pytest-cov, ruff).
uv run pytest --cov=src/lsps --cov-report=term-missinguv run ruff format src/ tests/ # auto-format
uv run ruff check src/ tests/ # lintTo auto-fix lint issues flagged as safe to fix automatically:
uv run ruff check --fix src/ tests/This project is licensed under the GNU General Public License v3.0 or later.
See LICENSE for the full text.