System and method for classifying and identifying epilepsy in electroencephalogram signal based on time sequence
By combining cross-domain hybrid self-supervised learning and multi-scale EEG feature learning with epileptic seizure-guided self-attention learning, the problems of poor generalization ability and heavy computational burden of existing epileptic seizure recognition models are solved, and efficient and accurate epileptic seizure recognition is achieved.
Patent Information
- Application Number
- CN202510701721.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-09
AI Technical Summary
Existing epileptic seizure recognition models have poor generalization ability under individual-specific training, data imbalance leads to information loss, and heavy computational burden, which affects actual clinical applications.
A cross-domain hybrid self-supervised learning module, a multi-scale EEG feature learning module and an epileptic seizure-guided self-attention learning module are adopted, combining time domain, spatial domain and frequency domain features, and through self-supervised learning tasks and multi-task training, the recognition accuracy and robustness of the model are improved.
The accuracy and robustness of epileptic seizure identification were improved, the false alarm rate was reduced, and the adaptability and generalization ability of the model were enhanced in different patient groups and environments.
Smart Images

Figure CN120611239A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent medical signal processing, and in particular to a system and method for classifying and identifying epilepsy in electroencephalogram (EEG) signals based on time series. Background Art
[0002] Epilepsy is a chronic neurological disease caused by sudden abnormal, hypersynchronized discharges of groups of brain neurons, manifesting as transient brain dysfunction. Epileptic seizures are often random, repetitive, and stereotyped, severely impacting patients' quality of life and health. Epileptic seizures can not only lead to loss of control of a patient's physical and cognitive functions, but can also cause sudden death from epilepsy. Therefore, timely and accurate identification of epileptic seizures is of great clinical significance for the diagnosis and treatment of patients. Epileptic seizures are often accompanied by abnormal electrical activity in the brain, and electroencephalography (EEG) is a non-invasive neuroimaging technique that records brain electrical activity. EEG has high temporal resolution and can capture the dynamic process of neuronal discharges in real time. By analyzing the time, frequency, and spatial domain features of EEG signals, clinicians can identify the characteristic patterns of abnormal discharges and determine the occurrence, type, and severity of epileptic seizures.
[0003] However, current epileptic seizure identification relies primarily on manual analysis of EEG signals by clinicians. Doctors typically need to screen long EEG recordings frame by frame for abnormal waveforms associated with epilepsy, such as spikes, sharp waves, or rhythmic discharges. This process is extremely time-consuming and requires a high level of experience and expertise from the analyst. Furthermore, due to the subjectivity of manual judgment, identification results between different doctors are often inconsistent and have a high rate of misjudgment. This inefficient and error-prone identification method has significant limitations in real-world clinical settings.
[0004] To address this issue, automatic epileptic seizure recognition methods based on deep learning have received widespread attention in recent years. Deep learning models can automatically extract features from large amounts of EEG data, significantly improving recognition accuracy and efficiency. However, existing epileptic seizure recognition models often adopt individual-specific training strategies, that is, model training is performed on specific patients. Although this method may show good detection performance on specific individuals, the model's generalization ability is poor, and it is difficult to maintain stable detection performance in different patient groups. In addition, epileptic EEG data is significantly unbalanced. Since epileptic seizures only occupy a very small part of the EEG recording, the ictal data is seriously insufficient compared to the large amount of interictal data. During the model training process, in order to achieve sample balance, it is usually necessary to randomly discard the interictal data, which not only wastes data resources, but may also lead to the loss of valuable sample information.
[0005] To address these issues, self-supervised learning and attention mechanisms have emerged as effective approaches to addressing the challenges of epileptic seizure identification in recent years. Cross-domain hybrid self-supervised learning, through collaborative learning across multiple feature spaces—time, space, and frequency—helps capture the potential multimodal information in EEG signals. Furthermore, the attention mechanism adaptively focuses on key features relevant to epileptic seizures, suppressing noise and redundant information, thereby improving model robustness and recognition accuracy.
[0006] Therefore, there is an urgent need for an epileptic seizure recognition model to achieve high-precision detection of epileptic seizures while reducing the computational burden to meet the needs of clinical epilepsy detection and long-term monitoring. Summary of the Invention
[0007] In response to the many shortcomings of existing epileptic seizure identification methods, the present invention proposes a system and method for classifying and identifying epilepsy in EEG signals based on time series, so as to effectively improve the accuracy and robustness of identification, while reducing the false alarm rate and computational cost. Existing methods mainly face problems such as limited model generalization ability, information loss caused by data imbalance, and computational burden caused by complex network structures, which seriously affect the application of models in actual clinical scenarios. To address these challenges, the model proposed in the present invention adopts a combination of a cross-domain hybrid self-supervised learning (CH-SSL) module, a multi-scale EEG feature learning (MEF) module, and an epileptic seizure-guided self-attention learning (SGS) module to form an end-to-end epileptic seizure identification framework.
[0008] In order to solve the problems of the prior art, the present invention adopts the following technical solutions:
[0009] A time-series-based epilepsy classification and recognition system in EEG signals, comprising: a cross-domain hybrid self-supervised learning module, a multi-scale EEG feature learning module, an epileptic seizure-guided self-attention learning module, and a classifier; the cross-domain hybrid self-supervised learning module comprises a time-domain context prediction task unit, a channel information reconstruction task unit, and a spectrum mask recognition task unit;
[0010] The cross-domain hybrid self-supervised learning module reconstructs the input EEG signal according to the time domain, spatial domain and frequency domain to obtain an EEG representation model; wherein:
[0011] The time domain context prediction task unit captures the dynamic change characteristics before and after the epileptic seizure by learning the time domain evolution law of the EEG signal;
[0012] The channel information reconstruction task unit is used to reconstruct the missing EEG signal channel data to enhance the EEG representation model's representation of spatial information;
[0013] The spectrum masking recognition task unit trains the EEG characterization model to characterize epileptic neural oscillations by randomly masking some EEG signal frequency components in the frequency domain;
[0014] The multi-scale EEG feature learning module obtains a first epilepsy EEG feature model by capturing local and global epilepsy features of the EEG representation model at different resolutions;
[0015] The epileptic seizure guided self-attention learning module optimizes the first epileptic EEG feature model by fusing temporal and spatial features to obtain a second epileptic EEG feature model;
[0016] The classifier classifies the EEG features of the second epileptic EEG feature model based on a long short-term memory network and outputs whether the EEG feature is an epileptic seizure.
[0017] Furthermore, the time-domain context prediction task unit captures the dynamic change characteristics before and after the epileptic seizure by learning the time-domain evolution law of the EEG signal; including:
[0018] The temporal context prediction task unit divides the EEG signal into several segments to capture the temporal dependency of the signal. Two prediction methods are used in task design: one is to use the current segment information to predict the next EEG signal, and the other is to use the current segment information to predict the previous EEG signal. In terms of task implementation, the temporal context prediction task unit adopts a self-supervised learning framework with an encoder-decoder structure. The self-supervised learning framework with an encoder-decoder structure consists of an encoder, a decoder, and multiple jump connections.
[0019] The encoder extracts multi-scale temporal EEG signal features,
[0020] The decoder calculates the dynamic change characteristics before and after the epileptic seizure based on the multi-scale temporal EEG features according to the following formula:
[0021]
[0022] Where M is the total number of segments, m represents the index of the signal segment currently being calculated, represents the true signal value of the m segment, represents the predicted signal value of m segments, τ, Represents the weighting factor for the forward and backward prediction errors.
[0023] Furthermore, the channel information reconstruction task unit enhances the spatial information representation process of the EEG representation model by reconstructing the missing EEG signal channel data; including: the channel information reconstruction task unit adopts an encoder-decoder structure network; wherein:
[0024] Divide the EEG signal into several EEG channel segments, and add masks to the EEG channel segments according to different brain regions;
[0025] Reconstruct the occluded EEG channel sample according to the following formula based on the information of other channels;
[0026]
[0027] Where N is the total number of samples, n is the index of the signal segment currently being calculated, and f c (n) represents the true value of the blocked channel signal, Represents the reconstructed value of the occluded channel signal;
[0028] The cross entropy between the brain region calculation of the occluded channel sample and its corresponding label is used to predict the spatial information representation of the brain region:
[0029]
[0030] Among them, j represents the brain area distribution, and j∈[0,1,2,3,4], One-Hot vector representing the true label encoding, Represents the predicted probability of the model output, μ j Represents the weight parameter, which is used to weight the samples.
[0031] Furthermore, the spectrum masking identification task unit trains the EEG characterization model to characterize the epileptic neural oscillation by masking some EEG signal frequency components in the frequency domain; comprising: the spectrum masking identification task unit adopts an encoder, a decoder and a discriminator, wherein:
[0032] Convert EEG signals from the time domain to the frequency domain and decompose them into different frequency bands (δ, θ, α, β, γ);
[0033] Filter out information of certain frequency bands and set pseudo labels to represent the index of the removed frequency bands;
[0034] A multi-layer perceptron is used to predict different frequency bands (δ, θ, α, β, γ), and the index of the masked frequency band is inferred based on the remaining frequency band information;
[0035] The time-frequency feature representation is obtained according to the following formula:
[0036]
[0037] Among them, i represents the pseudo label set, One-Hot vector representing the true label encoding, represents the predicted probability of the model output, ε i Represents the weight parameter, which is used to weight the samples;
[0038] The reconstruction loss is calculated as follows: Obtain epileptic neurological oscillations:
[0039]
[0040] Among them, f s (n) represents the true value of the spectrum mask signal, Represents the reconstructed value of the spectrum mask signal.
[0041] Furthermore, the epileptic seizure guided self-attention learning module optimizes the first epileptic EEG feature model by fusing temporal and spatial features to obtain the second epileptic EEG feature model, including:
[0042] The self-attention mechanism is used to capture the long-range temporal dependencies of EEG signals;
[0043] Through the sparse electrode adjacency matrix W se The SoftMax output of the multi-head self-attention layer is multiplied element-by-element according to the following formula, and the similarity between different channels is weighted to obtain the spatial dependency between different EEG electrodes:
[0044]
[0045] The attention matrix A(t) represents the weighted feature matrix generated by embedding the EEG signal at a specific time period t. It combines the temporal dependency of the EEG signal with the spatial interaction between channels. The calculation process is as follows:
[0046]
[0047] in: represents the EEG feature embedding in the tth time period, and and They are respectively projecting F(t) onto the query matrix Q t , key matrix K t Sum matrix V t The weight matrix, d is the scaling factor; where:
[0048] The sparse electrode adjacency matrix W se The following formula coordinates brain regions during epileptic seizures:
[0049]
[0050] Where: Dist(E X ,E Y ) represents EEG electrode E X and E Y; σ represents the standard deviation of the distance, which is used to control the scale of the Gaussian distribution.
[0051] Furthermore, the classifier classifies the EEG features of the second epileptic EEG feature model based on the long short-term memory network and outputs whether it is an epileptic seizure, including: the classifier module adopts a long short-term memory network structure, wherein:
[0052] The feature sequence extracted by the seizure-guided self-attention learning module is input into a maximum pooling layer to reduce the feature dimension while retaining key information;
[0053] The feature data are sequentially input into a long short-term memory network for time series modeling. The long short-term memory network captures long-distance temporal dependencies and feature changes across time steps in the EEG signal through a gating mechanism.
[0054] At each time step, the LSTM network generates a hidden state H based on the current input and the previous time step. t-1 Calculate the current hidden state H t , forming a dynamic feature representation; the feature vector output by the long short-term memory network is sent to the linear layer for mapping;
[0055] A random dropout layer is added after the linear layer to optimize the generalization ability of the second epileptic EEG feature model by randomly setting some neuron outputs to zero.
[0056] The mapped features are activated by the Sigmoid function to map the probability of epileptic seizure P to a probability value between 0 and 1;
[0057] P(y=1|x)=Sigmoid(W T Ht+b)
[0058] Where: W and b are the weights and biases of the linear layer;
[0059] The output layer generates a binary classification result of epileptic seizures based on the output results of Sigmoid, which is "Seizure" or "Normal", to achieve accurate identification of epileptic seizures.
[0060] The present invention can also be implemented by the following technical solution: comprising the following steps:
[0061] Pre-training phase:
[0062] The input EEG signal is reconstructed in the time domain, spatial domain and frequency domain to obtain the EEG representation model; where:
[0063] By learning the time domain evolution of EEG signals, the dynamic change characteristics before and after epileptic seizures can be captured;
[0064] Used to reconstruct missing EEG signal channel data to enhance the EEG representation model's representation of spatial information;
[0065] The EEG characterization model is trained to characterize epileptic neural oscillations by randomly masking some EEG signal frequency components in the frequency domain;
[0066] The first epilepsy EEG feature model is obtained by capturing the local and global epilepsy features of the EEG representation model at different resolutions;
[0067] The second epileptic EEG feature model is obtained by optimizing the first epileptic EEG feature model through fusing temporal and spatial features;
[0068] Classify the EEG features of the second epilepsy EEG feature model and output whether it is an epileptic seizure;
[0069] Training phase:
[0070] The epilepsy classification and recognition system is trained by the cross-domain hybrid self-supervision module, the multi-scale EEG feature learning module and the epileptic seizure-guided self-attention learning module to construct a second epilepsy EEG feature model, and the second epilepsy EEG feature model is trained by the classifier to output the final time series data.
[0071] Beneficial effects
[0072] 1. The present invention pre-trains the system by introducing a variety of self-supervised learning tasks to fully explore the potential features of EEG signals in the time, space and frequency domains. The cross-domain hybrid self-supervised learning module includes a time domain context prediction task, a channel information reconstruction task and a spectrum masking recognition task. The time domain context prediction task captures the dynamic change characteristics before and after the epileptic seizure by learning the time domain evolution law of the EEG signal. The channel information reconstruction task enhances the model's understanding of spatial information by reconstructing the missing EEG channel data. The spectrum masking recognition task trains the system's robust characterization capabilities for neural oscillation characteristics by randomly masking some frequency components in the frequency domain. Through multi-task collaborative training, the system can not only capture the dynamic characteristics of epileptic seizures, but also effectively model the interaction relationship between channels.
[0073] During the feature extraction phase, the multi-scale EEG feature learning module employs a multi-scale learning strategy to extract features from EEG signals at varying resolutions. The manifestations of epileptic seizures vary significantly between individuals, and multi-scale feature learning can capture the brain activity characteristics of epileptic patients at both local and global levels, helping to improve the model's generalization across individual scenarios. The MEF module utilizes an individual-specific feature adaptive adjustment mechanism to prevent overfitting of the model to specific patient characteristics, achieving feature normalization and correction.
[0074] To further improve the model's discriminative ability and feature characterization during epileptic seizures, the present invention proposes an epileptic seizure-guided self-attention learning module. The epileptic seizure-guided self-attention learning module models the temporal dependency and spatial correlation of EEG signals based on the self-attention mechanism. In the temporal dimension, the self-attention mechanism can capture the long-term dependencies between different time steps, thereby identifying abnormal signal changes before and after epileptic seizures. In the spatial dimension, the epileptic seizure-guided self-attention learning module introduces a sparse electrode adjacency matrix to construct a spatial interaction relationship based on the topological structure of the brain region, further improving the system's perception of the synchronous activity of brain regions during epileptic seizures.
[0075] To verify the effectiveness of the model of the present invention, the present invention collected EEG data including epileptic seizures and interictal periods from a large public epileptic seizure EEG database, and divided the data set into training, validation, and test sets according to patient independent distribution to ensure the independence of the model on data from different patients. Experimental results show that the model proposed by the present invention outperforms existing methods in multiple evaluation indicators, showing higher recognition accuracy and lower false alarm rate. At the same time, due to the use of a self-supervised pre-training strategy and a multi-scale feature learning mechanism, the model of the present invention shows significant robustness and generalization ability in data imbalance and cross-individual recognition tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 This is a flowchart of the overall framework of the time series data classification method based on the cross-domain hybrid self-supervised attention network described in an embodiment of the present invention, which mainly includes a cross-domain hybrid self-supervised learning module (CH-SSL), a multi-scale EEG feature learning module (MEF) and an epileptic seizure-guided self-attention learning module (SGS).
[0077] Figure 2 This is a specific structural framework diagram of the cross-domain hybrid self-supervised learning module described in an embodiment of the present invention, which includes three self-supervised tasks: time domain context prediction, channel information reconstruction, and spectrum mask recognition.
[0078] Figure 3 This is a specific structural framework diagram of the multi-scale EEG feature learning module described in an embodiment of the present invention.
[0079] Figure 4 This is a specific structural framework diagram of the epileptic seizure-guided self-attention learning module described in an embodiment of the present invention. DETAILED DESCRIPTION
[0080] The following is combined with Figure 1 The present invention is described as follows:
[0081] The present invention provides a system and method for classifying and identifying epilepsy in EEG signals based on time series. Specifically, the time series data classification model based on the cross-domain hybrid self-supervised attention network mainly includes a cross-domain hybrid self-supervised learning module, a multi-scale EEG feature learning module, an epileptic seizure-guided self-attention learning module and a classifier.
[0082] Figure 1 This system framework is described. Its modules work together to fully exploit the feature information in EEG signals for efficient epileptic seizure identification. The cross-domain hybrid self-supervised learning module employs a multi-task self-supervised training strategy, utilizing EEG signal features in the time, spatial, and frequency domains as input to achieve multi-faceted feature reconstruction and representation learning. This process captures temporal dynamics while preserving the spatial distribution of each electrode and the spectral characteristics of neural oscillations. Next, the pre-trained encoder model is applied to the downstream task of epileptic seizure identification. To further and more comprehensively extract information from EEG data, a multi-scale EEG feature learning module is employed to capture EEG features from epileptic patients at different scales. This module extracts local and temporal features from EEG signals using a deep convolutional neural network (CNN). This module uses multiple layers of convolution operations to capture local spatial features and temporal variations in EEG signals across different time windows using different receptive fields. The extracted high-dimensional features undergo dimensionality reduction before being fed into the seizure-guided self-attention learning module. The seizure-guided self-attention learning module further enhances feature interactions and correlations through a self-attention mechanism. The self-attention mechanism dynamically allocates attention weights to highlight key epilepsy-related information while suppressing irrelevant noise. By constructing an electrode adjacency matrix, the model can focus on key information and relevant channels before and after the seizure, strengthening the representation of spatiotemporal features. Finally, an LSTM-based classifier is applied to the processed features to determine the occurrence of an epileptic seizure.
[0083] 1. Cross-domain hybrid self-supervised learning module
[0084] In the task of epileptic seizure identification, EEG data usually has a significant imbalance, that is, the proportion of epileptic seizure data is lower than that of non-seizure data. This imbalance poses a challenge to the training and generalization of the model. In order to solve this problem, the present invention proposes a cross-domain hybrid self-supervised learning model, which realizes the feature reconstruction and representation learning of EEG signals by designing self-supervised tasks in the time domain, spatial domain and frequency domain respectively. The model adopts a multi-task training strategy, including tasks such as time domain context prediction, channel information reconstruction and spectrum mask recognition, to fully mine the implicit feature information in the data, thereby improving the feature representation ability of the model. Figure 2 The overall structure of the CH-SSL model is shown.
[0085] (1) Time domain context prediction task unit
[0086] In the actual clinical diagnosis process, doctors usually judge the start and end of epileptic seizures by analyzing the signal context information before and after the epileptic seizure. Based on this, the present invention introduces context information into the time domain self-supervision task, aiming to simulate the doctor's analysis process, thereby improving the model's ability to distinguish epileptic signals from normal signals. Figure 2 As shown in (a), the temporal context prediction task divides the EEG signal into several segments. By defining prediction windows and actual windows, the temporal dependencies of the signal are captured. In terms of task design, the present invention devises two prediction methods: one uses information from the current segment to predict the next EEG signal, and the other uses information from the current segment to predict the previous EEG signal. To implement the task, the present invention adopts an encoder-decoder self-supervised learning framework. This framework is based on a U-shaped network structure, comprising an encoder, a decoder, and multiple skip connections. The encoder-decoder structure uses the U-shaped architecture and skip connections to implement the temporal context prediction task. The encoder consists of four one-dimensional convolutional layers with a kernel size of 7, a stride of 2, and output channels of [32, 64, 128, 256]. Each convolutional layer undergoes batch norm, ReLU, and dropout. The decoder is symmetrical to the encoder and reconstructs the predicted segments, while skip connections preserve low-level temporal features. The encoder is shared across all self-supervised tasks to encourage unified representation learning and is retained during fine-tuning for end-to-end optimization. The encoder extracts multi-scale temporal features, and the decoder is responsible for generating prediction signals, preserving low-level feature details through skip connections. This structure enhances the ability to learn complex patterns in time series. It is defined as the minimum mean square error between the real and predicted EEG segments, including forward prediction error and backward prediction error, which promotes the model to learn time series patterns.
[0087]
[0088] Where M is the total number of segments, m represents the index of the signal segment currently being calculated, represents the true signal value of the m segment, represents the predicted signal value of m segments, τ, Represents the weight factor of the forward and backward prediction errors. By introducing contextual information, this task effectively captures the time-dependent characteristics of EEG signals and provides an effective time domain representation for downstream epileptic seizure recognition.
[0089] (2) Channel information reconstruction task unit
[0090] The channel information reconstruction task aims to learn the spatial dependencies and interactions between different channels in EEG signals. EEG signals are recorded synchronously by multiple channels, each of which corresponds to the electrical activity of a specific brain region. Epileptic seizures usually originate from a specific brain region and may spread to other brain regions during the seizure. By effectively reconstructing the relationship between each channel, the model can more accurately capture the dynamic changes between brain regions, thereby improving the accuracy of epileptic seizure identification. Figure 2 As shown in (b), in the channel information reconstruction task, the EEG signal is divided into several segments, and the EEG channels are divided according to different brain regions (frontal lobe, temporal lobe, central region, parietal lobe and occipital lobe). Then, masks are randomly added to the channel segments of different brain regions so that the signals of these brain regions cannot be directly input into the network. Finally, the model is required to reconstruct the occluded channel signals based on other channel information, and then the model is used to predict the brain region to which the occluded channel belongs. We use an encoder-decoder structure network for training, and the encoder is responsible for extracting feature representations to fully capture the spatial dependencies across brain regions. The decoder network performs channel reconstruction and brain region prediction, and adds multi-scale convolution to pass the detailed information of the encoding stage to the decoding stage to capture the spatial relationship between brain regions. Channel information reconstruction loss It is defined as the minimum mean square error between the reconstruction and the true channel information.
[0091]
[0092] Where N is the total number of samples, n is the index of the signal segment currently being calculated, and f c (n) represents the true value of the blocked channel signal, Represents the reconstructed value of the occluded channel signal. Prediction loss It is defined as the cross entropy between the brain region prediction of the occluded channel sample and its corresponding label (a total of 5 categories of labels).
[0093]
[0094] Among them, j represents the brain area distribution, and j∈[0,1,2,3,4], One-Hot vector representing the true label encoding, Represents the predicted probability of the model output, μ j The weight parameter is used to weight samples. By learning the connectivity between channels, the model can understand the diffusion characteristics of neural activity across brain regions during epileptic seizures and improve its ability to identify epileptic seizure patterns.
[0095] (3) Spectrum mask recognition task unit
[0096] The amplitude and frequency of EEG signals are significantly time-varying and show obvious non-steady-state characteristics. The main frequency components of EEG signals are concentrated between 0.5 and 100 Hz, and are usually divided into δ (0.5-4 Hz), θ (4-8 Hz), α (8-13 Hz), β (13-30 Hz) and γ (30-100 Hz) frequency bands. Each frequency band is associated with a specific cognitive state, emotional changes and neural activity, reflecting different brain functional states. For example, the significant enhancement of gamma waves during epileptic seizures indicates the synchronous high-frequency discharge of neuronal populations, while abnormal delta wave activity after the seizure is usually accompanied by brain function inhibition. Therefore, by analyzing the changing characteristics of EEG signals in different frequency bands, the frequency domain abnormalities during epileptic seizures can be effectively revealed. In order to fully explore the frequency domain characteristics of EEG signals and improve the learning ability of the model, the present invention proposes a self-supervised task based on spectral masking recognition. This task enhances the model's understanding and recognition ability of frequency domain features by masking and reconstructing frequency domain features. As Figure 2 As shown in (c), in the spectrum masking recognition task, the EEG signal is first converted from the time domain to the frequency domain and decomposed into different frequency bands (δ, θ, α, β, γ). Then, the information of certain frequency bands is randomly filtered out, and a pseudo label Y(i)∈[0,1,2,3,4] is set to represent the index of the removed frequency band. The model is required to perform two tasks during the training process: one is to predict the masked frequency band, and the other is to reconstruct the missing frequency band signal. The present invention uses a discriminator based on a multi-layer perceptron (MLP) for frequency band prediction. The discriminator infers the index of the masked frequency band based on the remaining frequency band information. At the same time, the encoder-decoder structure is used to reconstruct the masked frequency band signal. The encoder extracts the complete time-frequency feature representation and uses the decoder to extract the complete time-frequency feature representation. To reconstruct the lost frequency band, the encoder f s (n) can learn effective frequency correlations and features to form time-frequency representation. Consistent with the channel information reconstruction task, the spectrum mask recognition loss Defined as:
[0097]
[0098] Among them, i represents the pseudo label set, One-Hot vector representing the true label encoding, represents the predicted probability of the model output, ε i Represents the weight parameter, which is used to weight the samples. Reconstruction loss It can effectively measure the gap between the reconstruction result and the real signal.
[0099]
[0100] Among them, f s (n) represents the true value of the spectrum mask signal, Represents the reconstructed value of the spectral mask signal. The spectral mask recognition task can guide the model to autonomously learn and identify the characteristic distribution of different frequency bands in EEG signals, thereby improving the model's ability to recognize epileptic seizure signals.
[0101] (4) Multi-task learning loss function
[0102] The cross-domain hybrid self-supervised learning module will be based on the total loss function Joint training is performed, where λ1, λ2, λ3, λ4, and λ5 are hyperparameters used to balance the weights of the loss function in multi-task learning.
[0103]
[0104] CH-SSL aims to enhance the module's understanding of the temporal, spatial, and frequency domain consistency and semantic features of EEG signals, thereby significantly improving the model's ability to distinguish epileptic seizure signals from normal signals. Furthermore, CH-SSL optimizes the model's generalization capabilities by introducing diverse pre-training objectives and task designs. This strategy can effectively adapt to differences in signal characteristics across hospitals, patients, and devices, thereby improving the model's robustness and practicality in diverse environments. This approach not only improves the model's diagnostic accuracy but also provides a reliable foundation for the analysis and interpretation of cross-domain EEG data.
[0105] 2. Multi-scale EEG feature learning module
[0106] There are significant differences in epileptic seizure patterns between individuals, including whole-brain discharge patterns and localized seizure characteristics, which significantly increases the challenge of the model in capturing complex spatiotemporal dynamic changes. To address this problem, the MEF module proposed in this paper adopts a multi-scale representation method to extract diverse features of epileptic seizures from different levels to improve the recognition ability of the model and enhance its adaptability to individual differences. Figure 3 As shown, the original EEG signal Through progressive downsampling via depthwise convolution, feature representations at four different resolutions (M∈(200, 100, 50, 25)) are generated. Each layer is designed to capture features at half the resolution of the previous layer. This layer-by-layer downsampling reduces computational complexity while preserving both fine-grained and coarse-grained features, ensuring effective representation of both high- and low-frequency information. Based on multi-scale feature extraction, the feature branches at each scale are further fed into a convolutional layer for feature enhancement. To improve the training stability and feature representation capabilities of the deep network, residual blocks are introduced in each scale branch to mitigate the vanishing gradient problem and promote efficient information flow. The residual block design enables direct feature transfer through identity mapping, helping to preserve key information during feature fusion. Finally, feature branches are fused using element-wise addition, preserving the core information at each scale while enhancing global consistency. The MEF module establishes a comprehensive representation between global brain activity patterns and local dynamic features, improving the model's generalization and reducing its dependence on individual data. It demonstrates high robustness, particularly in situations where there is significant inter-patient variability and insufficient data diversity.
[0107] 3. Seizure-guided self-attention learning module
[0108] The recognition of epileptic seizures faces challenges such as complex spatiotemporal dynamic features and significant individual differences. To address this problem, the SGS module proposed in this paper aims to improve the model's epileptic seizure recognition ability by fusing temporal and spatial features. Figure 4 As shown in the figure, the module uses the self-attention mechanism to capture the long-range temporal dependencies in the EEG signal, and at the same time uses the sparse electrode adjacency matrix (W se ) to explore the spatial dependencies between different electrodes. Epilepsy seizures are usually characterized by a dynamic propagation process that gradually expands from local discharge to the whole brain. This module can effectively model the interaction between leads and reveal the spatial characteristics of signal propagation during seizures. In addition, W se As a priori knowledge, it further strengthens the model’s understanding of the synchronization and interaction between brain regions during epileptic seizures. xy Calculated by Gaussian kernel function, the formula is:
[0109]
[0110] Where: Dist(E X ,E Y ) represents EEG electrode E X and E YThe Euclidean distance between leads is calculated based on the internationally accepted 10-20 EEG electrode placement standard. σ represents the standard deviation of the distance and is used to control the scale of the Gaussian distribution. The Gaussian kernel function can effectively enhance the connection strength between close leads while rapidly attenuating the connection weights of distant leads, thereby achieving spatial sparsity. In addition, to further optimize the sparsity of the adjacency matrix, a sparsity threshold is set. The Euclidean distance is greater than The electrode connection weights are reset to 0, and only the connections with strong local correlation are retained. This sparse processing not only reduces the interference of redundant information, but also enhances the model's sensitivity to local area signals. In the SGS module, the self-attention mechanism is used to capture the long-range temporal dependencies of EEG signals, and the sparse electrode adjacency matrix W se is used to model spatial dependencies. se The element-wise multiplication with the SoftMax output of the multi-head self-attention layer effectively performs a weighted calculation on the similarity between different channels. The attention matrix A(t) represents the weighted feature matrix generated by embedding the EEG signal at a specific time period t. It combines the temporal dependency of the EEG signal with the spatial interaction between channels. Its calculation process is as follows:
[0111]
[0112] in: represents the EEG feature embedding in the tth time period, and and They are respectively projecting F(t) onto the query matrix Q t , key matrix K t Sum matrix V t The weight matrix of , d is the scaling factor. Sparse electrode adjacency matrix W se The introduction of can significantly weaken the interference signals between irrelevant channels and strengthen local connections with physiological significance. By combining the multi-head self-attention mechanism with the sparse electrode adjacency matrix, the SGS module can not only capture the long-distance temporal dependencies of EEG signals, but also reflect the spatial coupling characteristics with practical significance. This fusion strategy not only improves the sensitivity of the SGS module to epileptic seizure signals, but also captures the dynamic changes from local to global during the seizure process. Through the synergistic effect of the self-attention mechanism and the sparse adjacency matrix, the epileptic seizure recognition model is injected with higher spatiotemporal perception capabilities, allowing the model to more accurately focus on important connections across leads, thereby effectively improving the accuracy and robustness of epileptic seizure recognition.
[0113] 4. Classifier Module
[0114] The classifier module uses a structure based on the long short-term memory network (LSTM) for the final epileptic seizure classification. The feature sequence extracted by the self-attention learning module guided by the epileptic seizure is input into the maximum pooling layer to reduce the feature dimension while retaining key information. Subsequently, the feature data is sequentially input into the LSTM network for time series modeling. The LSTM network effectively captures the long-range temporal dependencies and feature changes across time steps in the EEG signal through the gating mechanism. At each time step, the LSTM classifies the EEG signal based on the current input and the hidden state (H) of the previous time step. t-1 ) calculate the current hidden state (H t ), forming a dynamic feature representation. The feature vector output by the LSTM is then fed into a linear layer for mapping to further extract high-level features. To reduce the risk of overfitting, a dropout layer (Dropout) is added after the linear layer to enhance the model's generalization ability by randomly setting some neuron outputs to zero. The mapped features are then passed through a Sigmoid activation function to map the seizure probability P(y=1|x) to a probability value between 0 and 1.
[0115] P(y=1|x)=Sigmoid(W T H t +b)
[0116] Where W and b are the weights and biases of the linear layer. Finally, the output layer generates a binary classification of epileptic seizures based on the sigmoid output: "Seizure" or "Normal," achieving accurate seizure identification. Through this series of processing, the classifier module effectively leverages temporal information and correlations in feature space, significantly improving the accuracy and robustness of epileptic seizure identification.
[0117] 5. Model training process
[0118] In the model training process of this invention, we used NVIDIA RTX 4090GPU (24GB video memory) for hardware acceleration and used the PyTorch framework in all training and testing stages. This invention uses the Adam optimizer with an initial learning rate of 10 -6, taking into account the memory capacity and the maximization of model optimization and network training speed, the batch size is set to 256 while ensuring model stability and training speed. An early stopping mechanism is introduced in the training process to prevent overfitting. When the verification loss does not decrease in 10 consecutive batches, the model training will stop early. To ensure the reliability of the results, each model is run three times with different random seeds. The specific training strategy includes two stages. First, the cross-domain hybrid self-supervised model is trained to obtain a pre-trained model, and then the pre-trained model is applied to the training of the final time series data classification model. Among them, the model without self-supervised pre-training uses random initialization parameters, while the model with self-supervised pre-training uses pre-training weights for parameter initialization. In order to comprehensively evaluate the performance of the model, the present invention uses four indicators: the area under the receiver operating characteristic curve (AUROC), accuracy, F1 score and false alarm rate for evaluation. These indicators can measure the performance of the model in the epileptic seizure recognition task from different dimensions, thereby ensuring the comprehensiveness and objectivity of the evaluation results.
[0119] Although the present invention has been described above, the present invention is not limited to the above-mentioned specific embodiments. The above-mentioned specific embodiments are merely illustrative and not restrictive. Under the guidance of the present invention, ordinary technicians in this field can make many variations without departing from the purpose of the present invention, and these are all protected by the present invention.
Claims
1. A system for classifying and identifying epilepsy in EEG signals based on time series, characterized by: The recognition system includes: a cross-domain hybrid self-supervised learning module, a multi-scale EEG feature learning module, an epileptic seizure-guided self-attention learning module and a classifier; the cross-domain hybrid self-supervised learning module includes a time domain context prediction task unit, a channel information reconstruction task unit and a spectrum mask recognition task unit; The cross-domain hybrid self-supervised learning module reconstructs the input EEG signal according to the time domain, spatial domain and frequency domain multi-task learning loss function to generate an EEG representation model; wherein: The time domain context prediction task unit captures the dynamic change characteristics before and after the epileptic seizure by learning the time domain evolution law of the EEG signal; The channel information reconstruction task unit is used to reconstruct the missing EEG signal channel data to enhance the EEG representation model's representation of spatial information; The spectrum masking recognition task unit trains the EEG characterization model to characterize epileptic neural oscillations by randomly masking some EEG signal frequency components in the frequency domain; The multi-scale EEG feature learning module obtains a first epilepsy EEG feature model by capturing local and global epilepsy features of the EEG representation model at different resolutions; The epileptic seizure guided self-attention learning module optimizes the first epileptic EEG feature model by fusing temporal and spatial features to obtain a second epileptic EEG feature model; The classifier classifies the EEG data features of the second epileptic EEG feature model based on a long short-term memory network and outputs whether it is an epileptic seizure.
2. The system for classifying and identifying epilepsy in EEG signals based on time series according to claim 1, characterized in that: The time-domain context prediction task unit captures the dynamic change characteristics before and after an epileptic seizure by learning the time-domain evolution law of the EEG signal; including: The temporal context prediction task unit divides the EEG signal into several segments to capture the temporal dependency of the signal. Two prediction methods are used in task design: one is to use the current segment information to predict the next EEG signal, and the other is to use the current segment information to predict the previous EEG signal. In terms of task implementation, the temporal context prediction task unit adopts a self-supervised learning framework with an encoder-decoder structure. The self-supervised learning framework with an encoder-decoder structure consists of an encoder, a decoder, and multiple skip connections. The encoder extracts multi-scale temporal EEG signal features, The decoder calculates the dynamic change characteristics before and after the epileptic seizure based on the multi-scale temporal EEG features according to the following formula: Where M is the total number of segments, m represents the index of the signal segment currently being calculated, represents the true signal value of the m segment, represents the predicted signal value of m segments, τ, Represents the weighting factor for the forward and backward prediction errors.
3. The epilepsy classification and identification system based on time series in EEG signals according to claim 1, characterized in that: The channel information reconstruction task unit enhances the spatial information representation process of the EEG representation model by reconstructing the missing EEG signal channel data; including: the channel information reconstruction task unit adopts an encoder-decoder structure network; wherein: Divide the EEG signal into several EEG channel segments, and add masks to the EEG channel segments according to different brain regions; Reconstruct the occluded EEG channel sample according to the following formula based on the information of other channels; Where N is the total number of samples, n is the index of the signal segment currently being calculated, and f c (n) represents the true value of the blocked channel signal, Represents the reconstructed value of the occluded channel signal; The cross entropy between the brain region calculation of the occluded channel sample and its corresponding label is used to predict the spatial information representation of the brain region: Among them, j represents the brain area distribution, and j∈[0,1,2,3,4], One-Hot vector representing the true label encoding, Represents the predicted probability of the model output, μ j Represents the weight parameter, which is used to weight the samples.
4. The system for classifying and identifying epilepsy in EEG signals based on time series according to claim 1, characterized in that: The spectrum masking recognition task unit trains the EEG characterization model to characterize the epileptic neural oscillation by masking some EEG signal frequency components in the frequency domain; the spectrum masking recognition task unit adopts an encoder, a decoder and a discriminator, wherein: Convert EEG signals from the time domain to the frequency domain and decompose them into different frequency bands (δ, θ, α, β, γ); Filter out information of certain frequency bands and set pseudo labels to represent the index of the removed frequency bands; A multi-layer perceptron is used to predict different frequency bands (δ, θ, α, β, γ), and the index of the masked frequency band is inferred based on the remaining frequency band information; The time-frequency feature representation is obtained according to the following formula: Among them, i represents the pseudo label set, One-Hot vector representing the true label encoding, represents the predicted probability of the model output, ε i Represents the weight parameter, which is used to weight the samples; The reconstruction loss is calculated as follows: Obtain epileptic neurological oscillations: Among them, f s (n) represents the true value of the spectrum mask signal, Represents the reconstructed value of the spectrum mask signal.
5. The system for classifying and identifying epilepsy in EEG signals based on time series according to claim 1, characterized in that: The epileptic seizure-guided self-attention learning module obtains a second epileptic EEG feature model by fusing temporal and spatial feature optimization, including: The self-attention mechanism is used to capture the long-range temporal dependencies of EEG signals; Through the sparse electrode adjacency matrix W se The SoftMax output of the multi-head self-attention layer is multiplied element-by-element according to the following formula, and the similarity between different channels is weighted to obtain the spatial dependency between different EEG electrodes: The attention matrix A(t) represents the weighted feature matrix generated by embedding the EEG signal at a specific time period t. It combines the temporal dependency of the EEG signal with the spatial interaction between channels. The calculation process is as follows: in: represents the EEG feature embedding in the t-th time period, and and They are respectively projecting F(t) onto the query matrix Q t , key matrix K t Sum matrix V t The weight matrix, d is the scaling factor; where: The sparse electrode adjacency matrix W se The following formula coordinates brain regions during epileptic seizures: Where: Dist(E X ,E Y ) represents EEG electrode E X and E Y ; σ represents the standard deviation of the distance, which is used to control the scale of the Gaussian distribution.
6. The system for classifying and identifying epilepsy in EEG signals based on time series according to claim 1, characterized in that: The classifier classifies the EEG features of the second epilepsy EEG feature model based on the long short-term memory network and outputs whether it is an epileptic seizure, including: the classifier module adopts a long short-term memory network structure, wherein: The feature sequence extracted by the seizure-guided self-attention learning module is input into a maximum pooling layer to reduce the feature dimension while retaining key information; The feature data are sequentially input into a long short-term memory network for time series modeling. The long short-term memory network captures long-distance temporal dependencies and feature changes across time steps in the EEG signal through a gating mechanism. At each time step, the LSTM network generates a hidden state H based on the current input and the previous time step. t-1 Calculate the current hidden state H t , forming a dynamic feature representation; the feature vector output by the long short-term memory network is sent to the linear layer for mapping; A random dropout layer is added after the linear layer to optimize the generalization ability of the second epileptic EEG feature model by randomly setting some neuron outputs to zero. The mapped features are activated by the Sigmoid function to map the probability of epileptic seizure P to a probability value between 0 and 1; P(y=1|x)=Sigmoid(W T H t +b) Where: W and b are the weights and biases of the linear layer; The output layer generates a binary classification result of epileptic seizure based on the output result of Sigmoid, which is "Seizure" or "Normal", to achieve accurate identification of epileptic seizures.
7. A method for classifying and identifying epilepsy in EEG signals based on time series, characterized by: The method is based on the system according to any one of claims 1 to 6, comprising the following steps: Pre-training phase: Reconstruct the multi-task learning loss function according to the time domain, spatial domain and frequency domain of the input EEG signal; Among them: λ1,λ2,λ3,λ4,λ5 are hyperparameters used to balance the weights of the loss function in multi-task learning; By learning the time domain evolution of EEG signals, the dynamic change characteristics before and after epileptic seizures can be captured; Where M is the total number of segments, m represents the index of the signal segment currently being calculated, represents the true signal value of the m segment, represents the predicted signal value of m segments, τ, Represents the weight factors of forward and backward prediction errors; The EEG representation model is used to reconstruct the missing EEG signal channel data to enhance the spatial information representation; wherein: The EEG characterization model is trained to characterize epileptic neural oscillations by randomly masking some EEG signal frequency components in the frequency domain; Divide the EEG signal into several EEG channel segments, and add masks to the EEG channel segments according to different brain regions; Reconstruct the occluded EEG channel sample according to the following formula based on the information of other channels; Where N is the total number of samples, n is the index of the signal segment currently being calculated, and f c (n) represents the true value of the blocked channel signal, Represents the reconstructed value of the occluded channel signal; The cross entropy between the brain region calculation of the occluded channel sample and its corresponding label is used to predict the spatial information representation of the brain region: Among them, j represents the brain area distribution, and j∈[0,1,2,3,4], One-Hot vector representing the true label encoding, Represents the predicted probability of the model output, μ j Represents the weight parameter, which is used to weight the samples; The first epilepsy EEG feature model is obtained by capturing the local and global epilepsy features of the EEG representation model at different resolutions; The second epileptic EEG feature model is obtained by optimizing the first epileptic EEG feature model through fusing temporal and spatial features; Classify the EEG features of the second epilepsy EEG feature model and output whether it is an epileptic seizure; Training phase: The epilepsy classification and recognition system is trained by the cross-domain hybrid self-supervision module, the multi-scale EEG feature learning module and the epileptic seizure-guided self-attention learning module to construct a second epilepsy EEG feature model, and the second epilepsy EEG feature model is trained by the classifier to output the final time series data.
Citation Information
Cited By
Detection device for high-frequency oscillation of electroencephalogram signals of intrusive brain machine
CN120938467A
Electroencephalogram signal classification method based on physical information residual polynomial network
CN121211018A
Electroencephalogram signal classification system and method oriented to class imbalance tasks
CN121370187A
Fungaltoxin detection system based on machine learning and biosensor
CN121580356A
Method and system for automatically detecting bad segments of electroencephalogram signals by comparing self-supervised learning
CN121705988A