Zero-Annotation Seizure Detection and Onset Zone Localization in Intracranial EEG via Self-Supervised Learning and Mahalanobis Distance Modeling | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Article Zero-Annotation Seizure Detection and Onset Zone Localization in Intracranial EEG via Self-Supervised Learning and Mahalanobis Distance Modeling Zhikai Yu This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-9568998/v1 This work is licensed under a CC BY 4.0 License Status: Posted Version 1 posted You are reading this latest preprint version Abstract Background and Objective: The detection of epileptic seizures in intracranial electroencephalography (iEEG) relies on segment by segment annotation by professional physicians, which hinders the promotion of automated systems in clinical practice. This study proposes a completely unsupervised seizure detection method that achieves high-precision seizure recognition and seizure onset zone (SOZ) localization through self supervised learning and personalized anomaly detection. Methods: We used a masked autoencoder (MAE) combined with subject contrastive learning to self supervise pre training of the Transformer encoder on 54 patients (SEEG/ECoG records) in the University of Pennsylvania Affiliated Hospital (HUP) dataset. Subsequently, individualized Mahalanobis distance was used as the anomaly score to achieve seizure detection without using seizure labels at all. To verify the generalizability of the model, we conducted zero sample transfer validation using the independent external dataset SWEC-ETHZ (18 patients, University Hospital Bern, Switzerland) without any fine-tuning of the model. Results: In the internal validation of HUP, the global AUROC of this method reached 0.963, the average AUROC of the subjects was 0.973 ± 0.055, and the AUROC of 51/54 subjects exceeded 0.90. Compared with the supervised leave one over cross validation (LOSO) baseline (optimal AUROC 0.796), the zero labeling method showed an average improvement of Δ=+0.158 (p<0.001) within the subject setting. In the zero sample transfer validation of the independent external dataset SWEC-ETHZ, the average AUROC was 0.843 ± 0.173, the median was 0.945, and the AUROC of 11/18 patients exceeded 0.80. The overall anatomical matching rate of SOZ among 31 patients with surgical outcomes was 71.0%, with a success rate of 81.0% in Engel grade 1 patients. Conclusion: This method does not require any manual annotation and achieves detection performance close to the upper bound of supervised methods on two independent central datasets, demonstrating significant cross center generalization ability. This framework provides a feasible path for real-time deployment of clinical iEEG. Health sciences/Neurology/Neurological disorders/Epilepsy Physical sciences/Mathematics and computing/Computational science Figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Introduction Drug resistant epilepsy affects approximately 50 million people worldwide, with about one-third of them experiencing poor response to antiepileptic drugs. For such patients, surgical resection or ablation of the seizure onset zone (SOZ) is currently one of the most effective treatment options. The core of SOZ localization relies on intracranial electroencephalography (iEEG) monitoring, including stereotactic electroencephalography (SEEG) and cortical electroencephalography (ECoG). This type of detection can directly record seizure activity at the level of neuronal discharge, with superior temporal and spatial resolution. However, the clinical application of iEEG data faces a fundamental challenge: accurate seizure detection highly relies on experienced neurologists to annotate segments of continuous recordings for hours or even days. This process is time-consuming, expensive to annotate, and there is systematic inter rater variability among different annotators. The annotation bottleneck not only limits the monitoring scale, but also poses a significant obstacle to the clinical promotion of supervised learning based automatic detection algorithms - each new patient needs to re annotate the data in order to train personalized models. In recent years, self supervised learning (SSL) has shown great potential in the field of medical signal processing. By learning discriminative representations from unlabeled data, SSL methods have the potential to break annotation dependencies. Masked autoencoders (MAE) force the model to learn the intrinsic statistical patterns of the signal by reconstructing randomly masked input segments; Combining contrastive learning can further enhance the consistency of representation across subjects. However, there is still a lack of systematic research on how to convert SSL pre trained feature representations into unlabeled seizure detection scores. This article proposes an end-to-end zero annotation iEEG seizure detection framework. Specifically, we first perform self supervised training on the Transformer encoder using MAE pre training loss and subject comparison loss on the multi subject iEEG data in the HUP dataset; Subsequently, for each target subject, an individualized Mahalanobis distance anomaly model was established using only their interictal data as the classification basis for seizure detection. The entire process does not require any manual annotation of seizures. The main contributions of this study include: (1) proposing and validating a complete zero label iEEG seizure detection method, achieving a global AUROC of 0.963 in internal validation of 54 patients; (2) Zero sample transfer validation was conducted on an independent external dataset (SWEC-ETHZ, 18 patients), with an average AUROC of 0.843; (3) It revealed that unsupervised methods were significantly better than supervised baselines across subjects under intra subject settings (Δ=+0.158), indicating that the consistency of signals within individuals is much greater than the differences between individuals; (4) Through clinical validation of SOZ localization, the anatomical matching rate of patients with successful surgery (Engel grade 1) reached 81.0%, providing direct evidence for the clinical usability of the method. Results Research Design and Data Overview This study used two independent iEEG datasets. The internal training and validation dataset comes from the publicly available dataset of the University of Pennsylvania Affiliated Hospital (HUP), which includes SEEG or ECoG records of 54 patients with drug-resistant epilepsy, all organized in BIDS format with a sampling rate of 256 Hz (preprocessed). 54 patients were included in the analysis, and the exclusion criteria were only data acquisition failure (no valid iEEG files), without post screening based on seizure detection performance. The external validation dataset is SWEC-ETHZ (Swiss University Hospital Bern/Swiss Federal Institute of Technology Zurich), which includes 2656 hours of continuous iEEG recordings from 18 patients, with sampling rates of 512 or 1024 Hz, and contains 116 seizure events. All preprocessing steps (bandpass filtering 1-120 Hz, 60 Hz notch, resampling to 256 Hz, common average reference, 1-second sliding window slicing) remain completely consistent on both datasets (see method). Self supervised pre training and personalized anomaly detection We have designed a detection framework consisting of two stages (Figure 1). In the pre training stage, the Transformer encoder (6 layers, embedding dimension 128) takes unlabeled iEEG segments of all subjects in the HUP as input, while optimizing the MAE reconstruction loss and subject comparison loss (λ=0.3), encouraging the model to distinguish the EEG models of different subjects in the feature space. In the inference stage, for the target subject, a low dimensional Mahalanobis distance model (PCA reduced to 16 dimensions, LedoitWolf covariance estimation) is established using only their interictal data. This model quantifies the degree of deviation between each 1-second segment and the normal iEEG distribution of the subject, and uses it as an abnormal seizure score without any interictal labels. HUP Internal Validation: Attack Detection Performance In the internal validation of all 54 subjects in HUP, the global AUROC of this method (calculated by combining the seizure and interictal segments of all subjects) was 0.963, and the average AUROC of the subjects was 0.973 ± 0.055 (Figure 2A). The individual AUROC of 51/54 subjects exceeded 0.90, with only 3 subjects falling below this threshold (the lowest value being 0.740). The average AUROC detected during the pre attack period (within 30 minutes before the onset of the attack) was 0.845 ± 0.118, significantly lower than that detected during the attack period (p<0.001, Mann Whitney U test, Figure 2B), reflecting relatively more subtle signal changes during the pre attack period (Figure 2C). Comparison with a supervised baseline system: 3 × 2 comparison matrix To fairly evaluate the actual value of the zero annotation method, we constructed a 3 × 2 comparison matrix on the same dataset (n=54), covering three types of methods (unsupervised, supervised linear, supervised MLP/CNN) and two evaluation settings (intra subject WS, LOSO across subjects), as shown in Table 1 and Figure 3. Table 1. 3×2 Method × Evaluation setting comparison (HUP, n=54). Green rows = this work (zero-label within-subject, A1). WS = within-subject; LOSO = leave-one-subject-out cross-subject. Method Evaluation setting Mean AUROC SD n Unsupervised (this work) Within-subject (WS) 0.954 0.073 54 Unsupervised (this work) LOSO (cross-subject) 0.797 0.170 54 Supervised Linear Within-subject (WS) 0.964 0.078 54 Supervised Linear LOSO (cross-subject) 0.842 0.180 54 Supervised MLP/CNN Within-subject (WS) 0.972 0.063 54 Supervised MLP/CNN LOSO (cross-subject) 0.796 0.142 54 Core finding: Under the subject specific setting, the performance difference between labeled and unlabeled individuals is extremely small (zero labeling 0.954 vs supervised linearity 0.964, with a difference of only 0.010); Under the cross subject LOSO setting, the performance of supervised methods significantly decreased (optimal 0.842). This model shows that the consistency of signals within individuals is far greater than the difference between individuals, making the personalized modeling of zero labeling comparable to the cross subject model trained with other's labeled data - even better than the latter under fair comparison (WS settings). Specifically, the zero labeled WS (A1, 0.954) is Δ=+0.112 higher than the supervised LOSO optimal baseline (0.842). In the paired comparison of each subject (Figure 3B), 100% of the subjects had zero labeled WS better than supervised LOSO, with an average improvement of Δ=+0.161. Cross center external verification: SWEC-ETHZ zero sample transfer On a completely independent SWEC-ETHZ dataset (18 patients, Bern University Hospital, Switzerland), the HUP pre trained encoder was used to directly infer (without any fine-tuning) and verify the cross center generalization ability of the method. The results showed that the average AUROC of 18 patients was 0.843 ± 0.173, the median AUROC was 0.945, and 11/18 patients (61.1%) had an AUROC exceeding 0.90 (Figure 4A). Compared with the internal validation of HUP, the performance of external validation has decreased (0.843 vs 0.973, Mann Whitney U test p<0.001, Figure 4B), but overall it remains at a clinically usable level. Seven patients with AUROC below 0.80 all exhibited high seizure frequency characteristics: Spearman correlation analysis showed a significant negative correlation between seizure frequency and AUROC (ρ=-0.69, p=0.002), and a significant correlation between seizure frequency (times/day) and AUROC (ρ=-0.60, p=0.009, see Supplementary Figure S3 for details). This mechanistic finding suggests that a large amount of subclinical discharges are mixed into the interictal data of high-frequency seizure patients, leading to contamination of the reference distribution of individualized Mahalanobis distance models and a decrease in anomaly detection ability. This is a known limitation faced by unsupervised methods based on interval modeling. Clinical correlation between SOZ localization and surgical outcomes We evaluated whether the channel level anomaly score was consistent with the anatomy of the surgical resection area in 31 subjects with complete surgical resection records and electrode spatial coordinate data. The overall anatomical matching rate was 71.0%, significantly higher than the random baseline (about 33%). Among 21 patients with Engel grade 1 (successful surgery, no or significantly reduced postoperative episodes), the anatomical matching rate reached 81.0%; Among the 9 patients with Engel 3+grade (surgical failure), it was 66.7% (Figure 5B). It is worth noting that there is no significant statistical correlation between Engel grading and seizure detection performance (clip level AUROC) (Wilcoxon test p=0.572, Figure 5A). This seemingly paradoxical finding actually has significant clinical implications: surgical failure is not due to incorrect method localization, but rather due to insufficient resection range or the presence of multiple lesions - some Engel 3+patients have an AUROC close to 1.0 for seizure detection (such as HUP114: 0.9996, HUP166: 0.9999), indicating that the model accurately identified the seizure areas, but the surgery itself failed to fully process these areas. This provides an independent quantitative perspective for understanding the fundamental challenges of intracranial epilepsy surgery. Discussion This study proposes and validates an end-to-end zero label intracranial EEG seizure detection and SOZ localization framework. The core discovery lies in the combination of self supervised Transformer encoder and individualized Mahalanobis distance modeling, which achieves detection performance close to the upper bound of supervised methods without using manual episode labeling, and demonstrates substantial cross center generalization ability on independent external central datasets. From a methodological perspective, the only 0.010 difference in AUROC between subjects with zero annotations and supervised methods reveals an important biological law: the iEEG of a single subject has a high degree of self consistency in the time dimension - the signal differences between episodes are much greater than the differences in similar states between different subjects. This characteristic gives unsupervised intra individual modeling a natural advantage, while cross subject models trained on a large amount of annotated data from others suffer from significant inter individual distribution shifts. One of the core contributions of this method is to explicitly incorporate this statistical pattern into the detection framework through personalized parameter estimation of Mahalanobis distance. The results of external validation (SWEC-ETHZ) further support the generalization of the framework. Despite significant differences in electrode configuration (SEEG/ECoG), sampling rate (256-1024 Hz), recording duration (several hours to hundreds of hours), and patient population between the two datasets, the HUP pre trained encoder was still able to achieve detection performance with an AUROC exceeding 0.90 in 11 out of 18 patients (61.1%) without any fine-tuning or transfer learning steps. The high seizure frequency characteristics (Spearman ρ=-0.69) of 7 poorly performing patients provide a mechanistic explanation for understanding the applicability boundaries of the method, and indicate future improvement directions: for high-frequency seizure patients, dynamic updates of the reference distribution based on seizure event timestamps (rather than continuous records) can be considered, or robust covariance estimation can be introduced to reduce the impact of data pollution during the seizure period. SOZ localization analysis revealed a clinical finding beyond seizure detection: decoupling between localization accuracy (Engel 1:81%) and surgical outcomes. In some Engel 3+(surgical failure) patients, our unsupervised method achieved near perfect seizure detection (AUROC>0.99), indicating that the method accurately identified the seizure area at the technical level. However, the surgical failure of patients was due to insufficient resection range or the presence of multiple seizure foci - this is currently the core challenge in the field of epilepsy surgery, not the limitation of seizure localization itself. This quantitative perspective helps distinguish between "positioning problems" and "surgical operation problems", and has reference value for designing more accurate surgical plans. This study has several limitations. Firstly, the HUP dataset is a single center dataset, and although external validation has been conducted on the SWEC-ETHZ dataset, larger scale multicenter prospective validation is still necessary. Secondly, in patients with high-frequency attacks (>8 times/day), the performance of this method decreases, and further algorithm improvement is needed. Thirdly, SOZ localization analysis is based on coarse-grained anatomical lobe classification, and precise millimeter level localization requires the combination of imaging data. Fourthly, the current framework has not established explicit models for physiological factors such as sleep wake cycles and adjustment of antiepileptic drugs, which may affect the stability of the reference distribution of interictal intervals. Overall, this study demonstrates that the combination of self supervised learning and personalized statistical modeling can achieve near supervised zero label seizure detection on clinical iEEG data, and has substantial cross center generalization ability. This framework is expected to rapidly deploy iEEG automatic analysis systems in resource limited clinical environments, especially in primary healthcare institutions lacking professional annotators, promoting further popularization of accurate diagnosis of epilepsy. References A. Epidemiology and clinical background of epilepsy Beghi E, Giussani G, Nichols E, et al. Global, regional, and national burden of epilepsy, 1990–2016: a systematic analysis for the Global Burden of Disease Study 2016[J]. The Lancet Neurology, 2019, 18(4): 357-375. Kwan P, Brodie M J. Early identification of refractory epilepsy[J]. New England Journal of Medicine, 2000, 342(5): 314-319. Engel J. Surgical treatment of the epilepsies[J]. (No Title), 1993. Wiebe S, Blume W T, Girvin J P, et al. A randomized, controlled trial of surgery for temporal-lobe epilepsy[J]. New England Journal of Medicine, 2001, 345(5): 311-318. Elger C E, Hoppe C. Diagnostic challenges in epilepsy: seizure under-reporting and seizure detection[J]. The Lancet Neurology, 2018, 17(3): 279-288. B. IEEG dataset Bernabei J M, Li A, Revell A Y, et al. HUP iEEG epilepsy dataset[J]. OpenNeuro, 2023. Bernabei J M, Sinha N, Arnold T C, et al. Normative intracranial EEG maps epileptogenic tissues in focal epilepsy[J]. Brain, 2022, 145(6): 1949-1961. Appelhoff S, Sanderson M, Brooks T L, et al. MNE-BIDS: Organizing electrophysiological data into the BIDS format and facilitating their analysis[J]. Journal of Open Source Software, 2019, 4(44): 1896. Burrello A, Cavigelli L, Schindler K, et al. Laelaps: An energy-efficient seizure detection algorithm from long-term human iEEG recordings without false alarms[C]//2019 Design, Automation & Test in Europe Conference & Exhibition (DATE). IEEE, 2019: 752-757. C. SWEC-ETHZ External Validation Dataset Burrello A, Benatti S, Schindler K, et al. An ensemble of hyperdimensional classifiers: Hardware-friendly short-latency seizure detection with automatic iEEG electrode selection[J]. IEEE journal of biomedical and health informatics, 2020, 25(4): 935-946. Sopic D, Aminifar A, Atienza D. e-glass: A wearable system for real-time detection of epileptic seizures[C]//2018 IEEE International Symposium on Circuits and Systems (ISCAS). IEEE, 2018: 1-5. D. IEEG seizure detection - supervised and traditional methods Kiral-Kornek I, Roy S, Nurse E, et al. Epileptic seizure prediction using big data and deep learning: toward a mobile system[J]. EBioMedicine, 2018, 27: 103-111. Lotte F, Bougrain L, Cichocki A, et al. A review of classification algorithms for EEG-based brain–computer interfaces: a 10 year update[J]. Journal of neural engineering, 2018, 15(3): 031005. Rasheed K, Qayyum A, Qadir J, et al. Machine learning for predicting epileptic seizures using EEG signals: A review[J]. IEEE reviews in biomedical engineering, 2020, 14: 139-155. Tran L V, Tran H M, Le T M, et al. Application of machine learning in epileptic seizure detection[J]. Diagnostics, 2022, 12(11): 2879. Jiang H, Kokkinos V, Ye S, et al. Interictal SEEG resting‐state connectivity localizes the seizure onset zone and predicts seizure outcome[J]. Advanced Science, 2022, 9(18): 2200887. E. Localization of onset zone (SOZ) Varatharajah Y, Chong M J, Saboo K, et al. EEG-GRAPH: a factor-graph-based model for capturing spatial, temporal, and observational relationships in electroencephalograms[J]. Advances in neural information processing systems, 2017, 30. Gunnarsdottir K M, Li A, Smith R J, et al. Source-sink connectivity: a novel interictal EEG marker for seizure localization[J]. Brain, 2022, 145(11): 3901-3915. Proix T, Truccolo W, Leguia M G, et al. Forecasting seizure risk in adults with focal epilepsy: a development and validation study[J]. The Lancet Neurology, 2021, 20(2): 127-135. F. Basic Methods of Self Supervised Learning He K, Chen X, Xie S, et al. Masked autoencoders are scalable vision learners[C]//Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. 2022: 16000-16009. Dosovitskiy A, Beyer L, Kolesnikov A, et al. An image is worth 16x16 words: Transformers for image recognition at scale[J]. arXiv preprint arXiv:2010.11929, 2020. Chen T, Kornblith S, Norouzi M, et al. A simple framework for contrastive learning of visual representations[C]//International conference on machine learning. PmLR, 2020: 1597-1607. Vaswani A, Shazeer N, Parmar N, et al. Attention is all you need[J]. Advances in neural information processing systems, 2017, 30. Devlin J, Chang M W, Lee K, et al. Bert: Pre-training of deep bidirectional transformers for language understanding[C]//Proceedings of the 2019 conference of the North American chapter of the association for computational linguistics: human language technologies, volume 1 (long and short papers). 2019: 4171-4186. Grill-Spector K, Malach R. The human visual cortex[J]. Annu. Rev. Neurosci., 2004, 27(1): 649-677. G. Biosignals/EEG Self Supervised Learning Jiang W B, Zhao L M, Lu B L. Large brain model for learning generic representations with tremendous EEG data in BCI[J]. arXiv preprint arXiv:2405.18765, 2024. Yang C, Westover M, Sun J. Biot: Biosignal transformer for cross-data learning in the wild[J]. Advances in Neural Information Processing Systems, 2023, 36: 78240-78260. Kostas D, Aroca-Ouellette S, Rudzicz F. BENDR: Using transformers and a contrastive self-supervised learning task to learn from massive amounts of EEG data[J]. Frontiers in Human Neuroscience, 2021, 15: 653659. Banville H, Chehab O, Hyvärinen A, et al. Uncovering the structure of clinical EEG signals with self-supervised learning[J]. Journal of Neural Engineering, 2021, 18(4): 046020. H. Anomaly detection and Mahalanobis distance method Kamoi R, Kobayashi K. Why is the mahalanobis distance effective for anomaly detection?[J]. arXiv preprint arXiv:2003.00402, 2020. Ledoit O, Wolf M. A well-conditioned estimator for large-dimensional covariance matrices[J]. Journal of multivariate analysis, 2004, 88(2): 365-411. Vyas S, Golub M D, Sussillo D, et al. Computation through neural population dynamics[J]. Annual review of neuroscience, 2020, 43(1): 249-275. I. Onset prediction, warning, and periodicity Baud M O, Kleen J K, Mirro E A, et al. Multi-day rhythms modulate seizure risk in epilepsy[J]. Nature communications, 2018, 9(1): 88. Karoly P J, Ung H, Grayden D B, et al. The circadian profile of epilepsy improves seizure forecasting[J]. Brain, 2017, 140(8): 2169-2182. Stirling R E, Cook M J, Grayden D B, et al. Seizure forecasting and cyclic control of seizures[J]. Epilepsia, 2021, 62: S2-S14. Cook M J, O'Brien T J, Berkovic S F, et al. Prediction of seizure likelihood with a long-term, implanted seizure advisory system in patients with drug-resistant epilepsy: a first-in-man study[J]. The Lancet Neurology, 2013, 12(6): 563-571. J. Transfer learning, domain adaptation, and cross center generalization Pan S J, Yang Q. A survey on transfer learning[J]. IEEE Transactions on knowledge and data engineering, 2009, 22(10): 1345-1359. Khalfallah S, Selmi K, Bouallegue K. EEGWaveNet: A Transfer and Federated Learning Framework for Cross-Dataset Seizure Detection[C]//2025 IEEE 22nd International Conference on Sciences and Techniques of Automatic Control and Computer Engineering (STA). IEEE, 2025: 346-353. K. Epilepsy Surgery and Surgical Outcome Evaluation Jobst B C, Cascino G D. Resective epilepsy surgery for drug-resistant focal epilepsy: a review[J]. Jama, 2015, 313(3): 285-293. Téllez-Zenteno J F, Dhar R, Wiebe S. Long-term seizure outcomes following epilepsy surgery: a systematic review and meta-analysis[J]. Brain, 2005, 128(5): 1188-1198. Luders H O. Conceptual considerations[J]. Epilepsy surgery, 1992: 51-62. Rosenow F, Lüders H. Presurgical evaluation of epilepsy[J]. Brain, 2001, 124(9): 1683-1700. L. Large scale basic models and medical AI Bommasani R, Hudson D A, Adeli E, et al. On the opportunities and risks of foundation models[J]. arXiv preprint arXiv:2108.07258, 2021. Moor M, Banerjee O, Abad Z S H, et al. Foundation models for generalist medical artificial intelligence[J]. Nature, 2023, 616(7956): 259-265. M. Representative iEEG Epilepsy Detection and Localization Study (Comparative Literature) Winterhalder M, Maiwald T, Voss H U, et al. The seizure prediction characteristic: a general framework to assess and compare seizure prediction methods[J]. Epilepsy & Behavior, 2003, 4(3): 318-325. Mormann F, Andrzejak R G, Elger C E, et al. Seizure prediction: the long and winding road[J]. Brain, 2007, 130(2): 314-333. Kuhlmann L, Lehnertz K, Richardson M P, et al. Seizure prediction—ready for a new era[J]. Nature Reviews Neurology, 2018, 14(10): 618-630. Truong N D, Nguyen A D, Kuhlmann L, et al. Convolutional neural networks for seizure prediction using intracranial and scalp electroencephalogram[J]. Neural networks, 2018, 105: 104-111. Reference Position Correspondence Table: (1) Introduction paragraph 1: References 1 (Global Burden of GBD Epilepsy), 2 (Kwan Refractory Epilepsy), 5 (Elger Labeling Challenge) (2) Introduction paragraph 2: Reference 42 (Rosenow preoperative evaluation), 4 (Wiebe surgical efficacy RCT) (3) Introduction paragraph 3: Citations 20 (He MAE), 22 (Chen SimCLR), 21 (Dosovitskiy ViT) (4) Result - Dataset: References 6 (HUP dataset), 8 (MNE-BIDS), 9 (Burrello SWEC short-term), 10 (Burrello SWEC long-term) (5) Result SOZ localization: References 7 (Bernabei 2022), 18 (Gunnarsdottir), 16 (Jiang 2022) cited (6) Results - Comparison of seizure prediction: References 19 (Proix Lancet Neurol), 33 (Baud Nat Commun), 47 (Kuhlmann Nat Rev Neurol) were cited (7) Method MAE pre training: References 20 (He CVPR 2022), 23 (Vaswani Attention), 24 (Devlin BERT) cited (8) Method - Comparative loss: References 22 (Chen SimCLR), 28 (Kostas BENDR), 29 (Banville J Neural Eng) were cited (9) Method - Mahalanobis distance: References 31 (Ledoit Wolf covariance estimation) and 32 (Vyas neural population dynamics) are cited (10) Discussion Transfer: References 37 (Pan Transfer Learning Review), 38 (Ye Cross Dataset EEG) (11) Discussion - Clinical Significance: References 39 (Jobst JAMA), 40 (T é llez Zenteno Brain), 41 (L ü ders Epilepsy Surgery) are cited (12) Discussion - Basic Model: References 43 (Bommasani Basic Model), 44 (Moor Nature Medical AI) (13) Supplementary - Comparison of External Validation Methods: References 12 (Kiral Kornek), 14 (Rasheed), 48 (Truong CNN Epilepsy Prediction) Methods Datasets HUP dataset: a publicly available intracranial EEG dataset from the University of Pennsylvania Affiliated Hospital, approved by the ethics committee and with patient informed consent. This study included 54 patients with drug-resistant epilepsy, and the recording modes included SEEG (SEEG) and ECoG. All data were organized in BIDS format, including events.tsv files indicating the start and end time of seizures. SWEC-ETHZ dataset: an open dataset from Bern University Hospital (Sleep Awakening Epilepsy Center) in Switzerland, containing 2656 hours of continuous iEEG recordings from 18 patients, 116 seizure events, raw sampling rates of 512 or 1024 Hz, stored in. mat format, with each file corresponding to 1 hour of continuous recording. Preprocessing Two datasets adopt a unified preprocessing process: (1) bandpass filtering 1-120 Hz (4th order Butterworth); (2) 60Hz notch filtering (iirnotch, Q=30); (3) Resampling to 256 Hz (multi-phase resampling, SWEC-ETHZ downsampling from 512/1024 Hz); (4) Common average reference; (5) 1 second non overlapping sliding window slice. According to the onset time annotation in events. tsv (HUP) or info. mat (SWEC-ETHZ), each 1-second segment is labeled as interictal (0), interictal (1), or pre interictal (2, within 30 minutes before onset) for evaluation and not for training. Self supervised pre training The Transformer encoder consists of 6 layers of encoder modules, with an embedding dimension of 128 and 4 attention heads. The 1-second, 256 sampling point timing signal input is evenly divided into 16 patches (16 sampling points per patch), mapped to a 128 dimensional feature space through a linear embedding layer, and overlaid with sine position encoding. Pre training uses two complementary losses: MAE reconstruction loss: Randomly mask 75% of the patches, requiring the encoder to reconstruct the original signal of the masked patch only based on visible patches. The loss function is the mean square error of the masked area. Subject comparison loss (λ=0.3): Gravity loss (narrowing feature distance) is calculated for segments of the same subject at different time periods, while repulsion loss (pushing feature distance) is calculated for segments of different subjects, using the InfoNCE framework. Training was conducted using all unlabeled fragments from all 54 participants of HUP (without distinguishing between periods/intervals), Adam optimizer, with a learning rate of 1e-4, trained for 57 epochs, and validated with a loss of 2.7221. Individualized Mahalanobis distance anomaly detection For the target subjects, only their interictal segments (label=0) are used to extract 128 dimensional feature representations through an encoder, which are then aggregated into feature vectors for each time window through channel averaging. Subsequently: (1) Standardization (StandardScaler); (2) PCA dimensionality reduction to 16 dimensions; (3) LedoitWolf regularizes covariance estimation. Define the Mahalanobis distance using the inverse matrix of the covariance matrix and the sample mean (Equation 1). When inferring, calculate the Mahalanobis distance score for all segments (interictal+interictal) of the target subject, and use this score to calculate the AUROC (higher score corresponds to higher probability of onset) for the interictal/interictal labels. Baseline method (B1) Supervised linearity: Train a logistic regression classifier on encoder features, with 50% data training and 50% testing within the subjects. (B2) Supervised linear LOSO: Train logistic regression using annotated data from the remaining 53 subjects and test it on the target subjects. (C1) Supervised MLP within subjects: Train 3 layers of MLP on encoder features for intra subject segmentation. (C2) Supervised CNN/MLP LOSO: Same as C1, but using LOSO training and evaluation settings. Channel level SOZ positioning Quantify the contribution of each channel to seizures by calculating the Net Seizure Anomaly Rate (SAR) of each channel: for the target subject, calculate the Mahalanobis distance time series of each channel, calculate the average score difference between the seizure period and the interictal period, take the centroid of the top-20% abnormal channels, and match them with the anatomical brain lobe labels of the surgical resection area. Successful matching is defined as the predicted brain lobe being consistent with the surgical target brain lobe (temporal lobe/frontal lobe/parietal lobe/other). Statistical analysis The comparison of AUROC differences was performed using Mann Whitney U test (bilateral). The statistical significance of SOZ localization matching rate was tested using Fisher's exact test and random permutation test (n=10000 times). The correlation analysis between Engel grading and AUROC was conducted using Kruskal Wallis test. The correlation between seizure frequency and AUROC is based on Spearman rank correlation. The significance threshold for all statistical tests is set to α=0.05 (two-sided). Additional Declarations There is NO Competing Interest. Supplementary Files Supplementarymaterials.docx Cite Share Download PDF Status: Posted Version 1 posted You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-9568998","acceptedTermsAndConditions":true,"allowDirectSubmit":true,"archivedVersions":[],"articleType":"Article","associatedPublications":[],"authors":[{"id":635653724,"identity":"597620d0-c1af-4acd-8f80-71a7fae24111","order_by":0,"name":"Zhikai Yu","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA0klEQVRIie3QMQrCMBTG8SeF6BDpJi849AophaLQw+jeQXAXXeLiAVoEvYJujpW3FlwVl4Lg3LHdbJ2c2rgJ5r8Fvh8hATCZfrXOEiVYVpLkxXeETc/xRp+ABOAe9ZjGWl5DX5SnkWeveU7AwbEHSTMRUeijSNFH6h9oNgI33k6aiT2siKswgJpEHCby3kJYTaYVcYhnxJkGed9yVuhL4qBHxP45H68Uei4xWX0ytr9FpnS8lWrh7i70yPMicOxhCwHoyc8Tts3rupnOymQymf65F3VHQQCrQ4k8AAAAAElFTkSuQmCC","orcid":"https://orcid.org/0009-0005-4985-4036","institution":"University College London","correspondingAuthor":true,"prefix":"","firstName":"Zhikai","middleName":"","lastName":"Yu","suffix":""}],"badges":[],"createdAt":"2026-04-29 18:10:35","currentVersionCode":1,"declarations":"","doi":"10.21203/rs.3.rs-9568998/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-9568998/v1","draftVersion":[],"editorialEvents":[],"editorialNote":"","failedWorkflow":false,"files":[{"id":108840491,"identity":"dca7d0c4-0438-45d6-8539-35487fd116ab","added_by":"auto","created_at":"2026-05-09 00:55:06","extension":"png","order_by":1,"title":"Figure 1","display":"","copyAsset":false,"role":"figure","size":445265,"visible":true,"origin":"","legend":"\u003cp\u003eSchematic diagram of the method framework. From left to right: intracranial EEG recordings (SEEG/ECoG, HUP: 54 subjects; SWEC-ETHZ: 18 subjects) → Preprocessing (bandpass filtering, resampling, co averaging reference, 1-second window slicing) → Self supervised pre training (MAE mask reconstruction+subject contrastive learning, Transformer encoder 6 layers × 128 dimensions) → Individualized anomaly detection (PCA+LedoitWolf Mahalanobis distance, label free) → Output (seizure detection AUROC 0.963); Warning before onset AUROC 0.845; The SOZ positioning matching rate is 71%. The entire framework does not require any manual annotation.\u003c/p\u003e","description":"","filename":"1.png","url":"https://assets-eu.researchsquare.com/files/rs-9568998/v1/0b5d81adc7b075b3975c70e9.png"},{"id":108840487,"identity":"d5674f7e-310d-412d-9cf8-66502e319cc1","added_by":"auto","created_at":"2026-05-09 00:55:06","extension":"png","order_by":2,"title":"Figure 2","display":"","copyAsset":false,"role":"figure","size":351883,"visible":true,"origin":"","legend":"\u003cp\u003eAttack detection performance of HUP dataset (n=54). A, The individual AUROC distribution of the subjects (violin plot+scatter plot) has a mean of 0.973 ± 0.054, with 51 out of 54 subjects exceeding 0.90 (gray dashed line). B, Comparison of AUROC (box plot+scatter plot) between seizure detection and pre seizure warning, Mann Whitney U test p\u0026lt;0.001. C, The cumulative distribution function of the two is marked by a gray dashed line with AUROC=0.90.\u003c/p\u003e","description":"","filename":"2.png","url":"https://assets-eu.researchsquare.com/files/rs-9568998/v1/690ab7a9827efcd79681fb59.png"},{"id":108840488,"identity":"957e637b-5d2b-4eb9-8fc6-8c0bac35b5a1","added_by":"auto","created_at":"2026-05-09 00:55:06","extension":"png","order_by":3,"title":"Figure 3","display":"","copyAsset":false,"role":"figure","size":410877,"visible":true,"origin":"","legend":"\u003cp\u003eComparison of 3 × 2 methods. A, The heatmap displays the average AUROC (mean ± standard deviation, n=54), The orange border indicates the method used in this article (within zero labeled subjects, A1=0.954). B, The scatter plot of zero labeled WS (vertical axis) and supervised LOSO (horizontal axis) AUROC for each subject, with the top of the diagonal indicating better zero labeling and 100% of subjects located above the diagonal, resulting in an average improvement of Δ=+0.161.\u003c/p\u003e","description":"","filename":"3.png","url":"https://assets-eu.researchsquare.com/files/rs-9568998/v1/09dd803ab18be1081da19d34.png"},{"id":108840489,"identity":"95fe762c-5a51-40b5-8107-3b773017d6e7","added_by":"auto","created_at":"2026-05-09 00:55:06","extension":"png","order_by":4,"title":"Figure 4","display":"","copyAsset":false,"role":"figure","size":409801,"visible":true,"origin":"","legend":"\u003cp\u003eSWEC-ETHZ external validation (n=18, HUP pre training, zero sample transfer). A,A bar chart of AUROC for 18 patients, arranged in ascending order of AUROC, with blue/orange representing AUROC ≥ 0.80 and\u0026lt;0.80, respectively, and a gray dashed line indicating the 0.80 reference line. B. Comparison of AUROC violin plots between HUP internal validation (n=54) and SWEC-ETHZ external validation (n=18), Mann Whitney U test p\u0026lt;0.001.\u003c/p\u003e","description":"","filename":"4.png","url":"https://assets-eu.researchsquare.com/files/rs-9568998/v1/425ad3205b794b5b52e92534.png"},{"id":108840490,"identity":"d54f87a4-87f5-4be3-b9f8-0fcc598754b0","added_by":"auto","created_at":"2026-05-09 00:55:06","extension":"png","order_by":5,"title":"Figure 5","display":"","copyAsset":false,"role":"figure","size":252771,"visible":true,"origin":"","legend":"\u003cp\u003eClinical correlation between SOZ localization and surgical outcomes. A, The clip level AUROC boxplots for seizure detection in patients with different Engel grades (Engel 1: n=31; Engel 2: n=5; Engel 3-4: n=10) showed no significant differences among the three groups (p=0.572, Mann Whitney U test). B, The SOZ localization anatomical matching rate (overall 71.0%, Engel 1: 81.0%, Engel 3+: 66.7%), with the gray dashed line representing the random baseline (approximately 33%).\u003c/p\u003e","description":"","filename":"5.png","url":"https://assets-eu.researchsquare.com/files/rs-9568998/v1/c08e9b18e44203cbae6c30b1.png"},{"id":108977141,"identity":"24936017-5d0c-4bb5-942d-aaac9fdeb6a8","added_by":"auto","created_at":"2026-05-11 11:30:34","extension":"pdf","order_by":0,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":1823565,"visible":true,"origin":"","legend":"","description":"","filename":"manuscript.pdf","url":"https://assets-eu.researchsquare.com/files/rs-9568998/v1/babf14bf-3c8e-4844-945a-485ee06ccd4e.pdf"},{"id":108840486,"identity":"e8be8c57-116d-4a82-8f55-2e6f167d1f4a","added_by":"auto","created_at":"2026-05-09 00:55:06","extension":"docx","order_by":1,"title":"","display":"","copyAsset":false,"role":"supplement","size":405322,"visible":true,"origin":"","legend":"","description":"","filename":"Supplementarymaterials.docx","url":"https://assets-eu.researchsquare.com/files/rs-9568998/v1/aa2f8950d693689e457f4d5e.docx"}],"financialInterests":"There is \u003cb\u003eNO\u003c/b\u003e Competing Interest.","formattedTitle":"Zero-Annotation Seizure Detection and Onset Zone Localization in Intracranial EEG via Self-Supervised Learning and Mahalanobis Distance Modeling","fulltext":[{"header":"Introduction","content":"\u003cp\u003eDrug resistant epilepsy affects approximately 50 million people worldwide, with about one-third of them experiencing poor response to antiepileptic drugs. For such patients, surgical resection or ablation of the seizure onset zone (SOZ) is currently one of the most effective treatment options. The core of SOZ localization relies on intracranial electroencephalography (iEEG) monitoring, including stereotactic electroencephalography (SEEG) and cortical electroencephalography (ECoG). This type of detection can directly record seizure activity at the level of neuronal discharge, with superior temporal and spatial resolution.\u003c/p\u003e\n\n\u003cp\u003eHowever, the clinical application of iEEG data faces a fundamental challenge: accurate seizure detection highly relies on experienced neurologists to annotate segments of continuous recordings for hours or even days. This process is time-consuming, expensive to annotate, and there is systematic inter rater variability among different annotators. The annotation bottleneck not only limits the monitoring scale, but also poses a significant obstacle to the clinical promotion of supervised learning based automatic detection algorithms - each new patient needs to re annotate the data in order to train personalized models.\u003c/p\u003e\n\n\u003cp\u003eIn recent years, self supervised learning (SSL) has shown great potential in the field of medical signal processing. By learning discriminative representations from unlabeled data, SSL methods have the potential to break annotation dependencies. Masked autoencoders (MAE) force the model to learn the intrinsic statistical patterns of the signal by reconstructing randomly masked input segments; Combining contrastive learning can further enhance the consistency of representation across subjects. However, there is still a lack of systematic research on how to convert SSL pre trained feature representations into unlabeled seizure detection scores.\u003c/p\u003e\n\n\u003cp\u003eThis article proposes an end-to-end zero annotation iEEG seizure detection framework. Specifically, we first perform self supervised training on the Transformer encoder using MAE pre training loss and subject comparison loss on the multi subject iEEG data in the HUP dataset; Subsequently, for each target subject, an individualized Mahalanobis distance anomaly model was established using only their interictal data as the classification basis for seizure detection. The entire process does not require any manual annotation of seizures.\u003c/p\u003e\n\n\u003cp\u003eThe main contributions of this study include: (1) proposing and validating a complete zero label iEEG seizure detection method, achieving a global AUROC of 0.963 in internal validation of 54 patients; (2) Zero sample transfer validation was conducted on an independent external dataset (SWEC-ETHZ, 18 patients), with an average AUROC of 0.843; (3) It revealed that unsupervised methods were significantly better than supervised baselines across subjects under intra subject settings (\u0026Delta;=+0.158), indicating that the consistency of signals within individuals is much greater than the differences between individuals; (4) Through clinical validation of SOZ localization, the anatomical matching rate of patients with successful surgery (Engel grade 1) reached 81.0%, providing direct evidence for the clinical usability of the method.\u003c/p\u003e"},{"header":"Results","content":"\u003cp\u003e\u003cstrong\u003eResearch Design and Data Overview\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eThis study used two independent iEEG datasets. The internal training and validation dataset comes from the publicly available dataset of the University of Pennsylvania Affiliated Hospital (HUP), which includes SEEG or ECoG records of 54 patients with drug-resistant epilepsy, all organized in BIDS format with a sampling rate of 256 Hz (preprocessed). 54 patients were included in the analysis, and the exclusion criteria were only data acquisition failure (no valid iEEG files), without post screening based on seizure detection performance. The external validation dataset is SWEC-ETHZ (Swiss University Hospital Bern/Swiss Federal Institute of Technology Zurich), which includes 2656 hours of continuous iEEG recordings from 18 patients, with sampling rates of 512 or 1024 Hz, and contains 116 seizure events. All preprocessing steps (bandpass filtering 1-120 Hz, 60 Hz notch, resampling to 256 Hz, common average reference, 1-second sliding window slicing) remain completely consistent on both datasets (see method).\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eSelf supervised pre training and personalized anomaly detection\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eWe have designed a detection framework consisting of two stages (Figure 1). In the pre training stage, the Transformer encoder (6 layers, embedding dimension 128) takes unlabeled iEEG segments of all subjects in the HUP as input, while optimizing the MAE reconstruction loss and subject comparison loss (\u0026lambda;=0.3), encouraging the model to distinguish the EEG models of different subjects in the feature space. In the inference stage, for the target subject, a low dimensional Mahalanobis distance model (PCA reduced to 16 dimensions, LedoitWolf covariance estimation) is established using only their interictal data. This model quantifies the degree of deviation between each 1-second segment and the normal iEEG distribution of the subject, and uses it as an abnormal seizure score without any interictal labels.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eHUP Internal Validation: Attack Detection Performance\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eIn the internal validation of all 54 subjects in HUP, the global AUROC of this method (calculated by combining the seizure and interictal segments of all subjects) was 0.963, and the average AUROC of the subjects was 0.973 \u0026plusmn; 0.055 (Figure 2A). The individual AUROC of 51/54 subjects exceeded 0.90, with only 3 subjects falling below this threshold (the lowest value being 0.740). The average AUROC detected during the pre attack period (within 30 minutes before the onset of the attack) was 0.845 \u0026plusmn; 0.118, significantly lower than that detected during the attack period (p\u0026lt;0.001, Mann Whitney U test, Figure 2B), reflecting relatively more subtle signal changes during the pre attack period (Figure 2C).\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eComparison with a supervised baseline system: 3 \u0026times; 2 comparison matrix\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eTo fairly evaluate the actual value of the zero annotation method, we constructed a 3 \u0026times; 2 comparison matrix on the same dataset (n=54), covering three types of methods (unsupervised, supervised linear, supervised MLP/CNN) and two evaluation settings (intra subject WS, LOSO across subjects), as shown in Table 1 and Figure 3.\u003c/p\u003e\n\u003cp\u003eTable 1. 3\u0026times;2 Method \u0026times; Evaluation setting comparison (HUP, n=54). Green rows = this work (zero-label within-subject, A1). WS = within-subject; LOSO = leave-one-subject-out cross-subject.\u003c/p\u003e\n\u003ctable border=\"1\" cellspacing=\"0\" cellpadding=\"0\" width=\"644\"\u003e\n \u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 173px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eMethod\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eEvaluation setting\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eMean AUROC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eSD\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 98px;\"\u003e\n \u003cp\u003e\u003cstrong\u003en\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 173px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eUnsupervised (this work)\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eWithin-subject (WS)\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e\u003cstrong\u003e0.954\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e\u003cstrong\u003e0.073\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 98px;\"\u003e\n \u003cp\u003e\u003cstrong\u003e54\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 173px;\"\u003e\n \u003cp\u003eUnsupervised (this work)\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003eLOSO (cross-subject)\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.797\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.170\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 98px;\"\u003e\n \u003cp\u003e54\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 173px;\"\u003e\n \u003cp\u003eSupervised Linear\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003eWithin-subject (WS)\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.964\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.078\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 98px;\"\u003e\n \u003cp\u003e54\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 173px;\"\u003e\n \u003cp\u003eSupervised Linear\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003eLOSO (cross-subject)\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.842\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.180\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 98px;\"\u003e\n \u003cp\u003e54\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 173px;\"\u003e\n \u003cp\u003eSupervised MLP/CNN\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003eWithin-subject (WS)\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.972\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.063\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 98px;\"\u003e\n \u003cp\u003e54\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 173px;\"\u003e\n \u003cp\u003eSupervised MLP/CNN\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003eLOSO (cross-subject)\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.796\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 124px;\"\u003e\n \u003cp\u003e0.142\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 98px;\"\u003e\n \u003cp\u003e54\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eCore finding: Under the subject specific setting, the performance difference between labeled and unlabeled individuals is extremely small (zero labeling 0.954 vs supervised linearity 0.964, with a difference of only 0.010); Under the cross subject LOSO setting, the performance of supervised methods significantly decreased (optimal 0.842). This model shows that the consistency of signals within individuals is far greater than the difference between individuals, making the personalized modeling of zero labeling comparable to the cross subject model trained with other\u0026apos;s labeled data - even better than the latter under fair comparison (WS settings). Specifically, the zero labeled WS (A1, 0.954) is \u0026Delta;=+0.112 higher than the supervised LOSO optimal baseline (0.842). In the paired comparison of each subject (Figure 3B), 100% of the subjects had zero labeled WS better than supervised LOSO, with an average improvement of \u0026Delta;=+0.161.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eCross center external verification: SWEC-ETHZ zero sample transfer\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eOn a completely independent SWEC-ETHZ dataset (18 patients, Bern University Hospital, Switzerland), the HUP pre trained encoder was used to directly infer (without any fine-tuning) and verify the cross center generalization ability of the method. The results showed that the average AUROC of 18 patients was 0.843 \u0026plusmn; 0.173, the median AUROC was 0.945, and 11/18 patients (61.1%) had an AUROC exceeding 0.90 (Figure 4A). Compared with the internal validation of HUP, the performance of external validation has decreased (0.843 vs 0.973, Mann Whitney U test p\u0026lt;0.001, Figure 4B), but overall it remains at a clinically usable level.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eSeven patients with AUROC below 0.80 all exhibited high seizure frequency characteristics: Spearman correlation analysis showed a significant negative correlation between seizure frequency and AUROC (\u0026rho;=-0.69, p=0.002), and a significant correlation between seizure frequency (times/day) and AUROC (\u0026rho;=-0.60, p=0.009, see Supplementary Figure S3 for details). This mechanistic finding suggests that a large amount of subclinical discharges are mixed into the interictal data of high-frequency seizure patients, leading to contamination of the reference distribution of individualized Mahalanobis distance models and a decrease in anomaly detection ability. This is a known limitation faced by unsupervised methods based on interval modeling.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eClinical correlation between SOZ localization and surgical outcomes\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eWe evaluated whether the channel level anomaly score was consistent with the anatomy of the surgical resection area in 31 subjects with complete surgical resection records and electrode spatial coordinate data. The overall anatomical matching rate was 71.0%, significantly higher than the random baseline (about 33%). Among 21 patients with Engel grade 1 (successful surgery, no or significantly reduced postoperative episodes), the anatomical matching rate reached 81.0%; Among the 9 patients with Engel 3+grade (surgical failure), it was 66.7% (Figure 5B).\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eIt is worth noting that there is no significant statistical correlation between Engel grading and seizure detection performance (clip level AUROC) (Wilcoxon test p=0.572, Figure 5A). This seemingly paradoxical finding actually has significant clinical implications: surgical failure is not due to incorrect method localization, but rather due to insufficient resection range or the presence of multiple lesions - some Engel 3+patients have an AUROC close to 1.0 for seizure detection (such as HUP114: 0.9996, HUP166: 0.9999), indicating that the model accurately identified the seizure areas, but the surgery itself failed to fully process these areas. This provides an independent quantitative perspective for understanding the fundamental challenges of intracranial epilepsy surgery.\u003c/p\u003e"},{"header":"Discussion","content":"\u003cp\u003eThis study proposes and validates an end-to-end zero label intracranial EEG seizure detection and SOZ localization framework. The core discovery lies in the combination of self supervised Transformer encoder and individualized Mahalanobis distance modeling, which achieves detection performance close to the upper bound of supervised methods without using manual episode labeling, and demonstrates substantial cross center generalization ability on independent external central datasets.\u003c/p\u003e\n\u003cp\u003eFrom a methodological perspective, the only 0.010 difference in AUROC between subjects with zero annotations and supervised methods reveals an important biological law: the iEEG of a single subject has a high degree of self consistency in the time dimension - the signal differences between episodes are much greater than the differences in similar states between different subjects. This characteristic gives unsupervised intra individual modeling a natural advantage, while cross subject models trained on a large amount of annotated data from others suffer from significant inter individual distribution shifts. One of the core contributions of this method is to explicitly incorporate this statistical pattern into the detection framework through personalized parameter estimation of Mahalanobis distance.\u003c/p\u003e\n\u003cp\u003eThe results of external validation (SWEC-ETHZ) further support the generalization of the framework. Despite significant differences in electrode configuration (SEEG/ECoG), sampling rate (256-1024 Hz), recording duration (several hours to hundreds of hours), and patient population between the two datasets, the HUP pre trained encoder was still able to achieve detection performance with an AUROC exceeding 0.90 in 11 out of 18 patients (61.1%) without any fine-tuning or transfer learning steps. The high seizure frequency characteristics (Spearman \u0026rho;=-0.69) of 7 poorly performing patients provide a mechanistic explanation for understanding the applicability boundaries of the method, and indicate future improvement directions: for high-frequency seizure patients, dynamic updates of the reference distribution based on seizure event timestamps (rather than continuous records) can be considered, or robust covariance estimation can be introduced to reduce the impact of data pollution during the seizure period.\u003c/p\u003e\n\u003cp\u003eSOZ localization analysis revealed a clinical finding beyond seizure detection: decoupling between localization accuracy (Engel 1:81%) and surgical outcomes. In some Engel 3+(surgical failure) patients, our unsupervised method achieved near perfect seizure detection (AUROC\u0026gt;0.99), indicating that the method accurately identified the seizure area at the technical level. However, the surgical failure of patients was due to insufficient resection range or the presence of multiple seizure foci - this is currently the core challenge in the field of epilepsy surgery, not the limitation of seizure localization itself. This quantitative perspective helps distinguish between \u0026quot;positioning problems\u0026quot; and \u0026quot;surgical operation problems\u0026quot;, and has reference value for designing more accurate surgical plans.\u003c/p\u003e\n\u003cp\u003eThis study has several limitations. Firstly, the HUP dataset is a single center dataset, and although external validation has been conducted on the SWEC-ETHZ dataset, larger scale multicenter prospective validation is still necessary. Secondly, in patients with high-frequency attacks (\u0026gt;8 times/day), the performance of this method decreases, and further algorithm improvement is needed. Thirdly, SOZ localization analysis is based on coarse-grained anatomical lobe classification, and precise millimeter level localization requires the combination of imaging data. Fourthly, the current framework has not established explicit models for physiological factors such as sleep wake cycles and adjustment of antiepileptic drugs, which may affect the stability of the reference distribution of interictal intervals.\u003c/p\u003e\n\u003cp\u003eOverall, this study demonstrates that the combination of self supervised learning and personalized statistical modeling can achieve near supervised zero label seizure detection on clinical iEEG data, and has substantial cross center generalization ability. This framework is expected to rapidly deploy iEEG automatic analysis systems in resource limited clinical environments, especially in primary healthcare institutions lacking professional annotators, promoting further popularization of accurate diagnosis of epilepsy.\u003c/p\u003e"},{"header":"References","content":"\u003cp\u003eA. Epidemiology and clinical background of epilepsy\u003c/p\u003e\n\u003cp\u003eBeghi E, Giussani G, Nichols E, et al. Global, regional, and national burden of epilepsy, 1990\u0026ndash;2016: a systematic analysis for the Global Burden of Disease Study 2016[J]. The Lancet Neurology, 2019, 18(4): 357-375.\u003c/p\u003e\n\u003cp\u003eKwan P, Brodie M J. Early identification of refractory epilepsy[J]. New England Journal of Medicine, 2000, 342(5): 314-319.\u003c/p\u003e\n\u003cp\u003eEngel J. Surgical treatment of the epilepsies[J]. (No Title), 1993.\u003c/p\u003e\n\u003cp\u003eWiebe S, Blume W T, Girvin J P, et al. A randomized, controlled trial of surgery for temporal-lobe epilepsy[J]. New England Journal of Medicine, 2001, 345(5): 311-318.\u003c/p\u003e\n\u003cp\u003eElger C E, Hoppe C. Diagnostic challenges in epilepsy: seizure under-reporting and seizure detection[J]. The Lancet Neurology, 2018, 17(3): 279-288.\u003c/p\u003e\n\u003cp\u003eB. IEEG dataset\u003c/p\u003e\n\u003cp\u003eBernabei J M, Li A, Revell A Y, et al. HUP iEEG epilepsy dataset[J]. OpenNeuro, 2023.\u003c/p\u003e\n\u003cp\u003eBernabei J M, Sinha N, Arnold T C, et al. Normative intracranial EEG maps epileptogenic tissues in focal epilepsy[J]. Brain, 2022, 145(6): 1949-1961.\u003c/p\u003e\n\u003cp\u003eAppelhoff S, Sanderson M, Brooks T L, et al. MNE-BIDS: Organizing electrophysiological data into the BIDS format and facilitating their analysis[J]. Journal of Open Source Software, 2019, 4(44): 1896.\u003c/p\u003e\n\u003cp\u003eBurrello A, Cavigelli L, Schindler K, et al. Laelaps: An energy-efficient seizure detection algorithm from long-term human iEEG recordings without false alarms[C]//2019 Design, Automation \u0026amp; Test in Europe Conference \u0026amp; Exhibition (DATE). IEEE, 2019: 752-757.\u003c/p\u003e\n\u003cp\u003eC. SWEC-ETHZ External Validation Dataset\u003c/p\u003e\n\u003cp\u003eBurrello A, Benatti S, Schindler K, et al. An ensemble of hyperdimensional classifiers: Hardware-friendly short-latency seizure detection with automatic iEEG electrode selection[J]. IEEE journal of biomedical and health informatics, 2020, 25(4): 935-946.\u003c/p\u003e\n\u003cp\u003eSopic D, Aminifar A, Atienza D. e-glass: A wearable system for real-time detection of epileptic seizures[C]//2018 IEEE International Symposium on Circuits and Systems (ISCAS). IEEE, 2018: 1-5.\u003c/p\u003e\n\u003cp\u003eD. IEEG seizure detection - supervised and traditional methods\u003c/p\u003e\n\u003cp\u003eKiral-Kornek I, Roy S, Nurse E, et al. Epileptic seizure prediction using big data and deep learning: toward a mobile system[J]. EBioMedicine, 2018, 27: 103-111.\u003c/p\u003e\n\u003cp\u003eLotte F, Bougrain L, Cichocki A, et al. A review of classification algorithms for EEG-based brain\u0026ndash;computer interfaces: a 10 year update[J]. Journal of neural engineering, 2018, 15(3): 031005.\u003c/p\u003e\n\u003cp\u003eRasheed K, Qayyum A, Qadir J, et al. Machine learning for predicting epileptic seizures using EEG signals: A review[J]. IEEE reviews in biomedical engineering, 2020, 14: 139-155.\u003c/p\u003e\n\u003cp\u003eTran L V, Tran H M, Le T M, et al. Application of machine learning in epileptic seizure detection[J]. Diagnostics, 2022, 12(11): 2879.\u003c/p\u003e\n\u003cp\u003eJiang H, Kokkinos V, Ye S, et al. Interictal SEEG resting‐state connectivity localizes the seizure onset zone and predicts seizure outcome[J]. Advanced Science, 2022, 9(18): 2200887.\u003c/p\u003e\n\u003cp\u003eE. Localization of onset zone (SOZ)\u003c/p\u003e\n\u003cp\u003eVaratharajah Y, Chong M J, Saboo K, et al. EEG-GRAPH: a factor-graph-based model for capturing spatial, temporal, and observational relationships in electroencephalograms[J]. Advances in neural information processing systems, 2017, 30.\u003c/p\u003e\n\u003cp\u003eGunnarsdottir K M, Li A, Smith R J, et al. Source-sink connectivity: a novel interictal EEG marker for seizure localization[J]. Brain, 2022, 145(11): 3901-3915.\u003c/p\u003e\n\u003cp\u003eProix T, Truccolo W, Leguia M G, et al. Forecasting seizure risk in adults with focal epilepsy: a development and validation study[J]. The Lancet Neurology, 2021, 20(2): 127-135.\u003c/p\u003e\n\u003cp\u003eF. Basic Methods of Self Supervised Learning\u003c/p\u003e\n\u003cp\u003eHe K, Chen X, Xie S, et al. Masked autoencoders are scalable vision learners[C]//Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. 2022: 16000-16009.\u003c/p\u003e\n\u003cp\u003eDosovitskiy A, Beyer L, Kolesnikov A, et al. An image is worth 16x16 words: Transformers for image recognition at scale[J]. arXiv preprint arXiv:2010.11929, 2020.\u003c/p\u003e\n\u003cp\u003eChen T, Kornblith S, Norouzi M, et al. A simple framework for contrastive learning of visual representations[C]//International conference on machine learning. PmLR, 2020: 1597-1607.\u003c/p\u003e\n\u003cp\u003eVaswani A, Shazeer N, Parmar N, et al. Attention is all you need[J]. Advances in neural information processing systems, 2017, 30.\u003c/p\u003e\n\u003cp\u003eDevlin J, Chang M W, Lee K, et al. Bert: Pre-training of deep bidirectional transformers for language understanding[C]//Proceedings of the 2019 conference of the North American chapter of the association for computational linguistics: human language technologies, volume 1 (long and short papers). 2019: 4171-4186.\u003c/p\u003e\n\u003cp\u003eGrill-Spector K, Malach R. The human visual cortex[J]. Annu. Rev. Neurosci., 2004, 27(1): 649-677.\u003c/p\u003e\n\u003cp\u003eG. Biosignals/EEG Self Supervised Learning\u003c/p\u003e\n\u003cp\u003eJiang W B, Zhao L M, Lu B L. Large brain model for learning generic representations with tremendous EEG data in BCI[J]. arXiv preprint arXiv:2405.18765, 2024.\u003c/p\u003e\n\u003cp\u003eYang C, Westover M, Sun J. Biot: Biosignal transformer for cross-data learning in the wild[J]. Advances in Neural Information Processing Systems, 2023, 36: 78240-78260.\u003c/p\u003e\n\u003cp\u003eKostas D, Aroca-Ouellette S, Rudzicz F. BENDR: Using transformers and a contrastive self-supervised learning task to learn from massive amounts of EEG data[J]. Frontiers in Human Neuroscience, 2021, 15: 653659.\u003c/p\u003e\n\u003cp\u003eBanville H, Chehab O, Hyv\u0026auml;rinen A, et al. Uncovering the structure of clinical EEG signals with self-supervised learning[J]. Journal of Neural Engineering, 2021, 18(4): 046020.\u003c/p\u003e\n\u003cp\u003eH. Anomaly detection and Mahalanobis distance method\u003c/p\u003e\n\u003cp\u003eKamoi R, Kobayashi K. Why is the mahalanobis distance effective for anomaly detection?[J]. arXiv preprint arXiv:2003.00402, 2020.\u003c/p\u003e\n\u003cp\u003eLedoit O, Wolf M. A well-conditioned estimator for large-dimensional covariance matrices[J]. Journal of multivariate analysis, 2004, 88(2): 365-411.\u003c/p\u003e\n\u003cp\u003eVyas S, Golub M D, Sussillo D, et al. Computation through neural population dynamics[J]. Annual review of neuroscience, 2020, 43(1): 249-275.\u003c/p\u003e\n\u003cp\u003eI. Onset prediction, warning, and periodicity\u003c/p\u003e\n\u003cp\u003eBaud M O, Kleen J K, Mirro E A, et al. Multi-day rhythms modulate seizure risk in epilepsy[J]. Nature communications, 2018, 9(1): 88.\u003c/p\u003e\n\u003cp\u003eKaroly P J, Ung H, Grayden D B, et al. The circadian profile of epilepsy improves seizure forecasting[J]. Brain, 2017, 140(8): 2169-2182.\u003c/p\u003e\n\u003cp\u003eStirling R E, Cook M J, Grayden D B, et al. Seizure forecasting and cyclic control of seizures[J]. Epilepsia, 2021, 62: S2-S14.\u003c/p\u003e\n\u003cp\u003eCook M J, O\u0026apos;Brien T J, Berkovic S F, et al. Prediction of seizure likelihood with a long-term, implanted seizure advisory system in patients with drug-resistant epilepsy: a first-in-man study[J]. The Lancet Neurology, 2013, 12(6): 563-571.\u003c/p\u003e\n\u003cp\u003eJ. Transfer learning, domain adaptation, and cross center generalization\u003c/p\u003e\n\u003cp\u003ePan S J, Yang Q. A survey on transfer learning[J]. IEEE Transactions on knowledge and data engineering, 2009, 22(10): 1345-1359.\u003c/p\u003e\n\u003cp\u003eKhalfallah S, Selmi K, Bouallegue K. EEGWaveNet: A Transfer and Federated Learning Framework for Cross-Dataset Seizure Detection[C]//2025 IEEE 22nd International Conference on Sciences and Techniques of Automatic Control and Computer Engineering (STA). IEEE, 2025: 346-353.\u003c/p\u003e\n\u003cp\u003eK. Epilepsy Surgery and Surgical Outcome Evaluation\u003c/p\u003e\n\u003cp\u003eJobst B C, Cascino G D. Resective epilepsy surgery for drug-resistant focal epilepsy: a review[J]. Jama, 2015, 313(3): 285-293.\u003c/p\u003e\n\u003cp\u003eT\u0026eacute;llez-Zenteno J F, Dhar R, Wiebe S. Long-term seizure outcomes following epilepsy surgery: a systematic review and meta-analysis[J]. Brain, 2005, 128(5): 1188-1198.\u003c/p\u003e\n\u003cp\u003eLuders H O. Conceptual considerations[J]. Epilepsy surgery, 1992: 51-62.\u003c/p\u003e\n\u003cp\u003eRosenow F, L\u0026uuml;ders H. Presurgical evaluation of epilepsy[J]. Brain, 2001, 124(9): 1683-1700.\u003c/p\u003e\n\u003cp\u003eL. Large scale basic models and medical AI\u003c/p\u003e\n\u003cp\u003eBommasani R, Hudson D A, Adeli E, et al. On the opportunities and risks of foundation models[J]. arXiv preprint arXiv:2108.07258, 2021.\u003c/p\u003e\n\u003cp\u003eMoor M, Banerjee O, Abad Z S H, et al. Foundation models for generalist medical artificial intelligence[J]. Nature, 2023, 616(7956): 259-265.\u003c/p\u003e\n\u003cp\u003eM. Representative iEEG Epilepsy Detection and Localization Study (Comparative Literature)\u003c/p\u003e\n\u003cp\u003eWinterhalder M, Maiwald T, Voss H U, et al. The seizure prediction characteristic: a general framework to assess and compare seizure prediction methods[J]. Epilepsy \u0026amp; Behavior, 2003, 4(3): 318-325.\u003c/p\u003e\n\u003cp\u003eMormann F, Andrzejak R G, Elger C E, et al. Seizure prediction: the long and winding road[J]. Brain, 2007, 130(2): 314-333.\u003c/p\u003e\n\u003cp\u003eKuhlmann L, Lehnertz K, Richardson M P, et al. Seizure prediction\u0026mdash;ready for a new era[J]. Nature Reviews Neurology, 2018, 14(10): 618-630.\u003c/p\u003e\n\u003cp\u003eTruong N D, Nguyen A D, Kuhlmann L, et al. Convolutional neural networks for seizure prediction using intracranial and scalp electroencephalogram[J]. Neural networks, 2018, 105: 104-111.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eReference Position Correspondence Table:\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003e(1) Introduction paragraph 1: References 1 (Global Burden of GBD Epilepsy), 2 (Kwan Refractory Epilepsy), 5 (Elger Labeling Challenge)\u003c/p\u003e\n\u003cp\u003e(2) Introduction paragraph 2: Reference 42 (Rosenow preoperative evaluation), 4 (Wiebe surgical efficacy RCT)\u003c/p\u003e\n\u003cp\u003e(3) Introduction paragraph 3: Citations 20 (He MAE), 22 (Chen SimCLR), 21 (Dosovitskiy ViT)\u003c/p\u003e\n\u003cp\u003e(4) Result - Dataset: References 6 (HUP dataset), 8 (MNE-BIDS), 9 (Burrello SWEC short-term), 10 (Burrello SWEC long-term)\u003c/p\u003e\n\u003cp\u003e(5) Result SOZ localization: References 7 (Bernabei 2022), 18 (Gunnarsdottir), 16 (Jiang 2022) cited\u003c/p\u003e\n\u003cp\u003e(6) Results - Comparison of seizure prediction: References 19 (Proix Lancet Neurol), 33 (Baud Nat Commun), 47 (Kuhlmann Nat Rev Neurol) were cited\u003c/p\u003e\n\u003cp\u003e(7) Method MAE pre training: References 20 (He CVPR 2022), 23 (Vaswani Attention), 24 (Devlin BERT) cited\u003c/p\u003e\n\u003cp\u003e(8) Method - Comparative loss: References 22 (Chen SimCLR), 28 (Kostas BENDR), 29 (Banville J Neural Eng) were cited\u003c/p\u003e\n\u003cp\u003e(9) Method - Mahalanobis distance: References 31 (Ledoit Wolf covariance estimation) and 32 (Vyas neural population dynamics) are cited\u003c/p\u003e\n\u003cp\u003e(10) Discussion Transfer: References 37 (Pan Transfer Learning Review), 38 (Ye Cross Dataset EEG)\u003c/p\u003e\n\u003cp\u003e(11) Discussion - Clinical Significance: References 39 (Jobst JAMA), 40 (T \u0026eacute; llez Zenteno Brain), 41 (L \u0026uuml; ders Epilepsy Surgery) are cited\u003c/p\u003e\n\u003cp\u003e(12) Discussion - Basic Model: References 43 (Bommasani Basic Model), 44 (Moor Nature Medical AI)\u003c/p\u003e\n\u003cp\u003e(13) Supplementary - Comparison of External Validation Methods: References 12 (Kiral Kornek), 14 (Rasheed), 48 (Truong CNN Epilepsy Prediction)\u003c/p\u003e"},{"header":"Methods","content":"\u003cp\u003e\u003cstrong\u003eDatasets\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eHUP dataset: a publicly available intracranial EEG dataset from the University of Pennsylvania Affiliated Hospital, approved by the ethics committee and with patient informed consent. This study included 54 patients with drug-resistant epilepsy, and the recording modes included SEEG (SEEG) and ECoG. All data were organized in BIDS format, including events.tsv files indicating the start and end time of seizures.\u003c/p\u003e\n\u003cp\u003eSWEC-ETHZ dataset: an open dataset from Bern University Hospital (Sleep Awakening Epilepsy Center) in Switzerland, containing 2656 hours of continuous iEEG recordings from 18 patients, 116 seizure events, raw sampling rates of 512 or 1024 Hz, stored in. mat format, with each file corresponding to 1 hour of continuous recording.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003ePreprocessing\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eTwo datasets adopt a unified preprocessing process: (1) bandpass filtering 1-120 Hz (4th order Butterworth); (2) 60Hz notch filtering (iirnotch, Q=30); (3) Resampling to 256 Hz (multi-phase resampling, SWEC-ETHZ downsampling from 512/1024 Hz); (4) Common average reference; (5) 1 second non overlapping sliding window slice. According to the onset time annotation in events. tsv (HUP) or info. mat (SWEC-ETHZ), each 1-second segment is labeled as interictal (0), interictal (1), or pre interictal (2, within 30 minutes before onset) for evaluation and not for training.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eSelf supervised pre training\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eThe Transformer encoder consists of 6 layers of encoder modules, with an embedding dimension of 128 and 4 attention heads. The 1-second, 256 sampling point timing signal input is evenly divided into 16 patches (16 sampling points per patch), mapped to a 128 dimensional feature space through a linear embedding layer, and overlaid with sine position encoding. Pre training uses two complementary losses:\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eMAE reconstruction loss: Randomly mask 75% of the patches, requiring the encoder to reconstruct the original signal of the masked patch only based on visible patches. The loss function is the mean square error of the masked area.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eSubject comparison loss (\u0026lambda;=0.3): Gravity loss (narrowing feature distance) is calculated for segments of the same subject at different time periods, while repulsion loss (pushing feature distance) is calculated for segments of different subjects, using the InfoNCE framework.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eTraining was conducted using all unlabeled fragments from all 54 participants of HUP (without distinguishing between periods/intervals), Adam optimizer, with a learning rate of 1e-4, trained for 57 epochs, and validated with a loss of 2.7221.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eIndividualized Mahalanobis distance anomaly detection\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eFor the target subjects, only their interictal segments (label=0) are used to extract 128 dimensional feature representations through an encoder, which are then aggregated into feature vectors for each time window through channel averaging. Subsequently: (1) Standardization (StandardScaler); (2) PCA dimensionality reduction to 16 dimensions; (3) LedoitWolf regularizes covariance estimation. Define the Mahalanobis distance using the inverse matrix of the covariance matrix and the sample mean (Equation 1). When inferring, calculate the Mahalanobis distance score for all segments (interictal+interictal) of the target subject, and use this score to calculate the AUROC (higher score corresponds to higher probability of onset) for the interictal/interictal labels.\u003c/p\u003e\n\u003cp\u003e\u003cimg src=\"https://myfiles.space/user_files/58895_8739fc6c57c1c19a/58895_custom_files/img1777897169.png\" width=\"583\" height=\"90\"\u003e\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eBaseline method\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e(B1) Supervised linearity: Train a logistic regression classifier on encoder features, with 50% data training and 50% testing within the subjects. (B2) Supervised linear LOSO: Train logistic regression using annotated data from the remaining 53 subjects and test it on the target subjects. (C1) Supervised MLP within subjects: Train 3 layers of MLP on encoder features for intra subject segmentation. (C2) Supervised CNN/MLP LOSO: Same as C1, but using LOSO training and evaluation settings.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eChannel level SOZ positioning \u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eQuantify the contribution of each channel to seizures by calculating the Net Seizure Anomaly Rate (SAR) of each channel: for the target subject, calculate the Mahalanobis distance time series of each channel, calculate the average score difference between the seizure period and the interictal period, take the centroid of the top-20% abnormal channels, and match them with the anatomical brain lobe labels of the surgical resection area. Successful matching is defined as the predicted brain lobe being consistent with the surgical target brain lobe (temporal lobe/frontal lobe/parietal lobe/other).\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eStatistical analysis\u003c/strong\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eThe comparison of AUROC differences was performed using Mann Whitney U test (bilateral). The statistical significance of SOZ localization matching rate was tested using Fisher\u0026apos;s exact test and random permutation test (n=10000 times). The correlation analysis between Engel grading and AUROC was conducted using Kruskal Wallis test. The correlation between seizure frequency and AUROC is based on Spearman rank correlation. The significance threshold for all statistical tests is set to \u0026alpha;=0.05 (two-sided).\u003c/p\u003e"}],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":true,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":true,"hideJournal":true,"highlight":"","institution":"","isAcceptedByJournal":false,"isAuthorSuppliedPdf":false,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":false,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"
[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true},"keywords":"","lastPublishedDoi":"10.21203/rs.3.rs-9568998/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-9568998/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"Background and Objective: The detection of epileptic seizures in intracranial electroencephalography (iEEG) relies on segment by segment annotation by professional physicians, which hinders the promotion of automated systems in clinical practice. This study proposes a completely unsupervised seizure detection method that achieves high-precision seizure recognition and seizure onset zone (SOZ) localization through self supervised learning and personalized anomaly detection.\r\n\r\nMethods: We used a masked autoencoder (MAE) combined with subject contrastive learning to self supervise pre training of the Transformer encoder on 54 patients (SEEG/ECoG records) in the University of Pennsylvania Affiliated Hospital (HUP) dataset. Subsequently, individualized Mahalanobis distance was used as the anomaly score to achieve seizure detection without using seizure labels at all. To verify the generalizability of the model, we conducted zero sample transfer validation using the independent external dataset SWEC-ETHZ (18 patients, University Hospital Bern, Switzerland) without any fine-tuning of the model.\r\n\r\nResults: In the internal validation of HUP, the global AUROC of this method reached 0.963, the average AUROC of the subjects was 0.973 ± 0.055, and the AUROC of 51/54 subjects exceeded 0.90. Compared with the supervised leave one over cross validation (LOSO) baseline (optimal AUROC 0.796), the zero labeling method showed an average improvement of Δ=+0.158 (p\u003c0.001) within the subject setting. In the zero sample transfer validation of the independent external dataset SWEC-ETHZ, the average AUROC was 0.843 ± 0.173, the median was 0.945, and the AUROC of 11/18 patients exceeded 0.80. The overall anatomical matching rate of SOZ among 31 patients with surgical outcomes was 71.0%, with a success rate of 81.0% in Engel grade 1 patients.\r\n\r\nConclusion: This method does not require any manual annotation and achieves detection performance close to the upper bound of supervised methods on two independent central datasets, demonstrating significant cross center generalization ability. This framework provides a feasible path for real-time deployment of clinical iEEG.","manuscriptTitle":"Zero-Annotation Seizure Detection and Onset Zone Localization in Intracranial EEG via Self-Supervised Learning and Mahalanobis Distance Modeling","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2026-05-09 00:54:54","doi":"10.21203/rs.3.rs-9568998/v1","editorialEvents":[{"type":"communityComments","content":0}],"status":"published","journal":{"display":true,"email":"
[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true}}],"origin":"","ownerIdentity":"010dd1b7-6a29-4b1f-afdf-fb194fcd3dd4","owner":[],"postedDate":"May 9th, 2026","published":true,"recentEditorialEvents":[{"type":"decision","content":"Reject before peer review","date":"2026-05-06T16:02:08+00:00","index":"","fulltext":""},{"type":"editorAssigned","content":"","date":"2026-05-05T15:51:54+00:00","index":"","fulltext":""},{"type":"submitted","content":"Nature Computational Science","date":"2026-05-01T23:09:01+00:00","index":"","fulltext":""}],"rejectedJournal":[],"revision":"","amendment":"","status":"posted","subjectAreas":[{"id":67654309,"name":"Health sciences/Neurology/Neurological disorders/Epilepsy"},{"id":67654310,"name":"Physical sciences/Mathematics and computing/Computational science"}],"tags":[],"updatedAt":"2026-05-09T00:55:00+00:00","versionOfRecord":[],"versionCreatedAt":"2026-05-09 00:54:54","video":"","vorDoi":"","vorDoiUrl":"","workflowStages":[]},"version":"v1","identity":"rs-9568998","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-9568998","identity":"rs-9568998","version":["v1"]},"buildId":"XKTyCvWXoU3ODBz1xrDgd","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}
Text is read by the "Ask this paper" AI Q&A widget below.
Extraction quality varies by source — PMC NXML preserves structure
cleanly, OA-HTML may include some navigation residue, and OA-PDF can
have broken hyphenation. The publisher copy
(via DOI)
is the canonical version.