Instructions to use Neuralace-AI/eeg-codec-41ch-120hz with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Neuralace-AI/eeg-codec-41ch-120hz with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Neuralace-AI/eeg-codec-41ch-120hz", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Neuralace-AI/eeg-codec-41ch-120hz", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
EEG Codec 41ch-120Hz
A neural codec for scalp EEG: 66Γ compression that keeps the brain signal. It turns 41-site EEG into discrete tokens at 0.3β4.8 kbps (raw is 78.7 kbps) and decodes them back to microvolts. It is causal, streams at 30 frames/s, has 9.4M parameters, and still works when parts of the cap are missing. It is the input layer of EEG Encoder 41ch-120Hz: compress first, then learn.
Highlights
| Fidelity | Pearson r .972 to the original signal at 4.8 kbps (16Γ compression), .918 at 1.2 kbps (66Γ), on 247 people it never saw |
| Beats classical coding | Higher fidelity than spatial PCA + DCT with entropy coding at the same bitrate, for 221 of 247 unseen people, with no entropy coding of its own |
| Keeps task information | At 1.2 kbps a downstream head scores .537 against .562 on the uncompressed signal. At 0.3 kbps it beats LaBraM and NeuroLM tokens at 0.53 kbps (.503 vs .430 / .475) |
| Fills in missing sites | Reconstructs a hidden 20% scalp region at r = .780, against .558 for spherical-spline interpolation |
| Robust foundation | An encoder built on the codec loses 3Γ less accuracy with 40% of a scalp region missing than the same encoder on raw signal (β.077 vs β.240) |
| Input | [B, 41, T] Β΅V at 120 Hz (EEGFeatureExtractor makes it from any recording) |
| Latent | [B, 256, T/4], 30 frames/s, continuous |
| Codes | [B, n_q, T/4], 16 residual levels Γ 1024 entries (10 bits) |
| Bitrate | 30 frames/s Γ 10 bit Γ n_q = 0.3 kbps (n_q=1) β¦ 4.8 kbps (n_q=16), one model for every rate |
| Parameters | 9.4M (7.3M weights + 2.1M codebook entries) |
Usage
import mne
import torch
from transformers import AutoFeatureExtractor, AutoModel
repo = "Neuralace-AI/eeg-codec-41ch-120hz"
fe = AutoFeatureExtractor.from_pretrained(repo, trust_remote_code=True)
codec = AutoModel.from_pretrained(repo, trust_remote_code=True).eval()
# any recording MNE can read; here PhysioNet EEGMMIDB subject 1, run 4 (downloaded by MNE)
raw = mne.io.read_raw_edf(mne.datasets.eegbci.load_data(1, [4])[0], preload=True)
inputs = fe(raw, return_tensors="pt") # input_values [1, 41, T] Β΅V @ 120 Hz, site_mask [1, 41]
with torch.no_grad():
enc = codec.encode(inputs["input_values"], num_quantizers=8) # 2.4 kbps
codes = enc.eeg_codes # [1, 8, T/4] int64
eeg = codec.decode(codes).eeg_values # [1, 41, T] Β΅V
eeg = codec(inputs["input_values"]).eeg_values # encode + decode, 16 levels
eeg = codec(inputs["input_values"], num_quantizers=0).eeg_values # no quantization: best fidelity
z = codec.get_latent(inputs["input_values"]) # [1, 256, T/4] continuous latent
Other inputs:
- An array:
fe(x_uv, ch_names=[...], sampling_rate=fs), withx_uvas[channels, samples]in microvolts. - Several equal-length windows: pass a list.
- Data already in the 41-site format:
already_preprocessed=True.
What the feature extractor does
This is the exact chain the codec was trained on:
- Keep the EEG channels.
- Notch at 50 and 60 Hz.
- Band-pass 0.1β75 Hz.
- Resample to 120 Hz (MNE defaults).
- Map channels onto the 41 sites by name.
EEG Fp1-REF,FC3.andfc3all match. Caps with fewer than 5 matching names but known electrode positions are spline-interpolated, and BioSemi A1βD32 caps always are. - Leave missing sites at zero. They are reported in
site_mask.
No re-referencing and no per-recording normalization: the model divides by 23.2 Β΅V and clips at Β±8 internally. The 41 sites are
C2 CP2 P2 Pz CPz Cz C1 CP1 P1 P3 PO7 P5 TP7 CP5 CP3 C3 PO8 P6 P4 TP8 CP6 CP4 C6 C4 FC6 FC4 FC2 F6 F4 F2 AF4 AF3 F5 F3 F1 Fz FC5 FC3 FC1 FCz C5.
They cover the central strip, so the 10-20 sites Fp1/2, F7/8, T7/8, P7/8 and O1/2 are not among them.
Results
All test data were never seen in training:
- Unseen people: 247 people from 111 datasets, held out by a fixed hash of their ID.
- Unseen lab: Schirrmeister 2017 (14 people), a whole lab and amplifier the codec never saw.
Compression vs fidelity (unseen people)
| Levels | kbps | Compression | Pearson r | SNR (dB) | Per-person SNR (dB) |
|---|---|---|---|---|---|
| 1 | 0.3 | 262Γ | .798 | 4.4 | 5.7 |
| 2 | 0.6 | 131Γ | .860 | 6.2 | 7.8 |
| 4 | 1.2 | 66Γ | .918 | 8.6 | 10.7 |
| 8 | 2.4 | 33Γ | .953 | 11.5 | 14.0 |
| 16 | 4.8 | 16Γ | .972 | 14.3 | 17.5 |
| continuous latent | β | β | .982 | 18.4 | 22.7 |
Against classical codecs at the same bitrate
The baselines are block DCT per site (dct) and a learned 41Γ41 spatial PCA followed by block DCT (kltdct, the strongest). Both
are rate-controlled with entropy coding learned on training people. Ours uses no entropy coding at all.
| Test set, 4.8 kbps | Ours | kltdct | dct | Ours β kltdct (paired) |
|---|---|---|---|---|
| Unseen people (247) | .972 | .955 | .941 | +.019 (SE .002), better for 221/247 |
| Unseen lab, Schirrmeister (14) | .965 | .952 | .911 | +.012 (SE .003), better for 13/14 |
In the beta and gamma bands, per-person SNR beats kltdct on every test set and at every bitrate, by +0.4 to +3.9 dB.
Task information in the bitstream, against other EEG tokenizers
A fixed transformer head is trained on what a receiver of the bitstream has: our dequantized latent, or the other model's codebook vectors. Balanced accuracy, mean of 4 tasks: motor execution (4 classes), motor imagery (4 classes), mental arithmetic, and a 3-class held-out task.
| Bitstream | kbps | Mean of 4 tasks |
|---|---|---|
| EEG Codec 41ch-120Hz, 1 level | 0.3 | .503 |
| EEG Codec 41ch-120Hz, 2 levels | 0.6 | .525 |
| EEG Codec 41ch-120Hz, 4 levels | 1.2 | .537 |
| EEG Codec 41ch-120Hz, 16 levels | 4.8 | .544 |
| NeuroLM VQ tokens | 0.53 | .475 |
| LaBraM VQ-NSP tokens | 0.53 | .430 |
| Raw signal, uncompressed | 78.7 | .562 |
At under 60% of their bitrate, a single level of our codes already carries more task information than either tokenizer.
Missing sites
The codec was trained with whole scalp regions hidden, so it works on caps with fewer sites and can fill in the gaps.
| Fill-in r at hidden sites (20% region) | Task score drop, 40% of sites removed | |
|---|---|---|
| EEG Codec 41ch-120Hz | .780 | β.117 |
| Spherical-spline interpolation | .558 | β |
| Raw signal | β | β.218 |
Why compress first
The same 114M encoder, pretrained the same way, once on this codec's latent (EEG Encoder 41ch-120Hz) and once directly on raw signal patches (EEG Encoder 41ch-120Hz (raw)):
| On the codec | On raw signal | |
|---|---|---|
| Fine-tuned, mean of 9 tasks | .752 | .750 |
| Drop with 40% of a scalp region missing | β.077 | β.240 |
| Drop with 40% of sites missing, scattered | β.058 | β.129 |
| PROTEUS 3-class BCI decoding, 10 unseen people (fine-tuned, 3 seeds) | .694 | .654 (codec better for 9/10 people) |
PROTEUS (NEMAR nm000290) was not used in pretraining; these are fine-tuning results, scored on people held out from fine-tuning.
The codec costs nothing on clean data, makes the encoder far more robust to missing sites, and improves BCI decoding on new people.
What each level carries
Level 1 alone holds 93β101% of the above-chance score for brain state, task paradigm and age, and 73β79% for ERPs and motor imagery. Later levels add detail for timing-heavy signals such as SSVEP and ERPs.
Training
| Data | 172 public scalp-EEG datasets (CC0, CC BY 4.0, ODC-By 1.0), 6,357 h, 28,226 recordings, all at 41 sites / 120 Hz through the chain above; 5,996 h for training; no labels |
| Held out | 5% of people (fixed hash) and all of Schirrmeister 2017 |
| Architecture | causal SEANet encoder (64 filters, one stride-2 stage) β 4-layer causal transformer (256-d, 8 heads, 10 s context) β stride-2 conv β RVQ 16 Γ 1024 (128-d codebooks, EMA updates, k-means init, dead-code reset) β mirror-image decoder |
| Quantizer training | per-sample quantizer dropout (1β16 levels); 50% of samples bypass quantization |
| Loss | L1 + multi-scale STFT (windows 20/40/80/160) + Pearson + commitment |
| Augmentation | gain 0.6β1.4, per-site gain 0.85β1.15, polarity flip 20%, left-right mirror, noise, site dropout; site hiding on 50% of samples (20β60% of sites, a contiguous region 75% of the time) |
| Optimisation | 200k steps, 8 GPUs Γ 42 crops of 12 s; AdamW 3e-4, betas (0.9, 0.95), wd 0.01, cosine schedule, 1k warm-up, grad clip 1.0 |
| Checkpoint | best held-out-people PCC (step 200k) |
Sampling weights go with β(hours) per dataset. Units were corrected for three datasets whose files were in the wrong units.
Limitations
- Montage. The 41-site central montage has no frontal-pole, lateral-temporal or occipital sites.
- Band. Content above 75 Hz is removed by the input chain.
- Privacy. The codes identify people (person-ID .93β.98 from the bitstream). Treat them as identifying data.
- Precision. With PyTorch's default TF32 convolutions on GPU, about 0.5% of the higher-level codes can differ. Set
torch.backends.cudnn.allow_tf32 = Falsefor bit-stable codes. - Seeds. One training seed.
Responsible use
EEG is sensitive personal data: it can reveal who a person is and information about their health. This model is released for research.
Intended use. Research on EEG representation learning, brain-computer interfaces and EEG benchmarks, on recordings made with the participants' informed consent and handled under the applicable data-protection law.
Not a medical device. The model has not been clinically validated. Do not use it for medical diagnosis, screening, treatment or any other clinical decision. Benchmark results on labels such as age or sex are research measurements, not medical assessments.
Do not use it to identify people. Its outputs identify individuals well (see Limitations). Do not use the model to identify, re-identify, track or profile people, to link EEG recordings to identities, or to infer health conditions or other sensitive attributes of a person without their explicit consent.
Other uses we do not support. Monitoring or surveillance of people without their informed consent; decisions about employment, education, insurance, credit or access to services; law enforcement, interrogation or lie detection.
Outputs are personal data. Features, codes and reconstructions computed from a person's EEG remain that person's data; protect them as you would the recording.
Files
| File | What it is |
|---|---|
model.safetensors, config.json, preprocessor_config.json, *.py |
The model in transformers format (AutoModel, AutoFeatureExtractor) for inference and fine-tuning. Weight normalisation is folded into plain convolution weights |
original/checkpoint.pt |
The same model as saved by our training code, for continuing training with it. It keeps the weight-norm parameters and the quantizer's training statistics |
training_checkpoint.json |
Training step and the sha256 of original/checkpoint.pt |
pretraining_datasets.csv |
Every pretraining dataset with its source and licence |
original/checkpoint.pt is a PyTorch dictionary with model (the state dict), conf (the training configuration) and step:
ck = torch.load("original/checkpoint.pt", map_location="cpu", weights_only=True)
Code and paper
The pretraining code is available on request. We will open-source all of our models, training and evaluation code, benchmarks and a research paper.
Licence
The model weights and code in this repository are licensed under
CC BY-NC 4.0 (attribution, non-commercial); the full text is in LICENSE.
Copyright 2026 Sabi. For commercial licensing, contact Sabi (sabi.com). The pretraining data are public datasets licensed CC0, CC BY 4.0
or ODC-By 1.0; every dataset, its source and licence are listed in pretraining_datasets.csv.
- Downloads last month
- 37