Skip to content

feat: multimodal BCI pipeline with real PhysioNet EDF validation#2

Open
zubyul wants to merge 5 commits intomainfrom
feat/bci-multimodal-pipeline
Open

feat: multimodal BCI pipeline with real PhysioNet EDF validation#2
zubyul wants to merge 5 commits intomainfrom
feat/bci-multimodal-pipeline

Conversation

@zubyul
Copy link

@zubyul zubyul commented Mar 7, 2026

Summary

  • 8 new Zig modules for brain-computer interface signal processing: DSI-24 EEG parser, fNIRS Modified Beer-Lambert Law, IVT eye tracking, LSL multi-modal sync, pose bridge, EDF writer, EDF reader, and end-to-end integration tests
  • Real-data validation against PhysioNet EEG Motor Movement/Imagery Dataset (65-channel, 160Hz BCI2000 recording, 1.2MB EDF+ file)
  • GF(3) conservation verified across all module boundaries: eeg(0) + fnirs(+1) + eye(-1) ≡ 0 (mod 3)

New Modules

Module LOC Purpose
dsi24_parser 318 Wearable Sensing DSI-24 24ch dry EEG packet parsing
fnirs_processor 442 Modified Beer-Lambert Law: raw optical → HbO/HbR/HbT
eyetracking 1442 IVT fixation/saccade classifier with pupillometry
lsl_inlet 1020 Lab Streaming Layer C FFI + software-only fallback
pose_bridge 301 Body tracking joint angles → movement trit
edf_writer 427 EDF+ format writer for EEG archival
edf_reader 334 EDF/EDF+ parser (validated against PhysioNet BCI2000)
bci_integration_test 343 11 end-to-end tests across all modalities

Test Fixtures

  • src/testdata/fixture_2ch.edf — 800-byte synthetic 2-channel EDF for embedded tests
  • testdata/S001R01.edf — downloaded at test time from PhysioNet (1.2MB, gitignored)
    curl -sL -o testdata/S001R01.edf \
      "https://physionet.org/files/eegmmidb/1.0.0/S001/S001R01.edf"

Test plan

  • zig build test-bci — all 11 integration tests + per-module unit tests pass
  • EDF writer→reader round-trip validates sample-level accuracy
  • Real PhysioNet 65-channel file parsed and validated (channel count, sample rate, sample values, physical units)
  • GF(3) trit conservation across fnirs/eye/bci module boundaries
  • CI: download PhysioNet fixture and run full validation

🤖 Generated with Claude Code

zubyul and others added 5 commits March 7, 2026 15:39
Add 8 Zig modules for brain-computer interface signal processing:
- dsi24_parser: Wearable Sensing DSI-24 24ch dry EEG packet parsing
- fnirs_processor: Modified Beer-Lambert Law (HbO/HbR/HbT from raw optical)
- eyetracking: IVT fixation/saccade classifier with pupillometry
- lsl_inlet: Lab Streaming Layer multi-modal temporal synchronization
- pose_bridge: Body tracking joint angles → movement trit classification
- edf_writer: EDF+ format writer for EEG archival
- edf_reader: EDF/EDF+ parser validated against PhysioNet BCI2000 data
- bci_integration_test: 11 end-to-end tests across all modalities

Real-data validation using PhysioNet EEG Motor Movement/Imagery Dataset
(S001R01.edf, 65ch, 160Hz, BCI2000). GF(3) conservation verified:
eeg(0) + fnirs(+1) + eye(-1) = 0 mod 3 across all module boundaries.

Python tools for LSL bridging, fNIRS mBLL, SNIRF/XDF export included.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
EDF reader now validates against 4 real-world EDF files:
- fixture_2ch.edf (synthetic, 800B)
- subsecond_starttime.edf (MNE testing, 4ch EDF+C, 17KB)
- test_utf8_annotations.edf (MNE testing, 12ch synthetic waveforms, 48KB)
- S001R01.edf (PhysioNet BCI2000, 65ch, 1.2MB, downloaded at test time)

Additional format samples for future parsers:
- minimal.xdf (XDF reference, 2 LSL streams, 2KB)
- minimum_example.snirf (fNIRS HDF5, 14KB)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Connect fft_bands and propagator modules to integration tests.
Test 12: EEG -> FFT -> BandPowers -> Cell -> neurofeedback_gate -> action.
Test 13: Multi-modal lattice fusion with contradiction detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Zero-allocation multi-channel EEG classifier using ensemble averaging
of spatially multiplexed reservoir states. Comptime-parameterized for
DSI-24 (21ch), Cyton (8ch), and arbitrary channel counts.

Features:
- Heuristic weight init (works without training)
- Uniform and entropy-weighted ensemble modes
- Propagator cell integration via CellValue
- Ring buffer for temporal smoothing (majority vote)
- 9 unit tests + 2 integration tests (14-15)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Normalized LMS weight adaptation makes learning rate independent of
feature scale (critical for FFT-derived band powers). Adds adapt() and
adaptFromBandPowers() to ERC, plus 3 unit tests and 1 integration test
(Test 16: zero-weight ERC learns correct trit classification from
synthetic EEG → FFT pipeline in 200 epochs).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant