Expand description
§exg-luna — LUNA seizure-detection EEG preprocessing pipeline
Part of the exg workspace.
Uses exg DSP primitives (filter design, resampling, montage conversion)
under the hood.
§Pipeline
Implements the full preprocessing chain used by the LUNA seizure detection model, matching the Python training pipeline:
- Channel rename (strip
"EEG "prefix,"-REF"/"-LE"suffix) - Pick standard 10-20 channels (21 electrodes)
- Bandpass filter 0.1–75 Hz (zero-phase FIR, MNE
_firwin_designparity) - Notch filter at 60 Hz (configurable for 50 Hz)
- Resample to 256 Hz (FFT polyphase)
- TCP bipolar montage (22 channels from 21 reference electrodes)
- Epoch into 5 s non-overlapping windows (1280 samples)
Note: Channel-wise z-score is not applied here — LUNA does that at
inference time inside the model. Use
exg::normalize::zscore_channelwise_inplace separately if needed.
§I/O
This crate also provides safetensors serialization of preprocessed epochs
in a format compatible with luna-rs InputBatch.
§Quick start
ⓘ
use exg::edf::open_raw_edf;
use exg_luna::{preprocess_luna, LunaPipelineConfig};
let raw = open_raw_edf("recording.edf").unwrap();
let data = raw.read_all_data().unwrap();
let ch_names = raw.channel_names();
let cfg = LunaPipelineConfig::default();
let epochs = preprocess_luna(data, &ch_names, raw.header.sample_rate, &cfg).unwrap();Structs§
- Luna
Epoch - A single epoch ready for LUNA inference.
- Luna
Pipeline Config - Configuration for the LUNA preprocessing pipeline.
Constants§
- STANDARD_
10_ 20 - The standard 21 electrodes of the 10-20 system used by TUH/LUNA.
Functions§
- export_
luna_ epochs - Export LUNA-format epochs to a safetensors file.
- load_
luna_ epochs - Load LUNA-format epochs from a safetensors file.
- preprocess_
luna - Run the LUNA preprocessing pipeline on a continuous recording.