Manuscript Offprint
arXiv:2611.09496Mosaic:montage-agnostic self-distilled graph learning for subject-independent ieeg seizure detection
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
ABSTRACT
Intracranial EEG provides high signal-to-noise ratio and spatial resolution for detecting epileptic activity, but patient-specific electrode placement leads to substantial variation in channel count and montage across subjects. This heterogeneity limits the generalization of existing detectors under subject-independent evaluation. We propose MOSAIC (MOntage-agnostic Self-distilled Adaptive Inter-channel Connectivity learning), a lightweight graph-learning framework for subject-independent iEEG seizure detection. MOSAIC pairs a shared convolutional channel encoder with a patient-agnostic channel-attention module that infers a weighted inter-channel adjacency matrix from the encoded features, requiring no fixed montage graph. An exponential moving average self-distillation objective regularizes each prediction toward a slowly updated per-patient teacher. Across four public iEEG corpora (SWEC-ETHZ long- and short-term, Mayo, FNUSA), MOSAIC outperforms state-of-the-art baselines in F2 and Cohen's while learning more stable inter-channel adjacencies, demonstrating that self-distilled connectivity learning transfers across unseen implantations.
Index Terms— Intracranial EEG (iEEG), seizure detection, graph neural networks, self-distillation
1. INTRODUCTION
Epilepsy is one of the world's most common serious neurological disorders, affecting an estimated 50 million people worldwide [1]. Roughly a third of patients are drug-resistant and depend on continuous seizure monitoring and, when eligible, on surgical resection of epileptogenic zone or neuromodulation [2]. Both still rest on visual review of scalp EEG or, for more precise localization, of invasive iEEG (SEEG/ECoG) [3] – a slow, subjective process that does not scale to modern continuous recordings.
Automated detection has progressed from classifiers based on handcrafted spectral, temporal, and spatial features, such as patient-specific SVMs [5], tree-based models [4, 2] and hyperdimensional-computing classifiers [6], to deep neural networks that learn representations directly from neural signals, ranging from scalp-map recurrent convolutional networks [7] to CNNs that learn spatial filters directly over a fixed electrode arrangement, such as EEGNet [8] and EEGWaveNet [9]. Graph neural networks (GNNs) further model
the montage explicitly, passing messages over an inter-channel adjacency: DCRNN [10] derives it from electrode geometry or signal correlation, and REST [11] pairs it with a recurrent residual-state update. In all these families the layout is fixed at training time and assumed to hold at deployment.
That assumption fails on iEEG. Although iEEG offers superior signal-to-noise ratio and localization [12], electrode count and placement are chosen individually per patient, so no montage graph is shared across subjects and fixed-topology detectors degrade under subject-independent evaluation. Transformer-based approaches sidestep this by letting self-attention model inter-channel relationships directly from the signal: MVPFormer [13] disentangles content, temporal, and spatial attention across arbitrary channel counts, and Brant [14] adds a dedicated spatial-attention encoder. Both, however, pay the quadratic compute and inference latency of full self-attention. Inferring the adjacency from a single short window also inherits the non-stationarity of iEEG itself [15]: consecutive windows from the same patient, recorded through the same electrodes, can yield significantly different graphs.
We introduce MOSAIC, a lightweight graph architecture that infers inter-channel connectivity per window from a single shared attention layer, and damps this window-to-window instability with an exponential moving average (EMA) self-distillation objective that regularizes each inferred graph toward a slowly updated, patient-specific consensus. MOSAIC therefore adapts to an arbitrary, unseen montage while keeping the inferred connectivity stable across windows.
2.1. Problem formulation
Each recording is a continuous multivariate iEEG time series, which we segment into non-overlapping windows of a fixed duration . Formally, a window is , where is the number of timepoints at sampling frequency , and is the number of channels. Both channel count and electrode placement may vary across patients. Each window carries a binary label , where marks a window containing expert-annotated seizure activity. The goal is subject-independent detection: at test time the model sees a patient absent from training.
2.2. Shared temporal encoder
Every channel's raw window is independently encoded by one shared 1D CNN to extract local temporal features: a stack of depthwise-separable convolutional layers, each followed by batch normalization and ReLU, producing a feature
Corresponding author: arya.jalali@epfl.ch This work was supported in part by the Swiss State Secretariat for Education, Research and Innovation (SERI) under Contract SCR0548363, the SwissChips initiative, and in part by the Swiss National Science Foundation (SNSF) Project Funding 200021-219752. The authors declare no conflicts of interest.

Fig. 1. Overview of MOSAIC. Each electrode signal in an iEEG window is encoded independently by a shared temporal encoder into channel-level node features . Shared query and key projections infer a row-normalized adjacency . Residual graph-convolution layers propagate information over the inferred graph, followed by channel pooling and binary classification. During training, adjacency predictions are grouped by patient and averaged to update a stop-gradient EMA teacher, and a KL-divergence term keeps each window-level adjacency consistent with the patient's historical adjacency structure.
map . Inspired by the channel-pooling strategy in CBAM [16], we pool over by concatenating mean and max pooling before projecting back to :
Max pooling is included specifically to retain sharp, spike-like transients that a mean pool alone would average away, which we hypothesize matters for the ictal discharges marking seizure onset. Stacking Eq. (1) over channels and projecting linearly gives node features before graph construction.
2.3. Channel-attention adjacency
We compute a row-stochastic weighted adjacency matrix as a function of the encoded features via a single shared self-attention layer [17] with separate query/key projections . Following [18], queries and keys are -normalized before the dot product (QK-norm),
and a learned scalar temperature s rescales the normalized dot product before a row-wise softmax,
2.4. EMA self-distillation regularizer
The adjacency of Eq. (3) is recomputed for every window and is free to fluctuate with local, possibly non-discriminative signal variation. Since a patient's electrode configuration is fixed, its channel-relationship structure should remain broadly stable across windows; we therefore impose a soft structural prior toward this consistency by maintaining a per-patient exponential moving average of the model's own past adjacency predictions. For a batch, let be the set of windows belonging to patient , , and the current adjacency for window . Each window is pulled toward the current teacher via a row-averaged KL-divergence,
where is a small constant for numerical stability. The batch distillation loss averages Eq. (4) within each patient before averaging over patients in the batch that already have a teacher is initialized from the first window of a newly seen patient):
After the loss is computed, is updated from a detached, batch-averaged adjacency ,
(6) where is the EMA momentum and denotes the stop-gradient operator. The total training loss is
with recovering the unregularized learned-adjacency ablation.
2.5. Graph convolution
Node features are updated by L layers of standard graph convolution over the learned adjacency A, each a linear transform, ReLU, dropout, and residual connection with layer norm:
(8)
The final layer's node features are mean-pooled over the channel dimension, and passed to a linear classifier producing the window-level logit.
3. EXPERIMENTS AND RESULTS
3.1. Experimental Settings
Datasets. We evaluate MOSAIC on four public iEEG corpora, following the evaluation procedure of [13]. The SWEC-ETHZ short-term [6] and long-term [19] corpora are continuous, multi-channel recordings with annotated seizure intervals, downsampled to 256 Hz, and we segment them into non-overlapping s windows labelled according to overlap with those seizure intervals. Mayo and FNUSA [20] instead consist of fixed-length, single-channel clips (3 s; 193k clips from 25 patients and 155k from 14 patients, respectively, downsampled to 2500 Hz) annotated as pathological activity, physiological activity, powerline noise, or artifact; we do not remove any noise from these corpora and merge powerline noise and artifact into the physiological class, to simulate a real clinical setup.
Baselines. We compare MOSAIC against EEGNet [8], DCRNN [10], SEEGNet [21], DMNet [22], a lightweight CNN baseline [23], and a Multitask Transformer [24]. SEEGNet and DMNet are designed for single-channel iEEG and are therefore not applicable to the multi-channel SWEC-ETHZ corpora (marked as – in Table 1).
Metrics. We report Cohen's [13] on SWEC-ETHZ and macro-F1, F2, and accuracy on all four corpora. F2 places greater weight on recall than precision, reflecting the higher cost of missed seizures.
Protocol and implementation. On the SWEC-ETHZ corpora we adopt a leave-one-patient-out protocol: for each fold, all patients but two are used for training, one is held out for validation, and the remaining patient is used for testing. Mayo and FNUSA are highly imbalanced across individual patients, so we instead follow the grouped leave-one-group-out protocol of [21]. Being single-channel, these two corpora also make the channel-attention adjacency of Eq. (3) degenerate, so on those two corpora MOSAIC reduces exactly to its shared encoder ( ). To ensure a fair comparison, we tune the hyperparameters of every baseline on validation loss. All models are implemented in PyTorch 2.11.0 (CUDA 13.0) and trained on two NVIDIA RTX PRO 6000 Blackwell GPUs with Adam [25] at a learning rate of for 10 epochs, with EMA momentum and distillation weight on the SWEC-ETHZ corpora. All reported results are averaged over 5 random seeds.
3.2. Main Results
Table 1 summarizes seizure-detection performance across the four datasets. MOSAIC outperforms every baseline on both SWEC-ETHZ corpora, improving over the strongest baseline by 1.8 points on the short-term corpus and 3.3 points on the long-term one, while training faster than the Multitask Transformer (100 vs. 300 min). This is because MOSAIC infers the adjacency once and reuses it across all graph layers instead of recomputing attention at every layer. The margin is far larger still against the graph-based baseline DCRNN [10]: +16.6 on the short-term corpus and +30.8 on the long-term one. On the single-channel Mayo and FNUSA, where MOSAIC reduces to its shared encoder (Section 3.1), it dominates on FNUSA and is competitive on Mayo, within 0.8 points of the best F2 and macro-F1. The learned adjacency and its regularizer are active only on the multi-channel SWEC-ETHZ corpora, precisely the variable-montage, subject-independent setting that clinical deployment demands, and it is there that the F2 margins are largest.
3.3. Ablation Experiments
Table 2 evaluates three components of MOSAIC: the shared temporal encoder (Section 2.2), the EMA self-distillation regularizer (Section 2.4, ), and the learned adjacency. Removing the temporal encoder causes the largest collapse: without an informative per-channel representation, the attention module has no signal from which to infer a meaningful adjacency. The remaining two rows isolate the contribution of the learned adjacency and its regularization. An unregularized learned adjacency does not improve over the uniform adjacency ( 48.3 vs. 48.8, identical F2), so learning the adjacency provides no benefit on its own; only the regularized adjacency improves over the uniform control, by – exceeding MOSAIC's own margin over the strongest baseline in Table 1, which the uniform-adjacency control would not surpass. The improvement is therefore attributable to the stabilization rather than to the attention mechanism itself. Figure 2 shows that the regularized adjacency remains near-uniform, departing from it in coherent query-key blocks, whereas the Transformer's deviation is dominated by column structure with near-identical rows: every query channel attends to essentially the same keys. Figure 3 shows it is also far more stable across windows than the undistilled adjacency, and more diffuse than both.
4. CONCLUSION
We presented MOSAIC, a graph neural network for subject-independent iEEG seizure detection that replaces fixed correlation graphs and per-patient adjacency parameters with a shared channel-attention layer that predicts a window-specific adjacency directly from encoded features, allowing adjacency construction itself to generalize to unseen patients. An EMA self-distillation regularizer stabilizes these window-level adjacencies across windows by pulling each prediction toward a slowly updated, per-patient average of the model's own past outputs, without any external supervision. Across four public iEEG corpora, MOSAIC matches or exceeds competitive baselines, its undistilled ablation, and a uniform-adjacency control. Because the EMA teacher is only ever a smoothed copy of the model's own predictions, however, the distillation loss acts as a pure variance reducer: it reduces variation in the adjacency but cannot correct a systematic bias, such as persistent concentration on a single dominant channel, the way an external supervisory signal could. Future work therefore includes extending the distillation
Table 1. Seizure detection results (%) across four public iEEG datasets. F2, m-F1 (macro-F1), and accuracy are reported for all datasets; Cohen's is additionally reported for the two SWEC-ETHZ corpora.
| Model | Mayo | FNUSA | SWEC (short-term) | SWEC (long-term) | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| F2 | m-F1 | acc. | F2 | m-F1 | acc. | F2 | m-F1 | acc. | F2 | m-F1 | acc. | |||
| SEEGNet | 62.4 | 74.9 | 85.0 | 80.4 | 85.4 | 88.8 | - | - | - | - | - | - | - | - |
| DMNet | 73.1 | 79.8 | 87.3 | 79.2 | 83.0 | 86.7 | - | - | - | - | - | - | - | - |
| EEGNet | 59.2 | 72.3 | 82.4 | 77.0 | 81.7 | 85.4 | 34.9 | 47.3 | 64.8 | 78.2 | 20.1 | 24.4 | 58.1 | 91.9 |
| DCRNN | 65.7 | 74.3 | 83.7 | 79.2 | 85.0 | 88.5 | 34.5 | 54.6 | 66.4 | 73.4 | 19.8 | 32.8 | 65.5 | 96.9 |
| Lightweight CNN | 75.8 | 83.9 | 91.5 | 82.0 | 86.2 | 89.4 | 46.6 | 60.3 | 70.2 | 77.4 | 40.2 | 44.3 | 69.4 | 96.4 |
| Multitask Transformer | 78.0 | 83.9 | 91.2 | 82.7 | 86.2 | 89.3 | 49.3 | 60.9 | 71.4 | 79.0 | 47.3 | 49.1 | 73.2 | 97.2 |
| MOSAIC (proposed) | 77.2 | 83.7 | 91.2 | 85.2 | 88.2 | 91.2 | 51.1 | 64.1 | 73.1 | 79.7 | 50.6 | 52.1 | 75.2 | 98.6 |

Fig. 2. Channel-attention deviations from uniform for one held-out patient. We plot , averaged over 60 windows. It measures departure from uniform attention (rows: query; columns: key). Panels use their own maximum absolute deviation for color scaling; mean is shown above each. The Transformer concentrates on fixed key columns; the undistilled model has the largest, least regular deviations; MOSAIC has smaller, coherent channel blocks. All three suppress the diagonal, already supplied by the residual in Eq. (8).
Table 2. Ablation study (%) isolating the temporal encoder, the EMA self-distillation regularizer, and the learned adjacency itself, on the two SWEC-ETHZ corpora.
| SWEC-ETHZ short-term | ||||
|---|---|---|---|---|
| Variant | F2 | m-F1 | acc. | |
| MOSAIC | 51.1 | 64.1 | 73.1 | 79.7 |
| w/o temporal encoder | 31.2 | 47.8 | 62.4 | 72.4 |
| w/o self-distillation | 48.3 | 62.4 | 72.0 | 79.8 |
| Uniform adjacency | 48.8 | 62.4 | 71.3 | 77.7 |
| SWEC-ETHZ long-term | ||||
|---|---|---|---|---|
| Variant | F2 | m-F1 | acc. | |
| MOSAIC | 50.6 | 52.1 | 75.2 | 98.6 |
| w/o temporal encoder | 17.9 | 17.4 | 58.3 | 96.1 |
| w/o self-distillation | 46.4 | 47.0 | 72.9 | 97.7 |
| Uniform adjacency | 46.9 | 46.8 | 73.0 | 98.4 |
target beyond a per-patient average – e.g., incorporating external supervision – and evaluating on scalp EEG.
COMPLIANCE WITH ETHICAL STANDARDS
This research was conducted retrospectively on de-identified human iEEG data released in open access by the original providers [6, 19, 20]. The Mayo and FNUSA recordings were collected under written

Fig. 3. Self-distillation keeps the channel-attention adjacency stable and diffuse ( patients). Top: standard deviation of attention weights across windows within a patient, which removing self-distillation raises roughly fourfold (). Bottom: effective channel fraction , . Undistilled attention concentrates on fewer than half of the channels; MOSAIC holds near 0.92.
informed consent with approval from the Mayo Clinic Institutional Review Board, the St. Anne's University Hospital Research Ethics Committee, and the Ethics Committee of Masaryk University; the
SWEC-ETHZ recordings are distributed in anonymized form by the Sleep-Wake-Epilepsy-Center, Inselspital Bern. No new human data were collected, and no additional ethical approval was required.
5. REFERENCES
[1] World Health Organization, “Epilepsy,” Fact sheet, Feb. 2024, [Online]. Available: https://www.who.int/news-room/fact-sheets/detail/epilepsy. Accessed: Sep. 13, 2026.
[2] Uisub Shin et al., “NeuralTree: A 256-channel 0.227- J/class versatile neural activity classification and closed-loop neuromodulation SoC,” IEEE Journal of Solid-State Circuits, vol. 57, no. 11, pp. 3243–3257, 2022.
[3] James Flanary et al., “Reliability of visual review of intracranial electroencephalogram in identifying the seizure onset zone: A systematic review and implications for the accuracy of automated methods,” Epilepsia, vol. 64, no. 1, pp. 6–16, 2023.
[4] Mahsa Shoaran, Benyamin Allahholizadeh Haghi, Milad Taghavi, Masoud Farivar, and Azita Emami-Neyestanak, “Energy-efficient classification for resource-constrained biomedical applications,” IEEE Journal on Emerging and Selected Topics in Circuits and Systems, vol. 8, no. 4, pp. 693–707, 2018.
[5] Ali H Shoeb and John V Guttag, “Application of machine learning to epileptic seizure detection,” in Proceedings of the 27th International Conference on Machine Learning (ICML), 2010, pp. 975–982.
[6] Alessio Burrello, Kaspar Schindler, Luca Benini, and Abbas Rahimi, “Hyperdimensional computing with local binary patterns: One-shot learning of seizure onset and identification of ictogenic brain regions using short-time iEEG recordings,” IEEE Transactions on Biomedical Engineering, vol. 67, no. 2, pp. 601–613, 2020.
[7] Pierre Thodoroff, Joelle Pineau, and Andrew Lim, “Learning robust features using deep learning for automatic seizure detection,” in Proceedings of the 1st Machine Learning for Healthcare Conference (MLHC). PMLR, 2016, vol. 56, pp. 178–190.
[8] Vernon J Lawhern, Amelia J Solon, Nicholas R Waytowich, Stephen M Gordon, Chou P Hung, and Brent J Lance, “EEG-Net: a compact convolutional neural network for EEG-based brain-computer interfaces,” Journal of Neural Engineering, vol. 15, no. 5, Art. no. 056013, 2018.
[9] Punnawish Thuwajit et al., “EEGWaveNet: Multiscale CNN-based spatiotemporal feature extraction for EEG seizure detection,” IEEE Transactions on Industrial Informatics, vol. 18, no. 8, pp. 5547–5557, 2022.
[10] Siyi Tang et al., “Self-supervised graph neural networks for improved electroencephalographic seizure analysis,” in International Conference on Learning Representations (ICLR), 2022.
[11] Arshia Afzal, Grigorios Chrysos, Volkan Cevher, and Mahsa Shoaran, “REST: Efficient and accelerated EEG seizure analysis through residual state updates,” in Proceedings of the 41st International Conference on Machine Learning. 2024, vol. 235, pp. 271–290, PMLR.
[12] Josef Parvizi and Sabine Kastner, “Promises and limitations of human intracranial electroencephalography,” Nature Neuroscience, vol. 21, no. 4, pp. 474–483, 2018.
[13] Francesco S. Carzaniga, Michael Hersche, Abu Sebastian, Kaspar Schindler, and Abbas Rahimi, “A foundation model with multi-variate parallel attention to generate neuronal activity,” in International Conference on Learning Representations (ICLR), 2026.
[14] Daoze Zhang, Zhizhang Yuan, Yang Yang, Junru Chen, Jingjing Wang, and Yafeng Li, “Brant: Foundation model for intracranial neural signal,” in Advances in Neural Information Processing Systems (NeurIPS), 2023, vol. 36.
[15] T. Dikanev, D. Smirnov, R. Wennberg, J. L. Perez Velazquez, and B. Bezruckho, “EEG nonstationarity during intracranially recorded seizures: statistical and dynamical analysis,” Clinical Neurophysiology, vol. 116, no. 8, pp. 1796–1807, 2005.
[16] Sanghyun Woo, Jongchan Park, Joon-Young Lee, and In So Kweon, “CBAM: Convolutional block attention module,” in Proceedings of the European Conference on Computer Vision (ECCV), 2018, pp. 3–19.
[17] Ashish Vaswani et al., “Attention is all you need,” in Advances in Neural Information Processing Systems (NeurIPS), 2017, vol. 30.
[18] Alex Henry, Prudhvi Raj Dachapally, Shubham Shantaram Pawar, and Yuxuan Chen, “Query-key normalization for transformers,” in Findings of the Association for Computational Linguistics: EMNLP 2020, Trevor Cohn, Yulan He, and Yang Liu, Eds., Online, Nov. 2020, pp. 4246–4253, Association for Computational Linguistics.
[19] Alessio Burrello, Lukas Cavigelli, Kaspar Schindler, Luca Benini, and Abbas Rahimi, “Laelaps: An energy-efficient seizure detection algorithm from long-term human iEEG recordings without false alarms,” in 2019 Design, Automation & Test in Europe Conference & Exhibition (DATE). IEEE, 2019, pp. 752–757.
[20] Petr Nejedly et al., “Multicenter intracranial EEG dataset for classification of graphoelements and artifactual signals,” Scientific Data, vol. 7, no. 1, Art. no. 179, 2020.
[21] Yiping Wang et al., “SEEG-Net: An explainable and deep learning-based cross-subject pathological activity detection method for drug-resistant epilepsy,” Computers in Biology and Medicine, vol. 148, Art. no. 105703, 2022.
[22] Shihao Tu et al., “DMNet: Self-comparison driven model for subject-independent seizure detection,” in Advances in Neural Information Processing Systems (NeurIPS), 2024, vol. 37.
[23] Xiaopeng Si et al., “Patient-independent seizure detection based on long-term iEEG and a novel lightweight CNN,” Journal of Neural Engineering, vol. 20, no. 1, Art. no. 016037, 2023.
[24] Yulin Sun et al., “Multi-task transformer network for subject-independent iEEG seizure detection,” Expert Systems with Applications, vol. 268, Art. no. 126282, 2025.
[25] Diederik P Kingma and Jimmy Ba, “Adam: A method for stochastic optimization,” in International Conference on Learning Representations (ICLR), 2015.