Epilepsy detection method, system and equipment based on electroencephalogram signal and medium
By constructing an epilepsy detection model based on graph attention network and Transformer network, the problem of insufficient feature extraction in epilepsy detection of EEG signals is solved, and highly accurate and stable epilepsy detection is achieved.
Patent Information
- Application Number
- CN202510704900.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-09-16
AI Technical Summary
Existing EEG signal epilepsy detection methods have problems such as poor accuracy, insufficient real-time performance, and the influence of individual differences. In particular, insufficient feature extraction in deep learning algorithms affects the accuracy of detection results.
A seizure detection model based on a graph attention network (GAT) and a Transformer network was developed. This model constructs a graph structure for EEG signals, calculates inter-channel correlations using the Pearson correlation coefficient, and combines it with a Softmax classifier for seizure detection. The model preprocesses multi-channel EEG signals, constructs a graph structure, extracts spatial features using the GAT, and uses a Transformer network for temporal feature extraction and binary seizure classification.
It improves the accuracy and stability of epilepsy detection, can effectively capture the spatial and temporal characteristics of EEG signals, and improves the accuracy and specificity of epilepsy detection.
Smart Images

Figure CN120643188A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electroencephalogram (EEG) signal processing, and in particular to an EEG signal-based epilepsy detection method, system, device, and medium. Background Art
[0002] Epilepsy is a disorder caused by abnormal and persistent neuronal discharges in the brain, leading to brain dysfunction and systemic convulsions. People with epilepsy may experience sudden seizures in their daily lives, which can cause serious injury or even death. Therefore, accurate and efficient epilepsy detection methods are crucial to ensuring human safety and have become a growing research hotspot.
[0003] In clinical medicine, important methods for diagnosing neurological diseases such as epilepsy include functional magnetic resonance imaging (fMRI), magnetoencephalography (MEG), and electroencephalography (EEG). Compared to the high costs of fMRI and MEG, EEG is more cost-effective, and its equipment is easier to use and maintain. During an epileptic seizure, EEG can detect abnormal changes in brain signals, helping doctors determine the type and location of the seizure. In addition, EEG can help doctors assess a patient's response to medication and decide whether to adjust the treatment plan. However, manual EEG analysis currently has many limitations, such as being cumbersome, poorly accurate, time-sensitive, and subject to individual differences. Therefore, finding a method to automatically detect epilepsy is of great significance.
[0004] In recent years, research on automatic epilepsy detection algorithms has mainly included machine learning and deep learning algorithms. In traditional machine learning techniques, feature and classification selection is done through trial and error. Developing reliable models requires a deep understanding of signal processing and data mining techniques. These models perform well on limited data. However, as data availability increases, machine learning techniques may perform poorly. With the development of deep learning, many deep learning-based epilepsy seizure detection methods have been proposed. Compared with machine learning methods, these neural network-based methods have higher accuracy. Currently, many researchers and institutions have applied convolutional neural networks (CNNs) and LSTM networks to epilepsy detection, but current deep learning algorithms still suffer from insufficient feature extraction, which in turn affects the accuracy of detection results. Summary of the Invention
[0005] The purpose of the present invention is to provide an epilepsy detection method, system, device and medium based on electroencephalogram signals, aiming to solve or improve at least one of the above-mentioned technical problems.
[0006] To achieve the above object, the present invention provides the following solutions:
[0007] An epilepsy detection method based on electroencephalogram (EEG) signals, comprising:
[0008] Obtaining multi-channel original EEG signals of the subject to be tested;
[0009] Preprocessing the multi-channel raw EEG signals and constructing a graphical structure for describing the spatial characteristics of the EEG signals; the graphical structure includes nodes and connecting lines, where the nodes represent the channels and the connecting lines represent the correlation coefficients between the channels;
[0010] The final epilepsy detection result is determined based on the graph structure and the epilepsy detection model; the epilepsy detection model includes a graph attention network, a Transformer network, and a Softmax classifier connected in sequence; wherein the graph attention network is used to aggregate spatial features between channels, the Transformer network is used to extract temporal features, and the Softmax classifier is used to perform binary epilepsy classification.
[0011] Optionally, preprocessing the multi-channel original EEG signals and constructing a graphic structure for describing the spatial features of the EEG signals specifically includes:
[0012] Dividing the multi-channel original EEG signal into multiple segments, passing the signal time window of each segment through a bandpass filter, and then performing normalization processing to obtain pre-processed segmented data;
[0013] Calculate the Pearson correlation coefficient between channels based on the segmented data, and construct a correlation matrix based on the correlation coefficient. For any component element in the correlation matrix, if it is less than a set threshold, it is set to 0; if it is greater than or equal to the set threshold, it is set to 1;
[0014] The non-zero values in the matrix are connected, and the correlation coefficient is used as the connection weight to obtain a graphical structure for describing the spatial characteristics of the EEG signal.
[0015] Optionally, determining a final epilepsy detection result according to the graphic structure and the epilepsy detection model specifically includes:
[0016] Inputting the image structure into the graph attention network for iterative operation to obtain a new graph structure with aggregated channel adjacent node features;
[0017] Inputting the new graph structure into the Transformer network to extract temporal features, thereby obtaining a feature graph with spatiotemporal features;
[0018] The feature map is input into the Softmax classifier for binary epilepsy classification to obtain the final epilepsy detection result.
[0019] Optionally, the Transformer network consists of L stacked encoder modules, each encoder module including a multi-attention mechanism and a fully connected feedforward network; each encoder module adopts a residual connection.
[0020] Optionally, the method further includes: training the epilepsy detection model;
[0021] The training process is as follows:
[0022] Obtaining a training data set; the training data set includes training data and corresponding training labels;
[0023] Build a pre-trained network;
[0024] The training data is input into the pre-trained network, and iterative training is performed with the goal of minimizing the loss between the network output and the training label, and the trained pre-trained network is determined as an epilepsy detection model; wherein the loss function in the iterative training adopts a focal loss function.
[0025] The present invention also provides an epilepsy detection system based on electroencephalogram signals, comprising:
[0026] A data acquisition unit, used to obtain multi-channel original EEG signals of the subject to be tested;
[0027] A data processing unit, configured to pre-process the multi-channel raw EEG signals and construct a graphical structure for describing the spatial characteristics of the EEG signals; the graphical structure includes nodes and connecting lines, where the nodes represent the channels and the connecting lines represent the correlation coefficients between the channels;
[0028] An epilepsy detection unit is configured to determine a final epilepsy detection result based on the graph structure and the epilepsy detection model; the epilepsy detection model comprises a graph attention network, a Transformer network, and a Softmax classifier connected in sequence; wherein the graph attention network is configured to aggregate spatial features between channels, the Transformer network is configured to extract temporal features, and the Softmax classifier is configured to perform binary epilepsy classification.
[0029] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the above-mentioned epilepsy detection method based on electroencephalogram signals.
[0030] The present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the above-mentioned epilepsy detection method based on electroencephalogram signals.
[0031] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0032] The present invention discloses an electroencephalogram (EEG)-based epilepsy detection method, system, device, and medium. The method comprises preprocessing a subject's multi-channel raw EEG signals and constructing a graphical structure for describing the spatial features of the EEG signals. The graphical structure comprises nodes and connecting lines, where nodes represent channels and connecting lines represent correlation coefficients between channels. The final epilepsy detection result is determined based on the graphical structure and an epilepsy detection model. The epilepsy detection model comprises a graph attention network, a Transformer network, and a Softmax classifier, which are sequentially connected. The graph attention network aggregates spatial features between channels, the Transformer network extracts temporal features, and the Softmax classifier performs binary epilepsy classification. The present invention can improve detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0034] Figure 1 is the overall flow chart of the model in this embodiment;
[0035] Figure 2 Schematic diagram of the correlation matrix in this embodiment;
[0036] Figure 3 This is a schematic diagram of the calculation details of the Graph attention layer in this embodiment;
[0037] Figure 4 Schematic diagram of the specific structure of the Transformer encoder in this embodiment. DETAILED DESCRIPTION
[0038] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0039] The purpose of the present invention is to provide an epilepsy detection method, system, device and medium based on electroencephalogram signals, aiming to solve or improve at least one of the above-mentioned technical problems.
[0040] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0041] like Figure 1 As shown, the present invention provides an epilepsy detection method based on electroencephalogram signals, comprising:
[0042] Step 100: Acquire multi-channel original EEG signals of the subject to be tested.
[0043] Step 200: Preprocess the multi-channel original EEG signals and construct a graphic structure for describing the spatial characteristics of the EEG signals; the graphic structure includes nodes and connecting lines, the nodes represent each channel, and the connecting lines represent the correlation coefficients between channels.
[0044] Step 300: Determine a final epilepsy detection result based on the graph structure and the epilepsy detection model; the epilepsy detection model includes a graph attention network, a Transformer network, and a Softmax classifier connected in sequence; wherein the graph attention network is used to aggregate spatial features between channels, the Transformer network is used to extract temporal features, and the Softmax classifier is used to perform binary epilepsy classification.
[0045] As a specific implementation, in order to solve the problem in the prior art that EEG signals are collected using electrodes in three-dimensional space, and thus there are hidden spatial relationships between electrodes, the following specific processing process is proposed.
[0046] First, the MNE toolbox in Python was used to read raw EEG data from a public dataset into a computer-readable format. The read EEG data was then divided into short time windows. The segmented signal time windows were passed through a bandpass filter and then normalized. The processed EEG data were then divided into training and test sets according to a specific ratio.
[0047] For each part of the segmented data, the Pearson correlation coefficient is calculated to determine the correlation between channels, and finally a graph structure is obtained. The signal data of each channel and the latent spatial relationship between multiple EEG channels are mapped to the nodes and connecting lines of the graph respectively.
[0048] The preprocessed EEG data and the generated graph structure are fed into the GAT model for spatial feature extraction. After computation using a multi-attention mechanism, a new graph structure is generated. This process is repeated again, ultimately yielding a new graph structure that aggregates features from adjacent nodes. This graph structure incorporates spatial information between EEG channels. This structure is then fed into a Transformer network as a time series for further temporal feature extraction. Finally, the output is fed into a Softmax classifier for binary epilepsy detection. The overall model flow is shown in the figure.
[0049] Graph modeling approach:
[0050] To assess the correlation between different EEG signal channels, the Pearson correlation coefficient is used to measure the correlation between channel pairs. Each channel is considered a node, and the correlation coefficient between different channels represents the connection weight. The raw values of the signal serve as node features. The Pearson correlation coefficient is a common statistical method for quantifying the correlation between two variables. It ranges from -1 to 1, with stronger correlations closer to 1 or -1. In the field of epileptic seizure detection, the Pearson correlation is widely used to assess the correlation between EEG signal features and the occurrence of epileptic seizures. In this paper, the Pearson correlation is used to calculate the correlation coefficient between different EEG channels.
[0051] The Pearson correlation coefficient (a measure of the degree of association between two variables) is calculated using the following formula:
[0052] Person=C(X,Y) / (S(X)*S(Y))
[0053] Where X and Y are two variables, C(X, Y) represents the covariance between X and Y, S(X) represents the standard deviation of X, and S(Y) represents the standard deviation of Y. The strength of the correlation between variables is usually judged based on the value range in Table 1:
[0054] Table 1. Correlation coefficient and correlation degree correspondence table
[0055] Correlation Coefficient Correlation 0.8-1.0 Very strong correlation 0.6-0.8 Strong correlation 0.4-0.6 Moderate correlation 0.2-0.4 Weak correlation 0.0-0.2 Very weak or no correlation
[0056] The correlation matrix is formed using the calculated Pearson correlation coefficient. The correlation matrix is used to represent the relationship between multiple variables. It is an n*n matrix, where n is the number of variables and each element corresponds to the correlation between each pair of variables. After obtaining the correlation matrix, as shown in Figure 2 As shown in Figure 2, a threshold is set. If the correlation between channels is less than this threshold, the corresponding value in the correlation matrix is set to 0; if it exceeds the threshold, it is set to 1. Finally, connections are formed in the graph based on the non-zero values in the matrix, thus building the graph structure.
[0057] Figure 2The correlation matrix for the 16 EEG channels of a given subject is shown. It reveals strong correlations between channels such as FP1-F3 and FP1-F7, P7-O1 and P3-O1, P6-O1 and P4-O2, P3-O2 and P3-O4, and FP2-F4 and FP2-F8, with correlation coefficients of 0.86, 0.69, 0.71, 0.77, and 0.76, respectively. Most correlations between channels are below 0.5. Adjacent channels exhibit the strongest correlations. To explore the spatial information of different channels, we model the EEG signal as a graph structure. Each EEG channel is treated as a node, and the links between nodes represent interactions between channels. Each node stores the raw EEG data for a channel. This graph is then used as input to a graph attention network (GAT) to extract spatial features between different channels. In the GAT, a self-attention mechanism dynamically calculates the relevance of each node to other nodes using the correlation coefficient as a weight, thereby promoting weighted node interactions for information propagation. In this way, GAT achieves fine-grained modeling and feature extraction of EEG signals, thereby achieving efficient and accurate detection of epileptic seizures.
[0058] Graph Attention Network:
[0059] Graph Attention Network (GAT) is a graph neural network model based on the attention mechanism for processing graph data. Research on GAT began in 2017 and has since been widely used in fields such as natural language processing, recommendation systems, and bioinformatics
[33] . The core idea of GAT is to apply the attention mechanism to each node in the graph to autonomously learn the important relationships between nodes. This enables GAT to better capture the complex structural information in the graph, outperforming traditional graph neural network models.
[0060] In recent years, GAT has garnered significant attention and achieved remarkable results in graph data processing and biomedicine. For example, GAT has been successfully applied to natural language processing tasks, achieving state-of-the-art results. GAT has also been widely used in the field of electroencephalogram (EEG) signals. For example, GAT can be used to classify and analyze EEG signals to detect epileptic activity or other abnormalities.
[0061] In EEG signal analysis, GAT can extract spatial features from EEG graphs. GAT learns the interdependencies between different leads in the EEG signal and uses these relationships for classification or other analysis. Compared to traditional graph neural network models, GAT exhibits strong learning and generalization capabilities, enabling it to capture complex structural information in EEG. Consequently, research on GAT in the EEG field has garnered widespread attention and achieved significant progress. In the field of epilepsy detection, GAT is widely used to study epileptic activity, demonstrating high accuracy and specificity. Next, we will detail the principles of GraphAttentionLayer and its application in epilepsy detection experiments.
[0062] The input of the GAT module is a set of feature vectors of the node, and the output is a set of new feature vectors of the node. To enhance the representativeness of the learned features, a shared weight matrix is applied to the linear mapping on each node. Then, the transformed features are concatenated, and the concatenated high-level features are mapped to real numbers. The formula can be expressed as:
[0063] k={k1,k2,...,k M},k i ∈R F
[0064] e ij =g(Wk i ,Wk j )
[0065] Where W represents a trainable weight matrix, e represents the correlation coefficient between two nodes, k represents the eigenvector of a node, and g represents a linear mapping. Next, we need to calculate the weights between nodes. Typically, the attention mechanism distributes attention across all nodes in the graph, which can lead to a loss of structural information. Here, we only consider the structure formed by a node's first-order neighboring nodes. The calculation is as follows:
[0066]
[0067] Where α represents the weight between nodes and V represents the set of first-order neighboring nodes of a node. Using the LeakyReLU activation function, the fully expanded formula can be expressed as:
[0068]
[0069] where a T ∈R 2Fis the parameter of the feedforward neural network, LeakyReLU is the nonlinear activation function, and || represents the vector concatenation operation. To improve the model's fitting ability, this paper adopts a multi-attention mechanism. To ensure the stability of the GAT model, the results of multiple attention mechanisms are averaged, each with different learning characteristics. Therefore, the learning characteristics of a node are calculated as follows:
[0070]
[0071] Where q represents any end of the multi-head attention mechanism, k i ′ represents the output of information aggregation from neighboring nodes.
[0072] Figure 3 The detailed computational process of the graph attention layer is described, where each patient is modeled as a graph structure. Spatial correlation aggregation is then performed to calculate the attention coefficient for each node and its neighboring nodes, thereby aggregating spatial correlations across channels. Finally, the output of the multi-attention mechanism is obtained, which forms a set of feature vectors that aggregate the spatial correlations between nodes. With the introduction of the attention mechanism, weights are only shared with neighboring nodes, without requiring information from the entire graph. If there is no connection between two nodes, their attention coefficients are not calculated. Therefore, the model has good robustness and can effectively extract spatial relationships between channels.
[0073] Transformer Network:
[0074] Compared to traditional recurrent neural networks like Bi-LSTM, the Transformer offers several advantages, particularly in processing long sequences. First, the Transformer utilizes an attention mechanism, enabling better learning of long-term dependencies. Second, its structure is simpler, as it does not require recursive connections or hidden states to retain information, enabling faster training and decision-making. These advantages make the Transformer particularly suitable for tasks involving learning from long sequences. In the field of EEG signal analysis, Transformer networks are used to detect abnormal activity in the EEG signals of epileptic patients. Leveraging their powerful pattern recognition capabilities, Transformer models can identify complex patterns in time series data. In epilepsy detection, Transformers are used to identify EEG signals preceding epileptic seizures, promoting early diagnosis and prevention. Furthermore, Transformers can classify different types of epileptic seizures and assess the severity of epilepsy in patients.
[0075] Overall, significant progress has been made in applying Transformers to EEG signals and epilepsy detection. Their ability to efficiently process variable-length sequences and high-dimensional data underscores their critical role in the early diagnosis and prevention of epileptic seizures. Next, we will delve deeper into the principles of Transformer networks and their application in epilepsy detection experiments.
[0076] We use a Transformer to extract temporal information from the EEG. The output of the GAT is linearly encoded and mapped. Positional embeddings are then added to the flattened 2D slice elements before entering the Transformer encoder. Finally, a softmax function is used for classification.
[0077] To match the input to the Transformer encoder, input x′∈R M×F′ It is split into a series of flat 2D slices of fixed size μ1×μ2. Therefore, each slice represents 1 second of multi-channel EEG signal. All slices are then mapped to a higher dimension for further training through a linear projection layer. In addition, to obtain global correlation, a class label X' is added, which is also the element used for the final classification task. The Transformer model processes the sequential data as a whole. To enable the model to understand position information, the position encoding vector is added to the input embedding. The core idea is to provide practical distance information in the attention calculation.
[0078] The values of the encoding vector usually follow a specific pattern. In this work, sine and cosine functions are chosen as encoding vectors. Based on this, the standard one-dimensional position EPOS∈R (N+1)×D Added to the slice embedding. The final input to the Transformer encoder is:
[0079]
[0080] We try to encode the input vector through the encoder module. The Transformer architecture consists of L stacked encoder modules. Each layer consists of two submodules: a multi-attention mechanism and a fully connected feedforward network, whose structure is as follows Figure 4 As shown in Figure 2. Each Transformer encoder uses a residual network to preserve input feature information and enhance model stability. The Transformer encoder input is first processed by a self-attention mechanism. During the computation, multiple attention layers are used to enhance the performance of the self-attention layer. The feature vector is then further embedded through a feedforward neural network. The specific computational process is as follows:
[0081] H l ′=MSA(LN(H l-1))+H l-1 ,l=1,2,...,L
[0082] H l =MLP(LN(H l ′))+H l ′,l=1,2,...,L
[0083] Among them, H l-1 Represents the input of the encoder, H l Represents the output of the encoder, and L is set to 4.
[0084] Loss function:
[0085] Class imbalance between positive and negative samples is a common problem in epilepsy detection. When the number of positive and negative samples is unbalanced, the model tends to favor the majority class, resulting in poor recognition of the minority class. To address this imbalance in EEG-based epilepsy seizure detection, this model introduces a focal loss function. The focal loss function aims to optimize classifier performance by adjusting the classifier's focus during training.
[0086] In the context of epilepsy detection research, the focal loss function has been used to enhance the performance of EEG classifiers. By assigning a larger weight to minority class samples and a smaller weight to majority class samples in the loss function, the focal loss function allows the model to focus more on minority class samples. This approach improves the sensitivity and specificity of epilepsy detection algorithms by prioritizing classification accuracy.
[0087] In the epilepsy detection task in this chapter, the classifier is trained with unbalanced samples. The focal loss function can solve the problem of sample imbalance, which is more in line with clinical medical practice.
[0088] The focal loss function modifies the cross entropy loss function by down-weighting the majority of samples during training. The binary cross entropy loss function is given by:
[0089]
[0090] In this equation, y represents the true label, and p is the output of the activation function (such as the sigmoid function), which ranges from 0 to 1. In this case, the loss function will dominate the direction of gradient descent, but due to sample imbalance, it may mask the influence of minority class samples.
[0091]
[0092] Here, α balances the importance of majority and minority samples, while γ adjusts the reduction rate. When γ = 0, the cross-entropy loss function and the focal loss function are equivalent. When γ > 0, the loss of easily classified samples is reduced, causing the model to pay more attention to difficult-to-classify samples. As γ increases, the impact of the adjustment factor also increases.
[0093] Based on the above technical solution, the following experiments and experimental results are provided.
[0094] Dataset
[0095] CHB-MIT dataset
[0096] The CHB-MIT dataset is a public dataset for epilepsy detection and diagnosis jointly established by the Massachusetts Institute of Technology (MIT) and the National Institutes of Health (NIH)
[38] . The dataset includes EEG data from 23 patients with intractable epilepsy, divided into 24 records, as shown in Table 2-1. Each case contains 9 to 42 consecutive .edf files from a single subject, and each patient has two hours or more of recording. It includes known epilepsy patients and non-epileptic subjects as controls. EEG signals are recorded from 18 electrodes, including 6 frontal electrodes, 6 top electrodes, and 6 temporal electrodes. All signals are sampled at 16-bit resolution and 256 Hz. The CHB-MIT dataset captures long-term multi-channel EEG recordings from children with intractable epilepsy and can be accessed through PhysioNet.org. These recordings follow international standards and have a total duration of 979 hours.
[0097] Due to the variability of EEG electrodes collected from each patient, we selected a set of 16 common channels from 16 patients. In the CHB-MIT dataset, we selected the following 16 channels: “FP1-F7”, “F7-T7”, “T7-P7”, “P7-O1”, “FP1-F3”, “F3-C3”, “C3-P3”, “P3-O1”, “FP2-F4”, “F4-C4”, “C4-P4”, “P4-O2”, “F8-T8”, “FZ-CZ”, “CZ-PZ”, and “FP2-F8”.
[0098] In the CHB-MIT dataset, EEG consists of long-term signals that are segmented into smaller slices. A sliding window is used to segment the long-term EEG signal into small segments. Each window lasts for 1 second, with an overlap ratio of 0.5. For example, given a 60-second EEG signal with a sampling frequency of 1 Hz, the dimension of the EEG signal is 60. After data segmentation, there will be 119 segments. Using the proposed method, these segments are analyzed and labeled in a continuous order. Single-subject experiments are performed with 3000 seconds of signal from each patient. To ensure sample balance, the positive-to-negative ratio is set to 1:1. Therefore, the duration of both epileptic seizure and normal signals is 1500 seconds. If the duration of a patient's epileptic seizure signal is less than 1500 seconds, oversampling is used. In addition, this paper uses 10-fold cross-validation to ensure the stability of the experiment.
[0099] TUH dataset
[0100] The TUH dataset is a large-scale multimodal EEG database that includes long-term EEG recordings and related clinical information from more than 2,000 patient cases. It was created by Temple University Medical Center and the Institute of Neuroscience in the United States to promote neuroscience research and the development of EEG signal processing algorithms
[39] . The dataset includes a large amount of EEG data collected using advanced medical equipment, including routine EEG, long-term EEG, and continuous EEG. It also includes clinical information related to EEG, such as patient history, diagnosis, and treatment plan. The TUH dataset is a very valuable resource for studying EEG and magnetoencephalography data, which is applicable to various research fields, including epilepsy detection, stroke diagnosis, brain injury treatment, etc. In addition, the TUH database is open to the public, allowing free access to its content. It contains more than 25,000 EEGs, as well as neurologist diagnosis records, patient history, gender, and age information. The EEG data is stored in the .edf file format, thereby preserving important metadata.
[0101] The TUSZ dataset, a subset of the TUH dataset, contains EEG data from 593 epilepsy patients, totaling 393.58 hours. The patients' ages ranged from 1 month to 83 years, with roughly equal gender distribution. Each patient underwent multiple EEG recordings, ranging in length from a few minutes to several hours. The EEG data varied in the number of channels, sampling length, and electrode layout. The raw signals were sampled at 250 Hz, with each recording having 20 to 128 channels. The TUSZ dataset provides rich clinical annotation information, including basic patient information, epilepsy type, medication details, medical images, surgical records, and more. These annotations make the TUSZ dataset an ideal resource for automated epilepsy detection and classification. The main directory of the TUSZ dataset includes a CSV file containing metadata about each patient and their samples, such as patient ID, sample ID, sample duration, and sample type (normal or epileptic). Each patient in the TUSZ dataset has a separate folder named after the patient ID. Within each patient's folder, there's a subfolder named "seizures" containing data files for all seizure cases, and a subfolder named "no_seizures" containing data files for all normal cases. Each data file is in .edf format and contains one or more EEG signal recordings, along with metadata such as sampling frequency and number of channels. This experiment is based on TUH version 1.5.1, and the dataset is being continuously updated.
[0102] In this work, we utilized the TUH dataset to validate the stability of our model. We selected 20 electrodes from the TUH dataset, including FP1-F7, F7-T3, T3-T5, T5-O1, FP2-F8, F8-T4, T4-T6, T6-O2, T3-C3, C3-CZ, CZ-C4, C4-T4, FP1-F3, F3-C3, C3-P3, P3-O1, FP2-F4, F4-C4, C4-P4, and P4-O2. For experiments involving single-subject validation, we selected 10 patients due to the significant inter-patient variability in the TUH dataset. The sample duration for each patient was set to 3000 seconds, with a positive-to-negative ratio of 1:1. We employed ten-fold cross-validation to ensure the stability of our experimental results, following a similar approach to the CHB-MIT dataset.
[0103] Experimental setup and evaluation metrics
[0104] In this experiment, we used a one-second sliding window to analyze EEG recordings from different channels. Due to the scarcity of seizure samples in the dataset, we used an overlapping window method with an overlap ratio of 0.5 to segment the seizure data. The test data was normalized using the mean and variance of the historical training data from the same patient.
[0105] The evaluation indicators selected in this paper include: accuracy, sensitivity, specificity, F1 score and AUC. The specific calculation method is as follows:
[0106] (1) Accuracy: the ratio of the number of correctly predicted samples to the total number of samples.
[0107]
[0108] (2) Sensitivity: Sensitivity represents the proportion of positive cases that are correctly identified as positive. Numerically, it is equal to recall. It indicates the sensitivity of the test method to the disease. A highly sensitive test method means that it can detect as many diseases as possible without missing any diagnoses.
[0109]
[0110] (3) Specificity: Specificity refers to the proportion of negative cases that are correctly identified as negative. It indicates the specificity of the test method for non-disease cases. A high specificity test method means that it can correctly diagnose healthy individuals as negative as much as possible, and will not mistakenly diagnose them as diseased.
[0111]
[0112] (4) F1 score: The F1 score is the harmonic mean of precision and recall. It reflects the balance between accurately predicting positive samples and recalling all positive samples. A higher F1 score indicates that the model can accurately predict positive samples while recalling as many positive samples as possible. In the field of epilepsy detection, the F1 score is an important evaluation metric because epilepsy is a serious disease that requires as many tests as possible while minimizing misdiagnosis.
[0113]
[0114] (5) AUC: The area under the ROC curve (AUC) reflects the trade-off between the true positive rate and the false positive rate in the model prediction and is used to measure the binary classification model.
[0115] In the above evaluation metrics: TP (True Positive) represents the number of correctly detected epileptic seizure segments. FN (False Negative) represents the number of incorrectly identified epileptic seizure segments. TN (True Negative) represents the number of correctly detected non-epileptic segments. FP (False Positive) represents the number of non-epileptic segments incorrectly detected as epileptic.
[0116] Ablation experiments
[0117] To validate the contribution of the combined GAT and Transformer model, we conducted ablation experiments, first comparing the GAT model, the Transformer model, and the combined GAT-Transformer model. To ensure experimental fairness, the model parameters were set identically, as shown in Table 2. Compared to the individual models, the combined model demonstrated significant improvements in accuracy, sensitivity, and specificity. For example, on the CHB-MIT dataset, the GAT-Transformer model achieved at least two percentage points higher accuracy, sensitivity, and specificity than using GAT and Transformer alone. Similar results were observed on the TUH dataset.
[0118] Compared to using GAT and Transformer separately, the GATTransformer model performed best, as confirmed in both datasets. Due to its ability to effectively exploit the temporal and spatial relationships between EEG channels, the combined model showed significantly enhanced learning ability.
[0119] Table 2. Comparison of ablation experiment results
[0120]
[0121] Single-person experiment
[0122] The proposed method was further validated by conducting 10-fold cross-validation experiments on the CHB-MIT and TUH datasets of individual patients. Each patient's seizure and non-seizure samples were divided into 10 folds, ensuring that each fold contained both seizure and non-seizure samples to capture the characteristics and variations of both classes during training.
[0123] The performance of the GATTransformer architecture for epileptic seizure detection was evaluated by comparing overall accuracy, sensitivity, specificity, and F1 score. To reduce overfitting, all experiments were repeated 10 times. The average results across all patients are shown in Tables 3 and 4.
[0124] On the CHB-MIT dataset, the method achieved average accuracy, sensitivity, and specificity of 98.52%, 97.75%, and 94.34%, respectively. On the TUH dataset, the average accuracy, sensitivity, and specificity were 98.02%, 97.70%, and 99.06%, respectively. The sensitivity exceeded 95% for most patients, and reached 100% for a few.
[0125] In terms of specificity, 30 patients had a specificity value exceeding 90%. Only 4 patients had a specificity below 90%, partly due to the small number of seizures and significant external noise affecting the scalp EEG recordings.
[0126] On the CHB-MIT dataset, the F1 score and AUC were 95.9% and 96.81%, respectively, while on the TUH dataset, the F1 score was 97.86% and the AUC was 97.80%. These results indicate that the accuracy and stability of the model are satisfactory and can help clinicians make diagnoses.
[0127] In addition, in all scenarios, all p-values are less than 0.005, indicating that there are significant differences in the decision variables learned by the model, further confirming the effectiveness of the proposed method.
[0128] Table 3. GATTransformer cross-experiment results (CHB-MIT dataset)
[0129]
[0130] Table 4. GATTransformer frequency division experiment results (TUH dataset)
[0131]
[0132]
[0133] As shown above, this study conducted experiments on the publicly available EEG datasets CHB-MIT and TUH. The proposed detection model outperformed or performed on par with existing technologies on both datasets, fully validating the model's effectiveness in epileptic seizure detection.
[0134] Therefore, this application first constructs a graph structure based on the patient's multi-channel original EEG signals to deeply describe the spatial characteristics of the EEG signals. The Pearson correlation coefficient is used to calculate the correlation values between different channels, and based on these correlations, the input samples are modeled as a graph structure. Each channel is regarded as a node, the correlation coefficients between different channels are regarded as connection weights, and the original signal values represent the node features. The nodes of the graph structure represent various channels, and the connecting lines represent the correlations between channels. Then, an automatic epilepsy detection model based on GraphAttentionNetworks (GAT) and Transformer network is constructed. GAT is used as the front end and the Transformer network is used as the back end. The GAT layer aggregates the spatial features between channels, and then sends the output feature map to the Transformer network for temporal feature extraction and binary epilepsy classification. Finally, the model is experimentally tested and its performance is verified on the CHB-MIT and TUH datasets, which fully demonstrates the effectiveness of the proposed method.
[0135] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0136] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only intended to help understand the core concept of the present invention. At the same time, those skilled in the art will find that the specific implementation methods and application scopes may vary based on the concept of the present invention. In summary, the contents of this specification should not be construed as limiting the present invention.
Claims
1. A method for detecting epilepsy based on electroencephalogram signals, characterized in that: include: Obtaining multi-channel original EEG signals of the subject to be tested; Preprocessing the multi-channel raw EEG signals and constructing a graphical structure for describing the spatial characteristics of the EEG signals; the graphical structure includes nodes and connecting lines, where the nodes represent the channels and the connecting lines represent the correlation coefficients between the channels; The final epilepsy detection result is determined based on the graph structure and the epilepsy detection model; the epilepsy detection model includes a graph attention network, a Transformer network, and a Softmax classifier connected in sequence; wherein the graph attention network is used to aggregate spatial features between channels, the Transformer network is used to extract temporal features, and the Softmax classifier is used to perform binary epilepsy classification.
2. The epilepsy detection method based on electroencephalogram signals according to claim 1, characterized in that: Preprocessing the multi-channel raw EEG signals and constructing a graphic structure for describing the spatial characteristics of the EEG signals, specifically including: Dividing the multi-channel original EEG signal into multiple segments, passing the signal time window of each segment through a bandpass filter, and then performing normalization processing to obtain pre-processed segmented data; Calculate the Pearson correlation coefficient between channels based on the segmented data, and construct a correlation matrix based on the correlation coefficient. For any component element in the correlation matrix, if it is less than a set threshold, it is set to 0; if it is greater than or equal to the set threshold, it is set to 1; The non-zero values in the matrix are connected, and the correlation coefficient is used as the connection weight to obtain a graphical structure for describing the spatial characteristics of the EEG signal.
3. The epilepsy detection method based on electroencephalogram signals according to claim 1, characterized in that: Determining a final epilepsy detection result based on the graphic structure and the epilepsy detection model includes: Inputting the image structure into the graph attention network for iterative operation to obtain a new graph structure with aggregated channel adjacent node features; Inputting the new graph structure into the Transformer network to extract temporal features, thereby obtaining a feature graph with spatiotemporal features; The feature map is input into the Softmax classifier for binary epilepsy classification to obtain the final epilepsy detection result.
4. The epilepsy detection method based on electroencephalogram signals according to claim 1, characterized in that: The Transformer network consists of L stacked encoder modules, each of which includes a multi-attention mechanism and a fully connected feedforward network; each encoder module adopts residual connection.
5. The epilepsy detection method based on electroencephalogram signals according to claim 1, characterized in that: Also includes: Training the epilepsy detection model; The training process is as follows: Obtaining a training data set; the training data set includes training data and corresponding training labels; Build a pre-trained network; The training data is input into the pre-trained network, and iterative training is performed with the goal of minimizing the loss between the network output and the training label, and the trained pre-trained network is determined as an epilepsy detection model; wherein the loss function in the iterative training adopts a focal loss function.
6. An epilepsy detection system based on electroencephalogram signals, characterized in that: include: A data acquisition unit, used to obtain multi-channel original EEG signals of the subject to be tested; A data processing unit, configured to pre-process the multi-channel raw EEG signals and construct a graphical structure for describing the spatial characteristics of the EEG signals; the graphical structure includes nodes and connecting lines, where the nodes represent the channels and the connecting lines represent the correlation coefficients between the channels; An epilepsy detection unit is configured to determine a final epilepsy detection result based on the graph structure and the epilepsy detection model; the epilepsy detection model comprises a graph attention network, a Transformer network, and a Softmax classifier connected in sequence; wherein the graph attention network is configured to aggregate spatial features between channels, the Transformer network is configured to extract temporal features, and the Softmax classifier is configured to perform binary epilepsy classification.
7. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the epilepsy detection method based on electroencephalogram signals according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that It stores a computer program, which, when executed by a processor, implements the epilepsy detection method based on electroencephalogram signals as described in any one of claims 1 to 5.
Citation Information
Cited By
Epilepsy prediction system based on multivariate weighted joint recursion and graph attention network
CN120859445A