EEG representation · Core ML
CBraMod · Embeddings
Five seconds of EEG, as a vector.
The pretrained CBraMod backbone as a native Core ML embedder. A 14-channel, five-second window in; a 14,000-dimensional embedding out.
- Input
- [1, 14, 1000] at 200 Hz
- Output
- [1, 14000]
- Precision
- fp32
- Parity
- Worst rel-L2 1.3 × 10⁻⁵
- License
- BSD-3-Clause
- Updated
- 19 Aug 2026
Overview
CBraMod is a foundation model for EEG that attends across channels and across time separately: criss-cross attention. This package is its pretrained backbone with the classification head removed, converted to Core ML.
A five-second, 14-channel window becomes a 14,000-dimensional embedding for any downstream decoder you train, on the device that records it.
Fig. 01 · Shapes
Fourteen channels, five patches, two hundred dimensions
Diagram of the CBraMod embedding shapes. A 14-channel, 1,000-sample EEG window at 200 Hz, tensor [1, 14, 1000], is cut into five one-second patches of 200 samples per channel. Patch embedding turns each patch into a token of 200 values, giving a 14 by 5 grid of tokens that is 200 values deep, [1, 14, 5, 200]. Criss-cross attention mixes each token with the tokens in its column (the 14 channels in the same second: spatial) and, separately, in its row (the 5 seconds of the same channel: temporal); the shape does not change. The tokens are then flattened channel by channel into one vector of 14 × 5 × 200 = 14,000 values, [1, 14000], so one channel occupies 5 adjacent tokens and one patch every 5th token. The figure follows channel 06, patch 3, which lands at values 5,400 to 5,599. Traces and values are illustrative.
EEG window
[1, 14, 1000]
14 channels × 1,000 samples: five seconds at 200 Hz, cut into five one-second patches.
Patch + embed200 samples → 200 values
Tokens
[1, 14, 5, 200]
One token per channel per second, each 200 values deep. Attention changes the values, never the shape.
- Criss-cross attention
- Spatial · the 14 channels of one second
- Temporal · the 5 seconds of one channel
- The token followed through the figure
- Point at or tap any token, or use the arrow keys on the focused grid, to follow it instead
Flattenchannel, then patch, then value
Embedding
[1, 14000]
The 70 tokens laid end to end, channel by channel: 14 × 5 × 200 = 14,000 values.
one channel = 5 adjacent tokensone patch = every 5th token
channel 06, patch 3 → values 5,400–5,599
Validation
| Check | Result |
|---|---|
| Embedding parity vs PyTorch, real EEG | Worst relative L2 1.3 × 10⁻⁵ |
| Motor-imagery decoding on Core ML embeddings | Identical to PyTorch |
Numerical parity is necessary, not sufficient, so the package was also checked at the task level: a motor-imagery decoder trained on its embeddings reaches the same decisions as one trained on PyTorch embeddings.
Input contract
- Package
CBraModEmbedder.mlpackage- Input
eeg, float32 [1, 14, 1000]- Preprocessing
- Average reference and global z-score at 256 Hz, then resample to 200 Hz
- Output
embedding, float32 [1, 14000]
Know the boundaries
- Fixed input shape: 14 channels and 1,000 samples. Channel count and preprocessing must match.
- Embeddings are features. They are not calibrated intent probabilities, and a trained head is required for any decision.
- Not clinically validated.
About this page
Summarized from the public model card and its published files. Repository updated 19 Aug 2026; reviewed 26 Sep 2026. The Hugging Face card is the source of truth for licenses and current details.
Upstream: CBraMod / braindecode