DMNet: Self-comparison Driven Model for Subject-independent Seizure Detection

Authors: shihao  tu
linfeng  cao
daoze  zhang
junru  chen
lvbin  ma
yin  zhang
yang  yang
Venue: NeurIPS_cc_2024_Conference
Published: 2024-05-14 09:17:23

Abstract: Automated seizure detection (ASD) using intracranial electroencephalography (iEEG) is critical for effective epilepsy treatment. However, the significant domain shift of iEEG signals across subjects poses a major challenge, limiting their applicability in real-world clinical scenarios. In this paper, we address this issue by analyzing the primary cause behind the failure of existing iEEG models for subject-independent seizure detection, and identify a critical universal seizure pattern: seizure events consistently exhibit higher average amplitude compared to adjacent normal events. To mitigate the domain shifts and preserve the universal seizure patterns, we propose a novel self-comparison mechanism. This mechanism effectively aligns iEEG signals across subjects and time intervals. Building upon these findings, we propose Difference Matrix-based Neural Network (DMNet), a subject-independent seizure detection model, which leverages self-comparison based on two constructed (contextual, channel-level) references to mitigate shifts of iEEG, and utilize a simple yet effective difference matrix to encode the universal seizure patterns. Extensive experiments show that DMNet significantly outperforms previous SOTAs while maintaining high efficiency on a real-world clinical dataset collected by us and two public datasets for subject-independent seizure detection. Moreover, the visualization results demonstrate that the generated difference matrix can effectively capture the seizure activity changes during the seizure evolution process. Additionally, we deploy our method in an online diagnosis system to illustrate its effectiveness in real clinical applications.

Main paper: 
 introduction: 
 Epilepsy, a chronic neurological disorder, affects more than 65 million people around the world. Up to 70% of people with epilepsy can be free from seizure only if the seizure onset zone (SOZ) can be located and surgically removed [26] . To diagnose epilepsy, doctors rely on the assessment of electrical activities that reflect the state and function of the subject's brain. Electroencephalography (EEG) is a widely employed and cost-effective method to record these electrical activities by placing sensors on the scalp. However, as a non-invasive method, it is unable to accurately locate SOZ in the deep structures of the brain. Nowadays, iEEG is widely employed to identify and locate SOZ. Stereo-EEG, one representative iEEG technique, involves the deep implantation of electrodes within the brain to record electrical activities. These electrodes contain multiple recording contacts, called channels, and are placed across different regions of the brain, which provide stereoscopic recordings of the brain from both cortical and subcortical structures simultaneously [30] . This fully developed technique has been proven to be both effective and safe [5] .Given a substantial volume of iEEG data, we present a pipeline tailored to real-world application scenarios for automated seizure detection (ASD), as depicted in Fig. 1 (g) . Firstly, the ASD model is trained using data from accessible subjects. Subsequently, the trained model is applied to identify seizures in iEEG recordings from previously unseen subjects. Doctors can refer to the prediction results, allowing for a more accurate diagnosis and facilitating more effective treatment decisions.However, most existing ASD methods are built on non-invasive EEG with a subject-specific setting [38, 31] and subject-independent setting [2, 44, 11] . However, these EEG-based methods are prone to failure when applied to iEEG data. This is primarily due to the significantly higher complexity of iEEG signals compared to EEG signals. iEEG signals exhibit a greater level of intricacy as a result of the structural and functional disparities in brain neural activities. Furthermore, there are variations in the number and placement of invasive electrodes (Fig. 1 (a, b )), leading to significant domain shifts across different subjects. However, Existing methods that employ domain adversarial training for subject-independent seizure detection on iEEG signals may encounter negative transfer effects [23, 27] . Although [41] proposed a method that utilizes a series of intricate pre-training strategies to learn the general pattern across subjects, it lacks efficiency. Consequently, developing an effective and efficient subject-independent ASD method using iEEG is crucial for clinical diagnosis. Here, we discuss the primary challenges associated with iEEG in ASD. Challenges. The factors mentioned above cause a significant domain shift between subjects, posing an open question regarding the generalization of subject-independent epilepsy seizure detection using iEEG. This issue gives rise to challenges at both the subject level and the channel level:(1) How to capture the general distinguishable representation for normal and seizures between different subjects and time intervals? Due to individual differences that exist among subjects, the inherent properties of iEEG recordings, such as amplitude, frequency, and others, are personalized to each subject. Even within the same individual, brain activities vary over time.(2) How to reduce the inconsistency of the seizure patterns of different channels? The channels exhibit diverse patterns due to the iEEG records of various regions of the brain, potentially leading to conflicting patterns between subjects. For example, normal and seizure waves are indistinguishable between subjects or channels. As shown in Fig. 1 , the normal wave in (e) is difficult to distinguish from the seizure waves in (c) and (d), while the seizure event in (f) is often mistaken for the normal one. Therefore, the second challenge is to personalize the representations of brain activity independent of channels, allowing the model to adapt to different subjects.To address these challenges, we first propose the mechanism of self-comparison: comparing the target segment with adjacent normal segments. Subsequently, we conduct a comprehensive observation study (Sec. 3) to demonstrate the effectiveness of self-comparison. Our findings indicate that self-comparison can obtain a general distinguishable representation of normal ones and seizures.Drawing on these inspirations, we argue that the self-comparison mechanism is the key to easily and effectively capture subject-invariant patterns between subjects. To this end, we propose a novel model, namely Difference Matrix based neural Network (DMNet), for subject-independent seizure detection. Specifically, considering that different seizure events would present different neural activities (local bias) within different recording channels (global bias), we therefore introduce two reference objects (i.e., contextual reference and channel-level reference). These references ensure that we can capture both local and global dependencies within data, which are the primary contributors of distribution shift and can be effectively mitigated through the self-comparison mechanism. Subsequently, we utilize a simple yet effective fully differencing operation to generate the difference matrix, which compares the target segment with its reference objects for self-comparison implementation. To effectively extract semantics from the difference matrix, we design a difference matrix encoder based on convolutional neural network (CNN) blocks to obtain the final representation of the detection segment. Our primary contributions are listed as follows:• We investigate the problem of subject-independent ASD based on the iEEG. Through comprehensive analysis, we identify the self-comparison mechanism as a simple yet effective way to capture the general representation. • We propose a novel model named DMNet for subject-independent ASD. The fully differencing operation based on contextual reference and channel-level reference for self-comparison can mitigate the local and global biases among subjects and channels, improving the generalizability of learned representations. • Extensive experiments on clinical and public iEEG datasets show DMNet outperforms existing SOTAs. Moreover, the generated difference matrix effectively captures seizure activity changes during the seizure evolution process. Furthermore, DMNet outperforms existing SOTAs while maintaining the high efficiency. Building on these strengths, we deploy our method in an online system, enhancing clinical applications by assisting medical professionals in the diagnosis of epilepsy and by facilitating the provision of more effective treatment options for patients. 
problem formulation: 
 In this work, the iEEG recording is regarded as a set of time series X = {x (i) } C i=1 , where C refers to the total number of channels. Each x (i) ∈ R T corresponds to a channel, and T refers to the total timestamp. We sequentially test the channels one after another. Specifically, given one channel of iEEG time seriesx (i) = {x (i) 1 , • • • , x (i)T } from a subject, we first divide the original recording data into segments for detection. For simplicity, we omit the channel index i in subsequent steps:EQUATIONwheres k = {x ℓ×k+1 , • • • , x ℓ×(k+1) }, 0 ≤ k ≤ m -1,ℓ is the number of timestamp for each segment, m is the total number of segments. Each segment s k has a corresponding label y k ∈ {0, 1}, indicating whether the segment contains a seizure event. In this work, our aim is to predict y k on each segment s k for different subjects.We define our problem as an innovative study of Domain Generalization (DG) [45] in the context of epileptic diagnosis. In this study, we treat each subject's data as a domain, and our goal is to utilize the data of available labeled subjects (source domains) to train a model that can be directly adopted to the subjects with unseen data (target domains). 
empirical analysis: 
 In this section, we first analyze the primary cause behind the failure of existing models for subjectindependent seizure detection of the iEEG and the reasons of occurrence. Then we explore the possibility of a domain-consistent seizure pattern existing within iEEG data, taking into account the Most previous studies [10, 16] assert that vanilla detection models trained independently by each subject are prone to failure when applied to other subjects. To analyze the direct cause of failure, we merge raw iEEG signals from all subjects and channels in a clinical iEEG dataset (details in App. C), and analyze the distributions of seizure and normal events. As depicted in Fig. 2 (a), the results reveal nearly identical means and close variances for both seizure and normal signals in the merged data. This similarity leads to the indistinguishability between normal and seizure signals across subjects, which becomes a direct factor to the failure of subject-dependent models.For a detailed analysis, we partition the iEEG signals into multiple intervals, each comprising 250 timestamps, for each subject. We then compute the distributions of seizure and normal events within each interval. Through empirical analysis, we observe significant domain shifts both across different subjects (inter-subject) and different time intervals for the same subject (intra-subject). Fig. 2 (b) presents the normal and seizure distributions within four intervals randomly sampled from subjects P1 and P2, where the distribution patterns of normal and seizure exhibit substantial variation across different time intervals and subjects. This observation aligns with findings from previous studies in neural science and medicine, which have consistently reported that brain signals exhibit high variability between subjects and sessions due to inherent background neural activities [33] , seizure patterns [14] , electrode locations [9] , etc.Despite the pronounced domain shift observed in iEEG signals across subjects and time intervals, there is a notable commonality among subjects. Specifically, seizure events consistently demonstrate a higher average amplitude in the frequency domain compared to their background signal (adjacent normal events), indicating more intense neural oscillatory activities. This finding is consistent with previous studies in the field [34, 21] .Based on the commonality above, we propose a novel self-comparison mechanism, which compares the target segment with its adjacent normal segment, to mitigate domain shifts between subjects and time intervals. To verify the effectiveness of this mechanism, we conduct an empirical study. First, for each subject, we partition the contiguous iEEG data into small segments. Considering that the spectral signal of brain data can effectively track transient changes before and during seizures [6] , we proceed to transform these segments into the frequency domain using Discrete Fourier Transform (DFT). Subsequently, we calculate the spectrum differences by subtracting the spectrum of the target segment from those of adjacent segments on both sides of the target segment. We then sum up the absolute values of these differences, generating a single value D for each target segment.  
methodology: 
 Inspired by the above observations, we propose a subject-independent seizure detection framework called DMNet, which leverages self-comparison to alleviate the distribution shift and preserve the domain consistency while distinguishing seizure patterns.Overview. The overall framework is illustrated in Fig. 3 . First, for each detection segment s k , we construct two reference segments (contextual reference : L c (s k ) / R c (s k ), channel-level reference : L cℓ (s k ) / R cℓ (s k )) to compare with the target segment (Fig. 3 , left). Then we use a simple yet effective fully differencing operation with signed-min-max normalization for self-comparison implementation, and the compared information is encoded by a difference matrix (DM) (Fig. 3 , middle). Then we employ a CNN-based difference matrix encoder to learn the latent representation of DM, and use a classifier for seizure detection (Fig. 3 , right).Contextual Reference. The structural and functional differences in brain neural activity lead to distribution shifts between subjects, and even across different time intervals within the same subject. Based on the insights from observation studies in Section 3.2, we propose to compare the seizure wave with its adjacent contexts for the identification of seizure activities, as it significantly mitigates the domain shifts between subjects and preserves a domain-consistent and distinguishable pattern of seizure events. However, capturing the long dependencies between seizure events and their contexts is challenging with a single contextual segment. This is because a typical epileptic seizure phase consists of preseizure aura, seizure onset, and post-seizure periods, with varying duration (ranging from seconds to minutes or longer in the case of status epilepticus) [12] . To this end, we first extract 2 × N temporal segments {s i } k-N ≤i≤k-1 and {s i } k+1≤i≤k+N from both sides of s k (each contains L = N × ℓ timestamps in total, with each segment consisting of ℓ timestamps), ensuring that the context contain abundant normal information for comparison. Subsequently, we apply DFT to convert these segments into the frequency domain representation ∈ R d . Finally, the frequency domain segments obtained from the left and right sides are referred as the contextual references of s k , denoted asL c (s k ) ∈ R N ×d and R c (s k ) ∈ R N ×d ( ) respectively.Channel-level Reference. Different physiological brain regions have variations in neural activities [37] , leading to distribution shifts between channels, even within the same subject. Although contextual reference can reduce local bias, it fails to address global bias. Moreover, for prolonged epileptic seizures, solely considering the adjacent contextual reference segments may not provide sufficient normal information as background for comparison. To address these issues, we introduce channel-level reference as representative features of channels. The aim is to personalize channels, alleviate global bias, and provide comprehensive global background information of normal events. Specifically, we adopt the K-Means [24] algorithm to identify the most representative patterns within a channel. First, we divide the entire time series of each channel into segments with length ℓ. Then, similar with contextual reference, we use DFT to obtain the frequency domain representation ∈ R d of all segments. Next, the K-Means clustering algorithm is applied to group all frequency domain representations into K clusters. Finally, we arrange the clusters in descending order according to the number of elements they contain (denoted asC 1 , C 2 , • • • , C K , where |C 1 | ≥ |C 2 | ≥ • • • ≥ |C K |).The arrangement indicates that the higher the index of the cluster, the lower the frequency of occurrence of the corresponding general pattern in the respective channel.To obtain the general patterns of the channel, we use the centroid of each cluster, resulting in the final representation denoted as µ k ∈ R d , k = 1, ..., K. These µ k values are then concatenated to construct the left side channel-level reference L cℓ (s k ) ∈ R K×d . Empirically, the right side R cℓ (s k ) is formed by reversing the order of L cℓ (s k ).In this subsection, we present the self-comparison implementation based on the constructed references and target segments through a simple yet effective approach of fully differencing operation. The comparison information is encoded using a difference matrix (DM).We first obtain the frequency domain representation x f k ( ) of target segment s k via DFT, and then concatenate x f k with the constructed contextual ( ) and channel-level ( ) references to form the augmented segment xf k (as shown in Figure 3 , bottom-left):EQUATIONwhere || is a concatenate operation and xf k ∈ R (2N +2K+1)×d . Fully Differencing Operation. To implement self-comparison of target segment and references, we introduce a fully differencing operation. Unlike traditional first-order differencing [13] that considers only adjacent points, the fully differencing operation makes a pairwise comparison across all segments in xf k (described in Equation 3 and Fig. 3 , middle), which can more effectively capture the essential seizure patterns of brain activities. Moreover, since there are inherent scale differences in the vanilla difference matrix D k caused by varying magnitudes between seizure and normal iEEG signals across subjects, channels and time intervals, min-max normalization is adopted to address the scale difference issue. After these two operations, a synthetic difference matrix Dk can be obtained:EQUATIONEQUATIONThe generated difference matrix Dk contains rich semantic information about the evolution of seizures. We provide a more detailed discussion on each component of the difference matrix Dk and the corresponding semantic properties in App B.Difference Matrix Encoder. To well capture and learn these essential differences, we adopt the CNNs as the DM encoder (Fig. 3 ,right), which have been proven to be powerful in learning representations from 2D matrices [35, 42] . The output of the CNNs will be concatenated as a representation Ẑ of the DM. Finally, Ẑ will be fed into a linear classifier to obtain the detection result. 
experiments: 
 In this section, we conduct extensive experiments on public and clinical iEEG datasets to address three primary research questions: RQ1. How does the proposed DMNet model perform in subjectindependent seizure detection compared to other methods? RQ2. Do the proposed contextual reference, channel-level reference and difference matrix contribute to seizure detection? RQ3. How does the difference matrix reflect seizure activity changes during seizure evolution process?Datasets. To evaluate the performance of our DMNet model, we conduct experiments on both the public benchmark dataset, which includes MAYO and FNUSA [25] , and the private clinical dataset (details refer to App. C).Evaluation Metrics. For fair comparison, we use precision, recall, F1-score and F2-score as evaluation metrics. Typically, F2-score is particularly emphasized in practical clinical studies [15, 43] since overlooking any seizure can be costly in terms of diagnosis. Therefore, in our study, the F2-score serves as the primary metric for comparison.Settings. To conduct the experiment under the domain generalization settings, we divide the subjects in the datasets into multiple groups and assign different groups as source and target domains for model training, validation and testing. A more detailed description of experimental setup that includes DMNet hyperparameters and setup on clinical and public datasets, can be found in App. D.Baselines. We compare the proposed DMNet with state-of-the-art subject-independent seizure detection algorithms for both iEEG-based methods and EEG-based methods. For iEEG-based methods, we compared against SICR [17] , SEEG-Net [39] , and PPi [41] . For EEG-based methods, we compared against Abou-Abbas et al. [2] , Zhao et al. [44] , and Dissanayake et al. [11] . Additionally, we compare the performance with the domain generalization (DG) algorithms in other areas like Self-Reg [18] , GroupDRO [32] , MTL [7] , CORAL [36] , CDANN [22] , SD [28] , IB-IRM [3] , VREx [19] , IB-ERM [4] , TRM [40] . More details of the baselines are shown in App. A.The overall performance of our proposed model DMNet and other baselines for subject-independent seizure detection are presented in Tab. 1. From the results, we can see that our proposed DMNet significantly outperforms other SOTA subject-independent seizure detection algorithms and the latest domain generalization methods, with an average improvement of 9.41%, 14.81% and 4.97% in terms of F2 score on clinical and public datasets (MAYO and FNUSA) respectively. These results highlight the superior generalization ability of DMNet. Compared to DG baselines, our model exhibits a substantial margin in all evaluation metrics, suggesting that general DG baselines fail to capture the diverse and evolving distribution patterns of iEEG over time. Furthermore, the EEG-based methods proposed by [2] , [44] and [11] may not be adept at handling complex iEEG signals, which lead to subpar performance. Although the iEEG-based methods [41] , SEEG-Net [39] and SICR [17] outperform most EEG-based methods and DG methods on F2-score, they still fall short of the performance compared to our model. This may be attributed to the fact that they do not explicitly capture the general pattern of difference between normal and seizure signals. In contrast, we utilize a difference matrix to achieve a distinguishable representation of normal and seizure.To validate the contribution of each component of our proposed DMNet, we conduct ablation studies on key components (w/o means without and w/ means with). The results of the ablation evaluation can be seen in Tab. Difference Matrix. Removing DM leads to a significant drop in model performance, indicating the effectiveness of a fully differencing operation for the implementation of self-comparison. In contrast, recall, F1 score and F2-score initially increase when ℓ ranges from 100 to 200 but then decline. This suggests that shorter segment lengths (ℓ) fail to provide representative semantic information, preventing the model from capturing long-term dependencies in the brain signal. Conversely, excessively long segment lengths can result in coarse-grained temporal representations, leading to the loss of fine-grained patterns and details.Number of Clusters K. We vary the number of clusters K in channel-level reference, which controls the number of generated channel representative features of a specific channel. As we can see in Fig. 5 (c), the evaluation metrics (recall, F1 score, and F2-score) demonstrate an initial increase followed by a decrease trend as K varies from 6 to 12. However, precision shows an upward trend. This indicates that introducing global information can reduce false positive samples but it also affects recall. Therefore, it is necessary to consider trade-offs when selecting the value of K.To further assess the generalization capability of DMNet on a broader range of subjects with greater heterogeneity, we evaluated the model on data of 179 previously unseen subjects from the large TUSZ EEG dataset [1] . Additional details about this evaluation study are provided in App.F.Model Efficiency. We compare the model efficiency of DMNet and several benchmark models in terms of parameter count and average inference time per patient file. As shown in Fig. 5 (d) , the parameter count of DMNet is only 19.4% of the model with the smallest parameter count, but its performance is 109.4% of the best-performing model. Additionally, DMNet has an average inference time of 45.5 seconds per subject file, which is also the fastest among all models. Overall, DMNet demonstrates significant advantages in both parameter count and inference time. Therefore, DMNet is an ideal choice, providing a reliable and high-performance solution for real application scenario. Online Deployment. DMNet has been deployed on an online system (Fig. 6 ), which illustrates the effectiveness of our method in a real clinical application. This system serves as an auxiliary tool for expert doctors, significantly enhancing the accuracy and efficiency of the diagnostic process. The system comprises two important pages: the overview page and the detail page. The overview page (Fig. In the center of the page, the purple section represents the true seizure annotations provided by doctors, while the yellow section showcases our model's predictions. As depicted in the figure, the predictions of our model align well with the actual seizures.6 
related work: 
 Epileptic Seizure Detection for EEG. Data-driven methods for seizure detection have gained attention in clinical medicine. [38] combine CNN and SVM, [31] leverage frequency components and CNN. However, these methods are subject-specific and not suitable for real-world application.Several efforts have been made in the study of subject-independent methods in EEG. [2] proposed and investigates a subject-independent seizure detection model that uses stable EEG-based features obtained by comparing multiple feature selection methods. [44] proposed two subject independent deep learning architectures with different learning strategies that can learn a global function utilizing data from multiple subjects. [11] proposed IBA (Information Bottleneck Attribution), a subjectindependent seizure detection model that utilizes multi-view information. It employs adversarial deep learning to learn seizure-specific feature representations directly from raw EEG data. However, these methods are based on non-invasive EEG recordings.Epileptic Seizure Detection for iEEG. iEEG, through the placement of electrodes inside or on the surface of the brain, offers higher temporal and spatial resolution, enabling more accurate capture and analysis of brain activity in specific regions, including subtle changes in electrophysiological signals. Consequently, this has spurred research into epilepsy detection based on iEEG [26] . There are several seizure detection methods being designed in subject-independent settings, which are more applicable to real-world scenarios. SEEG-Net [39] and SICR [17] proposed adversarial training to learn subject-invariant features on iEEG recordings. However, their experiments were carried out on small, manually denoised datasets with a balanced positive-negative sample ratio, resulting in a significant data bias that deviates from real clinical requirements. Moreover, [41] proposed a method that utilizes a series of intricate pre-training strategies to learn general pattern cross subjects, which is lack of efficiency.General Domain Generalization. Our work focuses on detecting seizure events in unseen subjects, which can be framed as the domain generalization (DG) problem [45] . Existing DG studies can be categorized into two groups: Invariant representation based method [36, 22, 4, 18, 3, 7] and Learning strategy based method [20, 32, 19, 28] . Invariant representation methods aim to learn domain-invariant representations. CORAL [36] aligns covariance in feature layers, enhancing the extraction of domain-invariant features. CDANN [22] introduces adversarial training to encourage robust and domain-invariant feature learning. IB-ERM [4] minimizes empirical risk across domains to improve generalization. SelfReg [18] uses self-supervised learning and contrastive loss to capture invariant information across domains. Learning strategy methods aim to enhance generalization capability through various learning strategies. GroupDRO [32] achieves higher worst-group accuracy by coupling robust optimization models with increased regularization. VREx [19] penalizes the variance of training risks to improve domain extrapolation. Despite prior efforts, DG problems in time series, like iEEG signals, continue to be a relatively unexplored area and poses considerable challenges due to the diverse and evolving distribution patterns with time.Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results?Answer: [Yes]Justification: We give a detailed description of our experiment setting in Appendix D. We also do a hyperparameter analysis in the Section 5.Guidelines:• The answer NA means that the paper does not include experiments.• The experimental setting should be presented in the core of the paper to a level of detail that is necessary to appreciate the results and make sense of them. • The full details can be provided either with the code, in appendix, or as supplemental material. 
conclusion: 
 In this paper, we present a novel seizure detection framework called DMNet. Our model addresses the challenge of generalization across different subjects by incorporating a self-comparison mechanism to capture the subject-invariant representation. Extensive experiments conducted on clinical intracranial EEG dataset and public dataset demonstrate the effectiveness of our model in subject-independent seizure detection tasks. Moreover, our generated difference matrix effectively captures seizure activity changes during the seizure evolution process, which is valuable for clinicians to better understand the seizure event and develop more effective treatment. Furthermore, DMNet outperforms existing SOTAs while maintaining the high efficiency. Based on these, we deploy our method in an online system, enhancing clinical applications by assisting physicians in the diagnosis of epilepsy and in offering optimal treatment strategies. We hope that this work will shed light on the development of a more robust subject-independent seizure detection system.Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?Answer: [Yes] Justification: The standard derivation is shown in the Appendix G.Guidelines:• The answer NA means that the paper does not include experiments.• The authors should answer "Yes" if the results are accompanied by error bars, confidence intervals, or statistical significance tests, at least for the experiments that support the main claims of the paper.• The factors of variability that the error bars are capturing should be clearly stated (for example, train/test split, initialization, random drawing of some parameter, or overall run with given experimental conditions). • The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.) • The assumptions made should be given (e.g., Normally distributed errors). • It should be clear whether the error bar is the standard deviation or the standard error of the mean. Guidelines:• The answer NA means that the authors have not reviewed the NeurIPS Code of Ethics.• If the authors answer No, they should explain the special circumstances that require a deviation from the Code of Ethics. • The authors should make sure to preserve anonymity (e.g., if there is a special consideration due to laws or regulations in their jurisdiction). 
broader impacts: 
 Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed? 
safeguards: 
 Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)?Answer: [No] Justification: This paper poses no such risks.Guidelines:• The answer NA means that the paper poses no such risks.• Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters. • Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images. • We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort.12. Licenses for existing assets Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?Answer: [Yes]Justification: All the existing assets are properly referenced.Guidelines:• The answer NA means that the paper does not use existing assets.• The authors should cite the original paper that produced the code package or dataset.• The authors should state which version of the asset is used and, if possible, include a URL. • The name of the license (e.g., CC-BY 4.0) should be included for each asset.• For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided.• If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset. • For existing datasets that are re-packaged, both the original license and the license of the derived asset (if it has changed) should be provided. • If this information is not available online, the authors are encouraged to reach out to the asset's creators. 
new assets: 
 Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?Answer: [Yes] Justification: Our code is provided as a supplement.Guidelines:• The answer NA means that the paper does not release new assets.• Researchers should communicate the details of the dataset/code/model as part of their submissions via structured templates. This includes details about training, license, limitations, etc. • The paper should discuss whether and how consent was obtained from people whose asset is used. • At submission time, remember to anonymize your assets (if applicable). You can either create an anonymized URL or include an anonymized zip file. 
crowdsourcing and research with human subjects: 
 Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)?Answer: [NA] Justification: This paper does not involve crowdsourcing nor research with human subjects.Guidelines:• The answer NA means that the paper does not involve crowdsourcing nor research with human subjects. • Including this information in the supplemental material is fine, but if the main contribution of the paper involves human subjects, then as much detail as possible should be included in the main paper. • According to the NeurIPS Code of Ethics, workers involved in data collection, curation, or other labor should be paid at least the minimum wage in the country of the data collector. 
institutional review board (irb) approvals or equivalent for research with human subjects: 
 Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained?Answer: [No] Justification: This paper does not involve crowdsourcing nor research with human subjects.Guidelines:• The answer NA means that the paper does not involve crowdsourcing nor research with human subjects. • Depending on the country in which research is conducted, IRB approval (or equivalent) may be required for any human subjects research. If you obtained IRB approval, you should clearly state this in the paper.• We recognize that the procedures for this may vary significantly between institutions and locations, and we expect authors to adhere to the NeurIPS Code of Ethics and the guidelines for their institution. • For initial submissions, do not include any information that would break anonymity (if applicable), such as the institution conducting the review. 
 
 Appendix: Firstly, we compare our model to other iEEG-based subject-independent epilepsy detection models. The Details of these baseline models are given here:• SICR [17] : a framework that learns class-relevant and subject-invariant feature representations, which shows a promising performance in non-invasive brain-computer interface.• SEEG-Net [39] : a model that can address the problems of sample imbalance, cross-subject domain shift, and poor interpretability and realizes high-sensitivity SEEG pathological activity detection. The source code of SEEG-Net is not released, so we implement it by ourselves to conduct the experiments.• PPi [39] : proposed a method that utilizes a series of pre-training strategies to extract rich information from iEEG data while preserving the unique characteristics between brain signals recorded from different brain areas.Secondly, we also compare our model to several EEG-based subject-independent epilepsy detection models. The Details of these baseline models are given here:• [2] : they propose and investigates a patient-independent seizure detection model that uses stable EEG-based features obtained by comparing multiple feature selection methods.• [44] : they propose two subject independent deep learning architectures with different learning strategies that can learn a global function utilizing data from multiple subjects.• [11] : they propose a subject-independent seizure detection model, called IBA (Information Bottleneck Attribution), that utilizes multi-view information. By employing adversarial deep learning, the model learns seizure-specific feature representations directly from raw EEG data.Moreover, we offer more details on comparisons to other latest domain generalization methods utilized in this paper:• CDANN [22] : an end-to-end conditional invariant deep DG approach by leveraging deep neural networks for domain-invariant representation learning.• CORAL [36] : an unsupervised domain adaptation method that aligns the second-order statistics of the source and target distributions with a linear transformation.• GroupDRO [32] : a model coupling group DRO models with increased regularization, where DRO allows to learn models that instead minimize the worst-case training loss over a set of groups.• MTL [8] : a representative framework for DG, which augments the original feature space with the marginal distribution of feature vectors.• SD [29] : a regularization method aimed at decoupling feature learning dynamics, improving accuracy and robustness in cases hindered by gradient starvation.• SelfReg [18] : a regularization method for DG based on contrastive learning, self-supervised contrastive regularization.• TRM [40] : a robust estimation criterion that is specifically geared towards optimizing transfer to new environments.• VREx [19] : a penalty on the variance of training risks as a simpler variant based on a form of robust optimization over a perturbation set of extrapolated domains.• IB-ERM [4] : a DG method that improve generalization via minimizes the empirical risk over multiple domains.• IB-IRM [4] : a DG method that improve generalization via minimizes the invariant risk over multiple domains. Contextual ReferenceNormal SeizureIn this section, we present visualizations of the difference matrix (DM) constructed in Section 4.2, for providing an in-depth analysis of the DM properties. Initially, the difference matrix is constructed separately for normal and seizure segments of all subjects using the method mentioned in Section 4. Next, we average all difference matrices of normal and seizure segments to obtain the averaged 2-dimensional matrices. These two averaged 2D matrices are shown in the second row of Fig. 7 .The green square with dashed line represents the difference between the channel-level reference and target segment x f k . A zoom-in visualization is provided in the first row of the Fig. 7 . The left (normal) shows little difference of x f k with most of the channel patterns (small cluster index), but significant difference with a small portion of channel patterns (large cluster index). Conversely, the right one (seizure) exhibits the opposite pattern, validating the effectiveness of channel-level reference. Furthermore, the red square with the dashed line represents the difference within x f k (only containing contextual reference). The third row of the figure presents a zoom-in visualization, showing a smooth 2-dimensional matrix for normal event and a rough 2-dimensional matrix for seizure event. This demonstrates the effectiveness of introducing contextual reference.To evaluate the performance of our model, we conduct extensive experiments on the following two datasets.Clinical Dataset. The clinical dataset in our study is provided by a first-class hospital, and the intracranial EEG electrode implantation surgery and data collection are approved by the official ethics committee. For each subject, 4 to 10 invasive electrodes with 52 to 126 channels are implanted according to clinical needs to obtain brain signals. The dataset is quite massive due to the high frequency and multiple channels used to record intracranial EEG data, with more than 738 recording hours and 877.3GB total size. Data are labeled by professional neurologists at point level. Moreover, the positive sample (seizure event) ratio of a single subject in our dataset is around 0.003 on average, which is extremely imbalanced. More details can be found in Table 3 .Public Dataset. The public dataset MAYO and FNUSA [25] used in our paper, is collected from St. Anne's University Hospital (Brno, Czech Republic). This dataset is composed of intracranial EEG data collected in an awake resting state from 38 diagnosed subjects. Specifically, the dataset comprises a total of 348,300 segments. Each segment spans a duration of 3 seconds and consists of 15,000 data points, with a sampling frequency of 5000Hz. These segments are labeled into 4 categories, including physiological activity, pathological activity (seizure event), artifacts, and power line noise. We follow the setup in [39] of omitting invalid data from one subject while retaining the data from 30 subjects for analysis. More details can be found in Table 3 . 0 C+D B A 1 B+D C A 2 B+C D A 3 C+D A B 4 A+D C B 5 A+C D B 6 B+D A C 7 A+D B C 8 A+B D C 9 B+C A D 10 A+C B D 11 A+B C D Public 0 A+B+C+D E F 1 A+B+C+F D E 2 A+B+E+F C D 3 A+D+E+F B C 4 C+D+E+F A B 5 B+C+D+E F AAll experiments were run on a Linux system with 2 CPUs (AMD EPYC 7H12 64-Core Processor) and 4 GPUs (NVIDIA GeForce RTX 3090).Setup on Clinical Dataset. To conduct the experiment under domain generalization setting, we divide these subjects in a clinical dataset into 4 groups, each group contains 2 subjects (detailed grouping information is listed in Table 4 ). For model training and testing, we adopt a "2-1-1 setting" for the division of training, validation, and test sets. Specifically, we assign two groups to the training set and one group to the validation set, collectively forming the source domains. Additionally, we assign another group as the target domain for testing. For a comprehensive experiment, we conduct the experiments under 12 different grouping combinations (detailed settings in Table 5 ). To reduce computational load, we downsample the data to 250Hz. The length of the patch ℓ is set to 1 second (250 data points). More experimental details, including model and optimization settings, are listed in Table 2 .Setup on Public Dataset. For the public dataset, we employ the grouping strategy mentioned in [39] . Specifically, we divide these subjects into 6 groups. We adopt a "4-1-1 setting" for model training, validation, and testing, respectively: randomly choose 5 groups (4 testing groups and 1 validation group) as the source domain, while the other one group as the target domain for testing. For the public dataset, we conduct the experiments under 6 different grouping combinations (detailed setups in Table 5 ). Moreover, because the public dataset is sampled data, there is no complete channel data, so for DMNet with public data, we remove the channel-level reference. More experimental details, including model and optimization settings are listed in Table 2 .To additional illustrate the effectiveness of our proposed DMNet, we present the visualization results of the difference matrix throughout the entire seizure process in Fig. 8 . The upper figure shows the raw iEEG signal that contains a complete seizure process, where the gray wave represents the normal signal and the purple wave represents the seizure. The green masked blocks indicate the segments for detection. Notably, distinctions between seizure and normal matrices are evident during the evolution of the seizure. For segments that are temporally closer to the seizure events, the difference matrices tend to be rougher (e.g., segments c, d, and e) and vice versa (e.g., segments a, b, f, and g). In summary, this case clearly illustrates how the difference matrix captures the seizure activity changes in different frequency bands, and indicates the effectiveness of our proposed method.To further evaluate the generalization capability of DMNet across a wider range of subjects with greater heterogeneity, we assessed the model using data from the extensive TUSZ EEG dataset [1] which encompasses numerous subjects. After data preprocessing, we retained data from 179 subjects, dividing them into training, validation, and testing sets in a 6:2:2 ratio, with distinct subjects in each split. Please refer to Tab. 6 for the results of the experiment. The results indicate that DMNet There are two main limitations to my approach. Firstly, it lacks a theoretical foundation, which may call into question the effectiveness and reliability of the method. It becomes challenging to explain and justify the underlying principles behind the approach. Secondly, although the method is efficient, it suffers from a limited number of parameters. This limitation can potentially impact the generalizability of the method. Therefore, while the method may show promising results in specific contexts, caution should be exercised when applying it to broader or unfamiliar situations. Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material? Answer: [Yes] Justification: The private dataset so one may cannot reproduce the experiments on the private dataset. However, we also use another two public datasets, and the code of our work is fully provided too, which could help you understand our work.• The answer NA means that paper does not include experiments requiring code. • Providing as much information as possible in supplemental material (appended to the paper) is recommended, but including URLs to data and code is permitted.Justification: There is no social impact of the work performed.Guidelines:• The answer NA means that there is no societal impact of the work performed.• If the authors answer NA or No, they should explain why their work has no societal impact or why the paper does not address societal impact. • Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations. • The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster. • The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology. • If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML).† Corresponding authors. 


Decision: The authors present Difference Matrix-based Neural Network for subject-independent automatic seizure detection. The model addresses the domain shift in iEEG signals across different subjects by leveraging a self-comparison mechanism that can enhance the model's ability to perform effectively across new subjects without additional training. The approach is novel and well presented. Several concerns on empirical evaluation and hyper-parameter selection process are well addressed by the additional experiments and explanations in the authors' rebuttal.

Reviews: review: paper_summary: paper_summary: The paper proposes DMNet, a Difference Matrix-based Neural Network for subject-independent seizure detection using intracranial electroencephalography (iEEG). The model addresses the domain shift in iEEG signals across different subjects by leveraging a self-comparison mechanism that aligns iEEG signals and encodes universal seizure patterns. DMNet utilizes contextual and channel-level references to mitigate shifts and employs a difference matrix to capture seizure activity changes effectively. The authors report that DMNet outperforms state-of-the-art models and is highly efficient in real-world clinical applications.
strength_weakness: strength_weakness: 1. If the right side R_cl merely reverses the left side L_cl, is it redundant?

2. The three datasets used for evaluation have small numbers of subjects. Could the authors include an experiment on EEG data with more subjects?

3. On MAYO and FNUSA, where positive sample ratio is non-trivial, the model has a much higher recall than precision, showing it’s prone to false positives. Do the authors have some preliminary justifications/explanations for this feature?

4. The performance improvement is incremental. In Table 1, if we check F1 score which is a combination of Recall and Precision, we find that on MAYO and FUNSA, the proposed model only outperforms the best baseline for around 1%. Without std reported, we cannot judge is the increment is caused by randomness. On Clinical dataset, the margin is 3% which is good.
questions: questions: See weakness above.
limitations: limitations: I didn't find a discussion on the limitations of this work.
paper_summary: paper_summary: This paper revolves around subject-independent seizure detection using intracranial electroencephalography (iEEG) signals. The primary challenge is the domain shift in iEEG signals across different subjects, which hinders the generalization of seizure detection models to new subjects. Existing models often fail to adapt to these domain shifts, leading to reduced performance in subject-independent scenarios.

The authors highlight the limitations of existing iEEG models, which struggle with subject-independent seizure detection due to the variability in iEEG signals across individuals. Previous approaches have not effectively addressed the domain shift issue, resulting in suboptimal performance when applied to new subjects. This sets the stage for the need for a novel model like DMNet that can overcome these challenges and improve subject-independent seizure detection.

The authors have employed a self-comparison mechanism within DMNet, allowing the model to compare iEEG signals within the same subject and across different subjects. This mechanism enables DMNet to learn subject-independent representations of seizure patterns, enhancing its generalization capabilities. Additionally, the novel neural network architecture of DMNet is tailored to leverage these self-comparisons efficiently, leading to improved performance in subject-independent seizure detection tasks.
strength_weakness: strength_weakness: 1.	The paper lacks extensive experimental validation across diverse datasets. This limitation restricts the demonstrated generalizability and robustness of DMNet. For stronger validation, experiments on multiple, varied iEEG datasets would be necessary to affirm the model's efficacy across different scenarios.
2.	The paper could benefit from a more thorough explanation of the theoretical foundations of DMNet. Providing detailed assumptions and complete proofs for the methodologies proposed would enhance the rigor of the research and strengthen the credibility of the model’s theoretical underpinnings.
3.	The model's architecture, characterized by a limited number of parameters, may hinder its adaptability and performance in diverse situations. While the simplicity of fewer parameters might benefit specific conditions, it could limit the model’s ability to handle new or complex data effectively. This could affect the model's application in broader or more varied contexts.
questions: questions: 1.	Could you provide more detailed insights into how the domain shift in iEEG signals manifests across different subjects?

2.	How does DMNet specifically address and mitigate this domain shift issue? Are there any theoretical or empirical justifications for the effectiveness of this approach in handling these shifts?

3.	Can you provide a detailed comparison between DMNet and existing iEEG models for subject-independent seizure detection in terms of key performance metrics such as sensitivity, specificity, and computational efficiency?

4.	Can you provide details on the experimental setup, including data preprocessing, model training, hyperparameter tuning, and the evaluation metrics used?

5.	How does DMNet fare in real-world clinical applications for subject-independent seizure detection?

6.	Have there been any pilot studies or practical implementations of DMNet in clinical settings? What were the findings regarding its effectiveness and usability?

7.	What are the potential challenges or limitations in deploying DMNet in real clinical scenarios, and how does the model address these to ensure practical utility and scalability?
limitations: limitations: The authors have adequately addressed the limitations and identified no potential negative societal impacts of their work.
paper_summary: paper_summary: The paper presents a seizure detection approach for spotting seizure segments in long recordings by comparing the differences in spectral content between the target segment to be labeled and surrounding context segments and some prototypical context segments, obtained as centroids by clustering the channel, along the differences between these segments organized into a matrix. A CNN based network then processes this matrix using the distribution of differences to understand if the differences are indicative of a seizure.  Results show state-of-the-art performance a multiple datasets.
strength_weakness: strength_weakness: There are few points that are not clear  (see questions).

My main concern is that when looking at the appendix, the data division and hyper-parameter selection is not clear. There is a set of basic hyper-parameters that in Table 2 that seems to be set globally, but now clear how. Then there is a validation set in each split. Perhaps this validation split is used just for choosing the stoping criterion. To choose the best hyper-parameters based on test set performance across all folds is not a valid approach (as it uses test set performance to choose a model architecture). A fair approach would be conduct internally the hyper-parameter selection based on validation in each fold.

Overall, there is lack of intuition (or theory) on when and why organizing the total set of differences into a matrix makes sense. Although it is meaningful to organize neighboring segments there isn't any spatial ordering between centroids differences.  It would seem that multiple branches to compare the none contiguous with 1D convolutions (across frequencies and then channels) before  CNN (bu
questions: questions: Line 82: "of normal and " -> "of normal segments and"

In Figure 2(b) it looks like the data has not be high-pass filtered based on the cross-time analysis.  How would high pass filtering affect the proposed methodology as well as the challenges in existing data?

Line 160, as the discrete Fourier transform will be complex valued, it is the sum of the magnitude of the differences, unless only the amplitudes are preserved. Notably, by Parseval's theorem the sum of the squared magnitudes of the differences is the same as the sum of the squared magnitude in the time domain. Thus, as the phase may vary it should be the absolute value of the differences in the magnitude (or squared magnitude).  Later on 196 these are stated to be $d$-dimensional real vectors so the reader can finally assume they are magnitudes (which are non-negative).

I don't understand lines 214–217, why would the clusters have left and right meaning and why would duplicating them in reverse order matter in the construction of the difference matrix? 

While the left and right windows have ordered information its still not clear why appending the cluster centroids to both sides helps or why a single vector representation of the difference of the target to the rest couldn't be used. The reader is left to guess that the additional differences simply provide context for the differences to the target.

Figure 3 is not sufficient for the neural network architecture. How does the "global average pooling"  operate as it seems to take the two previous maxPool2D layers along with the output of the 2 by 2 max pooling... How was this design chosen? 

 As mentioned in the limitations in the appendix, the method may be limited due to limited parameters to tune during training. I have two suggestions:
1. Use an ablation on the 2D matrix vectorizing the redundant differences and using a network with full connected layers rather than the matrix organized version processed with a CNN.
2. Learn weightings on the frequencies.
limitations: limitations: Limited by unclear operation.
paper_summary: paper_summary: The authors present an algorithms for subject-independent automatic seizure detection. the algorithm exploits the dynamic behavior of seizures by including a contextual region of analysis, and a channel reference, where contextual refer to the time window close to the window of analysis, and the channel reference to the long term average behavior of the signal. They propose to capture the differences in this dynamic behavior, in the frequency domain, in the Difference Matrix, which is then input in a CNN for its classification. The authors show the results for three different datasets, 2 public and one private, compared with different state of the art algorithms for seizure detection. They demonstrate that DMNet outperforms other algorithms.
strength_weakness: strength_weakness: 1. Can you indicate the sampling frequency of the signals analyzed? Also, you make the analysis based on number of samples, but I do believe this is dependent on the sampling frequency. For instance, if I evaluate the length of segment L for a signals sampled at 250Hz, or a signal sampled at 1KHz, the results with respect to performance metrics might be different. Can you elaborate a bit more about this? Will your algorithm work also for different sampling frequencies, or it should be fine tuned?


minor:

1. Can you improve the legibility of the figures, perhaps using a larger font in some cases and/or using alight font instead of a bold one in other cases. 
2. Line 85 use named or called, since namely is used to express the specific details of something but not to assign a name. 
3. I considere that the deployment of an online system should be listed as a separate contribution, since merging the third contribution with this mitigates negatively the impact of this item.
4. Line 162, I think you refer to figure 2c and 2d, and not to figure 3.
questions: questions: 1. The channel-level reference also contain information of seizures, would it be possible to generate this reference pattern only for free of seizures segments? What is the possible impact of having information in this reference free of seizures, or containing seizures? Can you elaborate about this?
2. Is a linear classifier good enough to discriminate between the latent representation Z, for normal and seizure segments? Did you also explore the use of other classifiers?.
limitations: limitations: None

Comments: title: Thank you
Rebuttal by Authors
Clarification of Hyper-parameter selection
Thanks for the reviews
Hyperparameter Selection in Experiments in Our Main Body
Settings of Cross-dataset Experiment in rebuttal
Hyper-parameter selection confusion
Clarification on Ethical Approval
Some minor typos fixes in GR1
comment: We truly appreciate your effort in helping us to strengthen the paper and your support for our work.
I thank the authors for their reply to my inquiries. I am satisfied with the answers and have no further comments.
Thank you for your thorough review and for acknowledging our efforts to address your concerns. We appreciate your feedback and would like to address the remaining points you've raised.

**Chronological Split.** We sincerely apologize for the oversight in not explicitly mentioning the chronological split between validation and test sets in our original manuscript. This was an unintentional omission on our part. We will add this crucial information to our experiment section in our revised manuscript, clearly stating: "For each subject, their iEEG signal is further divided into two parts based on time, with the first 20% of the data extracted for validation and the remaining data used for testing."

**Consistency Across Baselines.** We appreciate you bringing this important point to our attention. We can confirm that the same methodology, including the chronological split and hyperparameter selection process, was applied consistently across all baselines and our proposed model. This ensures a fair comparison and maintains the integrity of our results. We will add a detailed description in our revised manuscript explicitly stating the consistency of our methodology across all models. This addition ensures transparency and allows for proper replication of our experiments.

Morevoer, whether a global hyperparameter can be used to achieve good performance across various domains is also a consideration, as this also reflects the model's generalization ability. Therefore, we adopted this setup in our experiments.

We thank you for your diligence in reviewing our work. Your comments have helped us improve the clarity and rigor of our paper.
Thank you for the efforts to address my concerns—they are mostly addressed. I agree that global hyper-parameter selection can cause information leakage but avoiding it requires different hyper-parameters per model.  I would like to highlight that this detailed methodology was not provided in the original submission. I find no mention of chronological split between validation and test in the original manuscript pertaining to  "Please note that for each subject, their SEEG signal is further divided into two parts based on time, with the first 20% of the data extracted for validation and the remaining data used for testing." It is not clear to me that all of the baselines follow the same methodology. It would seem unfair to use a more involved approach for hyper-parameter selection when the goal is really to tell if the proposed architecture is significantly better.  Can this be confirmed for all of the baselines?
Please refer to our latest responses to the questions posed by **Reviewer EpQU**.

**Minors:**

Thank you for pointing out the typo in Table 3 of the attached PDF.

The "FNUSA" in Table 3 should be corrected to "Clinical," and I will make the necessary correction in the manuscript.
We are truly grateful for the reviewer’s feedback and recognition of our efforts.
### Hyperparameter Selection in Experiments in Our Main Body.

For global hyper-parameter selection, we first randomly divide the dataset into different groups, as detailed in Table 4 of the Appendix. We then conduct trials according to the setup in Table 5 of the Appendix, with each trial involving distinct groups for training, validation, and testing.

Please note that for each subject, their SEEG signal is further divided into two parts based on time, with the first 20% of the data extracted for validation and the remaining data used for testing. However, when the data is used as part of the training set, the entire dataset is utilized.

The entire trial process includes two main procedures:

1. Global hyper-parameter selection.
   For global hyper-parameter selection, we train the model and evaluate the performance score on the training and validation group pairs for each trial (e.g., 12 pairs in total for the Clinical dataset). We then select the set of hyper-parameters that achieve the best average scores across all group pairs, thereby determining the global hyper-parameters. The set of hyper-parameters is listed in Table 2 in Appendix.

2. Model training and testing under the selected global hyper-parameters.
   In the model training and testing process, for each trial, we deploy DMNet with the selected global hyper-parameters on the training (source) group for model training and evaluate the performance on the validation set. The model that achieves the best scores on the validation set is then used to evaluate performance on another test set.

It's important to note that by dividing the validation and testing segments for each subject, we ensure that the test data remains strictly unseen during global hyper-parameter selection. One potential risk is domain information leakage, as global hyper-parameter selection inevitably allows the learner to have a preliminary view of a small portion of data across all domains. However, we argue that this trade-off is acceptable for the following reasons:

- Global hyper-parameter selection facilitates the practical deployment of deep learning models in real clinical scenarios and enhances domain generalization. Specifically, it enables us to identify a more general set of settings that are potentially suitable for most domains. This allows us to directly deploy the model with these global settings for a new patient without the need for hyper-parameter searching or training the model from scratch, greatly improving the scalability of deep learning models in real applications. Please note that some previous works [1,2], global hyper-parameters are also utilized for cross domain testing. 

- Using global hyper-parameters ensures a fairer performance comparison across different domains. If each fold (trial) uses different hyper-parameters, performance discrepancies might arise from the hyper-parameters rather than the model itself.

Additionally, in our added experiments of rebuttal (PDF, Table 1 - Table 4), we conducted the additional cross-dataset experiments. In these experiments, since the distinct datasets for training&validation and testing, we have that the testing data and domain information is strictly independent with global hyper-parameter selection. The results indicates that our model DMNet also presents the superior performance compared to other baselines.

[1] Yuan et al,. PPi: Pretraining Brain Signal Model for Patient-independent Seizure Detection, NeurIPS'23

[2] Caiet al,. MBrain: A Multi-channel Self-Supervised Learning Framework for Brain Signals, KDD'23
We thank the reviewer for all the insightful comments. I will revise the paper to acknowledge that the decision to concatenate channel-wise references twice in the 2D matrix of differences is a heuristic choice.

Moreover, responses to specific comments are listed below.

### Settings of Cross-dataset Experiment in rebuttal.

Regarding the additional cross-dataset experiments, for the source dataset, we first randomly devide the subjects into several groups. We take the case of Clinical dataset (it will be divided into 4 groups) as source domain as an example for detailed illustration. 

To minimize experimental variability, we assign each group as a validation set (1 group) and the rest as a training set (comprising 3 groups), resulting in 4 experiments (listed below). 

Table-1:

| Experiment   | Training Set (3 groups)   | Validation Set (1 group) |
|:------------:|:-------------------------:|:------------------------:|
| Experiment 1 | Group 1, Group 2, Group 3 | Group 4                  |
| Experiment 2 | Group 1, Group 2, Group 4 | Group 3                  |
| Experiment 3 | Group 1, Group 3, Group 4 | Group 2                  |
| Experiment 4 | Group 2, Group 3, Group 4 | Group 1                  |

Next, for each experiment, we implement LODO on the training set (comprising 3 groups) to create a sub-training set (2 groups) and a sub-validation set (1 group) for hyperparameter selection. Finally, each experiment has 3 sub-experiments to select the hyperparameters. The 3 sub-experiments of experiment 1 are listed below, and the other experiments are constructed in a similar manner.

Table-2:

| Sub-Experiment   | Sub-Training Set (2 groups) | Sub-Validation Set (1 group) |
|:----------------:|:---------------------------:|:----------------------------:|
| Sub-Experiment 1 | Group 1, Group 2            | Group 3                      |
| Sub-Experiment 2 | Group 1, Group 3            | Group 2                      |
| Sub-Experiment 3 | Group 2, Group 3            | Group 1                      |

In this case, for each experiment, every set of parameters would yields 3 performance scores on 3 sub-experiments respectively, and then we select the set of hyperparameters achieving the best score as the global parameters for model implementation. So strictly speaking in our process, we regard group (containing 2 subjects) as a domain.
During model implementation, for each experiment in Table-1, we train the model using the training set of the clinical dataset and employ an early stopping strategy based on the validation set loss. The trained model is then utilized for evaluate the performance on the dateset of other two datasets (MAYO, FNUSA).
Please note that this process ensures the hyper-parameters are searched independently without any exposure to the test set. The final hyperparameter configurations for the three experiments are as follows:

Table-3:

| Source Domain | Clinical | FNUSA    | MAYO     |
|:----------------------------------------- |:--------:|:--------:|:--------:|
| Length of Segment                         | 250      | 450      | 500      |
| Number of Segment                         | 12       | 8        | 8        |
| Number of Cluster                         | 8        | 7        | 7        |
| Base filter Number                        | 64       | 16       | 8        |
| Learning Rate                             | 3.00E-04 | 3.00E-04 | 3.00E-04 |
| Batch Size                                | 32       | 24       | 24       |
Thanks for the response and I appreciate the new experiments on TUSZ along with the explanations on F2. I'd like to increase my score from 4 to 5.
Thank you for the response. I think some answers are satisfactory except those in the global response, where I ask more.

I think the paper should acknowledge that the twice concatenated channel-wise references in the  2D matrix of differences is an heuristic choice that tries to put a "round peg in a square hole". As in reality, the local operations in the CNN only make sense for the contextual references. A Transformer architecture that processes differences seems to make more sense.

I'll consider raising my score once the hyper-parameter selection process is clarified.
Thank you for the clarification on the reason to add channel-level reference on both sides, it dose makes sense due to CNNs local feature extraction. However, I disagree about CNNs properties. CNNs are not completely shift and rotation invariant, but can exhibit some local shift invariance through pooling, and rotation invariance can be also learned but is not intrinsic. 


The hyper-parameter selection via leave-one-domain out (LODO) generalization [2] is more involved than what is conducted in the additional experiments in the rebuttal. The rebuttal states "Maximize the average F1 across the held-out domains in all folds". But the PDF says only 1 dataset was used as source. Does this mean the domains are subjects like in the main body?  Otherwise, if dataset are domains to do the process of LODO, one needs at least two domains as source. Hyper-parameters that perform good on average (across either held out folds of subjects or held out domains) are then tested on the unused target domains. 

Could the authors report the selected hyper-parameters that were selected for each test set (by "for" I mean that they were selected without seeing the test set, but were selected with the intent of use on this test set)?
 
Similarly, I'm still not convinced that a rigorous selection was used in the main body results for the 2-1-1 or 4-1-1 strategy.  There should be a different set of hyper-parameters based on the  validation set in each fold, rather than one global one. Choosing one set of hyper-parameters based on average performance (without an additional test set) is not rigorous.

 
Table 3 in PDF must have wrong column labels for target domains...
Thank you for your valuable feedback. We appreciate your attention to detail and ethical considerations. We would like to address your concerns and provide further information listed below:

## 1. Acceptance of Ethics

- **Purpose of Data Use:** The implantation of invasive electrodes is used for epileptic lesions localization for surgical treatment. Data collection for academic research purposes is a byproduct. The subjects are clearly informed that the collected data would also be used for academic research.

* **Ethics Approval**: The clinical dataset used in our research was acquired in accordance with ethical guidelines and obtained approval from the Institutional Review Board (IRB) at **Human Research Ethics Committee, the Second Affiliated Hospital of Zhejiang University School of Medicine**. The IRB approval number is **2021065**. 
* **Region and Hospital**: The dataset includes patient data from **The second Affiliated Hospital Zhejiang University School of Medcine** located in **Hangzhou, Zhejiang Province, China**.

## 2. Subject Informed Consent

* **Consent Process**:  Informed consent was obtained from all participants before their data was used for research purposes. The consent process was conducted by **The second Affiliated Hospital Zhejiang University School of Medcine** using a standardized consent form approved by the IRB. Participants were informed about the purpose of the study, the data that would be collected, and their rights as research participants.
* **Timing of Consent Process**: Consent for data usage was obtained **before** the surgery, ensuring that participants were fully aware of the research before undergoing the procedure.

## 3. Details of the Trial 

### Inclusion Criteria

- **Age:** 3-60 years old.
- **Medical History:** Individuals who have received standard antiepileptic drug treatment under physician guidance, but have not effectively controlled seizures, diagnosed with drug-resistant epilepsy, and require preoperative assessment through SEEG.
- **Seizure Frequency:** A minimum of 8 seizures in the 8 weeks prior to the screening period, with no interval exceeding 25 days.
- **Anatomical Structure:** Skull thickness along the electrode implantation path ≥ 3mm.
- **Willingness:** Voluntary participation in this clinical trial and signing the informed consent form.

### Exclusion Criteria

- Patients with intracranial hemorrhage or increased intracranial pressure.
- Individuals with implanted devices such as pacemakers, electronic chips, stents, etc., who cannot undergo MRI scans.
- Those with bleeding disorders or coagulation abnormalities.
- Severe infections or individuals deemed by the investigator to be at risk of infection.
- History of allergies or hypersensitivity to implanted electrodes.
- Individuals with insulin-dependent diabetes.
- Individuals with psychiatric disorders or history thereof.

### Trial process

1. **Screening Period (-7-0 days):** Signing informed consent forms, collecting demographic data, medical history, allergy history, surgical history, family history, vital signs, laboratory tests (complete blood count, liver function, kidney function, coagulation function, C-reactive protein), CT scans, and 3.0T MRI scans.
2. **Day of Electrode Implantation (Day 0):** Checking vital signs, recording surgical information, conducting CT scans, and 3.0T MRI scans.
3. **Day of Electrode Removal (Within 28 days post-operation):** Checking vital signs, and conducting CT scans.
4. **Follow-up Period (3-7 days post-electrode removal):** Checking vital signs, and conducting laboratory tests (complete blood count, liver function, kidney function).

### Trial Duration

The trial period spans from the signing of the informed consent form to 3-7 days after electrode removal. Therefore, the entire trial process is expected to last approximately one month.

## 4. Labelling Process

* **Neurologist Recruitment**: Neurologists with expertise in epilepsy were recruited through online recruitment platform. The selection criteria included years of experience in epilepsy diagnosis and treatment, familiarity with iEEG data interpretation, and availability to participate in the labelling process.
* **Number of Neurologists**: **4** neurologists participated in the labelling process.
* **Compensation**: Neurologists' compensation is around 12,000 RMB per month, which refers to the monthly salary of neurologists. The compensation details were clearly outlined in the agreements with the neurologists.  

**Finally, we will revise the paper to include the detailed information provided above.** We hope this information addresses your concerns and clarifies the ethical aspects of our research.
**Some minor typos fixes in GR1**

I apologize for the typo in formula 1 and 3 in GR1. Below is the corrected formula 1 and 3.

XY00111: 
$$
\left[  \begin{matrix} 
0&X-Y&X&X&X-1&X-1&X-1\\\\
Y-X&0&Y&Y&Y-1&Y-1&Y-1\\\\
-X&-Y&0&0&-1&-1&-1\\\\
-X&-Y&0&0&-1&-1&-1\\\\ 
1-X&1-Y&1&1&0&0&0\\\\ 
1-X&1-Y&1&1&0&0&0\\\\ 
1-X&1-Y&1&1&0&0&0\\\\ 
\end{matrix}  \right]  \tag{1}
$$


XY00111YX: 
$$
\left[  \begin{matrix} 
0&X-Y&X&X&X-1&X-1&X-1&X-Y&0\\\\ 
Y-X&0&Y&Y&Y-1&Y-1&Y-1&0&Y-X\\\\ 
-X&-Y&0&0&-1&-1&-1&-Y&-X\\\\ 
-X&-Y&0&0&-1&-1&-1&-Y&-X\\\\ 
1-X&1-Y&1&1&0&0&0&1-Y&1-X\\\\ 
1-X&1-Y&1&1&0&0&0&1-Y&1-X\\\\ 
1-X&1-Y&1&1&0&0&0&1-Y&1-X\\\\ 
Y-X&0&Y&Y&Y-1&Y-1&Y-1&0&Y-X\\\\ 
0&X-Y&X&X&X-1&X-1&X-1&X-Y&0\\\\ 
\end{matrix}  \right]  \tag{3}
$$