npx claudepluginhub plurigrid/asi --plugin asiThis skill uses the workspace's default tool permissions.
Multimodal brain-computer interface pipeline for zig-syrup. Parses, processes, and classifies signals from EEG, fNIRS, eye tracking, and body pose modalities with GF(3) trit conservation.
Provides parametric OpenSCAD models for BCI hardware including electrode holders, paste adapters, headset hooks, pogo combs, fNIRS housings, and eurorack frames. Use for designing, modifying, or 3D-printing neuromodulation components.
Processes physiological signals including ECG, EEG, EDA, PPG, EMG, EOG for HRV analysis, complexity measures, and psychophysiology research using NeuroKit2.
Processes neurophysiological signals: ECG (HR/HRV/R-peaks), EEG (complexity/PSD), EMG (onset), EDA (SCR), PPG, RSP; simulates data. Python API returns pandas DataFrames for biosignal analysis.
Share bugs, ideas, or general feedback.
Multimodal brain-computer interface pipeline for zig-syrup. Parses, processes, and classifies signals from EEG, fNIRS, eye tracking, and body pose modalities with GF(3) trit conservation.
| Module | File | Trit | Purpose |
|---|---|---|---|
dsi24_parser | src/dsi24_parser.zig | 0 | Wearable Sensing DSI-24 24ch dry EEG (84-byte packets, ADS1299, 300Hz) |
fnirs_processor | src/fnirs_processor.zig | +1 | Modified Beer-Lambert Law: raw optical → HbO/HbR/HbT concentrations |
eyetracking | src/eyetracking.zig | -1 | IVT fixation/saccade classifier, pupillometry, blink detection |
lsl_inlet | src/lsl_inlet.zig | 0 | Lab Streaming Layer C FFI + software-only fallback, StreamSynchronizer |
pose_bridge | src/pose_bridge.zig | 0 | Body tracking joint angles → movement trit (tremor detection) |
edf_writer | src/edf_writer.zig | 0 | EDF+ format writer for EEG archival (MNE/EEGLAB compatible) |
edf_reader | src/edf_reader.zig | 0 | EDF/EDF+ parser validated against PhysioNet BCI2000 (65ch, 160Hz) |
bci_receiver | src/bci_receiver.zig | 0 | Universal 9-modality receiver (nRF5340 target) |
erc | src/erc.zig | 0 | Ensemble Reservoir Computing: ensemble averaging, NLMS online learning → trit |
fft_bands | src/fft_bands.zig | 0 | Comptime-memoized FFT, Welch PSD, EEG band extraction |
eeg(0) + fnirs(+1) + eye(-1) = 0 mod 3 ✓
Verified across module boundaries in bci_integration_test.zig (16 tests).
# Run all BCI tests
zig build test-bci
# With real PhysioNet data (downloads 1.2MB EDF)
curl -sL -o testdata/S001R01.edf \
"https://physionet.org/files/eegmmidb/1.0.0/S001/S001R01.edf"
zig build test-bci
| File | Size | Source | Tests |
|---|---|---|---|
src/testdata/fixture_2ch.edf | 800B | Synthetic | EDF round-trip, basic parsing |
src/testdata/subsecond_starttime.edf | 17KB | MNE testing | 4ch EDF+C, subsecond timestamps |
src/testdata/test_utf8_annotations.edf | 48KB | MNE testing | 12ch synthetic waveforms |
testdata/S001R01.edf | 1.2MB | PhysioNet BCI2000 | 65ch real EEG (gitignored) |
testdata/minimal.xdf | 2KB | xdf-modules | XDF reference (2 LSL streams) |
testdata/minimum_example.snirf | 14KB | fNIRS/snirf-samples | SNIRF HDF5 reference |
const sample = try dsi24.parseDSI24Packet(&packet_84bytes);
// sample.eeg_channels[0..21] — µV values
// sample.aux_channels[0..3]
// sample.sample_counter, .timestamp_us
const config = fnirs.WavelengthPair.plux(); // 660/860nm, DPF 6.51/5.60
const hemo = fnirs.beerLambert(delta_od1, delta_od2, config);
// hemo.hbo, .hbr, .hbt — µmol/L concentration changes
const reading = fnirs.FNIRSReading.fromConcentration(hemo, timestamp_ms, threshold);
// reading.trit — .plus (activation), .zero (baseline), .minus (deactivation)
const result = eye.classifyIVT(current_gaze, prev_gaze, .{});
// result.event — .fixation, .saccade, .blink
// result.velocity — degrees/second
// result.event.toTrit() — .zero (fixation), .plus (saccade), .minus (blink)
const edf = try edf_reader.EDFFile.parse(file_bytes);
// edf.n_channels, .n_records, .record_duration
// edf.channels[i].labelStr(), .unitStr(), .samples_per_record
const digital = try edf.getSample(record, channel, sample_idx);
const physical_uv = edf.toPhysical(channel, digital);
var reservoir = erc.Cyton.init(.entropy_weighted);
const result = reservoir.processFromBandPowers(all_bands);
// result.trit, .confidence, .logits[3], .ensemble_entropy
// Online adaptation (NLMS — learning rate independent of feature scale)
const config = erc.LearningConfig{ .learning_rate = 0.5 };
const mse = reservoir.adaptFromBandPowers(all_bands, .plus, config);
// mse → convergence monitor; weights adapt to real EEG data
// Propagator integration
const cv = reservoir.toCellValue(); // → CellValue(f32)
var sync = lsl.StreamSynchronizer.init();
const eeg_id = try sync.addStream(.{ .stream_type = .eeg, .nominal_rate = 300.0, ... });
// StreamType.trit(): eeg→0, fnirs→+1, eye_tracking→-1
| SDF Chapter | Score | Evidence |
|---|---|---|
| Ch1 Combinators (+1) | ★★★ | Composable parse→scale→classify pipeline |
| Ch2 DSL (-1) | ★★☆ | DSI-24 packet DSL, EDF header grammar |
| Ch3 Generic Arithmetic (0) | ★★☆ | Trit type generic across all modalities |
| Ch4 Pattern Matching (+1) | ★★★ | Packet type dispatch, IVT event classification |
| Ch6 Layering (+1) | ★★☆ | Physical/digital layers in EDF, metadata in LSL |
| Ch7 Propagators (0) | ★★★ | Full EEG→FFT→Cell→neurofeedback_gate pipeline, lattice contradiction detection |
| Ch8 Degeneracy (-1) | ★★★ | LSL software fallback, pose threshold redundancy |
New modalities added without modifying existing modules. Each sensor is a SensorConfig struct registered in UniversalReceiver.init().
Three clear layers: acquisition (parsers) → processing (mBLL/IVT/FFT) → classification (trit).
Validated on 4x NVIDIA GB10 nodes (aarch64-linux, 128GB unified memory each):
# Install zig on gx10 node
curl -sL -o /tmp/zig.tar.xz 'https://ziglang.org/download/0.15.2/zig-aarch64-linux-0.15.2.tar.xz'
mkdir -p ~/.local && tar xf /tmp/zig.tar.xz -C ~/.local/
ln -sf ~/.local/zig-aarch64-linux-0.15.2/zig ~/.local/bin/zig
# Clone and test
git clone -b feat/bci-multimodal-pipeline https://github.com/plurigrid/zig-syrup.git
cd zig-syrup && zig build test-bci
| Skill | Trit | Relation |
|---|---|---|
sdf | -1 | SDF verification framework |
zig | -1 | Zig ecosystem patterns |
zig-syrup-propagator-interleave | -1 | Propagator network bridge |
reafference-corollary-discharge | +1 | Corollary discharge → neurofeedback gate |
bci-colored-operad | +1 | Operadic composition of BCI channels |
sheaf-cohomology-bci | 0 | Sheaf-theoretic BCI signal fusion |
zig-syrup-bci(0) ⊗ sdf(-1) ⊗ bci-colored-operad(+1) = 0 ✓
zig-syrup-bci(0) ⊗ edf-reader(-1) ⊗ fnirs-processor(+1) = 0 ✓