Skip to content
Back to skills

Neuro Stimulus Timing Audit

ASecurity

Measure and correct stimulus presentation timing for EEG/MEG/BCI experiments using a photodiode, microphone or trigger loopback (PsychoPy, Psychtoolbox, Presentation, Unity, web experiments, SSVEP/P300 spellers). Use whenever the user asks how accurate their stimulus timing is, sees jittery or late ERPs, checks frame drops or display latency, or needs to correct event times before epoching.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 13, 2026
ai-agentspythonbash

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 13, 2026

npx -y skills add Hillock-NeuroTech/neurotech-skills --skill neuro-stimulus-timing-audit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Neuro Stimulus Timing Audit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Neuro Stimulus Timing Audit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hillock-neurotech-neuro-stimulus-timing-audit/badge)](https://www.skillsdirectory.com/skills/hillock-neurotech-neuro-stimulus-timing-audit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: neuro-stimulus-timing-audit
description: Measure and correct stimulus presentation timing for EEG/MEG/BCI experiments using a photodiode, microphone or trigger loopback (PsychoPy, Psychtoolbox, Presentation, Unity, web experiments, SSVEP/P300 spellers). Use whenever the user asks how accurate their stimulus timing is, sees jittery or late ERPs, checks frame drops or display latency, or needs to correct event times before epoching.
---

# Stimulus timing audit

The time a script logs a stimulus is not the time light leaves the screen
or sound leaves the speaker. Displays add a fixed lag plus frame-quantised
jitter, and dropped frames add whole frame periods. Measure with a sensor
on the output, recorded on the same amplifier as the brain data.

## 1. Set up the measurement

- Photodiode taped over a small patch in a screen corner that flips white
  with each stimulus; record it on an aux channel of the EEG amplifier.
- Audio: split the audio output into an aux channel or use a microphone.
- Keep the software marker (or TTL) too; the audit compares the two.

## 2. Measure with the bundled script

```bash
python scripts/photodiode_lag.py --sensor aux.npy --fs 1000 --markers marker_samples.npy \
       [--refresh 60] [--window-ms 200] [--polarity rise]
```

It finds the sensor onset after each marker (half-amplitude crossing),
reports lag statistics in ms, missed onsets, and whether lags cluster at
multiples of the frame period (frame drops). `--out corrected.npy` writes
corrected event samples.

## 3. Interpret

| Result | Meaning | Action |
|---|---|---|
| constant lag, small spread (under 1 ms) | display/audio latency only | shift events by the median lag |
| spread about one frame period | marker not synced to the display flip | send marker on flip (PsychoPy `win.callOnFlip`, Psychtoolbox `Screen('Flip')` timestamp) or use sensor onsets as events |
| lags at extra whole frames | dropped frames | reduce load, disable compositor effects, check refresh rate setting |
| missed onsets | stimulus not shown or sensor misplaced | check the log for those trials |

For SSVEP or flicker stimuli also check the actual flicker frequency from
the sensor spectrum, since frame drops shift it.

## 4. Report

Display/audio device, refresh rate, number of events, median lag, spread
(SD and range), frame drops, missed events, and the correction applied.

Files in this skill

  • SKILL.md2.3 KB
  • scripts/photodiode_lag.py3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.