Epilepsy prediction method based on adaptive space-time attention and dynamic fusion network

By adopting adaptive time and space attention and dynamic integration networks in epilepsy prediction technology, the existing technology has been solved in capturing long -term span and long -distance brain -dependent dependence. Applicable to low delay scenes.

CN119344751AActive Publication Date: 2025-01-24ANHUI UNIV

Patent Information

Application Number
CN202411897459.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-01-24
Estimated Expiration
2044-12-23

AI Technical Summary

Technical Problem

Existing epilepsy prediction techniques have shortcomings in accuracy, real-timeness, and model interpretability, especially in capturing dependencies between long-term spans and long-distance brain regions.

Method used

Using a method based on adaptive spatiotemporal attention and dynamic fusion network, EEG signals are captured through brain signal preprocessing module, contextual attention coding layer, long-range content dependence network, adaptive temporal state space modeling module and epilepsy prediction module multi-level dependencies and spatio-temporal dynamic characteristics.

Benefits of technology

Improve the accuracy and real -time of seizures, reduce the computing complexity and efficiency bottleneck, enhance the interpretability and adaptability of the model, and apply to low latency and real -time prediction scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119344751A_ABST
    Figure CN119344751A_ABST
Patent Text Reader

Abstract

The invention discloses an epilepsy prediction method based on a self-adaptive space-time attention and dynamic fusion network, and relates to a brain signal preprocessing module, a context attention coding layer, a long-distance content dependence network, a self-adaptive time sequence state space modeling module and an epilepsy prediction module. The brain signal preprocessing module obtains corresponding time domain information, frequency domain information and an adjacent matrix; an adjacent matrix is regarded as a graph structure, the weight of each edge of the graph structure is input into a context attention coding layer, spatial features between channels are extracted, the weight is dynamically adjusted through aggregation of neighbor node information and attention, and a node feature matrix is output; inputting the node feature matrix into a long-distance content-dependent network to output global spatial features and corresponding time sequences; obtaining space-time dynamic fusion features through a self-adaptive time sequence state space modeling module; and inputting the space-time dynamic fusion features into an epilepsy prediction module and then outputting an epilepsy prediction result According to the invention, accurate prediction can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to biomedical signal processing and deep learning technology, and in particular to an epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network. Background Art

[0002] Epilepsy is a serious neurological disease characterized by recurrent seizures caused by abnormal brain electrical activity. Such unpredictable seizures pose a huge threat to patients' daily lives and safety. Therefore, developing a technology that can accurately predict epileptic seizures in advance is of great clinical significance. In recent years, with the development of deep learning technology, more and more studies have attempted to use artificial intelligence for the prediction of epileptic seizures, mainly by analyzing electroencephalogram (EEG) signals to discover potential abnormal patterns. Although some existing methods have made some progress in the prediction of epileptic seizures, there are still significant deficiencies in accuracy, real-time and model interpretability.

[0003] At present, mainstream epilepsy prediction technologies can be roughly classified into models based on convolutional neural networks (CNN), recurrent neural networks (RNN, such as LSTM or GRU), and some models based on Transformer architecture. These technologies are mainly focused on extracting features from EEG signals and making predictions by modeling the temporal dynamic changes of signals.

[0004] However, existing similar technologies have several key defects:

[0005] 1. Limitations of modeling local or short-term dependencies

[0006] Many existing epilepsy prediction techniques rely on convolutional neural networks (CNNs) to extract features from EEG signals. CNNs are suitable for capturing local spatiotemporal features, however, due to the limitations of their receptive field, CNNs are limited in capturing dependencies between long time spans and distant brain regions. This results in it possibly missing some important long-range dependency features when processing complex EEG signals, which are often key predictive signals for epileptic seizures.

[0007] 2. Long-term dependent modeling efficiency issues

[0008] In order to capture the temporal dynamic characteristics of EEG signals, recurrent neural networks (such as LSTM or GRU) are widely used. However, RNN-type models often face the problems of gradient vanishing and low computational efficiency when processing signals with long time spans, which makes it difficult for the model to effectively model long-term dependencies. In addition, RNN needs to calculate sequence data step by step, which leads to high computational overhead when processing long sequences, making it difficult to achieve real-time prediction.

[0009] 3. Bottlenecks of computational complexity and efficiency

[0010] Some Transformer-based models excel in modeling long-distance dependencies because they can capture the global dependencies of the entire sequence through the self-attention mechanism. However, the traditional Transformer architecture has a quadratic complexity in self-attention calculation (related to the sequence length), which makes it face serious computational bottlenecks when processing long sequence data (long-term EEG signals). Therefore, these models usually require large-scale computing resources and are not suitable for use in low-latency, real-time prediction scenarios. Summary of the invention

[0011] Purpose of the invention: The purpose of the present invention is to solve the deficiencies in the prior art and to provide an epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network.

[0012] Technical solution: The present invention provides an epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network, involving a brain signal preprocessing module, a contextual attention encoding layer, a long-range content dependency network, an adaptive temporal state space modeling module and an epilepsy prediction module. The specific epilepsy prediction method includes the following steps:

[0013] Step 1: Input multi-channel EEG signals to the brain signal preprocessing module, preprocess the received EEG signals, obtain the corresponding time domain information and frequency domain information, and calculate the adjacency matrix of the EEG signal space structure through Spearman correlation. The adjacency matrix obtained here is a 0\1 binary matrix;

[0014] Step 2: The adjacency matrix obtained in step 1 is regarded as a graph structure. The nodes in the graph structure represent each EEG channel. The edges of the graph structure are established between the nodes with higher Spearman correlation. The weights of each edge are input into the contextual attention encoding layer. The contextual attention encoding layer uses the multi-head graph attention mechanism to extract the spatial features between each channel, and dynamically adjusts the weights through the aggregation of neighbor node information and attention, and finally outputs the node feature matrix. When this step uses the Spearman correlation to compose the graph, it is determined whether the correlation is high or low based on a predetermined threshold. For example, the threshold is set to 0.8. At this time, if the Spearman coefficient between any two nodes is greater than or equal to 0.8, the weight of the edge is 1, and if the Spearman coefficient between any two nodes is less than 0.8, the weight of the edge is 0.

[0015] Step 3: The node feature matrix obtained in step 2 is input into the long-range content dependency network. The long-range content dependency network captures the long-range global dependency relationship between multiple channels through the multi-level window self-attention mechanism SW-MSA and outputs the global spatial feature and the corresponding time series;

[0016] Step 4: Input the time series obtained in step 3 into the adaptive time series state space modeling module. The adaptive time series state space modeling module is based on the Mamba module and combines the state space model (SSM) and the convolutional neural network. The spatiotemporal dynamic fusion features are obtained through the adaptive time series state space modeling module.

[0017] Step 5: Input the spatiotemporal dynamic fusion features obtained in step 4 into an epilepsy prediction module. The epilepsy prediction module uses a fully connected layer to process the spatiotemporal dynamic fusion features and output an epilepsy prediction result.

[0018] In order to ensure that high-quality preprocessed signals are input into the subsequent contextual attention encoding layer and achieve more accurate epilepsy prediction, the preprocessing process of the brain signal preprocessing module is as follows:

[0019] Step 1.1: Filter the original multi-channel EEG signal to remove noise and high-frequency interference. First, perform a 1-40 Hz bandpass filter on the original EEG signal to remove noise and high-frequency interference to ensure that the signal quality is suitable for subsequent processing and analysis.

[0020] Step 1.2: Normalize the filtered EEG signal to standardize the signals of different channels to the same range to reduce the impact of data deviation;

[0021] Step 1.3: Perform short-time Fourier transform on the normalized EEG signal to obtain the time-frequency domain information of the EEG signal, which is more conducive to the feature representation learning in the later stage of the model to provide richer features and better capture the dynamic changes related to epilepsy;

[0022] Step 1.4, cut the signal after short-time Fourier transform into 4s time windows, and divide the long-term signal into multiple smaller windows to facilitate the extraction of time series features;

[0023] Step 1.5, calculate the Spearman correlation between each channel. By calculating the Spearman correlation coefficient, the nonlinear relationship between each channel is measured to generate an adjacency matrix representing the spatial structure of the EEG signal;

[0024] The formula for calculating the Spearman correlation is as follows:

[0025] ;

[0026] in, n is the number of samples, is the indices of the ith data point in variable X, is the indices of the ith data point in variable Y, is the sum of squares of the odd-order differences.

[0027] In order to further model the dependency relationship between brain regions, accurately capture the interaction between key brain regions, and improve the modeling accuracy of spatial dependency, the method for dynamically adjusting the weights of the contextual attention encoding layer is as follows:

[0028] First, each node calculates the attention weight based on its own and neighboring node features, and then the attention weight is combined with the Spearman correlation edge weight to affect feature aggregation, that is, weighted aggregation is performed based on the attention weight and edge weight to obtain the final feature representation of the node; the expression is as follows:

[0029] ;

[0030] In the above formula, represents the updated feature vector of node i, represents the set of neighbor nodes of node i, represents the attention weight between node i and node j, Represents the weight matrix, used for feature transformation, represents the feature vector of node j, represents the activation function, and each node in the graph structure contains the characteristic information of the corresponding channel (such as power spectrum density, frequency components, etc.). It is only the updated feature vector of node i. After similar updates are performed on all nodes in the entire graph, the set of all these feature vectors is the final node feature matrix.

[0031] In the graph structure here, the method for generating each edge is as follows: in the last step of the brain signal preprocessing module, the Spearman correlation calculation is performed on any two channels using the time window signal feature information to generate a correlation matrix (adjacency matrix), which reflects the signal synchronization between different channels and is input into the context attention coding layer as the edge weight in the graph structure. The nodes of the graph structure represent each EEG channel, carrying the frequency domain features in the short-time Fourier transform of the brain signal preprocessing module. The weight of each edge in the graph structure is the correlation coefficient value, which represents the signal similarity between two nodes (channels). The present invention allows the graph structure to change within each time window, so that the context attention coding layer can capture the dynamic interaction relationship between different channels over time.

[0032] In order to further extract global spatial features at different scales and capture the long-distance global dependencies between multiple channels, the long-distance content dependency network is based on the Swin Transformer architecture and blocks the node feature matrix, including alternating hierarchical window segmentation (to achieve long-distance dependency modeling across windows) and window multi-head self-attention operations. The expression is as follows:

[0033] ;

[0034] In the above formula, Represents the node matrix characteristics ( Towards higher-level representations via long-range content dependency networks ), represents the window multi-head self-attention operation, represents the shift window multi-head self-attention operation, Represents the global feature representation after Swin Transformer processing.

[0035] In order to capture the nonlinear timing characteristics in EEG signals and further enhance the timeliness of feature extraction, the adaptive timing state space modeling module captures the nonlinear timing characteristics in EEG signals. The calculation formula is as follows:

[0036] ;

[0037] In the above formula, represents the state of the current time step, represents the state of the previous time step, represents the input signal at the current time step (here yes a subset at a specific time step as input for temporal state space modeling); Represents a state update function, which is used to update the state according to the previous state and the current input. The spatiotemporal features fused by the adaptive temporal state space modeling module are passed to the epilepsy prediction module, which includes a multi-layer fully connected layer, and the spatiotemporal dynamic fusion features are further classified into two categories. The input prediction results include pre-ictal / interictal periods.

[0038] Beneficial effects: Compared with the prior art, the present invention has the following advantages:

[0039] 1. Multi-level dependency modeling

[0040] Adaptive spatiotemporal attention and dynamic fusion networks can capture and understand the feature relationships in EEG signals at different levels. The characteristics of epileptic seizures may be manifested at different temporal and spatial scales. Adaptive spatiotemporal attention and dynamic fusion networks successfully capture and understand the feature relationships in EEG signals by combining spatial context dependency, long-range content modeling, and adaptive timing control.

[0041] 2. Adaptation and real-time optimization

[0042] Traditional epilepsy prediction methods (such as those based on RNN or CNN) have the problem of overfitting redundant information or failing to adapt to instantaneous changes in signals when processing EEG signals. The adaptive spatiotemporal attention and dynamic fusion network achieves adaptive signal optimization through adaptive temporal state space modeling, which can eliminate unimportant information in real time and focus on key frequency bands. This not only improves the accuracy of prediction, but also significantly reduces the amount of model calculation, making it suitable for real-time application scenarios.

[0043] 3. Efficient computing and long-time signal processing

[0044] The hierarchical windowing mechanism in the long-range content dependency network enables the model to capture long-range dependencies while maintaining linear computational complexity, significantly improving reasoning efficiency. Compared with the computational bottleneck faced by the traditional Transformer method on long sequences, the adaptive spatiotemporal attention and dynamic fusion network make it more efficient in processing large-scale EEG signal data and can achieve real-time inference in complex tasks. Adaptive temporal state space modeling further has linear time complexity in long-range temporal modeling, ensuring the model's long-range prediction capability.

[0045] 4. Simplicity and adjustability: Each module of the present invention can be adjusted through hyperparameters, which is convenient for technicians to optimize the model according to different prediction requirements. At the same time, the modular design makes the network structure flexible and easy to adjust, which can meet the epilepsy prediction needs in different scenarios.

[0046] 5. Good scalability: When the computational complexity is not too high, the adaptive spatiotemporal attention and dynamic fusion network still maintain a high prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 It is a schematic diagram of the framework of the present invention;

[0048] Figure 2 It is a schematic diagram of the overall implementation process of the present invention;

[0049] Figure 3 It is the prediction effect diagram in the embodiment. DETAILED DESCRIPTION

[0050] The technical solution of the present invention is described in detail below, but the protection scope of the present invention is not limited to the embodiments.

[0051] like Figure 1 As shown, the epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network of the present invention involves a brain signal preprocessing module, a contextual attention encoding layer, a long-range content dependency network, an adaptive temporal state space modeling module and an epilepsy prediction module. The specific epilepsy prediction method includes the following steps:

[0052] Step 1: Input multi-channel EEG signals to the brain signal preprocessing module, preprocess the received EEG signals, obtain the corresponding time domain information and frequency domain information, and calculate the adjacency matrix of the EEG signal spatial structure through Spearman correlation. The adjacency matrix is ​​a 0\1 binary matrix;

[0053] Step 2: The adjacency matrix obtained in step 1 is regarded as a graph structure. The nodes in the graph structure represent each EEG channel. The edges of the graph structure are established between the nodes with higher Spearman correlation. The weights of each edge are input into the contextual attention encoding layer. The contextual attention encoding layer uses the multi-head graph attention mechanism to extract the spatial features between each channel, and dynamically adjusts the weights through the aggregation of neighbor node information and attention, and finally outputs the node feature matrix.

[0054] Step 3: The node feature matrix obtained in step 2 is input into the long-range content dependency network. The long-range content dependency network captures the long-range global dependency relationship between multiple channels through the multi-level window self-attention mechanism SW-MSA, and outputs the global spatial features and the corresponding time series.

[0055] Step 4: Input the time series obtained in step 3 into the adaptive time series state space modeling module. The adaptive time series state space modeling module is based on the Mamba module and combines the state space model SSM and the convolutional neural network to obtain the spatiotemporal dynamic fusion features through the adaptive time series state space modeling module.

[0056] Step 5: Input the spatiotemporal dynamic fusion features obtained in step 4 into an epilepsy prediction module. The epilepsy prediction module uses a fully connected layer to process the spatiotemporal dynamic fusion features and output an epilepsy prediction result.

[0057] The modules of this embodiment transmit information through standard signal connections. The original EEG signal is output through the brain signal processing module as the input of the contextual attention coding layer to capture the spatial dependency between brain regions; the output of the contextual attention coding layer (spatial topological matrix) is used as the input of the long-distance content dependency network to further model global features and capture long-distance signal dependencies; the output of the long-distance content dependency network (content dependency matrix) is passed to the adaptive temporal state space modeling module to adaptively control the temporal dynamics of the signal, retain key features, and eliminate irrelevant information; the output of the adaptive temporal state space modeling module (space-time fusion features) is passed to the epilepsy prediction module to perform epilepsy prediction.

[0058] The preprocessing process of the above brain signal preprocessing module is as follows:

[0059] Step 1.1, filter the original multi-channel EEG signal to remove noise and high-frequency interference;

[0060] Step 1.2: normalize the filtered EEG signal to standardize the signals of different channels to the same range;

[0061] Step 1.3, perform short-time Fourier transform on the normalized EEG signal to remove noise and interference in the signal;

[0062] Step 1.4, cut the signal after short-time Fourier transform into 4s time windows, and divide the long-term signal into multiple smaller windows to facilitate the extraction of time series features;

[0063] Step 1.5, calculate the Spearman correlation between each channel. By calculating the Spearman correlation coefficient, the nonlinear relationship between each channel is measured to generate an adjacency matrix representing the spatial structure of the EEG signal;

[0064] The formula for calculating the Spearman correlation is as follows:

[0065] ;

[0066] in, n is the number of samples, is the indices of the ith data point in variable X, is the indices of the ith data point in variable Y, is the sum of squares of the odd-order differences.

[0067] The method for dynamically adjusting the weights of the contextual attention encoding layer in this embodiment is:

[0068] First, each node calculates the attention weight based on its own and neighboring node features, and then the attention weight is combined with the Spearman correlation edge weight to affect feature aggregation, that is, weighted aggregation is performed based on the attention weight and edge weight to obtain the final feature representation of the node; the expression is as follows:

[0069] ;

[0070] In the above formula, represents the updated feature vector of node i, represents the set of neighbor nodes of node i, represents the attention weight between node i and node j, Represents the weight matrix, used for feature transformation, represents the feature vector of node j, Represents the activation function, and each node in the graph structure contains the feature information of the corresponding channel.

[0071] The contextual attention encoding layer of this embodiment is based on the Graph Attention Network (GAT) of graph representation learning, and its core is the multi-head attention mechanism. The preprocessed EEG signal is regarded as a graph structure, and the spatial features between channels are extracted using the graph attention mechanism. The influence of different channels is dynamically adjusted through the aggregation of neighbor node information and the allocation of attention weights to ensure that the features of key nodes are retained and the modeling accuracy of spatial dependencies is improved. The attention weight obtained here reflects the degree of dependence of each node on its neighbor nodes. For example, in certain time windows, a specific channel may be more important to the prediction result. The contextual attention encoding layer will assign it a higher weight in the calculation, and can dynamically adjust the influence of each channel on the overall graph structure in different time windows.

[0072] The long-range content dependency network is based on the Swin Transformer architecture and processes the node feature matrix in blocks, including alternating hierarchical window segmentation and window multi-head self-attention operation. The expression is as follows:

[0073] ;

[0074] In the above formula, represents the node matrix characteristics, represents the window multi-head self-attention operation, represents the shift window multi-head self-attention operation, Represents the global feature representation after Swin Transformer processing.

[0075] The adaptive temporal state-space modeling module of this embodiment captures the nonlinear temporal characteristics in the EEG signal, and the calculation formula is as follows:

[0076] ;

[0077] In the above formula, represents the state of the current time step, represents the state of the previous time step, Represents the input signal at the current time step; Represents the state update function, which is used to update the state based on the previous state and the current input.

[0078] The above-mentioned adaptive time series state space modeling module is based on the Mamba module, which dynamically updates the state information of the input sequence through a selective state space model combined with temporal recursive operations; it implements selective weight allocation based on the input signal, so that the model can adjust the state according to the current input at each time step, thereby improving the accuracy and computational efficiency of time series information modeling.

[0079] In order to further verify the feasibility and technical effect of the present invention, the technical solution of the present invention is applied to a specific scenario, which specifically includes the following contents.

[0080] Step 1: Data acquisition and preprocessing

[0081] 1. Signal acquisition: Get multi-channel EEG signals from 22 EEG leads to form the original signal matrix.

[0082] 2. Filtering: Use a 1-40Hz bandpass filter to remove noise and retain signals within the effective frequency range.

[0083] 3. Normalization: Normalize the signal to make it fit within the specified range to ensure data consistency.

[0084] 4. Short-time Fourier transform: Short-time Fourier transform further converts the time domain information of the signal into frequency domain information to provide richer features, thereby better capturing the dynamic changes related to epilepsy.

[0085] 5. Signal cutting: Cut the preprocessed signal into multiple segments according to the time window length of 4 seconds.

[0086] 6. Calculate the Spearman correlation: Calculate the Spearman correlation between signals from different channels to generate the adjacency matrix.

[0087] The signal of each channel after the above preprocessing is regarded as a graph node, and whether there is a connecting edge between the corresponding nodes is determined according to the correlation between the channel signals to obtain the graph structure; the Spearman correlation between any two channel signals is calculated to determine whether the Pearson correlation is greater than the set threshold. If so, it means that there is a correlation between the corresponding two channel signals, and there is a connecting edge between the corresponding two nodes; otherwise, it means that there is no connecting edge between the corresponding two nodes.

[0088] Step 2: Input the processed multi-channel EEG signal and graph structure into the contextual attention encoding layer

[0089] 1. Input signal: Input the EEG signal matrix containing node features and the adjacency matrix generated by Spearman correlation.

[0090] 2. Attention mechanism: Each node learns the importance of its neighbor nodes through the traditional attention mechanism, and assigns different weights according to the relevance of different channels. Supplement: After experiments, it is best to choose to pass through two graph attention mechanism layers.

[0091] 3. Output features: The final output is the weighted node feature matrix (spatial topology matrix), which contains the dependency relationship between each brain region and its adjacent brain regions and is passed to the next module.

[0092] Step 3: Use the long-range content dependency network (based on the hierarchical window self-attention mechanism) to process the node feature matrix

[0093] 1. Input signal: node feature matrix after being processed by the contextual attention encoding layer.

[0094] 2. Patch partition layer + linear embedding layer: split the input into appropriate non-overlapping windows. EEG signals are usually multi-channel time series data, so a movable window is selected to split the signal, and each window will be used as a "token" to input the long-range content dependency network.

[0095] 3. Windowed multi-head self-attention layer: Divide the input features into multiple non-overlapping windows and calculate the multi-head self-attention independently in each window.

[0096] 4. Multilayer Perceptron: Perform nonlinear transformation on the output of the window multi-head self-attention layer to enhance the model's feature expression ability; MLP is used to increase the network's depth and nonlinear feature extraction capabilities. Supplement: The two MLP layers have the same effect.

[0097] 5. Shift window multi-head self-attention layer:

[0098] Based on the calculation of the previous layer, the window position is moved and then multi-head self-attention is calculated in the offset window. The purpose of this is to break the boundary of the original window so that the information between different windows can interact, thereby better modeling global features.

[0099] 6. Output features: After processing, a spatial feature matrix with global dependencies is generated and output to the next module.

[0100] Step 4: Use the adaptive time series state space modeling module to process the spatial feature matrix

[0101] Input signal: The spatial feature matrix output by the long-range content dependency network is input into the adaptive temporal state space modeling module.

[0102] 1. Input projection layer: The input projection layer expands the signal to a higher dimension through linear transformation, which helps the model capture more features and information. The expression is as follows:

[0103] ;

[0104] In the above formula, is the input projection matrix, which transforms the original signal dimension from Convert to ; is the bias term; is the signal after projection;

[0105] 2. Selective state space model layer: This layer uses the selective state space model (SSM) to process sequence data. Here, the model dynamically updates the hidden state through state space transformation to capture the temporal dependencies in the EEG signal. Through state space transformation and selection mechanism, it captures important temporal features in the EEG signal and remembers useful information over a long time span. The expression is as follows: ; ;

[0106] represents the state transfer matrix, defining the dynamics of the hidden state; is the mapping from input to hidden state; is the mapping from hidden state to output; is the time step Input features of is the time step The hidden state of

[0107] 3. Nonlinear activation layer + normalization layer: The introduction of nonlinearity enables the model to learn more complex feature representations. After normalization, the stability of signal propagation is maintained.

[0108] Non-linear activation: ,in yes Activation function;

[0109] Normalization: ;

[0110] In the above formula and They are The mean and standard deviation of and are learnable scaling and translation parameters;

[0111] 4. Output projection layer: compresses the features back to low dimensions to provide input for the epilepsy prediction mechanism. The expression is as follows:

[0112] ;

[0113] In the above formula, is the output projection matrix, is the bias term, is the output signal.

[0114] 5. Output features: The features after spatiotemporal dynamic fusion are passed to the epilepsy prediction module.

[0115] In the processing of all layers, the dynamic temporal state space module ensures computational efficiency through parallel computing and memory optimization. For example, it speeds up the state update process through a parallel scanning algorithm and optimizes resource usage by reducing data transfer between GPU cache and main memory. This ensures that the model runs efficiently when processing EEG signals, especially without causing computational bottlenecks when processing large amounts of data.

[0116] Step 5: Use the epilepsy prediction module to perform binary classification on the features after spatiotemporal dynamic fusion, that is, process the features after spatiotemporal dynamic fusion through a fully connected neural network and output the epilepsy prediction results.

[0117] like Figure 3 As shown, a section of the EEG activity graph of a patient in the CHB dataset of this embodiment is shown. In this EEG graph, different stages of epileptic seizure, pre-ictal period and interictal period can be seen, as well as the prediction results of the model for these stages. The marked red box area represents the prediction results of the model for the pre-ictal period, including correct predictions and incorrect predictions; the correctly predicted area usually indicates that the model has made a correct alarm when the epileptic seizure is about to occur, while the incorrect prediction refers to the model's misjudgment of the non-pre-ictal state, which may lead to unnecessary intervention or missed opportunities to prevent epileptic seizures.

[0118] This embodiment further applies the technical solution of the present invention to the CHB dataset.

[0119] Table 1 Contents of the CHB dataset

[0120] patient gender Age (years) Episode duration (seconds) Interictal time (hours) 1 male 11 352 63.9 2 female 11 172 33 3 male 14 402 31 4 female 22 329 149.05 5 male 7 558 35 6 male 1.5 153 40.85 7 male 14.5 325 58 8 female 3.5 919 15 9 male 10 276 62.3 10 female 3 412 37 11 male 12 806 32 12 male 2 1478 11 13 male 3 535 25 14 male 9 168 19 15 male 16 1787 26 16 male 7 84 13 17 male 12 293 18 18 male 18 317 30 19 male 19 234 27 20 male 6 294 22.06 21 male 13 199 29 22 male 9 204 28 23 male 6 424 18.1

[0121] The prediction results include the following four situations:

[0122] TP (True Positive) refers to the number of samples that are actually positive but are correctly predicted to be positive (preictal period is correctly predicted to be preictal period).

[0123] TN (True Negative) refers to the number of samples that are actually negative but are correctly predicted as negative (normal periods are correctly predicted as normal).

[0124] FN (False Negative) refers to the number of samples that are actually positive but are mistakenly predicted as negative (preictal period is predicted as interictal period).

[0125] FP (False Positive) refers to the number of samples that are actually negative but are incorrectly predicted as positive (normal periods are incorrectly predicted as epileptic seizures).

[0126] Since the ultimate goal of the present invention is to predict epilepsy based on the binary classification of spatiotemporal fusion features, the model can correctly screen out the preictal stage. The evaluation indicators are mainly AUC, Sen, and Spe.

[0127] 1. AUC: It is used to evaluate the overall distinguishing ability of the model. It can comprehensively reflect the performance of the model under various possible thresholds and is an important overall performance indicator.

[0128] AUC refers to the area under the ROC curve (Receiver Operating Characteristic Curve), which is a curve drawn with sensitivity as the vertical axis and 1-specificity as the horizontal axis, with a value between 0 and 1. In epilepsy prediction, the higher the AUC means the stronger the model's ability to distinguish between pre-ictal and interictal periods.

[0129] 2. Sensitivity (Sen): It is used to measure the model's ability to detect epileptic seizures, with the focus on reducing missed reports. The higher the sensitivity, the less likely it is to miss the golden time before an epileptic seizure, allowing patients to take medication in time for prevention.

[0130] ;

[0131] 3. Specificity (Spe): It is used to measure the model's ability to identify normal situations, with the focus on reducing false positives. The higher the specificity, the fewer false positives and the less impact on the patient's normal life.

[0132] ;

[0133] Here, the technical solution of the present invention is further compared with the prior art in terms of the above indicators, as shown in Table 2.

[0134] Table 2 Comparison data with existing technology experiments

[0135] method AUC(%) Sensitivity (%) Specificity (%) Cross Correlations - 84.00 63.00 SVM - 92.70 - RF - 82.07 95.33 RDANet 91.26 89.25 - CNN 92.80 - - LSTM+ResNet - 93.70 - Transformer+CNN 93.50 91.50 - EGCN 92.00 - - The present invention 95.32 97.36 96.34

[0136] It can be seen from the above experimental results that the present invention can capture and understand the characteristic relationships in EEG signals at different levels, and successfully capture and understand the characteristic relationships in EEG signals by combining spatial context dependency, long-range content modeling, and adaptive timing control. Specifically:

[0137] The spatial dependencies between brain regions in EEG signals are captured by the contextual attention encoding layer. Compared with traditional methods that are limited to local or fixed connection patterns, the adaptive attention mechanism in the contextual attention encoding layer enables the model to dynamically assign different attention weights according to the signal, thereby more accurately capturing the brain region connections that have a key impact on epileptic seizure prediction. The long-range content dependency network is used to model long-range feature dependencies, allowing the model to effectively process signals that span long time or spatial ranges. The local window and offset strategy in the long-range content dependency network gradually accumulates global information while retaining computational efficiency, giving the model a stronger understanding of complex long-range dependencies. The adaptive temporal state space modeling module is specifically responsible for fine-tuning temporal dynamics, filtering out redundant information in an adaptive manner, and retaining only the most important temporal features for epileptic seizure prediction. This selective control of temporal information makes the model more efficient and significantly enhances the ability to handle long-range dependencies.

Claims

1. An epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network, characterized in that: Involving a brain signal preprocessing module, a contextual attention encoding layer, a long-range content dependency network, an adaptive temporal state space modeling module and an epilepsy prediction module, the specific epilepsy prediction method includes the following steps: Step 1: Input multi-channel EEG signals to the brain signal preprocessing module, preprocess the received EEG signals, obtain the corresponding time domain information and frequency domain information, and calculate the adjacency matrix of the EEG signal space structure through Spearman correlation. The adjacency matrix obtained here is a 0\1 binary matrix; Step 2: The adjacency matrix obtained in step 1 is regarded as a graph structure. The nodes in the graph structure represent each EEG channel. The edges of the graph structure are established between the nodes with higher Spearman correlation. The weights of each edge are input into the contextual attention encoding layer. The contextual attention encoding layer uses the multi-head graph attention mechanism to extract the spatial features between each channel, and dynamically adjusts the weights through the aggregation of neighbor node information and attention, and finally outputs the node feature matrix. Step 3: The node feature matrix obtained in step 2 is input into the long-range content dependency network. The long-range content dependency network captures the long-range global dependency relationship between multiple channels through the multi-level window self-attention mechanism SW-MSA and outputs the global spatial feature and the corresponding time series; Step 4: Input the time series obtained in step 3 into the adaptive time series state space modeling module. The adaptive time series state space modeling module is based on the Mamba module and combines the state space model SSM and the convolutional neural network to obtain the spatiotemporal dynamic fusion features through the adaptive time series state space modeling module. Step 5: Input the spatiotemporal dynamic fusion features obtained in step 4 into an epilepsy prediction module. The epilepsy prediction module uses a fully connected layer to process the spatiotemporal dynamic fusion features and output an epilepsy prediction result.

2. The epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network according to claim 1, characterized in that: The preprocessing process of the brain signal preprocessing module is as follows: Step 1.1, filter the original multi-channel EEG signal to remove noise and high-frequency interference; Step 1.2: normalize the filtered EEG signal to standardize the signals of different channels to the same range; Step 1.3, perform short-time Fourier transform on the normalized EEG signal to obtain frequency domain information; Step 1.4, cut the signal after short-time Fourier transform into 4s time windows, and divide the long-term signal into multiple smaller windows to facilitate the extraction of time series features; Step 1.5, calculate the Spearman correlation between each channel. By calculating the Spearman correlation coefficient, the nonlinear relationship between each channel is measured to generate an adjacency matrix representing the spatial structure of the EEG signal; The calculation formula for Spearman correlation is as follows: ; in, n is the number of samples, is the indices of the ith data point in variable X, is the indices of the ith data point in variable Y, is the sum of squares of the odd-order differences.

3. The epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network according to claim 1, characterized in that: The method for dynamically adjusting the weights of the contextual attention encoding layer is: First, each node calculates the attention weight based on its own and neighboring node features, and then the attention weight is combined with the Spearman correlation edge weight to affect feature aggregation, that is, weighted aggregation is performed based on the attention weight and edge weight to obtain the final feature representation of the node; the expression as follows: ; In the above formula, represents the updated feature vector of node i, represents the set of neighbor nodes of node i, represents the attention weight between node i and node j, Represents the weight matrix, used for feature transformation, represents the feature vector of node j, Represents the activation function, and each node in the graph structure contains the feature information of the corresponding channel.

4. The epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network according to claim 1, characterized in that: The long-range content dependency network is based on the Swin Transformer architecture and processes the node feature matrix in blocks, including alternating hierarchical window segmentation and window multi-head self-attention operation. The expression is as follows: ; In the above formula, represents the node matrix characteristics, represents the window multi-head self-attention operation, represents the shift window multi-head self-attention operation, Represents the global feature representation after Swin Transformer processing.

5. The epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network according to claim 1, characterized in that: The adaptive temporal state-space modeling module captures the nonlinear temporal characteristics in the EEG signal, and the calculation formula is as follows: ; In the above formula, represents the state of the current time step, represents the state of the previous time step, Represents the input signal at the current time step; Represents the state update function, which is used to update the state based on the previous state and the current input.

6. The epilepsy prediction method based on adaptive spatiotemporal attention and dynamic fusion network according to claim 1, characterized in that: The epilepsy prediction module includes multiple fully connected layers, which dynamically fuses spatiotemporal features for binary classification, and the input prediction results include pre-ictal period / interictal period.

Citation Information

Patent Citations

  • Epilepsy electroencephalogram signal monitoring method and system based on space-time attention mechanism

    CN115590529A

  • Epileptic seizure prediction model training method and epileptic seizure prediction system

    CN117562551A

  • Epilepsy prediction method and device

    CN117752308A

  • Epilepsy prediction method and system in combination with spatial-temporal characteristics

    CN118072947A

  • Epilepsy electroencephalogram signal classification method based on time-space-frequency attention

    CN118319247A

Cited By

  • Method, device and equipment for predicting concentration of inhalable particles based on meteorological factors

    CN119724413A

  • Head-mounted brain body operation capability assessment method based on space-time dynamic fusion network

    CN119851952A

  • Intracranial electroencephalogram epileptic seizure early warning method based on multipath map brain network modeling

    CN119856911A

  • Bearing fault diagnosis method based on bidirectional Mama network

    CN119935555A

  • A bearing fault diagnosis method based on a bidirectional Mamba network

    CN119935555B