You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds Guetschel2026, the encoder shared by the 58 MAE/JEPA checkpoints of What masking geometry works best for EEG foundation models?.
The checkpoints load with from_pretrained directly from the original Hugging Face
repositories (PierreGtch/eeg-fm-masking_*); hub_repo_id() builds their names.
Optional fixed Gaussian random projection in the head (random_projection=5000, off by default), as in the OpenEEGBench ridge probe.
The shared model-test fixtures now use real channel names and positions from an MNE montage (separate commit); no test outcome changes in test/unit_tests/models.
Parity with the reference implementation. With the same released weights, the backbone features of braindecode and of the original ContextualEncoderBenchmarkWrapper are identical (torch.equal) in all 3722 comparisons: 4 checkpoints (final and epochs 1, 5, 9), 7 montages, windows of 200 to 12000 samples, float32 and float64. In CI, test_guetschel2026.py checks golden values computed with the original code.
Encoder shared by the 58 MAE/JEPA checkpoints of the EEG masking-geometry
study (Guetschel et al., 2026, arXiv:2609.33487), adapted from
PierreGtch/eeg-fm-masking (MIT). The module tree keeps the original
attribute names, so the released Hugging Face repositories load directly
with from_pretrained. Optional Gaussian random-projection head
(random_projection, random_projection_seed) and hub_repo_id helper.
The default 3-channel chs_info, the DANCE entry and the chs_info generated
by _get_signal_params used uniform random locs in [0, 1)^3. They now use
real channel names and head-frame positions (metres) from colin27_1005
(standard_1005 on MNE < 1.13), loaded lazily. The module-level _rng stream
is consumed as before.
…Figure 1
Every channel must lie between 5 cm and 20 cm from the head-frame origin,
which rejects positions in centimetres or millimetres and channels without
a position. The figure now shows both panels of Figure 1 of the paper.
Short sections in the style of REVE: architecture, the 58 checkpoints,
usage, random projection head, input requirements and differences from
the reference implementation.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.76%. Comparing base (b378bb1) to head (7332e45). ⚠️ Report is 4 commits behind head on master.
…dit false positives
The frequencies of the coordinate encoding are computed once into a
non-persistent buffer, so a float64 forward has no float32 tensor
(test_forward_in_dtype); a float32 to float64 cast is exact, so the features
stay bit-identical to the reference. nosec on the cls_token=None return
(B105) and on the subprocess of the fixture import test (B404, B603).
The channel-strategy guide now counts 24 pretrained EEG models.
… errors
- Inline the one-use private constants (_PRETRAIN_SFREQ, _MAX_SECONDS,
_SCALE_EPS, _N_STORED_TIME_PATCHES, _HUB_NAMESPACE, _MIN/_MAX_CH_DIST,
_MAX_LISTED_CHANNELS) with their one-line reason; keep the data tables.
- Fold _check_channel_distances (one caller) into __init__ and shorten its
error and the missing-location error; the tests follow the new wording.
- Call warn_if_sfreq_differs without the try/except around the mixin's
sfreq; it warns in the same cases (sfreq given or derivable).
- Docstring: License link line. NOTICE: the file line only.
- channel_strategies.rst: no model count (it goes stale with every port).
Forward outputs, gradients and state_dict keys are bit-identical to 94c1598.
Validate num_heads before using it as a divisor. With num_heads=0, this public constructor currently raises ZeroDivisionError at the modulo operation, and negative or non-integral values fail later with opaque tensor-shape errors instead of the ValueError used for other invalid architecture arguments.
Use lightweight projection in registry contract tests
braindecode/models/util.py:796
This registry entry exercises the 5000-dimensional default head in every generic model-contract test. With the default registry geometry (3 channels, 5 patches), each instance owns a 38.4M-element (~154 MB) projection buffer; test_registered_model_serialization_contract then retains the original, reconstructed, deep-copied, and pickled models simultaneously, so this single case consumes well over 800 MB before pickle's temporary bytes. Provide a lightweight projection override for registry-driven tests, as the dedicated return-feature and pretrained-compat cases already do, while retaining the explicit default-head test.
After model.double(), ch_pos is converted to float64, so new_empty makes the spatial encoding float64. The copied reference implementation in test_guetschel2026.py:330-339 always allocates this result as float32, then quantizes the sine/cosine values before they are added to a float64 residual. Consequently the float64 path is not bit-identical to the reference despite the PR's parity claim (the current test only checks it within 1e-3). Keep this helper's output float32 and let _ContextualEncoder cast it when adding it to the features.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
Guetschel2026, the encoder shared by the 58 MAE/JEPA checkpoints ofWhat masking geometry works best for EEG foundation models?.
The checkpoints load with
from_pretraineddirectly from the original Hugging Facerepositories (
PierreGtch/eeg-fm-masking_*);hub_repo_id()builds their names.random_projection=5000, off by default), as in the OpenEEGBench ridge probe.test/unit_tests/models.Parity with the reference implementation. With the same released weights, the backbone features of braindecode and of the original
ContextualEncoderBenchmarkWrapperare identical (torch.equal) in all 3722 comparisons: 4 checkpoints (final and epochs 1, 5, 9), 7 montages, windows of 200 to 12000 samples, float32 and float64. In CI,test_guetschel2026.pychecks golden values computed with the original code.