Automatic detection method of epilepsy based on multi-scale attention
By using a lightweight multi-scale attention network, combined with multi-scale principal component analysis and spatiotemporal feature extraction, the problem of insufficient real-time performance and accuracy in epilepsy detection in existing technologies is solved, and rapid and efficient automatic epilepsy detection is achieved.
Patent Information
- Application Number
- CN202410043702.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-11
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2044-01-11
AI Technical Summary
Existing deep learning-based automated epilepsy detection methods have poor real-time performance, which cannot meet clinical needs, and their accuracy is low due to the influence of doctors' subjective factors.
A lightweight multi-scale attention network is designed. Multi-scale principal component analysis is used to remove the correlation components of EEG signals. The multi-scale attention module is used to capture the information flow between leads. Features are extracted by combining the spatiotemporal module. Deep and shallow features are fused through residual network. Finally, multi-scale spatiotemporal features are reconstructed based on attention weighting mechanism for epilepsy detection.
It achieves rapid and high-precision detection of epilepsy signals, meeting the needs of real-time clinical detection and improving the accuracy and efficiency of detection.
Smart Images

Figure CN117909822B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of diagnostic and therapeutic technology, and proposes an automatic epilepsy detection method based on multi-scale attention by using multi-scale principal component analysis (MSPCA) algorithm to remove the correlated components of EEG signals. Background Technology
[0002] Epilepsy is a chronic neurological disease that seriously threatens patients' lives. Electroencephalography (EEG) is a crucial tool for clinical monitoring of epilepsy; however, manual testing results are subject to subjective factors from doctors, resulting in low accuracy. Deep learning-based automated epilepsy detection can avoid this problem and has attracted considerable attention from researchers. Currently, most studies utilize simple EEG preprocessing methods, complex EEG signal brain network feature extraction methods, and deep neural networks to extract the spatiotemporal features of signals. These methods result in long detection times, failing to meet the real-time requirements of automated clinical epilepsy detection. This invention designs a lightweight, multi-scale attention-based automated epilepsy detection network, which can rapidly achieve high-precision detection of epilepsy signals. Summary of the Invention
[0003] To address the current state of research, this invention proposes an automated epilepsy detection method based on multi-scale attention. To remove interference noise from epilepsy signals and rapidly and effectively utilize their inter-lead information flow, spatiotemporal features, multi-scale features, and implicit inter-scale correlations, this invention first uses multi-scale principal component analysis to remove correlation components between EEG signal leads. Then, a multi-scale attention module captures the inter-lead information flow at different scales of the EEG signal and amplifies the differences between leads. Next, a spatiotemporal module extracts spatiotemporal features based on one-dimensional convolution and fuses deep abstract features and shallow fine-grained features using a residual network. Finally, a scale reconstruction module captures the implicit correlation matrix between spatiotemporal scale features, and an attention-weighted mechanism reconstructs the multi-scale spatiotemporal features of the signal, ultimately achieving automated epilepsy detection.
[0004] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0005] Step 1: Dataset Segmentation and Balancing. For epilepsy EEG data, the data from the 20 minutes before a seizure, the 5 minutes after a seizure, and the 30 minutes between seizures are divided into pre-ictal, ictal, and interictal phases, respectively. A sliding window technique is used to balance the dataset, with a fixed window size of 4 seconds. A sliding window based on a dynamic step size is used to segment the ictal phase data, while a sliding window with a fixed step size and no window overlap is used for the interictal phase. Then, 80% and 20% of the samples in the dataset are selected as the training and test sets, respectively.
[0006] Step 2: Data preprocessing based on multi-scale principal component analysis (MSPCA). The original 23-lead EEG signal is first divided into different frequency bands using discrete wavelet transform. Signals from the same frequency band are then combined, and initial denoising is performed using principal component analysis (PCA) and wavelet thresholding. The signal is then reconstructed using wavelets, and finally, PCA is used for secondary denoising. The final output signal serves as the input feature for the network model.
[0007] Step 3: Establish a neural network based on multi-scale attention. The model consists of an input layer, a multi-scale attention module, a spatiotemporal feature extraction module, a scale reconstruction module, a classification module, and an output layer. The input layer is an n*s 2D matrix, where n is the number of leads and s is the length of the time segment. The multi-scale attention module first acquires the information outflow intensity between leads and outputs an attention matrix of dimension (23*23) through an attention module composed of linear layers. Then, it further weights the matrix onto the original signal to reconstruct the original EEG signal. Next, a pattern layer is constructed by six multi-scale attention pattern layers, deep convolutional blocks with kernel size (1,2) and stride of 2, and attention blocks based on linear+ELU layers. This pattern layer can capture the information flow between leads at different scales of the signal and reconstruct the extracted multi-scale features of the signal based on the attention weighting mechanism. Two to five multi-scale features are selected as the output. The spatiotemporal feature module has six layers, each consisting of two pattern layers based on convolution, normalization, and ReLU activation functions. The pattern layers are fused using a residual network for deep and shallow feature fusion. Then, the scale reconstruction module further captures the implicit correlation matrix between scales based on the attention layer and reconstructs the extracted multi-scale spatiotemporal features based on the attention weighting mechanism. Finally, the classification module, composed of two fully connected layers and log-softmax, realizes the automatic classification of epilepsy signals.
[0008] Step 4: Train the network model. First, divide the training set into batches of 32 and input them into the network model for training. After training, calculate the accuracy on the test set. Then, iteratively train the network parameters until the accuracy changes little during training, at which point training stops and the network model parameters are recorded.
[0009] Compared with the prior art, the present invention has the following advantages:
[0010] (1) To address the problem of poor real-time performance of current deep learning-based automatic epilepsy detection, a lightweight multi-scale attention network, spatiotemporal feature extraction network, and scale reconstruction network are used to extract the representative features of EEG signals in real time and effectively, thereby achieving automatic epilepsy detection. Attached Figure Description
[0011] Figure 1 This is the overall process of epilepsy detection methods.
[0012] Figure 2 It is a multi-scale attention network structure.
[0013] Figure 3 It is the overall process of model training and channel selection. Detailed Implementation
[0014] The present invention will now be described in detail with reference to specific implementation examples. These examples are provided to enable those skilled in the art to understand the specific process of the invention, but are not intended to limit the invention in any way. Furthermore, variations and improvements can be made based on the present invention without departing from its conceptual framework.
[0015] Deep learning-based epilepsy detection effectively utilizes the multi-scale features of EEG signals, demonstrating significant development potential. Related research employs complex algorithms or neural network techniques to extract brain network features from EEG signals, which are then directly used as classification features or further used to construct attention features to enhance the discriminative power of the original EEG signals. Some studies utilize deep two-dimensional convolution to extract temporal and spatial features. While these methods achieve good classification results, their implementation is complex, and the deep network dimensions prevent them from meeting the real-time clinical detection requirements. This invention designs a lightweight multi-scale attention network to achieve automatic detection of epilepsy signals.
[0016] The overall approach to epilepsy detection methods is as follows: Figure 1 It is mainly divided into three parts: data preprocessing, deep learning network construction, model training and testing.
[0017] Part 1: Data Preprocessing.
[0018] First, the CHB-MIT public dataset edf file was converted to a mat file using MATLAB. Then, the data was segmented into interictal, preictal, and ictal phases. Next, dynamic and static sliding window techniques were used to balance the dataset. Finally, the signal was denoised using the MSPCA algorithm. The original 23-lead EEG signal was first divided into different frequency bands using discrete wavelet transform. The 23-lead signals of the same frequency band were then combined, and principal component analysis (PCA) and wavelet thresholding were used to complete the initial denoising. The signal was then reconstructed using wavelet, and finally PCA was used to complete the secondary denoising. The final output signal was used as the input feature of the network model.
[0019] Part Two: Building a Deep Learning Network
[0020] First, a multi-scale attention module is established for the network. Its input is an n*s 2D matrix, where n is the number of leads and s is the length of the time segment. The module first obtains the information outflow intensity between leads through an attention module composed of linear layers and outputs an attention matrix with a dimension of (23*23). Then, it is further weighted onto the original signal to reconstruct the original EEG signal. Subsequently, a pattern layer composed of six multi-scale attention pattern layers, deep convolutional blocks with a kernel size of (1,2) and a stride of 2, and attention blocks based on linear+ELU layers can capture the information flow between leads at different scales of the signal and reconstruct the extracted multi-scale features of the signal based on the attention weighting mechanism. Two to five layers of multi-scale features are selected as the output.
[0021] Secondly, a spatiotemporal feature extraction module for the network is established. The module first extracts spatiotemporal features of multi-scale signals through two layers of spatiotemporal feature extraction blocks. The spatiotemporal feature extraction blocks are composed of one-dimensional convolution, normalization and ReLU activation functions. Then, a residual network is used to fuse the spatiotemporal features of deep and shallow layers to avoid missing the fine-grained features of shallow networks. Finally, a global average pooling layer is used to reduce the dimensionality of network features in order to accelerate the training speed of the network.
[0022] Then, a scale feature reconstruction module for the network is established. Based on a fully connected layer with a dimension of 1*(5*5), the implicit correlation features between multi-scale spatiotemporal features are captured and flattened into a 5*5 implicit correlation matrix. Then, based on the attention weighting mechanism, the differences between scale features are expanded, and a highly representative multi-scale spatiotemporal feature is constructed as the output.
[0023] Finally, a classification module is established. This module can further reduce the dimensionality of the spatiotemporal features of the previous layer input through two fully connected layers, and perform the final classification task based on log-softmax to reduce or avoid computational overflow.
[0024] Part 3: Training and testing of multi-scale attention network models.
[0025] The model first randomly groups the input dataset, then uses the leave-one-out-of-five method to divide the dataset into training and test sets, updating the network's input layer. Next, the training set is input into the network for parameter training. During training, the dataset is further divided into 32 batches, and the network model is trained based on these batches to prevent overfitting. When all batches have finished training, the average accuracy is calculated. If the accuracy is higher than the previous accuracy, the network parameters corresponding to the latest accuracy are recorded, and training continues. If the result is lower than the previous accuracy, training continues until the threshold is reached. If the threshold is reached, training ends.
[0026] To evaluate the model's efficiency, this invention uses F1 score, sensitivity, precision, and accuracy metrics to analyze the results, and compares the invented method with state-of-the-art methods for epilepsy detection. On the CHB-MIT dataset, the method achieves good average seizure detection rates of 98.55%, 98.75%, 98.57%, and 98.62% in 23 subjects, demonstrating its feasibility and superiority.
[0027] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the substantive content of the present invention. Unless otherwise specified, the embodiments and features of the present invention can be arbitrarily combined with each other.
Claims
1. An automated epilepsy detection method based on multi-scale attention, characterized in that, Includes the following steps: Step 1: Dataset Segmentation and Balancing; For epileptic EEG data, the data from the 20 minutes before a seizure, the 5 minutes after a seizure, and the 30 minutes between two seizures are divided into pre-ictal, ictal, and interictal phases, respectively; A sliding window technique is used to balance the dataset, with a fixed window size of 4 seconds. A sliding window based on a dynamic step size is used to segment the ictal phase data, while for the interictal phase, a sliding window with a fixed step size and no window overlap is used; Then, 80% and 20% of the samples in the dataset are selected as the training and test sets, respectively. Step 2: Data preprocessing based on multi-scale principal component analysis (MSPCA); the original 23-lead EEG signal is first divided into different frequency bands using discrete wavelet transform, and then the 23-lead signals of the same frequency band are combined. The initial denoising of the signal is completed by principal component analysis (PCA) and wavelet threshold denoising. Then, the signal is reconstructed by wavelet, and finally the signal is denoised again by PCA. The final output signal is used as the input feature of the network model. Step 3: Establish a neural network based on multi-scale attention. The model consists of an input layer, a multi-scale attention module, a spatiotemporal feature extraction module, a scale reconstruction module, a classification module, and an output layer. The input layer is an n*s 2D matrix, where n is the number of leads and s is the length of a time segment. The multi-scale attention module first obtains the information outflow intensity between leads through an attention module composed of linear structures and outputs an attention matrix with a dimension of (23*23). Then, it further weights the matrix to the original signal to reconstruct the original EEG signal. Finally, it passes through a deep convolutional block composed of six multi-scale attention pattern layers with a kernel size of (1,2) and a stride of 2, and a linear+ELU layer. Attention blocks form pattern layers, which can capture the information flow between leads at different scales of the signal and reconstruct the extracted multi-scale features of the signal based on the attention weighting mechanism. Two to five layers of multi-scale features are selected as output. The spatiotemporal feature module has six layers, each consisting of two pattern layers based on convolution, normalization and ReLU activation functions. The pattern layers are fused using a residual network for deep and shallow feature fusion. Then, through the scale reconstruction module, the implicit correlation matrix between scales is further captured based on the attention layers and the extracted multi-scale spatiotemporal features are reconstructed based on the attention weighting mechanism. Finally, through the classification module, which consists of two fully connected layers and log-softmax, the automatic classification of epilepsy signals is achieved. Step 4: Train the network model; First, divide the training set into 32-bit batches and input them into the network model for training. After training, calculate the accuracy of the test set. Then, iterate the training of the network parameters until the accuracy changes little during training. Stop training and record the network model parameters at this time.
2. The automatic epilepsy detection method based on multi-scale attention according to claim 1, characterized in that, Attention weighting mechanism and signal multi-scale feature representation based on multi-scale attention module, spatiotemporal feature extraction based on spatiotemporal extraction module, and inter-scale implicit feature extraction and scale feature reconstruction based on scale reconstruction module.
3. The automatic epilepsy detection method based on multi-scale attention according to claim 1, characterized in that, In the epilepsy detection method, the attention weighting mechanism method amplifies the differences in signals between leads based on the information interaction features between leads; the information interaction features are captured by a neural network, and the multi-scale feature expression of the signal is based on the extraction of features at different scales of the signal at the channel level based on one-dimensional deep convolution.
4. The automatic epilepsy detection method based on multi-scale attention according to claim 1, characterized in that, The key feature of spatiotemporal feature extraction lies in extracting spatiotemporal features based on one-dimensional convolution and fusing deep abstract features and shallow fine-grained features based on residual networks.
5. The automatic epilepsy detection method based on multi-scale attention according to claim 1, characterized in that, The features of inter-scale implicit feature extraction and scale feature reconstruction are as follows: The implicit correlation matrix of scale elements is captured based on a fully connected network, and scale features are reconstructed based on an attention mechanism.
Citation Information
Patent Citations
Epileptic intracranial electroencephalography signal warning method based on deep convolutional attention network
CN113786204A
Methods and systems for brain function analysis
US20150088024A1
