CodeBrain: Bridging Decoupled Tokenizer and Multi-Scale Architecture for EEG Foundation Model
Authors: Jingying Ma
Feng Wu
Qika Lin
Yucheng Xing
Chenyu Liu
Ziyu Jia
Mengling Feng
Venue: ICLR 2026 Poster (2026)
Keywords: EEG foundation model
Vector Quantization
State Space Model
Primary area: applications to neuroscience & cognitive science

Abstract: Electroencephalography (EEG) provides real-time insights into brain activity and supports diverse applications in neuroscience. While EEG foundation models (EFMs) have emerged to address the scalability issues of task-specific models, current approaches still yield clinically uninterpretable and weakly discriminative representations, inefficiently capturing global dependencies and neglecting important local neural events. We present CodeBrain, a two-stage EFM designed to fill this gap. In the first stage, we introduce the TFDual-Tokenizer, which decouples heterogeneous temporal and frequency EEG signals into discrete tokens, quadratically expanding the representation space to enhance discriminative power and offering domain-specific representation-level interpretability by suggesting potential links to neural events and spectral rhythms. In the second stage, we propose the multi-scale EEGSSM architecture, which combines structured global convolution with sliding window attention to efficiently capture both sparse long-range and local dependencies, reflecting the brain’s small-world topology. Pretrained on the largest public EEG corpus, CodeBrain achieves strong generalization across eight downstream tasks and ten datasets under distribution shifts, supported by comprehensive ablations, scaling-law analyzes, and interpretability evaluations. The code and the pretrained weights are available at https://github.com/jingyingma01/CodeBrain.

BRIDGING DECOUPLED TOKENIZER AND MULTI-SCALE ARCHITECTURE FOR EEG FOUNDATION MODEL
Jingying Ma'; Feng Wu' Qika Lin', Yucheng Xing! Chenyu Liu", Ziyu Jia S6t, Mengling Feng!. 1.2
'Saw Swee Hock School of Public Health, National University Singapore, Singapore Instiiutee of Data Science, National University of Singapore, Singapore
GGangghou Research Translation and Innovation Institute, National University of Singapore, Guangzhou, China
*College of Computing and Data Science, Nanyang Technological University, Singapore
'Beijing Key Laboratory of Brainnetome and Brain-Computer Interface, Institute of Automation, Chinese Academy of Sciences, Beijing, China Brainnetome Center, Institute of Automation, Chinese Academy of Sciences, Beijing, China fjingyingma, wufeng, xingyucheng]e @u nus. edu; qikalingf moxianiffoiiillmmmmmmmmmm i1. com; chenyu003@e .nt.. edu. sq jia. zi yuv out look com; mornine nus wwweeuusedduueee edd..g
ABSTRACT
Electroencephaloggaphy (EEG) provides real-time insights into brain activity and supports diverse applications in neuroscience. While EEG foundation models (EFMs) have emerged to address the scalability issues of task sssc-specific models, current approaches still yield clinically uninterpretable and weakly discrimina- tive representations, inefficiently capturing global dependencies and neglecting important local neural events. We present CodeBrain, a two-stage EFM designed to fill this gap. In the first stage, we introduce the decouples heterogeneous temporal and frequency EEG signals into discrete to- kens, quadratically expanding the representation space to enhance discrimina- tive power and offering domain-specific representation-leva interpretability by suggesting potential links to neural events and spectral rhythms. In the second stage, propose the multi-scale EEGSSM architecture, which combines struc- tured global convolution with sliding window attention to efficiently capture both sparse long-range and local dependencies. reflecting the brain's 's small-world topol- ogy. Pretrained on the largest public EEG corpus, CodeBrain achieves strong generalization across eight downstream tasks and datasets under distribution shifts, supported by comprehensive ablations, scaling-law analyzes, and inter- pretability evaluations. The code and the pretrained weights are available https: bttps://qithub com/ hctm://inyyiinnnmo/oooaaaaaaaaa
which
INTRODUCTION
Electroencephaalggaapy (EEG) captures brain activity via scalp electrodes (Niedermeyer & da Silva 2005) and provides high temporal-resolution signals for neuroscience and cognitive research (da Silva To enable automated analysis, researchers have developed various task-specific models for
2013)
applications such as sleep staging (Lee et al. 2025 Ma et al. 2025a), emotion recognition (Liu al. 2024b: Jia al. 2025), motor imagery (Li al. 2020 Jia al. 2020), and other applications (Guerra et al. 2024 Hu et al. 2024). However, building separate models from scratch for each task resource-intensive and limits scalability, shared knowledge across tasks cannot be effectively
"Equal contribution.
1 "Corrsponniig authors.

---

(a) EEG Heterogeneous structures
(b)
Compositional Interpretable Decoupled Tokenizer
Matched
Power Ampluss
C. NN Eearch
Embedding
Encoder
EEG Patches
Temporal
Existing Methods
Divergent
Mixed domain
Mixed Tokenizer
Frequency
N
Cinically untiterpretable
Representation Space.N
Label
N2Stage
REMStage
Tokens
Our Method
Matched
Temporal domain
Frequency
e.g.
Decoupled
Compositionl
N Tokens
Tokenizer
Divergent
interpretable
Representation
Temporal
spectral rhythms.
Tokens
Space:N²
Label
N3Stage
NT Stage
Frequency domain
Seaprin Multi-Scale Architecture
(e) Unified Gains Across
10 EEG Datasets
(c)
slow waye
Intcr-patch
feature
Methods
Existing
Smotoo Recegmibun (FAC20)
Classitation
X too dense
Self Amenttonn
Emoton Aecopaiio
Clroitstioon
megery
Models
Our
Method efficient
BENDR
small world shortcuts ssprre
long-range links
Global Comnalution
O(Nlog(N)
Ovivction
BIOT
LaBraM
(d)
Intra-patch
Spindie
feature Complex
Methods
Existing
Neglect
Shup Stapheg
CBraMod
REGPT
Mw
Method
Our
Attention (5WA)
Sliding Window
ASAUC
Dotection
Seiary
CodeBrain
Slide
Sieep Staping (URLIC S1)
Mentta
local clustering: Brain small-world motifs
Enagined Spurch Cassiiaation
Oetection
Figure 1: Rationale and overview of CodeBrain beyond existing EFMs. (a) EEG signals are het- erogeneous, patches matched in one domain may diverge in the other. (b) We then propose decoupled tokenizer for domain-specific interpretable representations while expanding the represen- tation space. (c-d) Inspired by the brain's 's small-world topology, a multi-scale architecture further captures inter-patch dependencies efficiently, while modeling overlooked intra-patch neural events. (e) These designs deliver performance gains across ten EEG datasets.
leveraged. Moreover, variations in channel configurations and input lengths across EEG tasks further hinder knowledge transfer. To tackle these issues, EEG foundation models (EFMs) are developed to learn universal representations for diverse downstream tasks (Zhou et al., 2025a).
Inspired by masked self- supervised pretraining natural language processing (Van Den Oord et al. 2017: Devlin et al.] (219)), current EFMs commonly adopt patch-wise representation learning: EEG signals are divided into patches, encoded into latent representations, and trained to reconstruct the masked portions. While this approach offers flexibility across varying channel configurations and input lengths by adjusting the patch number and arrangement, direct raw-signal reconstruction (Wang) et al. [2244a] 2025) remains challenging due to the inherent noise and variability of EEG. To mitigate tokenization (Jiang et al. 2024]] Pradeepkumar al. 2025), which abstracts away low-level fluctuations and provides
this, recent studies have introduced codebook-
robust latent space.
Despite these advances, existing EFMs still face critical limitations, calling for new architectures.
Failing Decouple Heterogeneous EEG for Domain-Specifee Interpretability. Recent EFMs adopt vector quantization for noise-robust representation (Jiang et al.) 2024 Pradeepkumar et al. 2025), following the VQ-VAE framework originally designed for images, where homogeneous visual features make single tokenizer sufficient Van Den Oord et al. 2017; Mentzer et al. 2024 Jii et al., 2025 Lin et al. 2025a). In contrast, EEG exhibits heterogeneous structures: temporal and frequency components reflect distinct aspects of brain activity (Miwakeichi et al. 2004). As illustrated in Fig. a)) signals matched in one domain may diverge in the other. Therefore, mixed tokenizer conflate domain-specifee patterns (Liu et al., (024c), weakening representation capacity and producing tokens difficult to align with clinically interpretable neural events or spectral rhythms.
Struggling with Efficiently Modeling Global Brain Dependencies. EEG signals exhibit sparse global dependencies and strong local correlations, reflecting the brain's 's small-world topology (Bull more & Sporns 2009 Bassett & Bullmore) 2006 He et al. 2009). Efficient modeling of such structure requires capturing relationships in a scalable way. However, most EFMs (Yang et al. 2023
Tiang al. 2024 Wang et al. 2024a 2025) adopt Transformer architectures with fully connected
2

---

self-attention (Vaswani al. 2017). This over-connected design is misaligned with the brain's 's sparse structure and struggles to efficienlly capture global dependencies due to its quadratic complexity with sequence length (Ta et al. 2021 Hong et al. 2025 Tegon et al. 2025).
Neglecting Local Dependencies within EEG Patches, EEG signals exhibit rich local waveform structures over short temporal windows, reflecting crucial transient neural events (e.g., sleep wave- forms in Fig. (d) (Taumm IV] 202T). However, most existing EFMs represent each EEG patch as a single token and apply attention mechanisms only at the patch level (Wang et al.) 2025 Jiang et al.) 2024). thereby ignoring important local dependencies within patches.
To address the above challenges, propose CodeBrain, novel EEG foundation model that integrates a decoupled tokenizer for domain-specific representation-leve interpretability with a brain-inspired multi-scale architecture. CodeBrain trained in two stages. In the first stage, we introduce the (Fig. [b), which decouples temporal and frequency EEG components into discrete tokens. the second stage, we develop EEGSSM, a masked self-supervised framework inspired by the brain's is small-worke topology. EEGSSM adopts a structured global convolution backbone, conceptually related to recent state-space sequence models (Smith et al. 2023 Li et al.. 2022, Gu et al.) 2022a), for sparse and efficient global modeling with a sliding window attention (SWA) mechanism for capturing local neural events overlooked by prior studies(Fig, [c-d)). Our detailed contributions are summarized as follows:
Decoupled Tokenizer for Domeii-Specific Representation-Levd Interpretability. We propose the TFDUAL-TOKENDEL which decouples temporal and frequency EEG components into discrete tokens. This design quadratically expands the representation space, and qualitative analyzes suggest that some tokens correspond to neural events and spectral rhythms. A contrastive objective is further applied to the temporal branch to stabilize training. To the best of our knowledge, this is the first tokenizer in EFMs to provide domain-specifer representation--evel interpretability.
Brain Small-World Topology Inspired Multi-Scale Architecture. We design EEGSSM, patch-wise self-supervised framework for EEG. Guided by the brain's small-world topology, employs structured global convolution to capture sparse long-range temporal dependencies and sliding window attention to model local neural events. In addition, dynamic positional embeddings are used to flexibly learn spatial channel correlations.
Strong Generalization and Comprehensive Validation. Pretrained on the largest publicly avail- able EEG corpus, TUEG (Obeid & Picone 2016), CodeBrain achieves strong performance on eight downstream tasks across ten datasets (Fig. I(e)) with distribution shifts in cohorts and channel configurations. This suggests the model design plays a central role in generalization. Comprehen- sive ablations, scaling-law analyzes, together with visualization and quantitative analyzes, further confirm its robustness, scalability, and provide domain-specific representation-level interpretability.
2 METHODOLOGY
2.1 MODEL ARCHITECTURE
We introduce CodeBrain, a two-stage pretraining framework designed to learn interpretable and universal EEG representations (Fig. 2 The model is motivated by complementary goals: 1) domain- specific interpretability via decoupled tokenization of heterogeneous temporal and frequency information, achieved by the proposed sequences inspired by the brain's 's small-world topology, addressed by the EEGSSM framework. This design lets Stage learn tokenizer of patch-level codes, while Stage 2 leverages it for EEG representations. We next provide a formal definition of the two stages to clarify their respective roles.
Tokenizze, and 2) multi-scale modeling of EEG
Stage 1: Decoupled Tokenization. Given normalized EEG patch R, where L is the patch length, our goal is to discretize x into temporal and frequency tokens, enabling domain- -ppecicc representation learning. Specifically, let Vt E R and f kxD denote the temporal and frequency codebooks, where is the vocabulary size and D is the embedding dimension of each token. The tokenizer function is defined vt, uf frokenizer (x), vt, vf R."
IN Stage 2: EEG Representation Learning, Given unlabeled EEG sequences X' = (Xm mm=1 where each X,, E XxT consists of C' channels, sampling rate f, and T' seconds. We divide each
3

---

sequence into non-overlapping patches of seconds, each patch length is ftt. train an encoder fenc IR x xxxx that produces latent representations Zm = fene (Xm).
-t The goal is to
Stagel: TFDual Tokenizer Pre- Training
StageZ: EEGSSM Pre- Pre-Training
Patchfied
M
ymu
M
From previous Layer
Multi-Scale
EEG
Mask
Iocse
SSM
Glabal Piterr-Piich Dependencies
M
M
RMS Norm
Come
DFFT
Pystseric
M My
Roch Noem
Embed
Enabed
Poyitional Embooliing
Cenv
EEGSSM Layer
Ontpur Fesuure
GELU
TFCony
Codebook
TF-Encuskr
NN Soarch
Layer
SGCoev
SWA
Local Intra-Pattch Depenciencies
Posilive Pair
EDGSSM
CINDAR Coodbook
Temponi Codebooke
Tanh
Sigmood
Concatenate C2
Contrastive Loss
Cune
CoBYY
Reconstruction
F-Deonder
T-Decoder
Skip Counectious
Frequency
Temporal
Toker
Temponii Token
Feature
Festure
Prndiction
Prodiztion
Figure 2: Overview of the CodeBrain framework. Left: TFDUAL-TOKENIZER learns to discretize EEG signals into temporal and frequency tokens using two separate codebooks, by reconstructing both the temporal waveforms and the frequency-doman magnitude and phase. Right: EEGSSM learns representations by predicting the discrete tokens of masked patches generated by TFDUAL- TOKENIZER.
2.2 TFDUAL-TOKENIZER PRETRAINING
Our TOOKNI-T includes shared neural encoder, dual tokenizer with separate code- books, and two decoders. The neural encoder extracts joint time-frequency embeddings from EEG patches, which then discretized into temporal and frequency tokens by the dual tokenizer. Each token stream is reconstructed by decoder to supervise codebook learning in its respective domain.
Neural Encoder For each patch x; E RR,, we apply the Discrete Fourier Transform (DFT) Coooley & Tukey 1965) to obtain its frequency representation:
[k] Dx.(x;),
where x; [kk denotes the k-th frequency component. x,[k] and the x; are fed into the TFCony module, where they processed in parallel through stacks of convolutional. batch normalization, and ReLU layers. The temporal representation ef = FFCono(x;) and frequency representation of TFConu(xx(k)) are concatenated to form time- fime-frequency embedding ef = Concat ef)-
To get patch representation εs we then add a positional embedding épos and feed it into TF-Encoder:
é Encoder(e, + epos).
(2)
We choose a Transformer encoder here since this stage is patch-to-token, where its ability to model local contextual relations makes it well-suited for capturing patch-level patterns. To keep the tokenizer channel-agnostic, Cpos shared temporal embeddings without channel-specife identities.
We use two separate tokenizers with distinct codebooks for the temporal and frequency domains, denoted as et,, ufy E RR,, where j 1...., K. Given the patch representation ē from the neural encoder, each tokenizer independently selects the nearest code from its codebook:
Dual Tokenizer
pl: = arg min ||ē - - pf: arg min || ufz1?
where pt, and pf denote the closest positions for the embeddings in the temporal and frequency domain codebook. The effectiveness of the Dual Tokenizer is based on the following proposition:
Proposition 2.1 Decoupling temporal and frequency codebooks yields representations that are no less effective than those from joint codebook.
4

---

For this Proposition, provide the proof in Appendix D empirical validation in Sections 3.4 and 3.5 and interpretabilityy analysis of the Dual Tokenizer in Appendix
Frequency Codebook Training To train the frequeney codebook, reconstruct amplitude and phase from the code embeddings. For each EEG patch, we apply the DFT to obtain the frequency representation: x = Re x [k:] + j Im (x;x([::) where Re{x;[kk]
[k]] and 1m(x; [Ki] are the real part and imaginary part respectively, then the amplitude and phase can be calculated as:
A, [e))x Im(xx oi arcian 2 [Im(x:(A]), Re(x:[k]))
We z-score normalization to ensure stable training. The code embedding of retrieved from the frequency codebook, is passed through the F-Decoder, which consists of a Transformer encoder followed by two linear layers:
Vi Encoder (Mttdder(M.P())))) vf" Encoder (MT.()))
(5)
where V and yf are the predicted amplitude and phase, respectively. The frequency codebook's training objective is the mean squared error (MSE) loss:
Ef
A:ll2 + Ilv!" 0:112.
Direct reconstruction of temporal features might lead non- convergence (Jiang et al. 2024). To address this, we combine contrastive loss with reconstruction loss train temporal codebook. Inspired by studies on physiological signals (Kiyasseh et al. 2021). we assume temporal dependencies exist between EEG segments, especially within the same channel. For an EEG segment Xm CCxx we split into two halves of length n/2. We use TF-Encoder in Eq.
Temporal Codebook Training
2 to obtain the representations of these two parts Xm1, Xm2 E C 2 xxx separately:
em Excoder(Xmi) m,)) E (1,2}.
We encourage the latent representations of different parts within a single segment e and em to be similar, while making those of the same part across different segments e and ex as distinct as possible, where X, E Cxxxx 8 F m, k + SimCLR loss (Chen et al. 2020) is used for training:
exp (sim(e)) (e e/12)/T)
CCL = log m
(8)
Σ
[etl exp (sim(e )/T)
where sim(e ein2) is the cosine similarity. > 0 is the temperature parameter, and IK [[ is an indicator function used to exclude itself. We introduce T-Decoder to reconstruct raw signals from the temporal code embedding é; which consists of a Transformer encoder followed by linear projection. Let yt be the Transformer output from Eq. (2) the overall training objective is:
C = =CL + 1lv! x; 112.
y Encoder (ML)()))
Finally, the training objective for the TFDUAL-TOKENIZES TOKENIZER can be defined as:
Σ CCL ΣΣ
cl c |sg((;) vl plt, 112 + (sg((e)) 11
Liokenizer
X.EX
X 1=0
codebook
(10)
+ ||e sg(ut 2 + 22 sg(wsf(())l
commitmet loss
where sg(.) denotes stop-gradient to avoid updating encoder parameters.
2.3 EEGSSM PRETRAINING
In this stage, we introduce novel convolutional structured state space model framework, called EEGSSM, composed of multiple EEGSSM blocks. To adapt to unseen channels, we first learn dynamic positional embeddings using a single depthwise 2D convolution with an asymmetric kernel, following the ACPE design (Wang et al., 2025), enabling the model to learn relative inter-channel structures and generalize across heterogeneous EEG channel layouts. The resulting features processed by EEGSSM blocks. Another ID convolutional layer then maps the output back to the token space for reconstructing the indices of masked tokens produced by the
5

---

EEGSSM Block Our EEGSSM block is composed of several blocks, which are integrated together through a residual connection mechanism. An EEGSSM block consists of a Layer Normalization, SGConv layer, SWA layer, and gating component. Afterward, we feed the intermediate variables into the SGConv layer to obtain a global receptive field through convolution SSM.
SGConv Layer: SGCony is structured SSM model (see Appendix and its convolution structure can be represented as a DFT formula:
C
using convolution architecture,
y F D2 Fuu, D diag(K
(11)
where Fy denotes the DFT matrix of size N, and the convolution can be computed in O(N log N) via FFT. As a type of convolutional SSM, SGConv improves the convolution kernel K in Eq. (22 by introducing two features: sparse parameterization and kernel decay, making SGConv easier and more efficient to compute compared to the traditional S4 kernel. Let L be the length of the input sequence. The convolution kernel K of SGConv is composed of several sub-kernels. Assuming the size of the first sub-kernel is d, with parameters w; E RRddd then the number of sub-kernels can be expressed as The convolution kernel K in Eq. (22) can thus be initialized as:
N (ogg(5) ( +
K == Z=Zl IKip K1 ..., -N- K; = a²
Upsamplegaoft--oo 1.0) =
(12)
where a denotes the decay coefficient, usually chosen to be 0.5, which induces the decaying structure. and Upsample(z) denotes upsampling x to length l. We also introduce the normalization constant Z to ensure that the convolution operation does not change the scale of the input.
Sliding Window Attention Layer. We included a sliding window attention (SWA) layer (Liu et al. 2021b) to capture fine-graine local temporal dependencies. Specifically, small fixed-length window is applied along the temporal dimension, allowing the model to directly attend to local contextual information within each window. By restricting attention to local regions, SWA effectively captures intra-patch temporal dynamics that are overlooked by previous models. Furthermore, under fixed window size, SWA reduces the quadratic complexity of global self-attention to linear complexity, enabling efficient training.
Gate Mechanism. we use gating mechanism to control the output of the block. We employ a gated unit similar to Wavenet (Obeid & Picone 2016), which can suppress useless or irrelevant features and help stabilize training in deep networks. We concatenate the global features output Yeg by the SGCony layer with the local features output yswa by SWA and feed them into a gated unit:
= La Comcal )sw o (W, x Concal (ysg: Moua))
(13)
81 = Conv (z), y/2 = Conv(z),
(14)
where land(()) and (-) are tanh function and sigmoid function, @ denotes an element-wise multipli- cation operator, Wy and Wg are learnable convolution filters. y1 becomes the input to the next block. while 3/2 will be aggregated to the output of SSM blocks through a skip connection.
Pre-Training Objective To help the EEGSSM model learn general EEG representations, we use a Masked Autoencoder (MAE) for self-supervised pre-training. For patched sample X = {a, i E [1, C1}, we randomly generate a mask M = {m, i E 21. C1} from Bernoulli distribution of proportion, where {0, 1}. We reconstruct the token indices of masked EEG patches from the TFDUAL-TOKENIZAA by cross-entropy loss. Let y/4 denotes the output of the EEGSSM block, the probability that the EEG signal matches the corresponding token 0; in the codebooks:
p(ulaxx) sof coftmax(CConie softmmar(Cono1(()))) ()x)))
(15)
Suppose the size of the pre-training set is N, the final cross-entropy loss is:
c-= =
p(uns (nns)=
(16)
1=0 nE =m,=1)

---

3 EXPERIMENTS
3.1 DATASETS
Pre-Trainin. We pretrain CodeBrain on the TUH EEG Corpus (Obeid & Picone 2016), the largest publicly available EEG dataset to date. Data processing follows a standardized pipeline based on prior works (Wang al. 2025 Zhou et al. 2025b): recordings shorter than 5 minutes are excluded, and the first and last minutes of each segment are removed. We retain 19 commonly used EEG channels (C3, C4, Cz, F3, F4, Fpl, Fp2. F7, F8, Fz, 01, O2, P3, P4, Pz, T3, T4, T5, T6), selected based on the international 10-20 system for electrode placement (HH 1958). We apply band-pass filtering (0.3-75 Hz), and notch filtering at 60 Hz to remove noise. The data is resampled to 200 Hz and divided into 30-second non-overlapping segments. Segments with absolute amplitudes over 100 μV are filtered out. To normalize the signals, each value is divided by 100. Each segment is split into I-second windows, resulting in 570 EEG patches per sample. After preprocessing. 1,109,545 samples (about 9,246 hours) are retained for pretraining.
Downstream Tasks. We evaluate CodeBrain eight downstream tasks across ten public EEG datasets, which span diverse applications and exhibit distribution shifts from the pretraining dataset assess generalizability. Detailed dataset configurations are in Table [.T] We perform cubjett or cross-session splits with strict separation between training. validation, and test sets. For FACED, we use 80 subjects for training. 20 for validation, and the remaining 23 for testing. In SEED-V. each session consists of 15 trials, which are evenly divided into training, validation, and test sets. ISRUC_S3 consists of 10 subjects, for which we apply an 8:1:1 cross-subject split. MentalA rithmetic consists of 36 subjects, and we use a 7:1:1 cross-subject split. BCIC2020-T3 follows the official competition protocol. In CHB-MIT, we use recordings from 19 subjects for training, and from subjects each for validation and testing. Additional dataset details are provided in the Appendix G
Table 1: Summary of downstream tasks and associated EEG datasets.
Downstream Tasks
Datasets
#Channels Length #Samples Class
FACED Chen al.
2023
32
10s
10,332
9-class
Emotion Recognition
SEED-V Lu et al. 2021a)
62
1s
117,744
5-class
ISRUC $
Khaligh et al.
2016
6
30s
86,320
5-class
Sleep Staging
ISRUC S3 Khalight et al.
2016
6
30s
8,500
5-class
Imagined Speech Classification BCIC 2020- T3 (Jeong
2022
64
3s
6,000
5-class
Mental Stress Detection
Mental Arithmetic (Mumtaz
2016
20
5s
1,707
2-class
Seizure Detection
CHB-MIT (Shocb) 20099)
16
10s
326,993
2-class
Motor Imagery Classification
SHU-MI (Goldberger ct al.
2000
32
4s
11,988
2-class
Event Type Classification
TUEV Obeid & Picone 2016)
16
5s
112,491
6-class
Abnormal Detection
TUAB Obeid & Picone
2016)
16
10s
409,455
2-class
3.2 EXPERIMENT SETTINGS
Experiment Setup. (1) Pretraining Setup. All experiments are conducted on NVIDIA 40GB A100 GPUs. The TFDUAL-TOKENIZER is trained with temporal and frequency codebooks of 4096 codes (32 dimensions) for 20 epochs, using a batch size of 256 and a learning rate of lc-4, across six A100 GPUs for approximately ten hours. An 8-layer EEGSSM backbone (15.17M) with a masking ratio of 0.5 is trained for 10 epochs, using a batch size of 256 on two A100 GPUs for about 24 hours.
(2) Finetuning Strategy. We evaluate the quality of the pretrained representations under full finetuning. All downstream task datasets are resampled to 200 Hz to match the pretraining configuration A three-layer MI.P is applied to aggregate channel information, compress the x--ecood sequence, and map the representation to the target class, with activation and dropout between layers.
Baselines. We compare our model with a comprehensive set of baseline models. Among the non- foundation baselines, EEGNet (Lawhern et al. 2018) and EEGConformer (Song et al.) 2022) represent compact architectures designed for efficient EEG decoding. ContraWR (Yang et al. 2021
is contrastive-leariing based small model, while ST-Transformer (Song et al.) (221) provides transformer backbone. These models serve as representative lightweight baselines commonly adopted across EEG classification tasks.
7

---

Table 2: Comparison results of different methods on representative downstream tasks.
FACED (9.Clss)
SEED-V (5-Class)
Methods
Cohen's 's Kappa
Weighted F1
Balanced Ace
Coben's Kappa
Weighted
Balanced Acc
EEGNet
0.3342 + 0.0251
0.4124 0.0141
0.4090 0.0122
0.1006 0.0143
0.2749 0.0098
0.2961 0.0102
EBGConformer
0.3858 0.0186
0.4514 0.0107
0,4559 0,0125
0.1772 0.0174
0,3487 a 0.0136
0.3537 0.0112
ContraWR
0,4231 0.0151
0.4887 0,0078
0.4887
0.1905
0,3544 a 0.0121
0.3546 0.0105
ST-Transformer
0.4137 + 0.0133
0.4795 + 0.0096
0,4810 0.0079
1083 + 0.0121
0.2833 + 0.0105
0.3052 0.0072
BENDR
0.4716 +: 0.0095
0.5340 0.0086
0,5320 0.0083
0.0335 0.0062
0.2026 0.0330
0.2231
0.0059
BIOT
0,4476 # 0.0254
0,5136
0.0112
0.5118 0.0118
0.2261 0.0262
0,3856 + 0.0203
0.3837 0.0187
LaBraM
0.4698 0.0102
0,5288 0.0188
0.5273 0.0107
0.2386 0.0209
0,3974 a 0.0111
0.3976 0.0138
EEGPT
0,4639 0.0023
0.3924 0.0017
0.4607 0.0014
0.1323 0.0062
0.3090 + 0.0052
0.3061 0.0044
CBraMod
0.5041 a 0.0122
0,5618 a 0,0093
0.5509 0.0089
0.2569 a: 0,0143
0,4101 a 0.0108
0,4091 0.0097
CodeBrain
0.5406 a: 0.0084
0,5953 20.0113
0.5941 0.0098
0.2735 a: 0.0032
0.4235 a 0.0022
0.4137 0.0023
ISRUC.S3 (5-Class)
BCIC 2020-T3 (5-Class)
Methods
Cohen's Kappa
Weighted Fl
Balanced Acc
Cohen's Kappa
Weighted F1
Balanced Ace
REGNet
0.7396 + 0.0155
0.7407 + 0.0184
0.7121 0.0134
0.4413 + 0.0102
0.3016 + 0.0123
0.4413 0.0096
EEGConfommer
0.7482 # 0.0164
0.7501 = 0.0211
0,7212 #: 0.0181
0.4488 = 0.0154
0,3133 a 0.0183
0.4506 = 0.0133
ContraWR
0.7493 = 0.0150
0.7513 a 0.0185
0.7226 0.0164
0.4407 = 0,0182
0,3078 a 0.0218
0.4257 = 0.0162
ST-Transformer
0.7388 + 0.0195
0.7399 + 0.0223
0,71 + 0.0197
0.4247 0.01
0.2941 + 0.0159
0.4126 0.0122
BENDR
0.5995 +: 0.0151
0.6789 a 0.0142
0.6352 0.0095
0.0607 a: 0.0093
0,2379 a 0.0165
0.2485 0.0075
BIOT
0.7168 + 0.01
0.7834 = 0.0096
0.7598 + 0.0109
0,3650 +: 0,0176
0.4917 # 0.0079
0.4920 = 0.0086
LaBraM
0.7194 = 0.0162
0.7843 = 0.0189
0,7617 = 0.0122
0,3800 # 0,0242
0,5054 # 0.0205
0,5060 = 0.0155
REGPT
0,6160+ 0.0856
0.6375 + 0.0632
0.6650 + 0.0311
0.0567 + 0.0164
0,2441 * 0.0105
0.2453 = 0.0131
CBraMed
0.7407 + 0.0251
0.8056 + 0.0219
0,7844 0.0126
0.4216 + 0.0163
0.5383 + 0.0096
0.5373 0.0108
CodeBrain
0.7671 0.0091
0,8202 0.0071
0.7856 0.0031
0.5127 0.0065
0.6101 0.0053
0.6101 0.0052
Mental Arithmetic (2-Class)
CHB.MIT (2-Class)
Methods
AUROC
PRAUC
Balanced Acc
AUROC
PRAUC
Balanced Ace
EEGNet
0.7321 + 0.0108
0.5763 0.0102
0.6770 0.0116
0.8048 0.0136
0.1914 + 0.0182
0.5658 0.0106
FEGConfamer
0.7424 + 0.0128
0.5829 0.0134
0.6805 0.0123
0.8226 0.0170
0,2209 0.0215
0.5976 0.0141
ContraWR
0.7332
0,5787 0.0164
0.6631
0.0097
0.8103
0,2279 a 0:0183
0.6351
0.0122
STTTrasfomeer
0.7132 0.0174
0,5672 0,0259
0.6631 0.0173
0.8237
0.1422 a 0.0094
0.5915 0.0195
BENDR
0.6248 a: 0.0765
0.3661 0,0672
0.5681 0.0448
0.8632 0.0526
0.3071 4 0.1240
0.5609 0.0432
BIOT
0,7536 0.0144
0.6004 0.0195
0.6875 0.0186
0.8761 0.0284
0,3277 # 0.0460
0.7068 0.0457
LaBraM
0.7721 # 0.0093
0,5999 = 0.0155
0.6909 0.0125
0.8679 0.0199
0.3287 : 0.0402
0.7075 0.0358
EEGPT
0.7162 + 0.0171
0,5081 + 0.0275
0.5597 0.0171
0.8892 0.0066
0.3073 + 0.0641
0.5481 0.0151
CBraMod
0.7905 0. 0.0073
0.6267 + 0.0099
0.7256 0.0132
0.8892 0.01
0.3689 + 0.0382
0.7398 0.0284
CodeBrain
0.8707 a 0.0209
0.7177 a 0.0421
0.7514 a 0.0203
0.8961 a: 0.0174
0.4377 a 0.0288
0.7273 0.0240
For EEG foundation models with publicly available pretrained weights, we include five representative methods that cover different pretraining paradigms. BENDR (Kostas et al. (222]) adopts a contrastive learning framework. BIOT (Yang et al. (003) uses patch-based continuous tokenization. LaBraM introduces discrete neural tokens through vector quantization (Jiang et al., 2024). EEGPT (Wang et al. 2024a) and CBraMod (Wang et al., 2025) rely on the masked reconstruction.
Evaluation Metric. For multi-class classification, we report Cohen's Kappa, Weighted F1 score, and Balanced Accuracy, with Kappa based on validation performance for testing. For binary classification, we use Area Under the ROC Curve (AUROC), Area Under the Precision-Recall Curve (PRAUC), and Balanced Accuracy, with AUROC based on validation performance for testing. All experiments are repeated with five random seeds, and we report the mean and standard deviation.
More details about hyperparameters, baselines, and evaluation metrics are provided in Appendix
3.3 COMPARISON WITH BASELINES
We ensure consistent data splits across all baselines. Results are reported six representative downstream datasets, with additional results provided in Appendix[[ As shown in Table CodeBrain achieves consistent performance gains compared baselines. For multi-class classification, it
8

---

Table 3: The results of ablation studies for tokenizer configurations and module components.
Dataset
Codebook
SWA
SGConv
Gate
Cohen's Kappa
Weighted
Balanced Accuracy
Dual
0.5406 : 0.0084
0.5953 = 0.0113
0.5941 = 0.0098
Temporal
0.4618 0.0072
0.5277 0.0067
0.5217 0.0056
Prequency
0.5006 0.0224
0.5607 + 0.0201
0.5580 + 0.0187
FACED 9-Class
Mixed
Dual
0.5222 + 0.0082
0.5811 + 0.0084
0,5765 + 0.0074
Dual
0.5192 0.0092
0.5792 0.0093
0.5736 0.0075
Dual
0.1936 0.1637
0.2627 0,1824
0,2858 1467
Dual
0.2578 = 0.0340
0,3363 + 0.0270
0,3431 + 0.0316
Dual
0.2735 1: 0.00122
0.4235 0.00222
0.4137 1 0.00232
Temporal
0.2633 0.0116
0A152 0.0092
04068 0.0074
Prequeney
0.2665 0.0208
0,186 0.0177
0,4098 0.0147
SEED-V S-Class
Mixed
0.2708 0.047
0,4244 0.0044
0.4124 0.0032
Dual
0.2589 0.0065
0.4199 0.0056
0,4029 0.0042
Dual
0.2561 0.0051
04400 + 0.0042
0.4019 0.0034
Dual
0,2062
Dual
0.22112 0.0076
0.3826 + 0.0057
0,3757 0.0052
Dual
0,7671 1 0.0091
0.8202 1 0.0071
0,7856 0.0031
Temporal
0.7314 0.0210
0.7916 + 0.0181
0.7565 + 0.0244
Frequency
0.7390 0.0601
0.7986 0.0514
0,7728 0.0361
ISRUC_S3
Mixed
0.7400 + 0.0217
0.7999 + 0.0171
0.7673 + 0.0157
3-Class
Dual
0.7558
0.8130
Dual
0.7359 + 0.0324
0,7950 + 0.0259
0,7621 + 0.0311
Dual
0.6218 0.0427
0.6956 0.0279
0.6664 0.0316
Dual
0.5478 0.0302
0.6429 0.0307
0.6258 0.0448
achieves the largest gain of +0.0911 119911n0 in Cohen's Kappa (21.6%), +0.0718 in Weighted F1 score (13.3%), +0.0728 in Balanced Ace (13.5%) on BCIC 2020-T3 over the strongest baseline (Wang et al. 2025). For binary classification, it achieves the largest gain of +0.0802 in AUROC (10.1%), +0.0910 in PRAUC (14.5%) and +0.0258 in Balanced Ace (3.6% on Mental Arithmetic over the strongest baseline. These results demonstrate the superior generalizability of CodeBrain.
3.4 ABLATION STUDY
We conduct ablation studies on three datasets with the same five seeds as the main experiments to evaluate the key components of CodeBrain (Table 3.3). Below is the detailed analysis:
(1) Tokenizer configuration: we compare the proposed using single domain codebook (Temporal Frequency) reconstructs both domains (Mixed). Across all datasets, the Dual codebook consistently yields superior performance, suggesting that maintaining separate temporal and frequency codebooks captures complementary information more effectively than merging them.
(Dual) with variants
shared codebook that jointly
(2) Contrastive learning (CL): We evaluate the impact of contrastive learning in TFDUAL- TOKENIZER pretraining. It leads to consistent gains, indicating better capture of temporal patterns. In addition, CL stabilizes the training dynamics and promotes faster and more stable convergence of the temporal codebook. Further analysis and evidence are provided in Appendix F
(3) Components of EEGSSM: Evaluating the SWA. SGConv, and Gate modules, which demonstrate improvements in EEG representation learning. Including the SWA module consistently improves per- formance, confirming its regularization effect capturing local dependencies. The gating mechanism also shows large impact, as it effectively stabilizes fine-tuning and prevents overfitting.
(4) Scaling Laws: Prior works Wang et al.) 2025 Jiang et al. 2024) explored scaling with 1-1000 hours of EEG data for pretraining. We extend to 1k-9k hours and 3M-150M models, ranging from 3.86M 3-layer model with a hidden size 128 to a 146.75M 12-layer model with hidden size of 384, enabling systematic exploration of scaling laws across depth and width. As shown in Figure 3 Kappa consistently improves with more data and parameters. These results confirm that larger models yield consistent but diminishing returns. Detailed results and efficiency analysis provided in Appendix[N] [N] These findings indicate that the 8-layer (15.17M) model is balanced choice between performance and computational efficiency.

---

We further investigate several key design choices, including mask ratio, SWA window size, codebook size, patch size, SGConv kernel parameters, and subband contributions in Appendix K Additional results robustness (Appendix MM), computational efficiency (Appendix D. low-resource settings (Appendix Op, and pretraining dynamics (Appendix further demonstrate the stability and efficiency.
FACED
SLEDAV
ISRUC S3
0.25
0.78
0.27
0.76
0.74
0.20
147
123456789
6
(M)
Training Dam (RI1)
Parameten(M)
Training Daia (LII)
Parameten(M)
Trinnng Data (LII)
Figure 3: Model and training data scaling laws of CodeBrain across three datasets Cohen's Kappa.
3.5 VECTOR VISUALIZATION
To demonstrate how the TFDual-Tokenizee models heterogeneous EEG, we visualize its learned temporal and frequency codes on the ISRUC_S3 dataset by mapping individual code indices back to their corresponding raw signals. As shown in Figure ab),,, each domain-specinti codebook captures meaningful representation-levee structures: temporal codes align with neural events (c.g., slow waves), while frequency codes highlight spectral rhythms such as dominant delta activity, both of which are informative for sleep staging. However, in many cases, neither domain alone is sufficient, and richer structure emerges only from their composition, as in Figure 4 cc)d, where the same temporal code can pair with different frequency codes, and vise versa, to yield complementary representations. This decoupled design expands the representation space and enhances interpretabilitty with additional meaningful tokens to neurophysiological features and quantitative analyzes provided in Appendix B
(a) Pattern Captured by Temporal Code No. 3323
(b) Pattern Captured by Frequency Code No. 2685
Modi A
Amplitude
bw
Temporul
0.5
Power
Doman
N3 Stage
Codehook
N3 Stage
Pa
Pea0os
Myr
Prens
Pruss
Pyass6"
Preas
Frequency
Doman
Codebook
Prozs
Eyszn
Press Prease
Pyzass
Fass + Pezzow
PrEsEh + Poasos
N2 Stage
REM Stage
NT Stage
N2 Stage
N3 Stage
NI Stage
(c) Temporal Code No. 668 Coupled with Frequency
(d) Frequency Code No. 1131 Coupled with Temporal
Codes Reflects Different Task Labels
Codes Reflects Different Task Lahels
Figure 4: Decoupled freeufeyy codes visualization on sleep staging dataset (ISRUC (3))
4 CONCLUSION
In this paper, we present CodeBrain, an EEG foundation model that unifies interpretable tokenization with brain-inspired multi-scale suati-scale architecture. The HFDUALL-TOKENPZA decouples heterogeneous EEG signals, expanding the representation space while suggesting domain-specifer representation- level interpretability, and the EEGSSM architecture integrates structured global convolution with sliding-window window attention to efficiently capture both long-range and local dependencies. Pretrained on the large-scale TUEG corpus, CodeBrain demonstrates strong generalization across eight tasks and ten datasets under distribution shifts, with comprehensive ablations, scaling- law analyses confirming robustness and scalability. These results establish CodeBrain as a strong foundation for neural time-series representation learning. Limitations and future work are discussed in Appendix P
10

---

ACKNOWLEDGMENT
This research is partially supported by the Singapore National Medical Research Council (NMRC) research grant (MOH-001838) the AI for Public Health Program (25-1447-A000)) the Saw Swee Hock School of Public Health, National University of Singapore; the Cisco-NUS Accelerated Digital Economy Corporate Laboratory (Award E0002), funded by STAR, CISCO Systems (USA) Pte. Ltd., and the National University of Singapore; the National University of Singapore President's Graduate Fellowship; the NUS- Guangzuug Research Translation and Innovation Institute Scholarship; the Youth Science Fund Project of National Natural Science Foundation of China (No.62306317) the Beijing Nova Program (Grant No. 20250484804); and the Young Elite Scientists Sponsorship Program of the Beijing High Innovation Plan (No20250912).
ETHICS STATEMENT
This research adheres to the ICLR Code of Ethics and Responsible Research Guidelines. We confirm that all aspects of the study conform to these guidelines. The work preserves anonymity requirements and does not deviate from the ethical principles set by ICLR. This paper does not involve human subjects, crowdsourcing, or sensitive user data. No Institutional Review Board (IRB) approval was required. The work does not release models or datasets with a high risk of misuse, and poses no privacy, security, or legal compliance concerns. Furthermore, it does not contain potentially harmful insights, discrimination or bias issues, or conflicts of interest. All experiments are conducted on publicly available EEG datasets, following research integrity and responsible research practices as required by the ICLR Code of Ethics. In addition, disclosures regarding the use of LLM are in the Appendix Q
REPRODUCIBILITY STATEMENT
We have made extensive efforts to ensure the reproducibility of our work. The complete implemen- tation and the pretrained weights are provided in /ttpps://githii thub com/ com/jingy iamma C1/ CodeBra i For theoretical results, all assumptions and complete proofs of the claims are included in Appendix D For experimental reproducibility, preprocessing procedures, and evaluation protocols in Section G as well as comprehensive hyperpa- rameter settings in Appendix[] These materials together ensure that both the theoretical and empirical results can independently verified.
provide detailed description of the datasets,
REFERENCES
Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, Ilge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Altman, Shyamal Anadkat, et Gpt-4 technical report. arXiv preprint arXiv:2303.0877: 2023.
Danielle Smith Bassett and ED Bullmore. Small-worke brain networks. The neuroscientist. 12(6): 512-523, 2006.
Richard B Berry, Rita Brooks, Charlene E Gamaldo, Susan M Harding, Carole Marcus, Bradley V Vaughn, et al. The aasm manual for the scoring of sleep and associated events. Rules. Terminology and Technical Specifications, Darien, Illinois, American Academy of Sleep Medicine, 176(2012):7. 2012.
Ed Bullmore and Olaf Sporns. Complex brain networks: graph theoretical analysis of structural and functional systems. Nature reviews neuroscience, 166 2009.
Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties self-supervised vision transformers. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 9650-9660, 2021.
Chi-Sheng Chen, Ying-Jung Chen, and Aidan Hung- Wen Tsai. Large cognition model: Towards pretrained eeg foundation model. arXiv preprint 2722 2025a.
11

---

Jingjing Chen, Xiaobin Wang, Chen Huang, Xin Hu, Xinke Shen, and Dan Zhang. A large finer- grained affective computing eeg dataset. Scientific Data, 10(1):740, 2023.
Junru Chen, Yang Yang, Tao Yu, Yingying Fan, Xiaolong Mo, and Carl Yang. Brainnet: Epileptic wave detection from seeg with hierarchical graph diffusion learning. In Proceedings of the 28th ACM SIGKDD conference on knowledge discovery and data mining, pp. 2741-2751, 2022.
Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pp. 1597-1607. PmLR, 2020.
Zheng Chen, Yasuko Matsubara, Yasushi Sakurai, and Jimeng Sun. Long-term eeg partitioning for seizure onset detection. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 39, pp. 14221-14229, 2025b.
Zhisheng Chen, Yingwei Zhang, Qizhen Lan, Tianyu Liu, Huacan Wang, Yi Ding, Ziyu Jia, Ronghao Chen, Kun Wang, and Xinliang Zhou. Uni-ntfm: A unified foundation model for eeg signal representation learning. arXiv preprint arXiv:2509.24222. 2025c.
James W Cooley and John W Tukey. An algorithm for the machine caleulation of complex fourier series. Mathematics of computation, 19990)) 1965.
Fernando Lopes da Silva. Eeg and meg: relevance to neuroscience. Neuron, 80(5): 11t111122211288 2013.
Tri Dao, Daniel Y Fu, Khaled K Saab, Armin W Thomas, Atri Rudra, and Christopher Ré. Hungry hungry hippos: Towards language modeling with state space models. arXiv preprint arXiv:2212. 14052, 2022.
Jacob Devlin, Ming-
Ming-Wei Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. Proceedings of the 2019 conference of the North American chapter of the association for computational linguistics: human language technologies, volume (long and short papers), pp. 4171-4188 2019.
Yi Ding, Yong Li, Hao Sun, Rui Liu, Chengxuan Tong, Chenyu Liu, Xinliang Zhou, and Cuntai Guan. deg-deformer: A dense convolutional transformer for brain-computer interfaces. IEEE Journal of Biomedical and Health Informatics, 29(3):999-1911 2024.
Daniel Y Fu, Elliot L Epstein, Eric Nguyen, Armin W Thomas, Michael Zhang, Tri Dao, Atri Rudra, and Christopher Ré. Simple hardware-efficien long convolutions for sequence modeling. In International Conference Machine Learning, pp. 10373-10391. PMLR, 2023.
Ary L Goldberger, Luis AN Amaral, Leon Glass, Jeffrey M Hausdorff, Plamen Ch Ivanov, Roger G Mark, Joseph E Mietus, George B Moody, Chung- Chung-Kang Peng, and H Eugene Stanley. Physiobank, physiotoolkit, and physionet: components new research resource for complex physiologic signals. circulation, 101(23):e21-e222 2000.
Albert Gu, Tri Dao, Stefano Ermon, Atri Rudra, and Christopher Ré. Hippo: Recurrent memory with optimal polynomial projections. Advances neural information processing systems, 33: 1487, 2020.
Albert Gu, Karan Goel, Ankit Gupta, and Christopher Ré. On the parameterization and initialization of diagonal state space models. Advances in Neural Information Processing Systems, 35:35971- 35983, 2022a.
Albert Gu, Karan Goel, and Christopher Re. Efficiently modeling long sequences with structured state spaces. In The Tenth International Conference on Learning Representations, 2022b.
Michele Guerra, Roberto Milanese, Michele Deodato, Madalina G Ciobanu, and Fausto Fasano. Exploring the diagnostic potential of llms in schizophrenia detcction through eeg analysis. In 2024 IEEE International Conference on Bioinformatics and Biomedicine (BIBM), pp. 2812-6819. IEEE, 2024.
12

---

Yiyu Gui, MingZhi Chen, Yuqi Su, Guibo Luo, and Yuchao Yang. Eegmamba: Bidirectional state space model with mixture of experts for eeg multi-task classification, 2024. URL https
//axxiv. otg/ abs 2207220274222
Hanning Guo, Farah Abdellatif, Yu Fu, N Jon Shah, Abigail Morrison, and Jürgen Dammers. Xaiguiformer: explainable artificial intelligence guided transformer for brain disorder identification. In The Thirteenth International Conference on Learning Representations, 2025.
Yong He, Jinhui Wang. Liang Wang, Zhang Chen, Chaogan Yan, Hong Yang, Hehan Tang, Chaozhe Zhu, Qiyong Gong, Yufeng Zang, et al. Uncovering intrinsic modular organization of spontaneous brain activity in humans. PloS one, 4(4):e5226, 2009.
JASPER HH. The ten-twenty electrode system of the international federation. Electroenceph clin Neurophysiol, 10:367-380, 1958.
Jiazhen Hong, Geoffrey Mackellar, and Soheila Ghane Eegm2: An efficient mamba-2-base self-supervised framework for long-sequence eeg modeling. arXiv preprint arXiv:2502.178733 2025.
Yongquan Hu, Shuning Zhang, Ting Dang, Hong Jia, Flora D Salim, Wen Hu, and Aaron Quigley. Exploring large-scale scale language models to evaluate eeg sagebased multimodal data for mental health. In Companion of the 2024 on ACM International Joint Conference Pervasive and Ubiquitous Computing, pp. 412-417, 2024.
Ji- Ji-Hoon Jeong, Hoong-Hyun Cho, Young-Eur Lee, Seo-Hyun Lee, Gi-Hwan Shin, Young- Kweon, José del R Millán, Klaus-Robert Müller, and Seong-Wor Whan Lee. 2020 international brain-computer interface competition: review. Frontiers in human neuroscience, 16:898300, 2022.
Ziyu Jia, Youfang Lin, Jing Wang, Kaixin Yang, Tianhang Liu, and Xinwang Zhang. Mmenn: A multi-branch multi-scale convolutional neural network for motor imagery classification. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, pp. 736-751. Springer, 2020.
Ziyu Jia, Tingyu Du, Zhengyu Tian, Hongkai Li, Yong Zhang, and Chenyu Liu. A multimodal bimamba network with test-time adaptation for emotion recognition based on physiological signals. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025.
Weibang Jiang, Liming Zhao, and Bao-liang Lu. Large brain model for learning generic represen- tations with tremendous eeg data in bei. In The Twelfth International Conference Learning Representations, 2024.
Weibang Jiang, Yansen Wang, Bao-liang Lu, and Dongsheng Li. Neurolm: universal multi-task foundation model for bridging the gap between language and eeg signals. In The Thirteenth International Conference on Learning Representations, 2025.
Jiarui Jin, Haoyu Wang, Hongyan Li, Jun Li, Jiahui Pan, and Shenda Hong. Reading your heart: Learning eeg words and sentences via pre-training ecg language model. In The Thirteenth International Conference Learning Representations, 2025.
Sirvan Khalighi, Teresa Sousa, José Moutinho Santos, and Urbano Nunes. Isruc-sleep: A comprehen- sive public dataset for sleep researchers. Computer methods and programs in biomedicine, 124: 180-192, 2016.
Dani Kiyasseh, Tingting Zhu, and David Clifton. Cloes: Contrastive learning of cardiac signals across space, time, and patients. In International Conference on Machine Learning, pp. 5606-5615. PMLR, 2021.
Demetres Kostas. Stephane AuelleOe,l,ette, and Frank Rudziez. Bendr: contrastive self-supervised learning task to learn from massive amounts of eeg data. Frontiers in Human Neuroscience, 15:653659, 2021.
Using transformers and
13

---

Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 66-71, 2018.
Vernon J Lawhern, Amelia Solon, Nicholas Waytowich, Stephen M Gordon, Chou Hung, and Brent Lance. Eegnet: a compact convolutional neural network for eeg-based brain- computr interfaces. Journal of neural engineering, 15(5):056013, 2018.
Hyojin Lee, You Rim Choi, Hyun Kyung Lee, Jaemin Jeong, Joopyo Hong. Hyun- Woo Shin, and Hyung-Sin Kim. Explainable vision transformer for automatic visual sleep staging multimodal pSg signals. npj Digital Medicine, 8(1):55, 2025.
Yuhong Li, Tianle Cai, Yi Zhang, Deming Chen, and Debadeepta Dey. What makes convolutional models great on long sequence modeling? arXiv preprint arXiv:2210.09298,, 2022.
Zhenqi Li, Jing Wang, Ziyu Jia, and Youfang Lin. Learning space-time-frqqumme representation with two-stream attention based 3d network for motor imagery classification. In 2020 IEEE International Conference on Data Mining (ICDM), pp. 1124-1129 IEEE, 2020.
Qika Lin, Tianzhe Zhao, Kai He, Zhen Peng. Fangzhi Xu, Ling Huang, Jingying Ma, and Mengling Feng. Self-supervised quantized representation for seamlessly integrating knowledge graphs with large language models. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 13587-13602, 2025a.
Qika Lin, Yifan Zhu, Xin Mei, Ling Huang, Jingying Ma, Kai He, Zhen Peng, Erik Cambria, and Mengling Feng. Has multimodal learning delivered universal intelligence healtheare? comprehensive survey. Information Fusion, 11:: 102795, 2025b.
Chenyu Liu, Xinliang Zhou, Jiaping Xiao, Zhengri Zhu, Liming Zhai, Ziyu Jia, and Yang Liu. Vsgt: Variational spatial and gaussian temporal graph models for eeg-based emotion recognition. In IJCAI, pp. 3078-3086, 2024a.
Chenyu Liu, Xinliang Zhou, Zhengri Zhu, Liming Zhai, Ziyu Jia, and Yang Liu. Vbh-gnn: Variational bayesian heterogeneous graph neural networks for cross-subject emotion recognition. In The Twelfth International Conference on Learning Representations, 2024b.
Chenyu Liu, Yuqiu Deng, Tianyu Liu, Jinan Zhou, Xinliang Zhou, Ziyu Jia, and Yi Ding. Echo: Toward contextual seq2seq paradigms in large eeg models. arXiv preprint arXiv:2509.22556. 2025.
Qijiong Liu, Xiaoyu Dong, Jiaren Xiao, Nuo Chen, Hengchang Hu, Jieming Zhu, Chenxu Zhu, Tetsuya Sakai, and Xiao-Ming Wu. Vector quantization for recommender systems: a review and outlook. arXiv preprint arXiv:2405.03110, 2024c.
Wei Liu, Jie-Lin Qiu, Wei- Zheng, and Bao- Bao- Liang Lu. Comparing recognition performance and robustness of multimodal deep learning models for multimodal emotion recognition. IEEE Transactions Cognitive and Developmental Systems, 14(2):715-729, 2021a.
Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 10012-10022, 2021b.
Jingying Ma, Qika Lin, Ziyu Jia, and Mengling Feng. St-usleepnet: A
coupling
prominence network for multi-channe sleep staging. In Proceedings of the Thirty-Fourts Interna- tional Joint Conference on Artificial Intelligence, pp. 4182-4190, 2025a.
Jingying Ma, Jinwei Wang, Lanlan Lu, Yexiang Sun, Mengling Feng, Feifei Zhang, Peng Shen, Zhiqin Jiang, Shenda Hong, and Luxia Zhang. Development and validation dynamic kidney failure prediction model based on deep learning: A real-world study with external validation. arXiv preprint arxiv:2501. 16388, 2025b.
Fabian Mentzer, David Minnen, Eirikur Agustsson, and Michael Tschannen. Finite scalar quantization: Vq vae made simple. In The Twelfth International Conference on Learning Representations, 2024.
14

---

Fumikazu Miwakeichi, Eduardo Martneez-Monter Pedro A Galdés-Sosaa Nobuaki Nishiyama, Hi- roaki Mizuhara, and Yoko Yamaguchi. Decomposing eeg data into space-time- wewtttiieeeeeeeee frequeenyy compo- nents using parallel factor analysis. Neurolmage, 22(3):0035-1055, 2004.
Navid Mohammadi Foumani, Geoffrey Mackellar, Soheila Ghane, Saad Irtza, Nam Nguyen, and Mahsa Salehi. Eeg2rep: enhancing self-supervised eeg representation through informative masked imputs. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pp. 5544-5555, 2024.
Wajid Mumtaz. MDD Patients and Healthy Controls EEG Data (New). Figshare, November 2016. URL httpthtttt/:shshhaeeeae
com articcles/cttasee//Bee Data New/ New/424417 4244171
Ernst Niedermeyer and FH Lopes da Silva. Ellectmencephallgrrapyyy basic principles, clinical applications, and related fiels.. Lippincott Williams & Wilkins, 2005.
Frontiers in Jathurshan Pradeepkumar, Xihao Piao, Zheng Chen, and Jimeng Sun. Single-channel eeg tokenization through freeufryyynccy modeling. arXiv preprint arXiv:2502. 2025.
Iyad Obeid and Joseph Picone. The temple university hospital eeg data corpus. neuroscience, 10:196, 2016.
Aniruddh Raghu, Payal Chandak, Ridwan Alam, John Guttag, and Collin M. Stultz. Sequential multi-dimensional self-supervised learning for clinical time series, 2023.
Syama Sundar Rangapuram, Matthias W Seeger, Jan Gasthaus, Lorenzo Stella, Yuyang Wang, and Tim Januschowski. Deep state space models for time series forecasting. Advances neural information processing systems, 31, 2018.
Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In 54th Annual Meeting of the Association for Computational Linguisties, pp- 1715-1725. Association for Computational Linguistics (ACL). 2016.
Ali Hossam Shoeb. Application of machine learning to epileptic seizure onset detection and treatment. PhD thesis, Massachusetts Institute of Technology, 2009.
Jimmy TH Smith, Andrew Warrington, and Scott Linderman. Simplified state space layers for sequence modeling. In The Eleventh International Conference on Learning Representations, 2023.
Yonghao Song, Xueyu Jia, Lie Yang, and Longhan Xie. Transformer-basee ppatial-tempora feature learning for eeg decoding. arXiv preprint 11X.:22006.1170, 2021.
Yonghao Song. Qingqing Zheng, Bingchuan Liu, and Xiaorong Gao. Eeg conformer: Convolutional transformer for eeg decoding and visualization. IEEE Transactions Neural Systems and Rehabilitation Engineering, 31:710-719, 2022.
William O Tatum IV. Handbook of EEG interpretation. Springer Publishing Company, 2021.
Yi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen, Dara Bahri, Philip Pham, Jinfeng Rao, Liu Yang, Sebastian Ruder, and Donald Metzler. Long range arena A benchmark for efficient transformers. The Ninth International Conference on Learning Representations, 2021. URL fittps://openrev/
https:
net www.:nne/oooorrreeee forum?id do
Anna Tegon, Thorir Mar Ingolfsson, Xiaying Wang, Luca Benini, and Yawei Li. Femba: Effi cient and scalable eeg analysis with a bidirectional mamba foundation model. arXiv preprint arXiv:2502. 06438, 064388 2025.
Xuan-The Tran, Linh Le, Quoc Toan Nguyen, Thomas Do, and Chin-Teng Lin. Eeg-ssm: Leveraging state-space model for dementia detection. arXiv preprint arXiv:2407.1780) 2024.
Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. In Advances in neural information processing systems, volume 30, 2017.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones. Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, volume 30, 2017.
15

---

Guangyu Wang, Wenchao Liu, Yuhong He, Cong Xu, Lin Ma, and Haifeng Li. Eegpt: Pretrained transformer for universal and reliable representation of eeg signals. In Advances in Neural Information Processing Systems, volume 37, pp. 99249-39280 2024a.
Jiquan Wang, Sha Zhao, Haiteng Jiang, Yangxuan Zhou, Zhenghe Yu, Tao Li, Shijian Li, and Gang Pan. Caresleepnet: a hybrid deep learning network for automatic sleep staging. IEEE Journal of Biomedical and Health Informatics, 2024b.
Jiquan Wang, Sha Zhao, Zhiling Luo, Yangxuan Zhou, Haiteng Jiang, Shijian Li, Tao Li, and Gang Pan. Cbramod: A criss-cross brain foundation model for eeg decoding. In The Third International Conference on Learning Representations, 2025.
Wenhai Wang, Jifeng Dai, Zhe Chen, Zhenhang Huang, Zhiqi Li, Xizhou Zhu, Xiaowei Hu, Tong Lu, Lewei Lu, Hongsheng Li, al. Internimage: Exploring large-scale scale vision foundation models with deformable convolutions. In Proceedings of the IEEE/CVF conference on computer vision and paltern recognition, pp. 14408-14419, 2023.
Yucheng Xing, Ling Huang. Jingying Ma, Ruping Hong, Jiangdong Qiu, Pei Liu, Kai He, Huazhu Fu, and Mengling Feng. Dpsurv: Dual-prototyy evidential fusion for uncertainty-awaat aware and interpretable whole-slide image survival prediction. arXiv preprint arXiv:2510.00055 2025.
Chaoqi Yang, Danica Xiao, M Brandon Westover, and Jimeng Sun. Self-supervised ceg representation learning for automatic sleep staging. arXiv preprint arXiv:21 2021.
Chaoqi Yang, M Westover, and Jimeng Sun. Biot: Biosignal transformer for cross-data learning in the wild. In Advances in Neural Information Processing Systems, volume 36, pp. 78240-78260, 2023.
Zhizhang Yuan, Daoze Zhang, Junru Chen, Gefei Gu, and Yang Yang. Brant-2: Foundation model for brain signals. CoRR, 2024.
Daoze Zhang, Zhizhang Yuan, Yang Yang, Junru Chen, Jingjing Wang, and Yafeng Li. Brant: Foundation model for intracranial neural signal. Advances in Neural Information Processing Systems, 04-23344-26321 2023.
Daoze Zhang, Zhizhang Yuan, Junru Chen, Kerui Chen, and Yang Yang. Brant-x: A unified physiological signal aligmment framework. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pp. 4155 4166, 2024.
Linqi Zhou, Michael Poli, Winnie Xu, Stefano Massaroli, and Stefano Ermon. Deep latent state space models for time-series generation. In International Conference Machine Learning, pp. 42625 42643.42643. PMLR, 2023.
Xinliang Zhou, Chenyu Liu, Zhisheng Chen, Kun Wang, Yi Ding, Ziyu Jia, and Qingsong Wen. Brain foundation models: A survey on advancements in neural signal processing and brain discovery. arXiv preprint ar MxXx:25533000550 2025a.
Yuchen Zhou, Jiamin Wu, Zichen Ren, Zhouheng Yao, Weiheng Lu, Kunyu Peng, Qihao Zheng, Chunfeng Song, Wanli Ouyang, and Chao Gou. Csbrain: cross-scale spatiotemporal brain foundation model for eeg decoding. arXiv preprint arXiv:2506.23000 23075, 2025b.
16

---

Appendix Contents
Related Work
18
Interpretability Analyses of TE TOKKNIZEE Representations
18
B.1
Exploring Frequency Token Patterns in Relation to Spectral Rhythms
19
B.2
Exploring Temporal Token Patterns in Relation to Neural Events
20
B.3
Class-Specific Token Ratio Analysis for TFDUAL- TFDUAL-TOKENIZZE TOKENIZER
21
B.4
Additional Ablations on Codebook Contribution
22
Structure State Space Model
22
Theoretical Analysis of Decoupled Codebook Training
24
E
Pretraining Results
25
E,
"FDUAL-TOKENIZER Pretraining Results
25
E.2 EEGSSSM Pretraining Results
26
Improving Temporal Codebook Learning via Contrastive Loss
26
Dataset Description
27
H Baselines and Metries Description
29
H.I Metries
29
H22 Baselines
29
Additional Evaluation Other BCT Tasks
30
J
Hyperparameter Setting
32
J.1
Pretraining Settings
33
J.2
Parameters of BEGSSM
33
J.3
Fine-tuning Settings on Downstream Tasks
34
K
Ablation on Design Choices
34
K.
Ablation on Mask Ratio
34
K.2
Ablation on SWA Window Size
................................
37
K.3
Ablation on Codebook Size
37
K.4
Ablation on Patch Size
38
K.5
Ablation on SGConv Kernel Parameters
38
K.6
Ablation on Subband
39
Backbone Efficiency Comparison
40
M
Model Robustness
41
M. Random Channel Dropout
41
M.2
Brain-Region Channel Dropout
42
M.3
Non-stationary Robustness
44
Detailed Results on Scaling Laws
44
N.I Scaling Laws with Respect to Training Data Volume
45
N.2
Scaling Laws with Respect to Model Size
................................
45
N.3 Computational Analysis Across Scales.
49
0
Low-Resource Comparison With Existing Methods
50
Limitations and Future Work
51
Use LLM
51
17

---

A RELATED WORK
EEG Foundation Models.
Inspired by foundation models in vision and language domains (Wang ).23). EEG research is shifting from task- models (Ding et al. Chen et al., 2025b; Liu et al. (024a) to EFMs for learning expressive
et al. 2023; Acchamm et al.
2024; Wang et al. | [2024b]
representations (Chen et al.]
3025c|Lin al. (025). Current EFMS can be divided into two categories.
1) Contrastive learning- srarning-based (CL. (Chen et | 2025a): BENDER (Kostas et al. (021) first showed
the ability of CL for EEG representations. Then, the Brant series (Zhang al. 2023 Yuan et al.)
2024: Zhang et al. 2024) enables joint representation learning across physiological signals using CL.
2) Reconstruction based: BIOT (Yang et al. 2023) pioneers moodl pretraining for biosignals, including EEG. Subsequent models focus specifically on EEG, learning representations by predicting masked discrete tokens (Jiang et al.
2024 2025) or reconstructing raw signals (Wang et al.) 2024a Mohammadi Foumani et al. 2024 Wang et al. 2025). Most existing EFMs adopt Transformer architecture, which is suboptimal for EBG due to poor handling of sparse dependencies, quadratic complexity, and the ignorance of local dependencies by treating each patch as a token.
Tokenization has been key in Natural Language Processing (NLP) for generat- ing generalizable and interpretable input representations (Sennrich et al.) 2016: Kudo & Richardson
EEG Tokenization.
2018). Inspired by this, early EFMs used patch-based continuous tokenization (Yang al. 2023
Yuan et al. 2024) to handle EEG noise and variability, but without quantization, leading to unbounded and less interpretable representations. LaBraM (Jiang et al.] 2024) introduced vector quantization to learn discrete EEG tokens, following the VQ-VAE design from vision tasks (Van Den Oord et al.
2017). However, this direct transfer overlooks EEG's heterogeneous structure, limiting representation reconstruction due to convergence issues with raw signals reconstruction. Later efforts (Pradeepkumar et al.) 2025 Jiang et al.) 2025 Guo et al. 2025) adopt frequency-dominant paradigm, where some methods employ single codebook for frequency modeling, limiting the representation space and interpretability.
capacity. Moreover, the tokenizer of LaBraM is trained only on frequency-domen
State Space Model. Recent works have focused on enhancing classic State-Space Models (SSM) to more efficiently model sequential data using deep learning. For example. Rangapuram al. (2018)
used recurrent neural networks to learn parameters in SSM. However, the most significant progress came from Gu al. (2022b) with the introduction of the structured state space model (S4), which reduces the computational complexity of SSM in modeling long sequences using a special state transition matrix (Gu al., (2020). These low-rank and normal matrices enable SSM to compute global convolution kernels efficiently through fast Fourier transform across the entire sequence. Subsequently, some works have further improved the shortcomings of S4 in areas such as model architecture (Smith et al., 2023) and convolution (Raghu et al., 2023), and have started applying tasks such as natural language processing (Dao et al. 2022 and time series analysis (Zhou et al. 2023). Recently, some works have also been applied to the EEG data, Tran et al. Tran et al. 2024) leveraging SSMs to detect dementia. They extract temporal information from EEG signals through the Mamba architecture and combine it with frequency domain features to better manage the complexity of multivariate EEG. In the work of Gui et al. (2024), SSM has also become the backbone network of the EEG foundation model. This further highlights the fast reasoning speed and efficient memory usage of the SSM model when processing EEG signals.
B INTERPRETABILITY ANALYSES OF TFDUAL-TOKENZER REPRESENTATIONN
We conduct representation-level interpretability analyses of the decoupled As case studies, we visualize selected tokens alongside well-established physiological patterns, il- lustrating that frequency codes reflect spectral rhythms and temporal codes align with characteristic waveform events. These qualitative examples show that the tokenizer does not discretize signals arbitrarily but organizes them into Nomain-relevan structures. We further complement these visual- izations with quantitative analysis of class-specift token usage across four datasets, demonstrating that the learned codebooks induce structured representation patterns. Such interpretability may help facilitate clinical understanding and trust (Ma et al. 2025b Xing et al. 2025).
18

---

B.1 EXPLORING FREQUENCY TOKEN PATTERNS IN RELATION TO SPECTRAL RHYTHMS
To illustrate the interpretable structure of the learned frequency tokens, we take sleep staging as an example downstream dataset. We focus on N2 and N3 stages, since they are characterized by the most distinctive spectral rhythms in clinical sleep scoring: spindle in the sigma band (11-16 Hz) for N2, and slow wave the delta band (0.5-4 Hz) for N3. Using token-activation statistics from the ISRUC S3 test set, we select the most frequently activated class-specific frequency tokens.
As shown in Figure frequency code No. 2298 tends to capture a sigma bump, with prominent peaks localized in the spindle range. This is similar to N2 spindles (Berry et al.) (012). Quantitatively, this code exhibited a clear sigma peak in approximately 15.4% of its assigned patches. Similarly, Figure shows that frequency code No. 32 predominantly encodes delta dominance, typical frequency feature of N3 sleep. This code displayed clear delta dominance in about 18.3% of its assigned segments. Taken together, these findings suggest that our frequency-brance tokenizer helps establish a frequency vocabulary for EEG.
Patterns Captured by Frequency Code No. 2298
Power
Power
Honer
Power
0.1
10
20
30
10
20
10
20
30
Fraquancy (Hz)
Fiequaney (H2)
Prequency (Ht)
Frequency (Bt)
Power
023
power
0.1
Sigma bump
a.
10
Power
N2 Stage
00 10 Prequency
Prequency
02
Power
Frequency (Hzz)
Frequency (11x)
Prequency (12z)
Power
Power
Power
Power
0.1
10
20
30
10
20
10 Prequency (Hz)
Prequency (Hz)
Frequency (Hz)
Prequency (HR)
Figure 5: Frequency code capturing sigma bump, a typical spectral rhythm of N2 stage.
Patterns Captured by Frequency Code No. 32
Power
0.5
Power
05
Power
10
10
30
20
10
20
Proquency (Hiz)
Frequency (71p)
Frequency (thr)
Preqpency (122)
Rower
Power
Delta power deminance
10
30
Power
N3 Stage
10
20
30
Froquency (Hz)
Frequency (Br)
Power
0.5
Power
85
Frequency (IIz)
Froguaney (H2)
Froquency (H2)
Ponerr
0.5
Power
Ponor
Woost
30
30
10
20
30
16
20
10 Frequencc (Hi)
Fraquancy (Hz)
Frequency (H4)
Frequsnacy (Hi))
Figure 6: Frequency code capturing delta dominance, a typical spectral rhythm of N3 stage.
19

---

B.2 EXPLORING TEMPORAL TOKEN PATTERNS IN RELATION TO NEURAL EVENTS
In addition to spectral rhythms, we applied the same token-activation-bent based selection procedure to the temporal codes on ISRUC_S3 examine whether the tokenizer captures coherent and clinically recognizable structures in the raw EEG waveforms. Figure and Figure show that certain codes align with K-complexes and sleep spindles, the hallmark waveforms of N2 sleep. Quantitatively, x 5.34% of the assigned patches contained K-complexes and z 7.01% contained spindles. These rates are consistent with clinical expectations (1-2 K-complexes and 2-5 spindles per minute in N2 Berry et al. (2012) and, when considering the overall prevalence of N2 in five-class sleep staging, still substantially exceed what would be expected from random token usage.
Patterns Captured by Temporal Code No. 1459
Auglinue (18)
Amplinde DAV)
Auglindee (WV)
spindle N2 Stage
M Mre
WN
A pmr
Mhwn MMy,yWi Wiw www
80
Time 6i)
Tase (6)
Auglttak (AY)
Ampliikk
W A h NM
M www My Naw Mow 1/1
dz
Time do
us
66
02
Tame
Time
Auginale (19)
Amplinde (PP)
Auplitde
my Maltrr mn
-py M
02
Auglinal (A))
Auplimse (I))
00
02
05
Time 63)
Time (5)
Thaee 64)
Figure 7: Temporal code capturing sleep spindle, typical neural events of N2 stage.
Patterns Captured by Temporal Code No. 134
Ampliaae (W))
Amplisse (PF)
Stage you
www.
K. Complex
02
06
80
04 66
05
02
u5
Time 64)
Time
6))
Time (4)
Anglhaue (AT)
My Man N/w
Amplitte
02
Angittale 6.1)
Amplinsk (VV)
00
06
06
Lize (3)
Time (1)
Lime (5)
AuglibaeeW
Amplinade
Auploste (WV]
w
My Mwma//mm y
02
86
66
02
C4
do
05
Time
Figure 8: Temporal code capturing K complex, a typical neural events of N2 stage.
Figure 9 shows that temporal code No. 1537 corresponds to slow waves, the defining feature of N3 sleep, occurring in ~ 40.4% of its assigned patches. This exceeds the 20% per-epoch criterion for N3 scoring Berry et al. (012)) and, given the overall prevalence of N3, indicates that this token provides meaningful link to neural events.
20

---

Patterns Captured by Temporal Code No. 1537
Anylitale GNV
Amplitude (aV)
Amplital
Slow Wave
N3 Stage
62
06
6b
02
Time DX
Line
Time
Auginaae (181)
Auplinde
Amplinate
02
06
(3)
Anyittal (4V)
Anplidde
Amplitsk
00
06
04
66
Time 69)
Time (6)
Time 63)
Augliuue (AV)
Amplinade (px)
Auplinde (WV)
ww
02
06
02
04
0s
Time
Figure 9: Temporal code capturing slow wave, a typical neural events of N3 stage.
Taken together, these observations suggest that the temporal branch of our tokenizer contributes to establishing vocabulary of neurophysiologial events, complementing the requeencydommall findings. While temporal waveforms are often noisier and harder to model than spectral rhythms (Jiang al. 2024), our decoupled design allows temporal tokens to emerge with meaningful associations to critical neural events. This indicates that the temporal branch offers useful insights to clinically relevant waveforms and demonstrates the effectiveness of our approach in capturing complementary structure.
B.3 FLASS-SPECIFES TOKEN RATIO ANALYSIS FOR TFDUAL- TOKKNIZEE
To further characterize the representation structure learned by the TFDUAL-TOKENIZER we analyze the distribution of token usage across classes on unseen downstream datasets. This analysis aims to examine whether the decoupled tokenizer induces more structured and class-consistent token activation patterns, which would support our motivation for separating temporal and frequency domains at the representation level.
token (code) considered class-specific if predominantly appears in samples of single class. Formally, for given token c, let (v()) denote the number of times e appears in class The dominance ratio is defined as:
Dominance(c) = maxy N:9))
(17)
Σ, N:())
Dominance(c) 2 т (we use = 1), the token deemed class-specific. The class-specific ratio for codebook is then computed as:
# class-specific tokens
Class-Specific Token Ratio
(18)
Total tokens in codebook
Figure [0 LOillustrates the proportion of class-specifie tokens derived from three configurations: using only the temporal codebook, only the frequency codebook, and a combination both (TF-Decoupled), We employ two independent codebooks capture complementary information via the proposed TFDUAL- TFDUAL-TOOKENIZE TOKENIZER module.
Across all four datasets, including for emotion recognition (FACED and SEED-V) and two for sleep staging (ISRUC S3 and ISRUC S1), the decoupled codebook consistently achieves the highest class-specific token ratios, reaching 54.7% ISRUC S3 and 46.4% FACED. These
21

---

results confirm that decoupling temporal and frequency domain information significantly enhances the model's ability to capture structured representation.
60
5%.7%
Mass-Speeifii Token Ratio (%)
50
46.4%
46.2%
40.7%
40
Temporal
30
26.2%
Frequency
Class- Specific
23.4%
TF-Decoupled
18.5%
20
13.2%
11.2%
10.9%
10
7.8%
2.5%
FACED
SEED-V
ISRUC_SS S3
ISRUC_S S1
Figure 10: Slass-specific code ratio across different codebooks.
B.4 ADDITIONAT. ABLATIONS ON CODEBOOK CONTRIBUTION
To further examine the role the tokenizer in pretraining, we provide additional exploratory evidence on how the the codebooks influence representation learning. These analyses extend the comparisons in Table 3.3 where the decoupled design outperforms temporal-only, frequency-only. and mixed codebooks. Specifically, compare the following ablations the ISRUC_SS dataset:
Raw-signal reconstruction. We remove the tokenizer entirely and train the EEGSSM backbone directly to reconstruct raw waveforms, thereby eliminating the discretization step.
Masked codebook. We identify the top 50% most frequently activated tokens across both codebooks on ISRUC S3. During pretraining, whenever segment is assigned one of these tokens, we replace with a placeholder, effectively masking half of the vocabulary and preventing the model from relying these high-activation codes.
Table 4 reports downstream performance ISRUC_S3 under these settings.
Table 4: Ablations of the codebook contribution ISRUC_S3.
Setting
Cohen's
Weighted F1
Balanced Acc
FFDDual.tokenizn (ours)
0.7671 = 0.0091
0.8202 0.0071
0.7856 0.0031
Raw-signal Reconstruction
0.7503 + 0.0087
0.8014 = 0.0079
0.7763 = 0.0048
Masked Codebook
0.7426 + 0.0102
0.7931 + 0.0084
0.7690 0.0063
These experiments do suggest that specific interpretable codes directly determine task outcomes. However, they provide supporting evidence that the decoupled tokenizer imparts useful structure during pretraining, and that entirely removing partially disabling the codebooks leads consistently degraded downstream performance. These observations reinforce the contribution of the tokenizer at the representation level.
C STRUCTURE STATE SPACE MODEL
The state-space model is a classic model in control theory, and it represents the operational state of a system using first-order differential equations (ODE). A continuous state-space model can be defined
22

---

in the following form:
r1(1) Ax(t) + v()))
+ Du(t);
(19)
where u(t) is vector that represents the imput of the system, while y(t) is vector that represents the output of the system, xt)) and its derivative x' xt(t) represent the latent states of the system, typically in the form of an N-D vector. And A, B, C, D here are the state, input, output, and feedforward matrices, defining the relationship between the input, output, and state vector. Following Gu et al. (Gu et al., 2022b), D is set equal to 0 since it can be replaced by the residual connection. Now, Equation 20 resembles an architecture similar to RNN, allowing us to recurrently compute Tj. Let unroll Eq 20 as follows:
the initial state be k = 0, and
yk Buo CAR-IBu, +... + CABu CBu
(20)
y - Ku, K Therefore, SSM can be transformed from the form of recurrent neural network convolutional neural network. During training, the K can be considered as a I-D globe convolution kernel, so the y can be calculated via the "long" convolution, allowing us use the fast Fourier transform to efficiently compute the SSM convolutional kernel K. However, directly computing the convolution in Equation can be very expensive for long sequences. We can use the Fast Fourier Transform to accelerate it. The form of this convolution can be written as:
CABB, .... C)+
(21)
y= FN Dj DuINu D2 diag(KFx))
(22)
where FN denotes the DFT matrix of size N. This FFT convolution has a computational complexity of (n)oogn))). Following (Li al. 2022 Fu et al. 2023). we hope to parameterize directly rather than through B, C because we can climinate complex paramcterization and accelerate the entire convolution.
While Eq. 22 shows that the SSM can be computed using FFT-based convolution, it is important to formalize the complexity guarantee. We now state the following proposition.
Proposition 1. Let (A, B, C, D) denote the discretized state-space matrices of an S4 layer, with input sequence u E NR,N The output y E TR.N can be written as a linear convolution y = * u with kernel
Nio D, kn = -C B, n 2 1.
Using the convolution theorem and the FFT, this convolution can be computed in time O N).
Proof. This proof follows the proof in Lemma C.2 of Gu et al. (022b):
Expanding the recurrence
En+1 = Axn + Bup
Un = Can + Dwns
(23)
yields
yn = Dun
CAn-1-iBul
kn-t Uts
(24)
t=0
1=0
where Ko D and k. CA Thus y k u.
Let FN denote the N-point DFT. By the convolution theorem,
Fx(u) (x) o Fx(u),
(25)
so that
(Fx ( FN(u)). The cost of forward FFT, element-wise product, and inverse FFT is OoNlog log
(26)
The $4 parameterization ensures A admits a takes the form
(DPLR) structure, so the kernel
kn
aay
2
r &
N
(27)
j=l
Each exponential sequence can be generated recursively in O(N), yielding all ko. .... .., kN-1 - in linear time.
Combining the above.
T(N)= = ON log N)+ +
(NN)
( N).
(28)
FFT convolution
kemel generation
23

---

D THEORETICAL ANALYSIS OF DECOUPLED CODEBOOK TRAINING
Proposition 2.1. Let X = (X,, denote the temporal and frequency representations of an EEG segment, assumed approximately independent. Consider additive reconstruction distortion
d(x, ④) = de( kx) , y). Under fixed total codebook size K = =2 a product codebook
C. x Cj with [Crl = 2 and [C,l = =2 R& + R2 = RR achieves minimum expected distortion
Pinad R))
min R
(29)
which satisfies
D
(R)
Drrod R)),
(30)
where D Diie(B)) (R) is the minimum distortion of a single mixed codebook Ciis Rd of size 2
Proof. The argument combines the separability of the rate-distortion (R-D) function for independent sources under additive distortion and the high-rate quantization approximation to the Shannon R-D limit.
Let X (X),X)) with X₁ 1 y,, and distortion
d(x, f) = d, d,(x,, + (
(31)
Then the Shannon R-D function satisfies
R(D) =
min De-Dy=D
(R((Di)+ + Rr)
(32)
where (-) and (-) are the marginal R-D functions for X₁ and x.. By convex duality, the optimal test channel factorizes:
p(ie; St x1, p(ue xx) p(ks xz))
(33)
and the optimal distortion allocation solves
min (D(D)) + RD() s.t. Dj - D,= DD Dr
(34)
with KKT condition
= R2
At rate R. bits for X, and Ry bits for X, (with R2 R2 R), the minimal achievable distortions
D2 (R)) and Dj D2(Rg) (Ry). In the high-rate regime, practical vector quantizers approach these Shannon limits, yielding
Dpred R4, Ry)
+
(35)
Optimizing over all feasible splits gives
Proal (R)
min
(D)(R.) + ()()))
(36)
R2 + Ry =
Any mixed codebook Cmix C Rddtdd with |Cmix| = f cannot beat the Shannon R-D limit, so
D miix (R) > (R)
(37)
But from
34
35
(*)
min R
(D) DD(
Driua (R).
(38)
Therefore,
D (R)
D (R).
(39)
Remark. We acknowledge that theoretically, X, and X, are coupled via the Fourier Transform. However, within the context Neural Vector Quantization, they behave as heterogeneous sources of information. For example, topological features in waveforms (e.g., K-complexes) and frequency den- sities in frequency (e.g.. Alpha rhythms) impose orthogonal constraints on the codebook optimization landscape. Therefore, the "approximate independence" in Proposition 2.1 should be interpreted as the functional independence of semantic distortions in the latent representation space, rather than the statistical independence of the signals.
24

---

E PRETRAINING RESULTS
Our model follows a two-stage pretraining framework. In the first stage, we train the TFDUAL- TOKENIZER, which independently tokenizes EEG signals both the temporal and frequency domains. This tokenizer is optimized to reconstruct the original raw EEG signals, amplitude, and phase components, thereby producing discrete code representations with structural interpretability. In the second stage, we pretrain the EEGSSM encoder using masked modeling objective: given the original EEG signals as input, the model learns to predict the corresponding masked tokens generated from the TODDUAL-TOKKNIZRRR
This section reports the pretraining results of both stages, including loss convergence, reconstruction dynamics, and codebook utilization patterns.
E.1 TFDUAL-TOKENIZE PRETRAINING RESULTS
Total Training Loss The total pretraining loss curve of the OFDUAL-TOKENTES is shown in Figure I1 The model demonstrates a rapid initial decrease in loss during the first few epochs,
followed by slower but consistent decline.
2.0
1.9
1/2
1.6
20
Eppoch
Figure 11: Pretraining loss curve of TEDUAL-TOKENIZER
We report the pretraining reconstruction loss TFDUAL-TOKENIZER in Figure 12 The temporal codebook is trained to reconstruct raw EEG signals in the time domain, while the frequency codebook is trained to reconstruct the corresponding amplitude and phase components in the frequency domain. All three loss curves exhibit sharp initial decline, followed by gradual convergence, indicating stable optimization.
Reconstruction Loss.
Raw Signals Reconstruction Loss
Amplitude Reconstruction Loss
Phase Reconstruction Loss
0.26
0.010
0.24
0.84
0.009
0.008
0.20
0.007
0.18
0.006
0.76
0.055
0.14
0.084
0.12
0.76
0.10
0.74
14
12
10
Epoch
Epoch
Epoch
Figure 12: Pretraining loss curve TOOUNIIT
Unused Codes Analysis. During pretraining, track the number of unused codes in both the temporal and frequency codebooks the TFDUAAL-TOKENIZER each with size of 4096. As shown in Figure 13 the frequency codebook demonstrates rapid decrease in unused codes, while the
25

---

temporal codebook shows slower and more incremental reduction. A more detailed analysis of the complementarity is provided Section B.3
Unused Temporal Codes
Unused Frequency Codes
300
200
Count
275
Count
100-
250
225
10
12
14
16
18
20
Epoch
Epoch
Figure 13: Unused code dynamics of the TOKEAI-
E.2 EEGSSSM PRETRAINING RESULTS
We plot the pretraining loss curve of EEGSSM in Figure We select epoch 10 as the checkpoint for downstream fine-tuning. We observe that the pretraining loss of EEGSSM decreases rapidly from epoch
(9.04 - 6.39), then flattens gradually after epoch 10 (6.01 - 5.66). Using epoch 10 for fine-tuning is balance between representation strength and generalization. Overtraining EEG, prone to noise and inter-subject variability, can reduce transferability. Epoch 10 serves as conservative yet effective checkpoint. This practice is consistent with trends in foundation models from NLP (Devlin et al.] (2019) and vision (Caron et al.) (021). where mid-training checkpoints often lead to better downstream performance than final ones due reduced overfitiing the pretext task.
Pretraining Loss
Used tuning
8.5
800
7.0
6.3
5.5
Epoch
Figure 14: Pretraining loss curve of EEGSSM.
F IMPROVING TEMPORAL CODEBOOK LEARNING VIA CONTRASTIVE LOSS
To improve the learning of the temporal codebook in our TFDUAL- TOKUNIIE, we introduce contrastive loss as one of the objectives during pretraining. This design is motivated by observations from prior work LaBraM Uiang al. 2024). where the authors report that reconstructing raw EEG signals leads to unconvergence, and thus omit the temporal reconstruction objective entirely.
To better understand this limitation, we first implemented a baseline reconstruction raw signals within the LaBraM framework and observed that the training loss plateaued a high value (between 0.128 and 0.131), showing no convergence over training epochs. To mitigate this, we introduce a TF. Conv module before the Transformer encoder, designed to extract temporal-frequency representations before tokenization. While this stabilizes training to some extent, we still observe significant issues with code utilization and loss convergence. Therefore, incorporate lightweight contrastive loss,
26

---

applied over temporal representations before quantization, to encourage the model to organize similar input patterns closer in the latent space. As shown in Figure 15 this improves the optimization of the reconstruction loss and reduces the number of unused temporal codes during training.
These results demonstrate that contrastive regularization acts as an effective prior for stabilizing discrete token learning, particularly when reconstructing raw signals. It both improves convergence and mitigates codebook collapse in the temporal branch of the tokenizer.
Raw Signals Reconstruction Loss
Unused Code in Temporal Codebook
0.012
400
With Contrastive Loss
0.010
Without Contrastive Loss
350
0.008
With Contrastive Loss
300
Without Contrastive Loss
0.006
250
0.004
10
15
20
$
10 Epoch
15
20
Epoch
Figure 15: Effect of contrastive loss on temporal codebook learning.
G DATASET DESCRIPTION
We evaluate the CodeBrain across eight diverse downstream tasks covering ten publicly available EEG datasets. Notably, these datasets exhibit substantial variability in channel configurations (ranging from 6 to 64), sequence lengths (from 1s 30s), and task complexities (2-class to 9-class), highlighting the versatility and robustness of Code Brain across different EEG applications. The following sections describe each dataset in detail, including its task objective and data split strategy. A comprehensive analysis of each dataset is provided below.
Emotion Recognition. We conduct emotion recognition experiments on two widely used EEG datasets: FACED (Chen et al. (003)) and SEED-V (Liu et al. 2021a).
The FACED dataset FFiner-Grained Affective Computing EEG Dataset) is large-scale EEG dataset for emotion recognition tasks (Chen et al.) 2023). It consists of 32-channel EEG recordings sampled 250 Hz from 123 participants, each exposed to 28 video clips designed to elicit nine distinct emotional states: amusement, inspiration, joy, tenderness, anger. fear, disgust, sadness, and neutral. These cover both positive and negative affective categories. Each EEG trial is 10 seconds long and is subsequently resampled to 200 Hz, resulting in total of 10,332 clean EEG segments. For fair comparison, we adopt the same subject- wabject-wiseetaa split as in (Wang et al. 2025): subjects 1-80 are used for training, 81-100 for validation, and 101-123 for testing, ensuring subject overlap across splits and enabling evaluation of cross-subject generalization.
SEED-V (Liu al., 2021a) is an EEG dataset designed for emotion recognition, covering five emotional categories: happy, sad, neutral, disgust, and fear. It consists of 62-channel EEG recordings collected at 1000 Hz from 16 subjects, each participating in three sessions. Each session includes 15 trials, which are evenly divided into training, validation, and test sets (5 trials each). The EEG signals are segmented into 1 1-second windows, yielding a total of 117,744 samples, and resampled to 200 Hz.
Sleep Staging. We use two datasets, ISRUC S1 and ISRUC S3 (Khalighi et al. 2016), for sleep stage classification. Both datasets are annotated according to the American Academy of Sleep Medicine (AASM) standard (Berry et al. 2012), with five sleep stages: Wake, NREMI (NI), NREM (N2), NREM (N3), and REM. Each EEG segment corresponds to a 30-second epoch.
ISRUC_S1 includes EEG recordings from 100 subjects using six channels at sampling rate of 200 Hz. We adopt a subject-wise split, with 80 subjects for training. 10 for validation, and 10 for testing. As the transition rules between sleep stages carry important temporal patterns, we follow prior work
(Wang et al.] 2024a| 2025) Zhou et al. 20255) and insert a Transformer layer on top of the prediction head during fine-tuning better capture sequence-level dependencies. We set the input sequence
27

---

length to 20, and discard segments that cannot be evenly divided. In total, 86,320 labeled samples retained.
ISRUC S3 is smaller dataset comprising recordings from 10 subjects, also sampled at 200 Hz with six channels, totaling 8,500 labeled segments. We follow an 8:1:1 subject-wise split for training, validation, and testing-
Imagined Speech Classification. The BCIC2020-T3 dataset (Jeong et al.) 2022 was released as part of the 2020 International Brain-Computer Interface Competition and focuses on imagined speech decoding. It contains EEG recordings from 15 participants who were instructed to silently imagine speaking five specific words or phrases, "hello", " "help me", " "stop", "thank you", and "yes". EEG signals were collected using 64 scalp channels a sampling rate of 256 Hz and were subsequently resampled to 200 Hz for preprocessing consistency. Each subject completed 80 trials per class, resulting in a total of 6,000 trials. The dataset provides predefined training, validation, and test splits, with 60, 10, and 10 trials per class, respectively, facilitating fair model evaluation like existing baselines (Wang et al. 2025).
Mental Stress Detection. The Mental Arithmetic dataset (Mumtaz 2016) supports the task of mental stress detection using EEG signals. It contains recordings from 36 subjects under two distinct cognitive conditions: resting and active engagement in mental arithmetic. EEG data labeled as "no stress" correspond to resting periods prior the task, while "stress" labels are assigned to recordings during task performance. The signals were acquired using 20 electrodes placed according to the international 10-20 system, with original sampling rate of 500 Hz. For consistency, the signals resampled to 200 Hz and band-pass filtered between 0.5-45 Hz to suppress noise. Each recording is segmented into 5-second windows, yielding total of 1,707 samples. We adopt subject-wise split for fair evaluation with existing baselines (Wang et al. 2025): subjects 1-28 for training, 29-32 for validation, and 33-36 for testing.
Seizure Detection. The CHB-MIT dataset (Shoeb 2009) is a widely used benchmark for seizure detection from EEG signals. It contains long-term EEG recordings from 24 patients diagnosed with intractable epilepsy, collected at the Children's 's Hospital Boston. The subjects underwent continuous monitoring over several days. during which seizures were recorded following the tapering of anti- epileptic medications. EEG signals were acquired using the international 10-20 system and originally sampled at 256 Hz. In our setting, we adopt 16 channels commonly used in prior work (Yang et al.) 2023, Wang et al.] 2025), resample all signals to 200 Hz,, and segment them into 10-second non- overlapping windows, yielding 326,993 labeled samples across seizure and non-seizure classes. We follow a subject-wiss split: subjects 1-20 for training (excluding subjects with insufficient recordings), 21-22 for validation, and 23-24 for testing. Notably, this dataset is highly imbalanced, with seizure events constituting only a small fraction of the total samples, posing significant challenges for model training and evaluation.
Motor Imagery Classification. The SHU-MI dataset (Goldberger al. 2000) is designed for binary motor imagery classification, where participants are instructed to imagine movements of either the left or right hand. BEG signals were recorded from 25 subjects using 32-channel setup at an original sampling rate of 250 Hz. To ensure consistency with the pre-training setting, all signals are resampled to 200 Hz and segmented into 4-second -on-oaerlap windows, resulting in 11,988 labeled samples. A subject-wist split is applied for fair model evaluation like existing baselines (Wang et al. 2025), with subjects 1-15 used for training, 16-20 for validation, and 21-25 for testing. This dataset supports the development of BCI systems that decode motor intentions from brain activity without actual movement.
Event Type Classification. The TUEV dataset (Obeid Picone 2016) a clinically annotated EEG corpus used for multi-class event type classification. It includes six event categories: spike and sharp wave (SPSW), generalized periodic epileptiform discharges (GPED), periodic lateralized epileptiform discharges (PLED), eye movements (EYEM), artifacts (ARTF), and background activity (BCKC). EEG signals were originally recorded at 256 Hz using 23 channels. In line with prior work (Wang et al. 2025), we preprocess the data by selecting 16 bipolar montage channels based on the international 10-20 system. The signals are band-pass filtered between 0.3-75 Hz to suppress low- and high-frequency noise, and 60 Hz notch filter is applied to eliminate power line interference. All
28

---

recordings resampled to 200 Hz and segmented into 5-second windows, yielding 112,491 labeled samples. We follow the official train-test split and further divide the training subjects into training and validation sets in an 8:2 ratio, consistent with established benchmarks.
Abnormal Detection. The TUAB dataset (Obeid & Picone 2016) is employed for binary abnormal EEG detection, where each EEG recording is labeled as either normal or abnormal based on clinical interpretation. Originally recorded at 256 Hz using 23 channels, the dataset provides large-scale EEG recordings suitable for evaluating diagnostic models. To ensure fair comparison with prior work (Wang et al. ). we follow similar preprocessing protocol. Specifically, we select 16 bipolar montage channels following the international 10-20 system, apply band-pass filtering between 0.3-75 Hz to eliminate low- and high-frequency artifacts, and remove 60 Hz power line interference using a notch filter. The EEG signals then resampled 200 Hz and segmented into 10-second windows, resulting in 409,455 455 labeled samples. We follow the official train-test split and further divide the training set into training and validation subsets using an 8:2 subject- wise ratio, consistent with existing benchmarks.
H BASELINES AND METRICS DESCRIPTION
H.1 METRICS
To comprchensively evaluate our model, we compare it with a set of strong basclines commonly used EEG analysis. These baselines are evaluated using metrics tailored for class-imbalanced scenarios, which are prevalent in EEG datasets. The metrics include:
Balanced Accuracy, which averages the recall across all classes and is particularly suitable for imbalanced multi-class classification tasks.
AUROC and PRAUC, which assess the performance of binary classifiers under different thresholds. While AUROC measures the trade-off between sensitivity and specificity. PRAUC focuses on precision-recall trade-offs, especially informative under severe class imbalance.
Cohen's Kappa, which quantifies inter-class agreement beyond chance and is employed as the primary metric for multi-class classification.
Weighted F1 Score, which combines precision and recall while adjusting for class support, ensuring fair performance measurement across imbalanced datasets.
For model selection and comparison, AUROC is used the main evaluation metric for binary classification tasks, and Cohen's 's Kappa is used for multi-class scenarios.
H.2 BASELINES
We compare our CodeBrain model against a comprehensive set of baseline models that include widely used task-specific models, as well as publicly available EEG foundation models.
EEGNet (Lawhern et al. 2018). EEGNet compact convolutional neural network specifically designed for EEGG-based BCI tasks. It adopts septhwwse-separable convolutions to disentangle temporal filtering and spatial pattern learning, enabling efficient parameter usage while preserving discriminative EEG features.
(Song et al., 2022). BEGConformer integrates convolutional front-ends with Transformer blocks to jointly capture local temporal dynamics and longer-range dependencies. Its convolution modules extract short-term EEG patterns, while the attention mechanism models cross-channel and tross-time interactions.
EEG Conformee
ContraWR YYng et al. 2021). ContraWR is self-supervised representation learning framework that uses contrastive learning with a weakly-supervinn relational task. By contrasting EEG segments from the same versus different contexts, the model learns invariant temporal representations without relying on explicit labels.
ST-Transformer (Song et al., 202T. ST-Transformer applies Transformer attention to EEG by factorizing spatial and temporal modeling. It processes EEG structured sequence across both
29

---

dimensions, where attention layers capture inter-channel relationships well as time- varying depen- dencies.
We also compare CodeBrain against publicly available EFMs that have released pre-trained weights, covering a diverse set of pretraining strategies to evaluate the effectiveness of different foundation model designs and pretraining paradigms under comparable settings.
BENDR (Kostas et al. 2021): We adopted BENDR (Bert-inspired Neural Data Representations) as baseline model, introduced by Kostas et al. BENDR is pioneering deep learning architecture for Ellecroenceehaaloggaphh (EEG) data, leveraging transformers and a contrastive self-supervised learning task. This approach enables the model to learn meaningful representations from vast amounts of unlabeled EEG data.
BIOT (Yang al. 2023); BIOT (Biosignal Transformer for Cross-data Learning in the Wild) is a transformerrbased architecture designed to handle cross-dataset EEG signal classification under domain shifts. It leverages domain-invartit invariant attention mechanism and contrastive representation learning to enhance generalization across different recording conditions and subject populations.
LJBaaM(Jiang et al. 2024): LaBraM (Large Brain Model) proposes scalable transformer-bases framework designed to learn generic EEG representations from large-scale brain signal datasets. By pretraining on a diverse corpus of EEG recordings, the model captures rich temporal and spatial features that transfer effectively to various downstream BCI tasks. The architecture incorporates efficient self-attention mechanisms and task-specific adapters to support flexible fine-tuning.
EEGPT [Wang et al. 2024a): EEGPT employs a dual self-supervised learning strategy that combines masked autoencoding with spatial temporall representation alignment, enhancing feature quality by focusing on high signal-to-noise ratio (SNR) representations rather than raw signals. The model's 's hi- crarchical architecture decouples spatial and temporal processing, improving computational efficiency and adaptability to various brain-computer interface (BCT) applications.
CBraMod (Wang et al., 2025): ) CBraMod (Criss-Crev Brain Foundation Model) is a transformer- based EEG foundation model that addresses the heterogeneous spatial and temporal dependencies inherent in EEG signals. It introduces a criss-cross transformer architecture comprising parallel spatial and temporal attention mechanisms, enabling separate yet simultaneous modeling of spatial and temporal relationships.
I ADDITIONAL EVALUATION ON OTHER BCI TASKS
We report the performance of CodeBrain on four additional EEG datasets not included in the main text, covering diverse domains of sleep staging, motor imagery, event detection, and abnormality classification in Tables 5 to 8 These allow us to assess the cross-domain generalization ability of our pretrained model beyond the main text.
We note that both TUAB and TUEV originate from the TUH EEG corpus (Obeid & Picone 2016). which overlaps with our pretraining source (TUEG). To avoid overfitting this distribution and promote generalization, we stop pretraining at epoch 10 as discussed in Section E.2 While this may limit gains on TUH datasets compared to previous EFM, such as CBraMod (trained for 40 epochs in the same pretraining dataset) (Wang et al. 2025). CodeBrain still achieves superior or competitive results.
ISRUC_S1 As shown in T CodeBrain achieves state-of-the-ar performance on ISRUC_S1 in terms of Cohen's 's Kappa (0.7476) and Weighted F1 (0.8020), slightly surpassing CBraMod (Wang ctt al. 2025) by +0.34 and +0.09 points, respectively. Its Balanced Accuracy of 0.7835 is also competitive, trailing the best result by only -0.30. These results highlight the model's ability to capture temporal dependencies and learn discriminative representations for 5-class sleep staging under cross-subject setting.
As shown in Table CodeBrain achieves the best overall performance SHU-MI across all three metrics. It obtains an AUROC of 0.7124 and an PRAUC of 0.7166, slightly improving over the previous best by +1.36 and +0.27 points, respectively. For Balanced Accuracy, it reaches 0.6431
SHU-MI
30

---

Table 5: Performance comparison the ISURC_S1 (5-Class) dataset.
Methods
Cohen's Kappa
Weighted F1
Balanced Accuracy
BEGNet
0.7040 = 0.0173
0.7513 # 0.0124
0.7154 0.0121
EEGConformer
0.7143 = 0.0162
0.7634 # 0.0155
0.7400 = 0.0133
ContraWR
0.7178 # 0.0156
0.7610 # 0.0137
0.7402 # 0.0126
ST-Transformer
0.7013 = 0.0352
0.7681 = 0.0175
0.7381 = 0.0205
BONDa et al.
2021
0.6956 + 0.0053
0.7569 + 0.0049
0.7401 = 0.0056
BIO1 Yang al. (2023)
0.7192 0.0231
0.7790 + 0.0146
0.7527 0.0121
LaBraMJiang et (2024)
0.7231 = 0.0182
0.7810 = 0.0133
0.7633 0.0102
EEGP Wang et al.
(2024a)
0.2223 = 0.0227
0.3111 0.0110
0.4012 = 0.0177
CBraMod Brag et al. (2025)
0.7442 + 0.0152
0.8011 + 0.0099
0.7865 = 0.0110
CodeBrain
0.7476 0.0040
0.8020 + 0.0018
0.7835 0.0033
(+0.61), with notably lower variance. These results underscore its strong generalization motor imagery decoding under a cross-subject protocol.
Table 6: Performance comparison the SHU-MI (2-Class) dataset.
Methods
AUROC
PRAUC
Balanced Accuracy
BEGNet
0.6283 # 0.0152
0.6311 # 0.0142
0.5889 = 0.0177
EEGConformer
0.6351 0.0101
0.6370 # 0.0093
0.5900 0.0107
ContraWR
0.6273 = 0.0113
0.6315 = 0.0105
0.5873 = 0.0128
STTrrnssfore
0.6431 = 0.0111
0.6394 = 0.0122
0.5992 = 0.0206
Kostas et al.
2021
0.5863 + 0.0280
0.5853 + 0.0268
0.5573 = 0.0227
BIOT Yang et al. (2033)
0.6609 = 0.0127
0.6770 = 0.0119
0.6179 = 0.0183
LaBraMJJang et al. (2024)
0.6604 = 0.0091
0.6761 = 0.0083
0.6166 0.0192
EEGP Wang et al.
(0224))
0.6241 + 0.0071
0.6266 + 0.0133
0.5778 + 0.0162
CBraMod CBraModWang et al. (2025
0.6988 + 0.0068
0.7139 + 0.0088
0.6370 = 0.0151
CodeBrain
0.7124 + 0.0050
0.7166 # 0.0106
0.6431 = 0.0066
As shown in Table 7 CodeBrain achieves the highest Cohen's Kappa (0,6912, an improve- ment of +0.0140 over the best baseline (Wang al. 2025)) and Weighted Fl (0.8362) on TUEV. Although its Balanced Accuracy is lower than CBraMod (Wang et al. 2025). we attribute this to reduced sensitivity on the rare SPSW class. Since TUEV shares distributional overlap with pretraining source (TUEG), we stop pretraining at epoch 10 to prevent overfitting, unlike CBraMod's 40-epoch training discussed in subsectton H.2 We also report LaBraM's results based its original 23-channel setting (Jiang et 2024). while CodeBrain follows the 16-channel configuration used in CBraMod. Similarly, EEGPT (Wang but applies two convolutional layers before entering the foundation model, followed by an ML. head. While such architectural choices may enhance performance, we follow their respective fine-tuning settings. In addition, following the experimental setup of CBraMod, we also report the results of experiments conducted by removing all TUEV and TUAB samples from the TUEG dataset. It can be seen that although our model's performance slightly declined on TUEV, it still surpassed other baselines. such cases, CodeBrain still outperforming both LaBraM and EEGPT under their own fine-tuning settings clearly demonstrates the robustness of our approach.
TUEV
(024a) does not adopt a linear fine-tuning protocol
TUAB
As shown in Table 8
CodeBrain achieves the highest Balanced Accuracy (0.8294)
TUAB, slightly outperforming CBraMod (Wang et al.) 2025). Similar to TUEV, TUAB is part of the TUH EEG corpus family (Obeid Picone 2016) and thus closely aligned with our pretraining
31

---

Table 7: Performance comparison on the TUEV (6-Class) dataset.
Methods
Cohen's Kappa
Weighted F1
Balanced Accuracy
EEGNet
0.3577 # 0.0155
0.6539 # 0.0120
0.3876 = 0.0143
EEGConformer
0.3967 = 0.0195
0.6983 + 0.0152
0.4074 = 0.0164
ContraWR
0.3912 # 0.0237
0.6893 # 0.0136
0.4384 # 0.0349
ST-Transformer
0.3765 = 0.0306
0.6823 = 0.0190
0.3984 0.0228
BoNDs et al.
2021
0.4271 = 0.0238
0.6755 + 0.0216
0.4363 = 0.0245
BI01 Yang al. (2023)
0.5273 = 0.0249
0.7492 + 0.0082
0.5281 0.0225
LaBraMJiang et (2024)
0.6637 = 0.0093
0.8312 = 0.0052
0.6409 = 0.0065
EEGP Wang et al. (2024a)
0.6351 = 0.0134
0.8187 = 0.0063
0.6232 = 0.0114
CBraMod Wang et al. (2025)
0.6772 = 0.0096
0.8342 + 0.0064
0.6671 = 0.0107
CodeBrain (Excluding)
0.6838 = 0.0291
0.8293 # 0.0163
0.6375 = 0.0182
CodeBrain
0.6912 = 0.0101
0.8362 # 0.0048
0.6428 = 0.0062
source (TUEG). As discussed in subsection E.2 we adopt an early stopping strategy at epoch 10 to mitigate overfitting to this distribution, which may partly account for the slightly lower AUROC and PRAUC compared to CBraMod, trained for 40 epochs on the same dataset. While LaBraM leverages a 23-channel montage (Jiang et al. 2024) and EEGPT (Wang et al.) 2024a) employs two convolutional layers before the foundation model, we retain their respective fine-tumi model is smaller on the TUAB dataset, and in some experiments it can even surpass situations without leaking. This may be due the larger size of the TUAB dataset. Despite these potentially stronger configurations, CodeBrain still exceeds both models under their own settings, highlighting its strong and consistent generalization.
comparison. In addition, the impact of duplicate data in the pre-training tine-tuning protocols for
Table 8: Performance comparison on the TUAB (2-Class) dataset.
Methods
Balanced Accuracy
PRAUC
AUROC
BEGNet
0.7642 # 0.0036
0.8299 # 0.0043
0.8412 # 0.0031
EEGConformer
0.7758 # 0.0049
0.8427 0.0054
0.8445 0.0038
ContraWR
0.7746 # 0.0041
0.8421 # 0.0104
0.8456 # 0.0074
ST-Transformer
0.7966 # 0.0023
0.8521 # 0.0026
0.8707 # 0.0019
Bosta et al.
2021
0.7714 = 0.0248
0.8412 # 0.0215
0.8426 = 0.0237
BIOT Yang et al. (0023)
0.7959 = 0.0057
0.8792 # 0.0023
0.8815 # 0.0043
LaBraMJiang et al. (2024)
0.8140 # 0.0019
0.8965 # 0.0016
0.9022 0.0009
EEGP Wang et al.
(2024a)
0.8038 # 0.0040
0.8891 # 0.0018
0.8811 0.0015
CBraMod Wang et al. (005
0.8289 = 0.0022
0.9258 # 0.0008
0.9227 + 0.0011
CodeBrain (Excluding)
0.8288 + 0.0064
0.9061 # 0.0039
0.9012 # 0.0020
CodeBrain
0.8294 # 0.0013
0.9100 # 0.0006
0.9030 + 0.0009
J HYPERPARAMETER SETTING
We provide detailed hyperparameter configurations for the two-stage pretraining of our CodeBrain model and the fine-tuning settings across ten downstream tasks.
32

---

J.1. PRETRAINING SETTINGS
The pretraining process consists of two stages: (1) training the TFDUAI- and (2) training the EEGSSM. The hyperparameters used in each stage are summarized in Table 9 and Table TO respectively.
Table 9: Hyperparameters for TFDUAL-TOKENZZE TOKENIZER.
Hyperparameters
Values
TFCony
Input channels
11, 8, 4]
Output channels
8, 4,4
Kernel size
(1, (1, (1,3),
Stride
(1, ().
Padding
{0, (0,
Transformer encoder layers
12
Transformer decoder layers
3
Hidden size
200
MLP size
800
Attention head number
8
Temporal Codebook size
4096 x 32
Frequency Codebook size
4096 32
Codebook initialization
Random init + I normalization
Batch size
256 le-4
Peak learning rate Minimal learning rate
le-5
Learning rate scheduler
Cosine
Optimizer
AdamW
Adam 3
(0.9, 0.99)
Weight decay
lc-4
Warm-up steps
5
Total epochs
20
Data stride
200
Contrastive temperature (r) 0.5
Table 10: Hyperparameters of pre- pre-training.
Hyperparameters
Values
Epochs
10
Batch size
256
Dropout
0.1
Optimizer
Adam
Learning rate
le-4
Adam 8
(0.9, 0.999)
Adam
1e-8
Weight decay
5e-3
Scheduler
CosincAnnealingLR
Minimal learning rate
le-5
Clipping gradient norm
5
J.2 PARAMETERS OF EEGSSM
The model architecture parameters used in EEGSSM during pre-training shown in Table 11
33

---

Table 11: Configuration of ERGSSM
Parameters
Values
Input size
200
Hidden dimension
200
Output size
200
Number of layers
Max sequence length
570
SGConv state
64
SGConv bidirectional
True
Layer normalization
True
Sliding window attention length
1s
J.3 FINE-TUNING SETTINGS ON DOWNSTREAM TASKS
The CodeBrain model is fine-tuned on ten downstream EEG classification tasks, each with task- specific hyperparameters. Following the general strategy adopted by prior EFMs, we adopt lightweight three-layer MLP as the probe head for all downstream tasks and fine-tune the entire model end-to-end. Table 1illsss the fine-tuning configurations including learning rate, weight decay, dropout rate, and batch size for each task. For sleep staging tasks, due to their strong temporal structure, we follow prior work (Wang et al. 2024a 2025) and insert an additional Transformer encoder on top of the projection head to jointly model the sequence of 20 consecutive EEG segments. This enables the model to capture inter-epoch transitions critical to sleep stage classification.
Table 12: Fine- Fine-tuning hyperparameters for downstream tasks.
Dataset
Learning Rate
Weight Decay
Dropout
Batch Size
FACED
5e-5
5e-4
0.1
16
SEED-V
5e-5
le-2
0.1
64
ISRUC_S
le-4
le-1
0.2
48
ISRUC_S3
le-4
le-1
0.2
48
BCIC2020-T3
5e-5
5e-2
0.1
32
Mental Arithmetic
3e-5
le-3
0.1
32
CHB-MIT
3e-5
le-2
0.4
64
SHU-MI
5e-5
5e-3
0.3
64
TUEV
2e-5
5e
0.3
64
TUAB
le-5
5e-5
0.4
512
K ABLATION ON DESIGN CHOICES
K.1 ABLATION ON MASK RATIO
We conduct an ablation study to investigate the effect of the mask ratio in the EEGSSM pretraining framework. As shown in Tables 13 and Figure T6 downstream performance consistently exhibits U-shaped trend with respect to the masking ratio across all three datasets: FACED, SEED-V. V, and ISRUC S3. Moderate masking (e.g., ratios around 0.4-0.6) leads to optimal performance, whereas excessively low (e.g., 0.1) or high (e.g., 0.9) ratios degrade generalization.
To further illustrate this pattern, we visualize the training loss curves across different mask ratios in Figure Interestingly, higher mask ratios result in slower convergence and higher final training loss, which is expected due to the increased difficulty of the reconstruction task. In contrast, lower mask ratios lead to faster and smoother loss reduction, but do not necessarily yield better downstream performance. This observation suggests a possible optimization-v -sseitioo-------e generalization pretext tasks (low mask ratio) more optimizable but may encourage the model learn shortcut solutions with limited generalizability, while overly difficult tasks (high mask ratio) may hinder effective representation learning due to insufficient learning signal. Moderate masking strikes
intiiiiaatioo-s-geeeaaaaaaaatt trade-off: easier
34

---

Table 13: Performance of CodeBrain on FACED dataset under different mask ratios.
Mask Ratio
Cohen's Kappa
Weighted FI
Balanced Accuracy
0.1
0.5184 + 0.0039
0.5746 + 0.0158
0.5692 + 0.0064
0.2
0.5239 + 0.0036
0.5834 = 0.0071
0.5821 = 0.0040
0.3
0.5327 + 0.0100
0.5859 = 0.0036
0.5836 + 0.0076
0.4
0.5391 = 0.0045
0.5938 0.0057
0.5904 = 0.0058
0.5
0.5406 + 0.0084
0.5953 = 0.0113
0.5941 + 0.0098
0.6
0.5295 + 0.0075
0.5822 = 0.0090
0.5793 = 0.0112
0.7
0.5242 + 0.0077
0.5800 = 0.0065
0.5744 + 0.0096
0.8
0.5157 = 0.0065
0.5564 0.0067
0.5528 = 0.0040
0.9
0.5034 + 0.0078
0.3457 = 0.0084
0.5451 + 0.0114
Table 14: Performance of CodeBrain SEED-V dataset under different mask ratios.
Mask Ratio
Cohen's Kappa
Weighted FI
Balanced Accuracy
0.1
0.2523 0.0051
0.4081 0.0030
0.3968 0.0031
0.2
0.2633 0.0033
0.4137 0.0027
0.4071 0.0035
0.3
0.2703 = 0.0043
0,4200 + 0.0048
0,4121 + 0.0041
0.4
0.2734 0.0042
0.4244 0.0029
0.4142 0.0055
0.5
0.2735 0.0032
0.4235 0.0022
0.4137 0.0023
0.6
0.2699 0.0041
0.4207 0.0059
0,4106 + 0.0048
0.7
0.2642 + 0.0045
0,4158 + 0.0033
0,4091 + 0.0040
0.8
0.2603 0.0031
0.4116 0.0041
0.4009 0.0025
0.9
0.2534 0.0036
0.4085 0.0024
0.3993 0.0055
Table 15: Performance of CodeBrain on ISRUC S3 dataset under different mask ratios.
Mask Ratio
Cohen's Kappa
Weighted F1
Balanced Accuracy
0.1
0.7252 0.0069
0.7865 0.0039
0.7686 + 0.0072
0.2
0.7403 0.0023
0.7982 0.0026
0.7752 0.0032
0.3
0.7501 0.0057
0.8013 0.0062
0.7766 0.0020
0.4
0.7608 + 0.0060
0.8168 + 0.0078
0.7846 + 0.0062
0.5
0.7671 0.0091
0.8202 0.0071
0.7856 0.0031
0.6
0.7661 0.0068
0.8219 0.0052
0.7826 0.0076
0.7
0.7577 0.0068
0.8161 0.0040
0.7782 0.0061
0.8
0.7471 + 0.0031
0.8090 + 0.0041
0.7658 + 0.0025
0.9
0.7504 0.0078
0.8125 + 0.0063
0.7668 0.0065
balance by being sufficiently challenging to promote abstraction, while still being learnable, thereby facilitating better generalization across downstream tasks.
35

---

Different Mask Ratios FACED
Cohen's Kappa
Weighted F1
Balanced Accuracy
0.60
0.55
0.38
0.52
0.54
0.54
Mask
Mask
Mask
(b) Different Mask Ratios SEED-V
Cohen's Kappa
Waighted F1
Balanced Accuracy
0.125
0.37
0.45
0.110
0.45
6400
0.35
4.0
0395
Mask Ratio
Mash Ratio
(c) Different Mask Ratios ISRUC S3
Cohen Kappa
Weighted F1
Balanced Accurney
0.79
082
0.75
0.50
0.77
0.79
0.72
Mask Ratio
Mask Ratio
Mask Ratio
Figure 16: Performance across different mask ratios on FACED, SEED-V, and ISRUC.S3.
Mask Ratio
FRGSSM Pre- Triining
8
0.6
0.5
0.2
0.1
Epoch
Figure 17: EEGSSM pre-
pre-Trainn Training loss curve for different mask ratios.
36

---

K.2 ABLATION ON SWA WINDOW SIZE
We conduct an ablation study on the SEED-V and FACED datasets to investigate the effect of the SWA window size in the EEGSSM framework. The SWA window size determines the temporal context involved in attention for modeling intra-patch dependencies. In practice, the window size set to an odd number so that each target patch attends to a symmetrie temporal neighborhood. As shown in Figure 18 and Figure 19 window size of 1 achieves the best performance on both datasets among the five evaluated settings. Increasing the window size enlarges the temporal context and makes SWA progressively closer to a broader self-attention mechanism. However, increasing the window size does not lead to consistent performance gains. Instead, the results fluctuate across different window sizes, and larger windows do not show clear advantages over the minimal setting. This observation suggests that the primary role of SWA is to capture local intra-patch temporal dynamics, which can be sufficiently modeled within a minimal context. Overall, the results indicate that SWA works best as a lightweight local module, providing effective intra-patch modeling without introducing unnecessary context.
Cohten' Keppe
Weighted F1
Belenced Accuracy
015
0.2
6.0
643
6.54
034
0.14
8:18
0.7
0.5
0.5
0:58
50A 5ize
SWA Sine
5408 Sice
Figure 18: Performance of different SWA window sizes the FACED dataset.
Cohen's Kappa
Welghted F1
Balanced Accuracy
2390
0/42-
0.00
1355.
0435
0420
2270
0-32
0.455
2255
0.15
0.400
1323-
0/12
4.00
1335
0.45
50A S.2
SBA Stee
50M Sze
Figure 19: Performance of different SWA window sizes on the SEED-V dataset.
K.3 ABLATION ON CODEBOOK SIZE
The size of the codebook is an important parameter; a codebook that is too large may lead to unstable training, while a codebook size that is too small may result in mixed information. Ideally, the codebook should maintain small amount of unused codes but not be O. We tested several combinations of different time-domain and frequency-domat codebook sizes to observe their unused codes during Tokenizer training.
Table 16 shows the unused temporal codes and unused frequency codes under different codebook size combinations. When both the Temporal codebook size and Frequency codebook size are set to 2048, the unused frequency code is 0, indicating that there duplicate frequency codes in the current codebook. When choosing a codebook size of 8192, the unused temporal codes reached 3401 and the unused frequency codes reached 1260, indicating that a large number of codes in the completed
37

---

training codebook not used. We ultimately selected 4096 for both. Although the frequency domain often yields richer representations, enlarging its codebook may increase reliance on it, so we kept temporal and frequency codebooks equal. Considering capacity and utilization, 4096-4096 offers the hest trade-off.
Table 16:
Temporal and frequency codebook statistics
Temporal Codebook Size
Frequency Codebook Size
Unused Temporal Codes
Unused Frequency Codes
2048
2048
12
2048
4096
116
4096
4096
225
165
4096
8192
321
931
8192
8192
3401
1260
K.4 ABLATION ON PATCH SIZE
The size of the patch window is also an important adjustable parameter, which affects temporal resolutions and masking strategies. To explore the impact of patch window size on the model, we used window sizes ranging from 0.5s to 5s for complete two-stage pre-training and full-parameter fine-tuning. Note that for some datasets where the patch size is larger than the channel length, such as SEED-V, we pad the portion exceeding the available data to match the patch size in this experiment.
Table 17 and Table 18 show the performance of our method with different patch sizes on the SEED-V V dataset and ISRUC_3 dataset. Notably, SEED-V, patch lengths longer than 1s require heavy padding, causing large performance drops; in ISRUC_S3, the shortest 0.5s patches achieve the worst performance, likely because they fragment key waveforms in sleep staging (c.g., Spindle 20.5s). From these results, the 1s setting supported by two key considerations:
Broad compatibility with downstream task. 1s is a divisor of most downstream sequence lengths (1-30s), minimizing padding and ensuring transferability. For example, the SEED-V -V dataset, if the patch size chosen by the model is greater than 1s, some methods (such as padding) need to be adopted enable model training. These methods may usually impair the model's performance because they introduce additional noise or increase computational load. EEG datasets with durations less than second are relatively rare, as most datasets have at least second of data. If the data does not exactly match the whole seconds, the cost of processing such a dataset is also relatively small. Prior EEG foundation models (e.g., LaBram (Tiang al. 2024). CBraMod (Wang et al. 2025) also adopt 1s patches for this reason.
Semantic integrity. Choosing a 1s patch length preserves the natural structure of EEG waveforms and prevents semantic fragmentation. Many physiologically meaningful EEG events have characteristic durations: for example, K-complexes are typically around 1s, spindles last 0.5-2s, and event-related potentials such as P300 occur in the range of 0.3-0.6s.. If patches are shorter than these characteristic scales, the temporal branch of the Tokeniize may only capture partial fragments of these waveforms, leading to loss of semantic context.
Table 17:
Performance on SEED-V with different patch sizes
Patch Length
Cohen's Kappa
Weighted
Balanced Accuracy
0.5s
0.2640::0.0033 0.2735+0.0033
0.4035:0.0025
0.3841=0.0025
1s
0.4235:0.0022
0.4137=0.0023
2s
0.1545++:0.00
0.3313+40.0036
0.3079=000049
5s
0.1557+0.0043
0.3340+=0.0029
0.3271=0.0044
K.5 ABLATION ON SGCONV KERNEL PARAMETERS
To justify the choice of the SGConv decay coefficient, we conduct a sensitivity analysis on three representative downstream datasets (FACED, SEED-V, ISRUC_S3). The results are shown in Table 19 The decay parameter a controls how rapidly spatial kernel weights diminish with topological distance and, therefore, plays central role in balancing locality preservation and kernel sparsification.
38

---

Table 18: Performance ISRUC_3 with different patch sizes
Patch Length
Cohen's ' Kappa
Weighted F1
Balanced Accuracy
0.5s
0.7405#:001102 0.7671#:00091
0.7950=0.0097
0.7420=0.0081
1s
0.8202=1000071
0.7856=000033
2s
0.7592++0.0079
0.8113=#0.088
0.7753=0.0087
5s
0.7601++000075
0.8096=#0.0074
0.7791=0.0096
Table 19: Sensitivity analysis of the SGConv decay coefficient across three downstream datasets.
SEED-V
Cohen's Kappa
Weighted F1
Balanced Accuracy
0.5 (default)
0.2735 = 0.0032
0.4235 = 0.0022
0,4137 = 0.0023
0.1
0.2629 # 0.0017
0.4159 + 0.0006
0.4044 + 0.0017
= 0.9
0.2318 # 0.0074
0.3851 = 0.0141
0.3819 = 0.0046
a = 2.0
0.2332 = 0.0077
0.3851 = 0.0090
0.3809 = 0.0069
FACED
Cohen's Kappa
Weighted F1
Balanced Accuracy
0.5 (default)
0.5406 # 0.0084
0.5953 + 0.0113
0.5941 + 0.0090
0.1
0.5295 = 0.0080
0.5853 = 0.0074
0.5839 + 0.0069
= 0.9
0.4681 = 0.0069
0.5270 = 0.0065
0.5314 + 0.0050
a = 2.0
0.4782 = 0.0037
0.5282 = 0.0068
0.5360 = 0.0035
ISRUC S3
Cohen's Kappa
Weighted F1
Balanced Accuracy
0.5 (default)
0.7671 = 0.0091
0.8202 = 0.0071
0.7856 + 0,0031
0.1
0.7132 = 0.0646
0.7834 = 0.0523
0.7575 = 0.0621
= 0.9
0.6073 = 0.0230
0.6966 = 0.0176
0.6564 = 0.0058
2.0
0.5600 = 0.0492
0.6572 = 0.0430
0.6227 = 0.0427
Across all datasets, 0.5 consistently yields the highest performance. Larger values (e.g., a 0.9) moderately weaken spatial locality, while very small values (e.g., a 0.1) oversparsify the kernel and markedly reduce accuracy. Increasing a towards and beyond 1 (e.g.. 2.0) weakens the decay and assigns relatively larger weights to distant sub-kernels, which harms spatial locality and leads to clear performance drops, especially on ISRUC_S3. In addition, excessively large decay coefficients may amplify gradients during backpropagation and introduce training instability. For these reasons, we recommend a to 1 and adopt a 0.5 as a stable and well-performing default.
K.6 ABLATION ON SUBBAND
To better understand the frequency dependencies encoded by CodeBrain, we conduct a systematic subband ablation study by masking each of the five canonical EEG frequency ranges; (0.5-4 Hz), 0 (4-8 Hz), a (8-13 Hz), 33 (13-30 Hz), and y (;30 Hz). Unlike random dropout, this setting allows to examine how the model allocates representational importance across physiologically meaningful frequency components. Experiments are performed on both the emotion recognition dataset (SEED-V) and the sleep-staging dataset (ISRUC_S3), covering two distinct neurophysiological tasks.
K.6.1 SEED-V (62 CHANNELS): SUBBAND CONTRIBUTIONS IN EMOTION RECOGNITION
Several key findings could be observed in this experiments:
Dominance of low-frequency structure. Removing 8, 0, or bands produces near-collapse of performance, indicating that emotional states are primarily encoded in slow and mid-range oscillations. This matches prior affective neuroscience findings showing that emotional arousal and valence strongly modulate rhythms below 13 Hz.
Residual robustness at higher frequencies. Ablating 3 and especially y reduces per- formance but does not catastrophically impair decoding. This suggests that CodeBrain
39

---

Table 20: Subband ablation results the SEED-V dataset.
Removed Band
Cohen's Kappa
Weighted Fl
Balanced Accuracy
None
0.2735 + 0.0032
0.4235 + 0.0022
0.4137 + 0.0023
8
0.0297 = 0.0027
0.2075 0.0105
0.2201 = 0.0004
0.0142 = 0.0050
0.1780 = 0.0176
0.2098 = 0.0039
0.0082 = 0.0070
0.1306 = 0.0536
0.2058 = 0.0049
3
0.0442 = 0.0120
0.2377 = 0.0068
0.2360 = 0.0095
y
0.1372 = 0.0081
0.3141 = 0.0086
0.3092 = 0.0044
leverages high-frequency activity as complementary contextual cues rather than primary discriminative features.
Contrast with raw-signal models. Compared with prior end-to-end CNN/RNN models, the degradation patterns reveal that our decoupled tokenizer and cross-scale encoder preserve structured frequency dependencies rather than relying disproportionately one frequency range.
These observations highlight that the learned frequency representation is aligned with known emo- tional knowledge while still maintaining robustness across a broad range of frequencies.
K.6.2 ISRUC_S3 (6 CHANNELS): SUBBAND CONTRIBUTIONS IN SLEEP STAGING
Table 21: Subband ablation results on the ISRUC S3 dataset.
Removed Band
Cohen's Kappa
Weighted F1
Balanced Accuracy
None
0.7671 0.0091
0.8202 # 0.0071
0.7856 # 0.0031
0.0225 # 0.0391
0.1751 # 0.0843
0.2043 # 0.0237
0
0.0728 = 0.0557
0.1386 = 0.0341
0.2812 = 0.0749
0.1048 = 0.0221
0.1762 = 0.0186
0.3226 = 0.0293
0.2131 + 0.0660
0.2867 + 0.1185
0.3835 = 0.0446
0.3618 = 0.0012
0.4831 + 0.0291
0.4764 + 0.0082
Results on ISRUC_S3 sleep staging dataset reveal a qualitatively different frequency profile from SEED-V:
Critical dependence on and 6. Removing slow-wave components almost eliminates information, consistent with their central role in NREM transitions and slow oscillations during deep sleep.
Higher-frequency bands remain more robust. Masking 3 and 7 still reduces performance but to lesser extent, reflecting the fact that spindle- or arousal-related faster bursts are less dominant in the 6-channel ISRUC montage.
Psysiology-specifie feature reliance. The frequency sensitivity patterns differ from SEED- V, demonstrating that CodeBrain adapts its feature allocation depending task demands rather than relying on fixed frequency prior.
The subband ablation results across two very different datasets show that CodeBrain could capture frequency structure, leveraging low-frequency dynamics for both emotion and sleep tasks while maintaining robustness to higher-band perturbations.
L BACKBONE EFFICIENCY COMPARISON
To evaluate the computational efficiency of our SGConv layer in the EEGSSM block, we conduct experiments by replacing it with three common sequence modeling modules: CNN, LSTM, and Transformer. We compare their model sizes, floating- point operations (FLOPs), and iteration times, shown in Figure 20 Specifically, the CNN variant uses 3-layer depthwise separable convolution
40

---

block, while the LSTM and Transformer variants single layer of standard LSTM and Transformer Encoder (implemented by Pytorch), respectively. In terms of parameter count, SGConv contains 15.17M parameters, fewer than CNN (16.22M), LSTM (17. (17.35M), and Transformer (21.2M). For FL.Ps, SGConv also achieves the lowest computational cost at 8.74G, compared to Transformer's 27.79G. Regarding iteration time, SGConv is slightly slower than Transformer and CNN models in terms of training speed, but it outperforms the LSTM model. In summary, SGConv effectively reduces the number of parameters while maintaining computational complexity, which helps the model to be trained and inferred on smaller GPUs.
SGiomy (Uhrs)
CNN
LSTM
Tranefeemer
30
30
30:35
5
431
150
25
3.71
3.51
15.17
16.22
17.05
20-
15-
3
80
90.22
10
8.74
40
0
FLOP::
Time
Penk Memory (GHB)
Figure 20: Computational overhead of using different backbones in the EEGSSM module.
To further contextualize the computational efficiency of CodeBrain, we provide a comparison against widely used EEG foundation-mode baselines. Table [2 summarizes model parameters, multiply-accumulate operations (MACs), and floating-point operations (FLOPs), offering stable and hardware-agnostr metrics across architectures. Overall, CodeBrain achieves favorable balance between computational cost and representational capacity. Its FLOPs and MACs remain substantially lower than turge-scale models such as BENDR and EEGPT, while maintaining higher parameter efficiency than CBraMod and LaBraM. Notably, CodeBrain occupies a middle ground in model size: smaller than EEGPT while offering richer representational power than compact baselines like BIOT, This balanced compute-pens perputtee-rfoomacce trade-off aligns with design goal of building efficient yet high-capacity EEG foundation model suitable for both research and deployment on modest hardware.
Table 22: Compute comparison between CodeBrain and representative EEG foundation-model baselines.
Model
MACs
Params
FLOPs
BENDR
12.51G
959.84M
25.02G
BIOT
0.255G
3.20M
0.510G
LaBraM
0.67G
6.02M
1.34G
CBraMod
0.64G
4.03M
1.29G
EEGPT
4.89G
25.24M
9.79G
CodeBrain (Ours)
4.37G
15.17M
8.74G
M MODEL ROBUSTNESS
M.1 RANDOM CHANNEL DROPOUT
In real-world scenarios, the collection of EEG often encounters situations where channels are missing, especially when using machines from different manufacturers. To test the model's performance on datasets with missing channel data, randomly mask some channels in the training data for full parameter fine-tuning. We selected the FACED and SEED-V datasets for experiments because they represent short-sequence and long-sequence cases respectively, and their numbers of channels relatively complete.
We evaluate the performance of the CodeBrain model and CBraMod model in scenarios with missing channels. We conducted three different experiments, randomly masking 12.5%, 25%, and 50% the channels in each experiment, respectively. Figure 2T shows results of the experiment. It can be
41

---

(a) Masked channels in Training FACED
Kappa
Weighted
Balanced Accuncy
0.52
Caddran ChoMMd
0.55
Codetron ClisMied
0.58
Caldraa
0:50
Kayee
0.46-
0.22
0.4
020-
042
Madi Chazade
Channde
Maak Chazzol
(b) Masked channels Truining on SEED-V
Cobon's Kaypa
Weighted P1
Dalanced
0.7-
Caldenin ClraMMed
Cokttrn ClieaMed
042
Colemin ClraMaad
0.2-
041
0.4
0.5-
0.40-
0.2
0.99
032
0.37
16
Maik
Figure 21: Performance after randomly masking different numbers of channels during the full parameter fine-tuning stage.
that our CodeBrain model outperforms the CBraMod model in all channel masking scenarios. On the FACED dataset, our model's performance after masking 25% of the channels is still close to that of CBraMod without masking. The performance decline of the CBraMod model is also faster than that of our model. This trend is even more pronounced on the SEED-V dataset. Through this experiment, we can demonstrate that the channel robustness of Code Brain is stronger than that of the CBraMod model, retaining most of its performance even in cases of channel failure.
M.2 BRAIN-REGION CHANNEL DROPOUT
While random channel masking simulates incidental electrode failures, it does not capture the struc- tured spatial organization of the EEG montage. To provide a neuroscientifically meaningful robustness evaluation, we conduct region-based masking on both the high-density SEED-V dataset (62 channels) and the minimal-mone -mnntae- ISRUC S3 dataset (6 channels). These experiments simulate clinically relevant scenarios such reference-electrodde failures, lobe-specific dropout, and hemisphere-level signal loss. We also compare CodeBrain with the strongest baseline, CBraMod.
1.2.1 REGION- BASED ABLATIONS ON THE -EN-SIYNITT SEED-V V DATASET (62 CHANNELS)
We design nine anatomically meaningful masking patterns, including (1) reference/hemisphhrre fail- ures (midline-only, left-hemisphere masked, right-hemisphere masked), and (2) lobe-level dropout over occipital, frontal, temporal, central, frontocentral, and parietal regions. The results are summa- rized in Table
Across nearly all masking conditions, CodeBrain maintains stronger performance than CBraMod, particularly under lobe-level dropout (occipital, temporal, central), suggesting that its modeling is less reliant any single anatomical region. The severe degradation under midline-onl signals further highlights the importance of distributed multi-lobe information in emotion aootion-related EEG.
42

---

Table 23: Region-masking results the SEED-V dataset (62 channels).
Mask Setting
Model
Cohen's 's Kappa
Weighted F1
Balanced Accuracy
Baseline (no mask)
CBraMod
0.2569 + 0.0143
0,4101 = 0.0108
0.4091 = 0.0097
CodeBrain
0.2735 + 0.0032
0.4235 + 0.0022
0.4137 = 0.0023
Only midline
CBraMod
0.0114 = 0.0098
0.1740 = 0.0121
0.2077 = 0.0018
CodeBrain
0.0201 = 0.0098
0.1610 = 0.0087
0.2169 = 0.0067
Left hemisphere
CBraMod
0.0672 + 0.0260
0.2505 + 0.0227
0.2541 + 0.0226
CodeBrain
0.0956 = 0.0030
0.2779 = 0.0051
0.2750 = 0.0030
Right hemisphere
CBraMod
0.0586 + 0.0171
0.2500 + 0.0214
0.2466 + 0.0149
CodeBrain
0.0678 = 0.0195
0.2540 = 0.0066
0.2569 # 0.0166
Occipital
CBraMod
0.1316 = 0.0217
0.3066 = 0.0167
0.3068 + 0.0174
CodeBrain
0.2258 = 0.0067
0.3851 = 0.0040
0.3818 + 0.0090
Frontal
CBraMod
0.0632 + 0.0222
0.2486 + 0.0177
0.2491 + 0.0189
CodeBrain
0.1255 = 0.0090
0.3025 = 0.0080
0.2976 + 0.0046
Temporal
CBraMod
0.1571 = 0.0284
0.3309 0.0222
0.3265 # 0.0227
CodeBrain
0.2311 = 0.0008
0.3922 = 0.0010
0.3824 = 0.0004
Central
CBraMod
0.1562 + 0.0419
0.3305 + 0.0336
0.3247 + 0.0321
CodeBrain
0.2410 = 0.0078
0.3997 = 0.0067
0.3894 + 0.0055
Frontocentral
CBraMod
0.1304 + 0.0304
0.3077 + 0.0263
0.3039 + 0.0244
CodeBrain
0. = 0.0090
0.3025 + 0.0080
0.2976 + 0.0047
Parietal
CBraMod
0.1571 = 0.0284
0.3309 + 0.0222
0.3265 + 0.0227
CodeBrain
0.2311 = 0.0008
0.3922 = 0.0010
0.3824 + 0.0004
M.2.2 REGION-BASED ABLATIONS ON THE MINIMAL-MONTAN ISRUC_S3 DATASET (6 CHANNELS)
To test robustness under extreme spatial sparsity, we perform structured region masking on the 6-channel A1/A2-referencee ISRUC_S3 montage. We evaluate reference-electrod failures (masking Al or A2) and lobe-specific removal (frontal, central, occipital). Results are shown in Table 24
Table 24: Region-masking results on the ISRUC_S3 dataset (6 channels).
Mask Setting
Model
Cohen's Kappa
Weighted F1
Balanced Accuracy
Baseline (no mask)
CBraMod
0.7407 = 0.0251 0.7671 = 0.0091
0.8056 = 0.0219
0.7844 = 0.0126 0.7856 + 0.0031
CodeBrain
0.8202 = 0.0071
Right hemisphere
CBraMod
0.6616 = 0.0263
0.7392 = 0.0292
0,6706 + 0.0212
CodeBrain
0.7430 = 0.0131
0.8047 = 0.0086
0.7760 # 0.0279
Left hemisphere
CBraMod
0.6198 = 0.12
0.6964 = 0.0958
0.6838 + 0.0815
CodeBrain
0.7318 = 0.0252
0.7989 + 0.0196
0.7819 = 0.0133
Occipital
CBraMod
0.7089 0.0412
0.7598 0.0321
0.7340 0.0269
CodeBrain
0.7447 = 0.0226
0.8065 + 0.0187
0.7824 # 0.0080
Central
CBraMod
0.6725 + 0.0106
0.7526 + 0.0074
0.6979 + 0.0164
CodeBrain
0.7479 + 0.0253
0.8111 + 0.0197
0.7790 + 0.0155
Frontal
CBraMod
0.7134 + 0.0245
0.7796 + 0.0184
0.7250 + 0.0327
CodeBrain
0.7295 + 0.0531
0.7936 + 0.0408
0.7825 + 0.0282
Even under this sparse spatial setup, CodeBrain consistently maintains strong performance compared with strong baselines across all mask types. This indicates that the learned representations are robust structured regional dropout and remain stable even when half or more channels removed.
43

---

Across both high-density and minimal minimal-montage datasets, region-based ablation demonstrates that CodeBrain preserves strong performance under structured channel dropout, highlighting its spatial robustness and reliable modeling of cross-regional EEG dependencies.
M.3 NON-STATIONARY ROBUSTNESS
EEG signals are inherently non-stationary, with gradual fluctuations caused by electrode impedance changes, autonomic modulation, motion artifacts, and slow drift in sensor baselines. To examine how well the learned representations tolerate such structured temporal drift, we introduce a sim- ple but effective perturbation: linear baseline shift. This perturbation exaggerates slow-varying non-stationarity beyond what naturally appears in the data, providing a controlled stress test of robust- ness. We evaluate both SEED-V (emotion recognition) and ISRUC_S3 (sleep staging), comparing CodeBrain with the strongest baseline, CBraMod. Results are summarized in Table 25
Table 25: Non-stationary robustness under linear baseline shift on SEED-V and ISRUC_S3.
SEED-V
Setting
Model
Cohen's Kappa
Weighted F1
Balanced Accuracy
Reference (no shift)
CodeBrain
0.2735 = 0.0032
0.4235 = 0.0022
0.4137 = 0.0023 0.4091 = 0.0097
CBraMod
0.2569 0.0143
0.4101 0.0108
Linear baseline shift
CodeBrain
0.2170 0.0345
0.3799 0.0276
0.3706 = 0.0259
CBraMod
0.2027 0.0147
0.3658 0.0136
0.3628 = 0.0111
ISRUC_S3
Setting
Model
Cohen's Kappa
Weighted F1
Balanced Accuracy
Reference (no shift)
CodeBrain
0.7671 = 0.0091
0.8202 + 0.0071
0.7856 = 0.0031
CBraMod
0.7407 = 0.0251
0.8056 + 0.0219
0.7844 # 0.0126
Linear baseline shift
CodeBrain
0.4762 0.0835
0.5914 0.0668
0.5617 = 0.0630
CBraMod
0.4242 # 0.0068
0.5478 + 0.0087
0.5268 # 0.0085
This controlled non statiinattiitt stress test reveals several consistent patterns. Moderate linear drift introduces clear performance degradation across both datasets, as expected for models trained under largely stationary conditions. The effect especially pronounced on ISRUC_S3, where the limited channel count amplifies the impact of baseline shifts. Despite this, CodeBrain retains larger proportion of its original performance than CBraMod, suggesting that it yields more stable representations under slow global waveform drift. We also observe deeendennd differences in sensitivity: emotion recognition disproportionately affected in low-frequency components, whereas sleep staging exhibits structures these tasks rely on. Overall, the results indicate that CodeBrain maintains strong robustness non-stationary perturbations, making it suitable for real-world settings where gradual baseline drift and electrode instability are unavoidable.
uniform degradation across metrics, reflecting the different spectral
N DETAILED RESULTS ON SCALING LAWS
We provide the detailed scaling law results for both data and model size across three representative EEG datasets (FACED, SEED-V, and ISRUC_S3). covering three evaluation metries. For brevity, only Cohen's kappa scores are included in the main text, while full results are provided in this section. Prior work (Wang al. 2025 Jiang et al. 2024) has explored the effect of scaling EEG foundation models using to 1000 hours of pretraining data. We extend this analysis in two key dimensions:
1. Scaling the pretraining data volume from Ik to 9k hours.
2. Investigating model scaling by varying the depth of the EEGSSM encoder from 3 layers (3.86M parameters) to 24 layers (146.750) parameters) and the hidden size from 128 384.
44

---

N.1 SCALING LAWS WITH RESPECT TO TRAINING DATA VOLUME
We examine how the volume of pretraining data influences the downstream performance of CodeBrain Specifically, we scale the pretraining duration from 1 to 9k hours and evaluate the resulting models on three downstream datasets: FACED, SEED-V, and ISRUC_S3. Detailed quantitative results across three evaluation metrics (Cohen's 's kappa, weighted F1 score, and balanced accuracy) are presented in Tables 26 27 and 28] respectively. As shown in Figure 22 increasing the amount of pretraining data generally leads to consistent improvements across all datasets and metrics. On FACED and ISRUC_S3, performance gains are steady throughout the entire range up to 9k hours, while on SEED-V, the trend is more modest and plateaus after 5k hours. These results highlight the importance of large-scale data for representation learning in EEG and suggest that further scaling may continue to yield performance benefits.
Table 26: Training data scaling laws of CodeBrain on FACED dataset.
Training Data
Cohen's Kappa
Weighted F1
Balanced Accuracy
1000 Hours
0.5014 + 0.0107
0.5462 + 0.0146
0,5452 + 0.0163
2000 Hours
0.5133 = 0.0068
0.5540 0.0120
0,5521 = 0.0133
3000 Hours
0.5189 = 0.0086
0.5688
0.0104
0,5687 + 0.0083
4000 Hours
0.5208 = 0.0032
0.5741
0.0041
0.5713 = 0.0024
5000 Hours
0.5171 0.0040
0.5692 0.0131
0.5661 = 0.0105
6000 Hours
0.5273 = 0.0085
0.5803 + 0.0064
0.5764 + 0.0069
7000 Hours
0.5328 = 0.0116
0.5854 = 0.0082
0.5809 = 0.0097
8000 Hours
0.5336 + 0.0082
0.5875 + 0.0071
0.5835 + 0.0072
9000 Hours
0.5406 = 0.0084
0.5953 + 0.0113
0.5941 + 0.0098
Table 27: Training data scaling laws of CodeBrain on SEED-V V dataset.
Training Data
Cohen's 's Kappa
Weighted F1
Balanced Accuracy
1000 Hours
0.2584 + 0.0044
0.3946 = 0.0063
0.3799 = 0.0096
2000 Hours
0.2648 # 0.0062
0.4042 = 0.0091
0.3961 # 0.0084
3000 Hours
0.2689 = 0.0055
0.4117 = 0.0075
0.4028 + 0.0082
4000 Hours
0.2672 # 0.0043
0.4121 = 0.0054
0.4022 # 0.0049
5000 Hours
0.2678 = 0.0069
0.4120 = 0.0084
0.4026 = 0.0067
6000 Hours
0.2669 = 0.0031
0.4113 # 0.0067
0.4030 = 0.0102
7000 Hours
0.2686 + 0.0043
0.4129 + 0.0052
0.4027 = 0.0048
8000 Hours
0.2703 + 0.0049
0.4165 + 0.0034
0.4094 # 0.0054
9000 Hours
0.2735 + 0.0032
0.4235 + 0.0022
0.4137 + 0.0023
In addition, visualize the pretraining optimization behavior across different data scales in Figure As expected, larger pretraining data consistently lead to lower training loss, indicating more effective representation learning. Notably, the convergence curves become progressively smoother and more stable as training data volume increases, suggesting improved optimization stability in large-scale regimes. While smaller training data volumes (e.g., 1k-3k hours) show relatively high starting loss and slower convergence, larger training data volumes (6k-9k hours) reach lower final losses and exhibit diminishing returns, aligning with trends observed in downstream performance. These findings provide further empirical support for the scalability of EEG foundation models and reinforce the role of large data enhancing both optimization and generalization.
N.2 SCALING LAWS WITH RESPECT TO MODEL SIZE
We further investigate how model parameters affect downstream performance by scaling the number of layers in the EEGSSM encoder from 3 to 8, resulting in parameter counts ranging from 6.82M to 15. 17M. Detailed results across the FACED, SEED-V, and ISRUC S3 datasets provided in
45

---

Table 28: Training data scaling laws of CodeBrain on the ISRUC_S3 dataset.
Training Data
Cohen's Kappa
Weighted
Balanced Accuracy
1000 Hours
0.7340 # 0.0187
0.7826 + 0.0154
0.7505 # 0.0192
2000 Hours
0.7347 = 0.0051
0.7869 + 0.0075
0.7524 + 0.0032
3000 Hours
0.7540 # 0.0106
0,8012 # 0.0093
0.7694 # 0.0089
4000 Hours
0.7590 + 0.0042
0.8108 + 0.0074
0.7753 = 0.0065
5000 Hours
0.7610 + 0.0058
0.8124 = 0.0102
0.7794 # 0.0086
6000 Hours
0.7681 = 0.0125
0.8190 = 0.0100
0.7856 + 0.0089
7000 Hours
0.7648 # 0.0079
0.8170 # 0.0076
0.7845 # 0.0076
8000 Hours
0.7668 = 0.0121
# 0.0109
0.7851 = 0.0116
9000 Hours
0.7671 + 0.0091
0.8202 + 0.0071
0.7856 + 0.0031
(a) Training Data Scaling Laws on FACED
Colen's is Kappu
Weighted F1
Balancod Accuracy
9.00
0.58
0.35
0.90
0.54
0.54
Truin mg Data (AF1)
Training Dutu (AH)
Training Data (KE9)
(b) Training Data Scaling Laws SEED-V
Colun's Kuppa
Weighted F1
Balanced Accuracy
941
0.39
0.37
Training
Tainin
Training
(c) Training Data Scaling Laws on ISRUC $3
Cohen's 's Kuppa
Weighted F1
Balanced Accurncy
0.99
0.77
0.75
1
3
7
3
Trainin Data (1.1))
Training Data (kI))
Training Data (K28)
Figure 22: Training data scaling laws on FACED, SEED-V, and ISRUC $3.
Tables 30 and 31 respectively. visualize the trend more clearly, Figure 24 presents the performance curves as model size increases. Across all three datasets and evaluation metrics, we observe a consistent performance gain as the model size increases. The improvements are particularly pronounced the FACED and ISRUC_S3 datasets, where all three metrics show steady growth up to the largest model. In contrast, performance on SEED-V improves more modestly and begins to plateau beyond 13.5M parameters. These results suggest that increasing model capacity can enhance generalization ability, especially for datasets with richer structure or more complex temporal dynamics, while also indicating that optimal scaling may be task-dependent.
46

---

12
EEGSSM Pre Training Loss
Traning Data (KH)
1000
2000
10-
3000
4000
5000
6000
7000
8000
9000
10
Epoch
Figure 23: EEGSSM pre-training loss curve for different training data volume.
Table 29: Model size scaling laws of CodeBrain on the FACED dataset.
Layer
Hidden size
Params
Cohen's Kappa
Weighted F1
Balanced Accuracy
128
3.86M
0.4786+000131
0.523110.0164
0.5287+0.0207
200
6.82M
0.4018:0.00165
0.5362:10.0113
0.531710.0182
200
8.49M
0.4988::000822
0.550610.0091
0.5497#0.0084
200
10.16M
0.5096::0.0049
0.5686+100104
0.5642=0.0067
6
200
11.83M
0.524410.0113
0.570510.0085
0.5778=000095
7
200
13.50M
0.5314::00066
0.5872+10.0800
0.5846+00.007
200
15.17M
0.5406:1000084
0.5953:0.0113
0.594110.0098
12
256
33.15M
0.5478+:0.0013
0.5912+0.0031
0.5901#0.0128
24
384
146.75M
0.550310.0120
0.596410.0118
0.598510.0233
Table Model size scaling laws of CodeBrain on the SEED-V dataset.
Layer
Hidden size
Params
Cohen's Kappa
Weighted
Balanced Accuracy
128
3.86M
0.2576:10.0047
0.3969++000022
0.3896+0.0027
200
6.82M
0.2609:10.0078
0,400411.0112
0.3956110.0098
4
200
8.49M
0.2638+000008
0.4108
0.4022+000121
200
10.16M
0.2645+00.0102
0.4127+0.0158
0.4013:1000884
200
11.83M
0.2663+000056
0.4202+000006
0.4075++000055
200
13.50M
0.2724410.055
0.4211
0.4120+10.0086
8
200
15.17M
0.2735+000032
0.4235+0.000
0.4137+000023
12
256
33.15M
0.2807+40.0029
0.4317+0000036
0.4182:10.0028
24
384
146.75M
0.2831+0.0033
0.4342+000030
0.4216+#00033
To better understand the optimization behavior during pretraining, we plot the training loss curves for different model sizes in Figure] 25 As expected, larger models consistently achieve lower final training loss, indicating stronger capacity to the pretraining objective. The loss reduction is particularly evident when increasing from 3 to 6 layers, while the gain starts to saturate beyond 7 layers. Even when increased to 24 layers, the reduction pre- training loss brought by more than 100M parameters is not significant. This trend mirrors the downstream performance in Figure 24 and
47

---

Table 31: Model size scaling laws of CodeBrain on the ISRUC_S3 dataset.
Layer
Hidden size
Params(M)
Cohen's Kappa
Weighted F1
Balanced Accuracy
128
3.86M
0.7434110.0087
0.7813=0.0107
0.7493=100008
200
6,82M
0.7456=10.0083
0.7862=0.0104
0.751420.0084
200
8.49M
0.7486:10.0014
0.7942+1000000
0.7604-10.0035
5
200
10.16M
0.7516:10.0023
0.7985=0.0056
0.7639=1000079
200
11.83M
0.7570
0.80641100068
0.7734
200
13.50M
0.7620=100004
0.8153
0.7824
200
15.17M
0.7671+0.009)
0.8202:+00001
0.7856-L0.0031
12
256
33.15M
0.7753+00.013
0.8316=20.0044
0.7940=1.0001
24
384
146.75M
0.7791+000010
0.8352
0.8008
(a) Model Size Scaling Laws on FACED
Cohen's Kappa
Weighted F1
Balanced Accuracy
0.56
0.625
0.60
0.52
0.500
0.48
0.52
0.525
33
147
33
147
33
147
Parameters (M)
Parameters (M)
Parameters (M)
(b) Model Size Scaling Laws on SEED-V
Cohen's Kappa
Weighted F1
Balanced Accuracy
0.43
0.42
0.42
0.4
0,27
0.4
0.26
0.39
0.39
33
147
33
147
33
147
(M)
Parameters (M)
Parameters (M)
(c) Model Size Scaling Laws on ISRUC S3
Cohen's Kappa
Weighted F1
Balanced Accuracy
0.84
0.80
0.78
0.82
0.78
0.76
0.80
0.74
33
147
33
147
33
147
(M)
Parameters (M)
Figure 24: Model size scaling laws FACED, SEED-V, and ISRUC S3.
Tables 29 suggesting that both optimization efficiency and generalization benefit from increased model size though with diminishing returns as parameter count grows. These results reinforce the scalability EEGSSM and underscore the importance of balancing capacity with specifc requirements.
48

---

12
Layers Parameters (M)
EEGSSM Pre- Training Loss
11
3/8.66
3/6.2
8,
5/ 10.16
6/ 11.83
7 13.5
1115..1
12/33.15
24/ 146.75
10
Epoch
Figure 25: EEGSSM pre-training loss curve for different model size.
Our results demonstrate consistent improvements downstream performance as both data volume and model capacity increase, suggesting that EEG foundation models may continue benefit from further scaling, similar to trends observed in vision and language domains.
N.3 COMPUTATIONAL ANALYSIS ACROSS SCALES.
Table 32: Computational analysis across different model scales.
Layer
Hidden Size
Params
FLOPs
Throughput
GPU Memory
128
3.96M
1.7G
4.90
4.87
200
6.82M
3.35G
4.62
5.63
200
8,49M
4.43G
3.77
6.48
200
10.
5.51G
3.67
7.33
6
200
11.83M
6.58G
3.52
8.10
200
13.50M
7.66G
2.94
8.95
8 200
15.17M
8.74G
2.78
9.79
12
256
34.38M
19.04G
1.84
15.41
24
384
146.75M
72.99G
1.47
38.43
Complementing the scaling analyses model size and data size presented the previous subsections, we further examine how computational cost scales with architectural capacity. This provides a detailed breakdown of parameters, FLOPs. throughput, and GPU memory usage across all CodeBrain model configurations, allowing holistic view of the efficiency capacity.
Table 32
shows smooth increase in parameters, FLOPs, and memory consumption as model depth and hidden size grow. Notably, throughput decreases sub-linearly with scale, demonstrating that the architecture maintains high computational efficiency even at larger capacities.
Lightweight variants (3-6 layers) offer high throughput (3.5-5 samples/s) and low memory usage (< GB), suitable for real-time or resource-constrained EEG applications. Mid-sized models (8-12 12 layers) provide excellent balance between performance and efficiency, which aligns with where the accuracy scaling curve begins to saturate. The largest configuration (24 layers, 146M parameters) substantially increases capacity and FLOPs, corresponding the upper regime of diminishing returns observed the model-size scaling law. We therefore select the 8-layer configuration as the main model used in experiments after balancing performance and efficiency.
Overall, these results show that CodeBrain follows predictable computational scaling behavior and offers flexible operating points for various deployment budgets.
49

---

O LOW-RESOURCE COMPARISON WITH EXISTING METHODS
Table 33: Comparison under data-limited settings on the FACED dataset (9-class).
Methods
Cohen's Kappa
Weighted F1 Balanced Accuracy
Linear Probing
LaBraM
0.3026 0.0121
0.3789 = 0.0154
= 0.0144
CBraMod
0.3378 0.0139
0.4123 # 0.0117
0.4146 + 0.0123
CodeBrain
0.3587 = 0.0136
0.4311 = 0.0109
0.4327 # 0.0127
10% Few-Shot
LaBraM
0.1358 + 0.0163
0.2247 = 0.0196
0.2265 + 0.0174
CBraMod
0.1632 0.0156
0.2595 = 0.0138
0.2604 = 0.0148
CodeBrain
0.1716 0.0101
0.2599 = 0.0104
0.2654
30% Few-Shot
BIOT
0.2573 0.0346
0.3501 = 0.0341
0.3428 # 0.0329
LaBraM
0,2672 0.0371
0.3548 = 0.0325
0.3513 = 0.0315
CBraMod
0.3239 0.0265
0.4056 = 0.0256
0.4035 # 0.0233
CodeBrain
0.3356 0.0253
0.4114 = 0.0225
0.4104 + 0.0281
Full Finetuning
BIOT
0.4476 0.0254
0.5136 = 0.01
0.5118 + 0.01 18
LaBraM
0.4698 0.0102
0.5288 = 0.0188
0.5273 = 0.0107
CBraMod
0.5041 = 0.0122
0.5618 = 0.0093
0.5509 = 0.0089
CodeBrain
0.5406 + 0.0084
0.5953 0.0113
0.5941 = 0.0098
Table 34: Comparison under data-limites limited settings on the SEED-V dataset (5-class).
Methods
Cohen's Kappa
Weighted F1
Balanced Accuracy
Linear Probing
LaBraM
0.1941 0.0184
0.3457 0.0135
0.3413 0.0144
CBraMod
0.2239 0.0053
0.3823 0.0041
0.3791 0.0050
CodeBrain
0.2302 + 0.0166
0.3889 # 0.0154
0.3829 + 0.0136
10% Few-Shot
LaBraM
0.0302 + 0.0065
0.2194 # 0.0079
0.2228 + 0.0091
CBraMod
0.0174 0.0029
0.2071 0.0125
0.2127 0.0023
CodeBrain
0.1690 0.0170
0.3410 0.0133
0.3331 0.0138
30% Few-Shot
BIOT
0.1775 0.0425
0.3492 = 0.0416
0.3505 0.0375
LaBraM
0,2044 + 0.0384
0.3700 = 0.0321
0.3686 + 0.0305
CBraMod
0.2291 0.0246
0.3886 # 0.0255
0.3877 0.0236
CodeBrain
0.2376 0.0284
0.3943 0.0259
0.3902 + 0.0271
Full Finetuning
BIOT
0.2261 0.0262
0.3856 0.0203
0.3837 0.0187
LaBraM
0.2386 + 0.0209
0.3974 0.0111
0.3976 0.0138
CBraMod
0.2569 + 0.0143
0.4101 + 0.0108
0,4091 + 0.0097
CodeBrain
0.2735 0.0032
0.4235 0.0022
0.4137 0.0023
50

---

To evaluate model performance under low www-reource conditions, we conduct experiments under three settings: 30% few-shot, 10% few-shot, and linear probing. The 30% and 10% settings reflect data- limited conditions, where only small portion of labeled training data is available. In contrast, linear probing represents a compute-limitd condition where the backbone is frozen, and only a single linear layer is trained. Results for the FACED (9-class) and SEED-V (5-class) datasets are reported in Tables 33 and 34
Across all three settings and both datasets, CodiBrain consistently achieves strong performance among the evaluated methods, demonstrating strong data efficiency and reliable transfer behavior under limited conditions. We also observe that few-shot performance is generally lower than linear probing, which is expected because full fine-tuning with very limited labeled data tends to be more sensitive to overfitting and distribution shift, whereas linear probing offers a more stable evaluation by freezing the backbone and relying only on the pretrained representations. This also confirms that the pretrained representations learned by CodeBrain already contain meaningful structure. Full- filltfinntnnnng results under full supervision are also included for reference.
While CodeBrain remains comparable to prior EFMs limited-data and compute-limited conditions, all models exhibit notable performance drops compared to full fine-tuning. EEG signals inherently exhibit extremely low signal-to-noie ratios and substantial domain shift across subjects, devices, montages, and recording setups. Under such conditions, small number of labeled samples is often insufficient to fully adapt pretrained representations to the target distribution, making low-resource EEG transfer challenging but important research problem.
P LIMITATIONS AND FUTURE WORK
Our work presents promising results but also highlights several limitations that offer directions for future exploration.
First, the interpretability analyses in this paper focus representation-leve structure learned during pretraining. As this paper centers on developing a foundation model, our focus is mainly placed on understanding the representation space learned during pretraining. Future work may incorporate decision- interpretability during finetuning, for example by exploring sparse codebook selection, task-guided gating mechanisms, or disentangling how temporal and frequency codes contribute to class-specific predictions.
Second, our model and experiments focus on only scalp EEG data. Extending the proposed framework to modalities with richer frequency content, such as intracranial EEG (iEEG), electrocorttioorrahy (ECoG), or stereo-EEG (sEEG) (Chen et al. 2022), offers an opportunity to study how the model behaves under substantially different signal characteristics (Lin et al. 20256
These offer promising directions toward building more general and more interpretable brain founda- tion models that operate across signal modalities and provide both meaningful insights.
Q USE OF LLM
In preparing this manuscript, we made use of large language models (LLMs) such ChatGPT, Gemini, and Deepseek for auxiliary writing support. Specifically, LLMs were employed three
ways:
(i) Polishing the English writing style, including grammar correction and improving fluency; (ii) Assisting with LaTeX formatting and typesetting to ensure consistent presentation of mathematical equations, tables, and figures.
All core technical content, theoretical results, and experimental findings were designed, implemented, and validated by the authors. LLM usage was restricted to language refinement and formatting assistance, without influencing the originality or validity of the scientific contributions.
51


Reviews:
[{"review_id": "SgYUCS4bbL", "reviewer": "Reviewer_uKaR", "summary": "This paper proposes a novel EEG foundation model named CodeBrain, with its core contributions as follows:  1) Designing the **TFDual-Tokenizer**, which generates discrete tokens by decoupling the heterogeneous temporal and frequency signals of EEG. This not only expands the representation space but also achieves domain-specific interpretability;  2) Proposing the **EEGSSM architecture**, which combines structured global convolution with sliding window attention. By simulating the brain's small-world topology, it efficiently captures both sparse long-range dependencies and local dependencies;  3) After pretraining on the large-scale public dataset, CodeBrain achieves superior generalization performance compared to 5 existing EEG foundation models across 8 downstream tasks (covering emotion recognition, sleep staging, etc.) and 10 datasets. Additionally, the robustness and scalability of the model are validated through ablation experiments and scaling law analyses.", "questions": "1. What is the codebook initialization strategy for the TFDual-Tokenizer? Do different strategies have significant impacts?\n2. What is the structure of the lightweight convolutional module? How does it capture inter-channel correlations?\n3. What is the rationale for the SGConv kernel parameters?\n4. What is the value of the temperature parameter τ in the SimCLR contrastive loss, and what is its selection basis?\n5. Why is the gating mechanism so crucial for model performance?", "limitations": "", "rating": 6, "confidence": 5, "soundness": 3, "presentation": 3, "contribution": 3, "strengths": "1. **Novel Architectural Design**: The decoupling of time-frequency tokenization addresses a critical limitation in existing EEG models, where joint encoding often conflates neural dynamics. This aligns with neurophysiological understanding that brain activity operates across dissociable temporal and spectral dimensions. \n2. **Comprehensive Benchmarking**: Testing on 8 diverse tasks (spanning cognitive, motor, and clinical domains) provides strong evidence for generalizability, a key requirement for foundation models.\n3. **Preliminary Interpretability**: The authors make meaningful preliminary efforts to link model components (i.e., temporal/frequency tokens) to known neural correlates (e.g., sleep spindles, slow waves, and spectral rhythms like delta activity).", "weaknesses": "This work demonstrates promising prospects for advancing EEG foundation models; however, addressing the following weaknesses is critical to validating its contributions to artificial intelligence and neuroscience.\n\n## Model-Related Weaknesses\n\n1. **Unsupported \"Approximate Independence\" Assumption in Proposition 2.1 (Section 2.2):** \n\n   A key concern is that EEG temporal representations $X_t$ and frequency representations $X_f$ are not independent—they exhibit inherent correlations. Yet, Proposition 2.1 assumes they are \"approximately independent\" to derive the distortion bound of the decoupled codebook, with no empirical analysis or theoretical justification provided. This casts doubt on the generalizability of Proposition 2.1.\n\n2. **Missing Codebook Initialization Strategy for TFDual-Tokenizer (Section 2.2):** \n\n   The TFDual-Tokenizer uses temporal and frequency codebooks, but the **codebook initialization method** is unspecified. For vector quantization based models, initialization directly affects codebook utilization and training stability. The absence of this detail hinders understanding of how codebook initialization influences model performance.\n\n3. **Unclear Structure and Mechanism of the \"Lightweight Convolutional Module\" (Section 2.3):** \n\n   The \"lightweight convolutional module\" for dynamic positional embeddings is poorly elaborated. Its unspecified architecture and the unexplained mechanism for capturing inter-channel correlations and adapting to unseen channels weaken the claims about the model's adaptability.\n\n4. **Unvalidated Rationale for SGConv Kernel Parameters (Section 2.3):**\n\n   The SGConv layer optimizes the convolution kernel $\\bar{K}$ via \"sparse parameterization\" and \"kernel decay,\" with the decay coefficient fixed at $\\alpha=0.5$. However, no comparisons with other $\\alpha$ values are conducted to assess impacts on model performance. The paper provides no basis for selecting $\\alpha=0.5$ (e.g., cross-validation results, neurophysiological plausibility), relying solely on an empirical value.\n\n## Experiment-Related Weaknesses\n\n1. **Incomplete Baseline Comparisons (Section 3):**\n\n   While the paper compares CodeBrain with 5 existing EEG foundation models, it omits traditional non-foundation models (e.g., EEGNet[1], EEG-Conformer[2]) as baselines. This makes it impossible to intuitively quantify the advantage of CodeBrain as a foundation model.\n\n2. **Unexplained Importance of the Gating Mechanism (Section 3.4):**\n\n   Ablation experiments show that removing the gating module causes a substantial drop in Cohen’s Kappa: 52.3% for FACED, 19.1% for SEED-V, and 28.6% for ISRUC S3. Despite this critical impact, the gating module is not a core innovation of the work. The paper fails to explain **why this specific gating design was adopted** (e.g., compatibility with EEGSSM) or **why it drives such significant performance gains**, weakening the justification for its inclusion.\n\n3. **Insufficient Details for Reproducibility (Appendices I):**\n\n   Appendix I lacks details on learning rate decay (e.g., warm-up steps for the Cosine scheduler), which is critical for stable training. The temperature parameter $τ$ for the contrastive loss (SimCLR) is not specified, and the rationale for its selection is not provided.\n\n## Analysis-Related Weaknesses\n\n1. **Inadequate Quantitative Support for Interpretability Claims (Figure 4):**\n\n   Figure 4 illustrates associations between temporal tokens and slow waves, and frequency tokens and delta rhythms, but only reports percentage values. No **statistical significance tests** (e.g., comparing with the matching rate of random tokens to rule out chance correlations) are performed, leaving the interpretability conclusions without statistical validation.\n\n2. **Missing Trade-off Analysis for Scaling Laws (Appendix N):**\n\n   Appendix N shows diminishing performance returns as model parameters increase from 3M to 150M, but no analysis of **computational efficiency trade-offs** is provided (e.g., FLOPs, training time, memory usage for different model sizes). Without quantifying whether marginal performance gains justify increased computational costs, the work fails to guide model size selection for practical applications.\n\n[1] Lawhern V J, Solon A J, Waytowich N R, et al. EEGNet: a compact convolutional neural network for EEG-based brain–computer interfaces[J]. Journal of neural engineering, 2018, 15(5): 056013.\n\n[2] Song Y, Zheng Q, Liu B, et al. EEG conformer: Convolutional transformer for EEG decoding and visualization[J]. IEEE Transactions on Neural Systems and Rehabilitation Engineering, 2022, 31: 710-719.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "cJO1IOSUcv", "reviewer": "Reviewer_mz4F", "summary": "The paper introduces CodeBrain, an EEG foundation model (EFM) designed to address key challenges in EEG analysis. CodeBrain uses a two-stage framework to improve both interpretability and efficiency in processing EEG data. In the first stage, the TFDual-Tokenizer decouples the temporal and frequency components of EEG signals into discrete tokens, enhancing the model’s ability to interpret domain-specific features. In the second stage, the EEGSSM architecture combines structured global convolutions with sliding window attention to capture both long-range dependencies and local neural events. The model is pretrained on the largest publicly available EEG corpus and tested across multiple downstream tasks and datasets, demonstrating strong generalization and performance improvements over existing baselines.", "questions": "1. Contrastive Learning: Why does splitting the data into two parts generate positive and negative samples? Are we conducting the contrastive analysis over each temporal code individually, or are we considering the entire patch (n code) for the contrastive task? Furthermore, how does the use of SimCLR contribute to solving convergence issues during training?\n2. State Space Model Architecture: Can you elaborate on the architectural choices in the state space model? \n3. Baseline: The paper claims that EFMs significantly outperform smaller supervised models like EEGNet and STTransformer.(“We do not include traditional supervised baselines such as EEGNet (Lawhern et al., 2018) or STTransformer (Song et al., 2021) in this comparison, as previous studies have consistently shown that EFMs significantly outperform these smaller supervised models. Our focus is therefore on evaluating the effectiveness of different foundation model designs and pretraining paradigms under comparable settings.” ) Can you provide more concrete evidence or experimental results to justify excluding these baselines from comparison? Also, how about other supervised models specifically  for each testing dataset?\n4. Swin vs. Other Transformer-Based Decoders: Why is the Swin transformer decoder preferred over other transformer-based decoders? Are there specific advantages that make Swin more suitable for EEG analysis, and if so, can you provide additional experimental results or explanations?\n5. Pretraining Time and Details: The paper lacks specific details about the pretraining time and other parameters. Could you clarify the pretraining setup, including the duration and computational resources involved, as well as any other important details that would help evaluate the practicality and scalability of the model?", "limitations": "", "rating": 8, "confidence": 5, "soundness": 3, "presentation": 4, "contribution": 3, "strengths": "CodeBrain introduces the decoupling of temporal and frequency EEG components via the TFDual-Tokenizer, which provides domain-specific interpretability. This is a novel approach not seen in previous EEG foundation models. The manuscript is comprehensive, well-structured, and tackles important issues in EEG signal representation learning. It presents a clear solution to existing challenges in terms of both efficiency and interpretability. The paper includes extensive experiments across 8 downstream tasks and 10 datasets, demonstrating the model’s generalizability under various distribution shifts. Detailed ablation studies, scaling-law analyses, and interpretability evaluations further confirm the robustness and effectiveness of CodeBrain.", "weaknesses": "The paper lacks sufficient evidence to support the claim that EFMs outperform traditional models like EEGNet and STTransformer, as it does not include these models for comparison. Additionally, the justification for choosing the Swin transformer decoder over other transformer-based decoders is not well-explained, and there is a lack of detail regarding pretraining time and other crucial parameters, which hinders the assessment of model efficiency and scalability.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "xnLzA47Jh8", "reviewer": "Reviewer_a5Jx", "summary": "This study presents an interpretable EEG foundation model, CodeBrain, which integrates both local and global information. Selected codes deriving from TFDual-Tokenizer contain strong clinical meaning and could serve as an effective “EEG vocabulary”, which seems to improve the interpretability. Further, the authors conduct extensive experiments to validate the effectiveness of nearly every component of the proposed framework.", "questions": "1. According to the paper, the authors pretrain several versions of the EFM. I recommend including some main versions and their corresponding model sizes in the main text rather than only in the Appendix. Initially, it was unclear which model version the reported results referred to in the main content, forcing readers to cross-check details in the Appendix. Presenting this information earlier would improve clarity and readability.\n2. Regarding the TFDual-Tokenizer, have the authors considered a sparse code strategy based on a gate mechanism, where only the frequency, temporal, or occasionally dual code is selected for a given patch? $N^2$ representation space may introduce some redundancy, as suggested by the unused token experiments.\n\nI will remain active during the rebuttal and may consider adjusting my score based on the authors’ responses.", "limitations": "", "rating": 4, "confidence": 4, "soundness": 3, "presentation": 4, "contribution": 3, "strengths": "1. The authors propose a domain-specific and interpretable TFDual-Tokenizer, which decomposes raw EEG signals into frequency and temporal domains to generate dual-domain tokens, thereby enhancing the representation capability of the model.\n2. The proposed EEGSSM architecture integrates multi-scale information and enhances the representation of intra-patch features through a sliding-window attention mechanism.\n3. In addition to extensive empirical experiments, the study provides strong theoretical support for the proposed methods.", "weaknesses": "1. Although the selected codes in Appendix B are associated with clinically meaningful patterns, the criteria for their selection and their specific contribution to model performance remain unclear. While these codes are intuitively appealing, the paper does not provide concrete evidence demonstrating their impact on improving downstream task performance. Without such evidence, the explanation may not be important for model decision in the down-stream tasks and could potentially mislead researchers, as model reasoning does not necessarily align with human intuition. Moreover, the analysis of class-specific token ratios does not convincingly support a relationship between the proposed interpretable codes and performance gains. In a word, no evidence directly shows that those interpretable codes play a primary role in the model’s decision-making process.\n\n2. If my understanding is correct, in Equation (17) defining the dominance ratio, $max_y N_c^{(y)}$ should always be smaller than $\\sum_{y} N_c^{(y)}$ since the latter item $\\sum_{y} N_c^{(y)} = max_y N_c^{(y)} + other  N_c^{(y)}$. Therefore, the dominance ratio would be less than 1. Could the authors clarify why they define Dominance(c) > 1 as the criterion for identifying class-specific tokens?\n3. Duplication in Figure 3, the left and middle images are identical.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "Jl9uXBdSEO", "reviewer": "Reviewer_ATKr", "summary": "This paper presents CodeBrain, a two-stage EEG foundation model that aims to achieve both domain-specific interpretability and strong cross-task generalization. The first stage introduces a tokenizer which decouples temporal and frequency EEG features into discrete tokens, effectively enlarging the representation space and improving discriminability while maintaining interpretability linked to neural and spectral events. The second stage proposes a multi-scale SSM combining global convolutional layers and sliding-window attention, designed to capture both long-range dependencies and local neural patterns. CodeBrain demonstrates strong generalization across 8 downstream tasks and 10 datasets under distribution shifts.", "questions": "(1) Were the AUROC and AUPRC calculated in a balanced manner?\n\n(2) About channel robustness, have authors ever consider masking specific brain regions to provide insights into the robustness in neuroscientific or clinical settings? Random masking is unconvincing.\n\n(3) The authors used a tripartite splitting in their experimental setup. Why not use subject-independent cross-validation (see experimental setup in FAPEX, BrainWave, Brant, Scatterformer, etc.), which offers more robust statistical estimates while prevents any potential information leakage? \n\n(4) The authors should at least analyze MACs, Throughput/Latency, FLOPs of some of the best-performing baselines along with CodeBrain.", "limitations": "", "rating": 2, "confidence": 5, "soundness": 2, "presentation": 3, "contribution": 2, "strengths": "(1) The authors presented a time-frequency decoupled EEG tokenizer, combined with generative learning with multiscale SSM, with increased computational efficiency, which is somewhat novel especially w.r.t. the decoupled representation.\n\n(2) Strong cross-domain robustness and interpretability visualizations.\n\n(3) High clarity and well-organized figures.", "weaknesses": "(1) The overall work, both tokenizer and the generative pretraining, still seem incremental to me. It would be better to discuss and if possible, analyze quantitatively how it substantially improves EEG representation in actual subbands as well as varying, often non-stationary time-frequency landscape. It also fails to convince me how the current work architecturally and mechanistically innovates beyond LaBraM, Beatrix, EEGMamba, etc...  Also, time-frequency representation is not new at all. It seems that the authors still concentrate on Fourier spectrum for the frequency part.\n\n(2) It would be better to consider adding at least one or two supervised baselines as well as contrastive ones for a more comprehensive comparison.\n\n(3) I don't understand why the author completely disregarded gamma oscillations and higher-frequency activities from their analysis. Epileptic seizures, for example, often involve high-frequency outbursts during preictal and interictal stages. Such high-frequency activities are ubiquitous inother physiological activities as well. It is suggested that the authors should perform some ablative experiments to explore how their preprocessing pipeline is justified.\n\nStill, should the authors provide satisfactory clarification or partial resolution of these concerns, I would be open to increasing my score.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}]

Author rebuttal:

Decision: Accept (Poster)