Seizure detection and localization system and method incorporating time convolution and transformer network
By combining temporal convolutional networks and Transformer networks, the problem of lack of time dependence and localization accuracy in EEG signals in existing epilepsy seizure detection algorithms is solved, achieving high-precision epilepsy seizure detection and dynamic visualization localization, thus improving the accuracy and interpretability of epilepsy seizure detection.
Patent Information
- Application Number
- CN202510165760.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2045-02-14
AI Technical Summary
Existing epileptic seizure detection algorithms lack the ability to capture complex time-dependent features in EEG signals and struggle to provide high-precision seizure detection and localization of lesion brain regions. In particular, deep learning-based algorithms have poor interpretability and cannot provide dynamic visualization tools.
By combining a temporal convolutional network (TCN) and a Transformer network, EEG time-frequency features are extracted through S-transform. The local feature extraction capability of TCN and the long-range dependency of Transformer are utilized to detect and locate epileptic seizures. The attention weights of EEG channels are used to locate the brain regions where epileptic seizures occur and to achieve dynamic visualization.
It improves the accuracy and robustness of epileptic seizure detection, can accurately locate epileptic foci, reduce the false detection rate caused by artifacts and noise, provides a dynamic visualization tool for the brain region where epileptic seizures occur, and enhances the interpretability of test results.
Smart Images

Figure CN120203503B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of epilepsy EEG signal detection technology, and in particular to an epilepsy seizure detection and localization system and method that combines temporal convolution and Transformer networks. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] Epilepsy is a common neurological disorder characterized by recurrent and sudden seizures caused by abnormal neuronal discharges. Electroencephalography (EEG) is an important tool for diagnosing neurological disorders and monitoring brain activity, playing a crucial role in the detection and localization of epileptic seizures. Traditional epilepsy diagnosis relies on experienced neurologists manually reviewing long-term EEG recordings, which can lead to inefficiency and diagnostic bias. Therefore, developing algorithms for seizure detection and localization can reduce the workload of neurologists and assist in clinical epilepsy treatment and preoperative evaluation.
[0004] The development of automated seizure detection systems has spanned decades, achieving significant progress and applications. Selecting an optimal classifier to train the feature vector is a crucial step in the development of machine learning-based automated seizure detection systems. Common machine learning classifiers for seizure detection include random forests, support vector machines (SVMs), decision trees, and K-nearest neighbors. While machine learning-based classifiers offer the advantage of low complexity, they typically perform poorly on large datasets and lack the ability to capture the complex temporal dependencies inherent in EEG signals. The emergence of deep learning has spurred extensive research in seizure detection, with models such as convolutional neural networks (CNNs) and long short-term memory networks (LSTMs) demonstrating superior performance.
[0005] In clinical practice, EEG waveforms associated with epileptic seizures typically originate from a few channels in the seizure onset zone and then gradually expand to the entire brain or a specific region. Clinicians need to carefully analyze multi-channel EEG recordings of epilepsy patients to determine the type and mechanism of the seizure. However, most existing automated seizure detection algorithms, especially those based on deep learning, have poor interpretability, usually providing only binary detection results and lacking information on the localization of the brain region where the seizure occurs. Only a few algorithms provide localization information by incorporating channel selection techniques. For example, existing technologies disclose an automated channel selection algorithm that uses a supervised learning random forest classifier to accurately distinguish between EEG signals during the seizure phase, interictal phase, and early interictal phase, achieving high-precision seizure monitoring and channel selection. Existing technologies combine common common spatial pattern (CSP) features with support vector machines (SVM) for seizure detection and utilize weights in the CSP matrix to determine the abnormal EEG channels for each patient. Although these methods provide channel selection, they fail to provide dynamic visualization tools for lesion localization and higher localization accuracy, and there is still room for improvement in seizure detection performance. Summary of the Invention
[0006] To address the aforementioned issues, this invention proposes a system and method for detecting and locating epileptic seizures that combines temporal convolutional networks (TCNs) and Transformers. By combining TCNs and Transformers to process EEG time-frequency features, epileptic seizures can be detected. This approach fully leverages the capabilities of TCNs in local feature extraction and the advantages of Transformers in learning long-range dependencies, facilitating the identification of multi-scale EEG features related to epilepsy. Attention weights on EEG channels enable the localization of brain regions experiencing epileptic seizures, and dynamic visualization of the localization is achieved.
[0007] In some implementations, the following technical solutions are adopted:
[0008] A system for detecting and locating epileptic seizures combining temporal convolution and Transformer networks, comprising:
[0009] The data acquisition module is configured to acquire the multi-channel EEG signal to be tested through electrodes, a multi-channel EEG amplifier and an A / D converter connected in sequence, and to divide the multi-channel EEG signal into multiple multi-channel EEG signal segments according to time.
[0010] The data processing module is configured to extract the time-frequency features of each multi-channel EEG signal segment through S-transform and perform dimensionality reduction processing.
[0011] The epilepsy seizure detection module is configured to input dimensionality-reduced multi-channel EEG signal segments into a trained TCN-Transformer model to obtain epilepsy seizure detection results. Specifically, the TCN-Transformer model first extracts features along the time dimension from the input multi-channel EEG signal segments using a TCN network, then calculates the feature vector corresponding to each channel using a Transformer encoder. The feature vectors are then fed into a fully connected layer and passed through a Softmax layer to obtain the epilepsy seizure probability score for the corresponding multi-channel EEG signal segment. After smoothing filtering, if the score is greater than a set threshold, the EEG segment is identified as an epilepsy seizure segment; otherwise, it is considered a non-seizure segment, thus obtaining the final epilepsy seizure detection result.
[0012] The epilepsy localization module is configured to calculate the weight of each channel based on the epilepsy seizure probability score when an epileptic seizure is detected, generate the final activation vector of each channel based on the weight, and realize the localization and visualization of the epileptic seizure based on the activation vector.
[0013] As a further approach, the time-frequency features of multi-channel EEG signal segments are extracted using S-transform, specifically:
[0014]
[0015] Where x(t) is the original multichannel EEG signal segment, S x (τ,f) is the S-transform spectrum of x(t), where τ is the time offset and f is the frequency.
[0016] As a further solution, the specific process of dimensionality reduction is as follows:
[0017] The time-frequency feature matrix obtained by S-transform is decomposed into p*q sub-matrices by selecting a specific frequency range in the frequency dimension and dividing the selected frequency range into p sub-frequency bands and q sub-time periods in the time dimension.
[0018] The values in each submatrix are squared and summed to perform feature fusion, thereby reducing the dimensionality of the data; finally, an n-dimensional feature vector is obtained, where n is the number of channels.
[0019] As a further approach, the weight of each channel is calculated based on the epileptic seizure probability score, specifically as follows:
[0020] If the output of the Transformer encoder is denoted as Y k,t k represents the EEG channel, t represents the time step, and S represents the time step. cThe probability score of the EEG segment after passing through a fully connected layer and softmax by the Transformer encoder is represented by the channel weight α, which is calculated by computing the back gradient and performing global average pooling at each time step. k :
[0021]
[0022] Where T is the total number of time steps.
[0023] As a further approach, the final activation vector for channel k is generated based on the weights, specifically as follows:
[0024]
[0025] As a further solution, the localization and visualization of epileptic seizures are realized based on the activation vectors. Specifically, each channel corresponds to a different location in the brain region, and the activation vector of each channel is mapped onto the brain topology map to show the distribution of EEG signals in the spatial dimension, display the activation status of different brain regions, and realize the localization and visualization of epileptic seizures.
[0026] In other embodiments, the following technical solutions are adopted:
[0027] A method for detecting and localizing epileptic seizures combining temporal convolution and Transformer networks, comprising:
[0028] The multi-channel EEG signal to be tested is acquired by sequentially connecting electrodes, a multi-channel EEG amplifier and an A / D converter, and the multi-channel EEG signal is divided into multiple multi-channel EEG signal segments according to time.
[0029] For each multi-channel EEG signal segment, the time-frequency features of the multi-channel EEG signal segment are extracted by S-transform and then dimensionality reduction is performed.
[0030] The multi-channel EEG signal segments, after dimensionality reduction, are input into a trained TCN-Transformer model to obtain the epileptic seizure detection results. Specifically, the TCN-Transformer model first extracts features along the time dimension from the input multi-channel EEG signal segments using a TCN network, and then calculates the feature vector corresponding to each channel using a Transformer encoder. The feature vectors are then fed into a fully connected layer and passed through a Softmax layer to obtain the epileptic seizure probability score for the corresponding multi-channel EEG signal segment. After smoothing filtering, if the score is greater than a set threshold, the EEG segment is identified as an epileptic seizure segment; otherwise, it is considered a non-seizure segment, thus obtaining the final epileptic seizure detection result.
[0031] When an epileptic seizure is detected, the weight of each channel is calculated based on the seizure probability score, and the final activation vector of each channel is generated based on the weight. The epileptic seizure is then located and visualized based on the activation vector.
[0032] In other embodiments, the following technical solutions are adopted:
[0033] A terminal device includes a processor and a memory, the processor being used to implement instructions; the memory being used to store multiple instructions adapted for loading and execution by the processor of the above-described method for detecting and locating epileptic seizures using a combination of temporal convolution and Transformer networks.
[0034] In other embodiments, the following technical solutions are adopted:
[0035] A computer-readable storage medium storing a plurality of instructions adapted for loading and execution by a processor of a terminal device of the above-described method for detecting and locating epileptic seizures using a combination of temporal convolution and Transformer networks.
[0036] Compared with the prior art, the beneficial effects of the present invention are:
[0037] (1) This invention combines the TCN-Transformer model with EEG time-frequency features. This feature fusion strategy effectively captures time-frequency features while preserving channel information. By utilizing the local feature extraction capability of TCN and the long-range dependency mining capability of Transformer, this method can more comprehensively capture multi-scale features from multi-channel EEG data, thereby improving the accuracy and robustness of epileptic seizure detection.
[0038] (2) The Transformer model of this invention can calculate the activation (weight) vectors of brain electrical channels during epileptic seizures. Mapping the activation vectors onto a brain topology map can show the spatial distribution of brain electrical activity, enabling accurate localization and dynamic visualization of epileptic foci.
[0039] (3) When performing epileptic seizure detection, the present invention performs smoothing filtering on the detection results of multiple EEG signal segments, which can reduce the false detection rate (FDR) caused by artifacts and noise.
[0040] Other features and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0041] Figure 1 This is a schematic diagram of the epileptic seizure detection process based on temporal convolutional attention in an embodiment of the present invention;
[0042] Figure 2 The images show the electroencephalograms (EEGs) during and outside of seizures, along with their S-transform amplitude spectra, in an embodiment of the present invention.
[0043] Figure 3 This is a schematic diagram of the compression process of the time-frequency diagram obtained from a single-channel EEG signal by S-transform in an embodiment of the present invention;
[0044] Figure 4(a) is a schematic diagram of the Temporal Convolutional Network (TCN) architecture in an embodiment of the present invention;
[0045] Figure 4(b) is a structural diagram of each layer in the temporal convolutional network in an embodiment of the present invention;
[0046] Figure 5 This is a schematic diagram of the Transformer encoder and multi-head self-attention module structure in an embodiment of the present invention;
[0047] Figure 6 This is a schematic diagram of the post-processing procedure in an embodiment of the present invention;
[0048] Figure 7 This is a brain region activation map of 7 patients experiencing epileptic seizures in an embodiment of the present invention;
[0049] Figures 8(a)-8(c) These are the brain region activation map and the original EEG signal waveform during an epileptic seizure, respectively, as described in this embodiment. Detailed Implementation
[0050] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0051] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0052] Example 1
[0053] In one or more embodiments, a seizure detection and localization system combining temporal convolution and Transformer networks is disclosed, combining... Figure 1 Specifically, it includes:
[0054] (1) The data acquisition module is configured to acquire the multi-channel EEG signal to be tested through the EEG signal acquisition device and divide the multi-channel EEG signal into multiple multi-channel EEG signal segments according to time.
[0055] In this embodiment, the EEG signal acquisition device may include electrodes, a multi-channel EEG amplifier, and an A / D converter connected in sequence; multiple electrodes are distributed on the scalp surface to capture electrical signals from different areas of the brain, forming multi-channel EEG signals, thereby providing rich spatiotemporal information.
[0056] A complete multichannel EEG signal can be divided into multiple multichannel EEG signal segments according to time. For example, a complete multichannel EEG signal can be extracted into multiple multichannel EEG signal segments according to a set time interval.
[0057] (2) The data processing module is configured to extract the time-frequency features of each multi-channel EEG signal segment through S-transform and perform dimensionality reduction processing.
[0058] In this embodiment, each EEG signal segment is processed separately.
[0059] The S-transform enables multi-resolution analysis with relatively low computational complexity, making it suitable for processing non-stationary signals such as electroencephalogram (EEG) signals.
[0060] S-transform spectrum of time-domain signal x(t) x (τ,f) is defined as follows:
[0061] S x (τ,f)=e -i2πfτ W x (τ,f) (1)
[0062]
[0063] Among them, W x (τ,f) represents the wavelet transform of x(t), ω(t-τ,f) is the wavelet function, τ is the time offset, and f is the frequency. ω(t-τ,f) is defined as:
[0064]
[0065] Finally, the S-transform is expressed as:
[0066]
[0067] In this embodiment, each 4-second multi-channel EEG signal segment is denoted by x(t). The S-transform is applied to each 4-second 18-channel EEG signal segment, converting it from the time domain to the time-frequency domain. The resulting time-frequency matrix has dimensions of 18×128×1024, where 18 represents the number of EEG channels, 128 corresponds to the frequency range of 1 to 128 Hz, and 1024 represents the time step of each segment. Figure 2 This demonstrates the differences between EEG fragments from a single channel in patients chb01 during seizures and in non-seizure states; Figure 2 Images (a) and (b) show EEG fragments during and outside of seizures, respectively. Figure 2 (c) and (d) in the figure show the corresponding S-transform amplitude spectrum.
[0068] In the time-frequency power spectrum, the Y-axis represents the frequency range from 0 to 128 Hz, and the color intensity corresponds to the power associated with the corresponding time-frequency distribution. It can be seen that the time-frequency distribution obtained through the S-transform reveals a significant difference in frequency content between the seizure and non-seizure periods. During a seizure, the energy increases significantly over a wider frequency range compared to the low-frequency distribution in the non-seizure EEG signal, particularly between 1 and 50 Hz. This highlights the S-transform's ability to capture fine-grained time-frequency patterns that are not apparent in the original EEG signal.
[0069] Figure 3 This paper demonstrates the time-frequency fusion process of a single-channel EEG signal. The time-frequency distribution of the EEG signal obtained through S-transform is shown, with the horizontal axis representing time (0-4 seconds) and the vertical axis representing frequency (0-128 Hz). To reduce artifacts such as electromyographic interference, electrooculographic interference, and environmental noise, frequency components from 1-50 Hz were selected from the original EEG signal. Subsequently, the selected frequency band was divided into six sub-bands: delta wave (1-4 Hz), theta wave (4-8 Hz), alpha wave (8-12 Hz), beta wave (12-30 Hz), γ1 wave (30-40 Hz), and γ2 wave (40-50 Hz). On the time axis, each 4-second EEG segment was divided into two sub-segments, each lasting 2 seconds. As a result, the time-frequency matrix obtained from the S-transform was decomposed into 12 sub-matrices. The values in each sub-matrice were summed by squares for feature fusion and dimensionality reduction, resulting in a one-dimensional feature vector for that single channel. Time-frequency fusion of the n-channel EEG signals yielded an n-dimensional feature vector.
[0070] This embodiment reduces the dimension of each multi-channel EEG signal from 18×128×1024 to 18×12 through the fusion process, which greatly reduces the computational complexity of the model while preserving important information related to channels and frequencies, which helps to locate the activated brain regions during epileptic seizures.
[0071] (3) The epileptic seizure detection module is configured to input the multi-channel EEG signal segments processed by dimensionality reduction into the trained TCN-Transformer model to obtain the epileptic seizure detection result. The TCN-Transformer model first extracts features along the time dimension of the input multi-channel EEG signal segments through the TCN network, and then calculates the output of the TCN network through the multi-head attention block (MHA) and feedforward network (FFN) of the Transformer encoder to obtain the feature vector corresponding to each channel. The feature vector is sent into the fully connected layer and after Softmax, the epileptic seizure probability score of the corresponding multi-channel EEG signal segment is obtained. After smoothing filtering, if the score is greater than the set threshold, the EEG segment is judged as an epileptic seizure segment; otherwise, it is a non-seizure segment, and finally the epileptic seizure detection result is obtained.
[0072] This embodiment uses the TCN-Transformer model to capture the local and global dependencies of EEG signals associated with epileptic seizures, which helps to capture multi-channel EEG features.
[0073] This model can preserve EEG channel information and dynamically visualize active channels. It can also locate the brain region where epileptic seizures occur by using the attention weights of EEG channels, making the detection results highly interpretable.
[0074] Specifically, as shown in Figure 4(a), the Temporal Convolutional Network (TCN) in this embodiment adopts a four-layer structure, including one input layer, two hidden layers, and one output layer. The filter size is k=3, and the dilation factor is d=1,2,4. Each layer consists of three modules: causal convolution, dilated convolution, and residual connection, as shown in Figure 4(b). The model input is first fed into the causal convolution and dilated convolution, then passes through the normalization layers WeightNorm, ReLU, and Dropout in sequence, and finally passes through the residual connection to obtain the output.
[0075] Causal convolution is used to prevent the leakage of future information, ensuring that the output at time t depends only on elements at time t and earlier. Unlike traditional convolutional networks, causal convolution is a unidirectional structure that can only access past data. Furthermore, dilated convolution aims to better process long-term sequence data through a larger receptive field. The dilation rate is controlled by the hyperparameter d. The formula for dilated convolution is as follows:
[0076]
[0077] Where d is the expansion factor, M is the filter size, and (td*i) represents the position of the historical sequence.
[0078] As can be seen from the above analysis, dilated convolution can flexibly expand the receptive field by choosing a larger filter size M and a dilation factor d that grows exponentially with the network depth.
[0079] Since EEG signals are typical time-series data, TCN can extract features at multiple time steps, thus enhancing the extraction of EEG features along the time dimension. The preprocessed EEG signal is input into a four-layer TCN module for feature extraction along the time dimension. In this model, TCN maintains consistency in the dimensions of the input and output matrices, ensuring that the correlation between channels is preserved while extracting features.
[0080] In this embodiment, EEG data from each channel is treated as a label in the sequence; this process is called channel embedding. Given that epilepsy detection is essentially a classification task, this embodiment employs a multi-layered stacked Transformer encoder module. Specifically, the output of the TCN serves as the input feature of the Transformer encoder. The Transformer encoder consists of two main modules: a multi-head self-attention mechanism (MHA) and a feedforward network (FFN), both using residual connections. The FFN consists of two linear transformations connected by a ReLU activation function, facilitating the transformation of complex features.
[0081] Self-attention can be described as a mapping from a query Q to a set of key-value pairs (K,V). The dimensions of Q and K are d. k The dimension of V is d. v .
[0082] The output of sequence S after the self-attention mechanism can be calculated using the following formula:
[0083] [Q,K,V]=S[W Q W K W V (6)
[0084]
[0085] in and It is a linear transformation matrix; in the multi-head self-attention (MSA) mechanism, multiple self-attention operations run in parallel, and the output is obtained after concatenation:
[0086] MHA(S)=concat(head1(S),…,head h (S))W O (8)
[0087] in In this embodiment, d k =d v=d model / h, using multi-head attention with h=8.
[0088] Figure 5 The structure of the Transformer encoder and the multi-head self-attention (MHA) module is shown. The Transformer encoder in this study consists of L=2 layers, each containing h=8 attention heads. The process of the Transformer encoder can be represented by the following formula:
[0089] y i =MHA(S i-1 (9)
[0090] S i =LN(S i-1 +y i )+FFN(LN(y i (10)
[0091] Where i = 1, ..., L and L = 2. LN stands for Layer Normalization, which normalizes the features of each sample so that the mean is 0 and the variance is 1. LN(S i-1 +y i This involves layer normalization of the features following the residual connections. FFN stands for Feed-Forward Network, which typically consists of two linear transformations plus an activation function.
[0092] Finally, max pooling is performed along the first dimension of S to obtain the input to the fully connected (FC) module. The two FC layers contain 216 and 2 neurons respectively. Ultimately, the data from the FC layers is passed through a softmax layer to output the probabilities of seizures and non-seizure events, i.e., the seizure probability score.
[0093] Each channel of the EEG signal corresponds to activity at a specific spatial location in the brain, meaning that the spatial correlation between channels essentially reflects location information. Furthermore, this embodiment uses S-transform to extract the time-frequency representation of the raw EEG signal, thus eliminating the need for location information encoding to capture the time series; therefore, location encoding is unnecessary.
[0094] After obtaining the seizure probability score for each multi-channel EEG signal segment, the process also includes smoothing and filtering the detection probability scores; this mainly includes the following two steps:
[0095] (3-1) In order to eliminate isolated false positives, the probability scores of each multichannel EEG signal segment are first smoothed by applying a moving average filter (MAF).
[0096] (3-2) Thresholding is performed. The part of the probability score that exceeds the set threshold is assigned a value of 1, indicating that the corresponding multi-channel EEG signal segment is identified as an epileptic seizure. The probability score that does not exceed the threshold is assigned a value of 0, indicating that the corresponding multi-channel EEG signal segment is identified as a non-epilepsy seizure.
[0097] (3-3) The model's detection results were further processed using a 40-second window sliding (sliding 10 EEG segments at a time). If 5 or more segments within the window were classified as epileptic seizures, all multichannel EEG signal segments within that time period were labeled as epileptic seizures.
[0098] Figure 6 An example of a post-processing procedure is shown, in which, Figure 6 (a) in this embodiment shows the detection results of one hour of EEG signals by the TCN-Transformer model. Figure 6 (b) in the figure represents the output after smoothing by moving average filtering; Figure 6 (c) in the table represents the binary value result after thresholding. Figure 6 (d) in the figure represents the final result after the sliding window is marked.
[0099] (4) Epilepsy localization module, configured to calculate the weight of each channel based on the epilepsy seizure probability score when an epileptic seizure is detected, generate the final activation vector of each channel based on the weight, and realize the localization and visualization of the epileptic seizure based on the activation vector.
[0100] The interpretability of neural networks is crucial in medical applications. Fine-grained information, such as activated brain regions and EEG waveform frequencies, aids in the clinical diagnosis of epilepsy. The aforementioned EEG signal feature extraction process preserves channel and frequency information, enabling the TCN-Transformer model to allocate different attention to different channels and frequencies, thereby achieving the localization of epileptic foci.
[0101] This embodiment uses a multi-channel activation map method to visualize the localization of epileptic foci.
[0102] If the Transformer encoder output is Y k,t k represents the EEG channel, t represents the time step, and S represents the time step. c The probability score of the EEG segment after passing through a fully connected layer and softmax by the Transformer encoder is represented by the channel weight α, which is calculated by computing the back gradient and performing global average pooling at each time step. k :
[0103]
[0104] Where T is the total number of time steps.
[0105] Then, the channel weight α k The Transformer encoder output is Y k,t After performing a weighted summation and applying the ReLU function for normalization to retain the positive values contributing to epileptic seizures, the activation vector for channel k is finally obtained as follows:
[0106]
[0107] L(k) represents the activation vector of channel k, which is an n-dimensional array where n is the number of EEG channels.
[0108] This embodiment maps L(k) onto a brain topology map. The topology map reveals the activation levels of different brain regions during an epileptic seizure, as well as the roles of different brain regions in a seizure, thus enabling the localization and visualization of seizures. This embodiment allows visualization of brain regions involved in epileptic activity and provides a direct observation of the dynamic evolution of seizures, aiding in understanding the evolutionary mechanisms of epileptic seizures.
[0109] The system of this embodiment will be experimentally verified below.
[0110] This embodiment used long-term scalp electroencephalogram (EEG) data from 30 epilepsy patients. Signal acquisition followed the international 10-20 system for electrode placement and naming, and the start and end times of each epileptic seizure event were labeled by medical professionals. The experiment was conducted on a computer equipped with a 3.60GHz AMD Ryzen 5 2400G CPU and 16GB of RAM, and programmed using Python 3.6 and PyTorch 1.10.2.
[0111] Two metrics were used for evaluation: sensitivity and false positive rate (FDR). Sensitivity was defined as the ratio of correctly detected epileptic events to the total number of epileptic events used for validation per patient. FDR was measured by the average number of false positives per hour. In 172 epileptic seizure events, the model achieved an average sensitivity of 99.75%, with only one seizure event failing to be detected. The average false positive rate (FDR) was 0.21 times per hour, with 9 cases having an FDR of 0 times per hour.
[0112] By using the multi-channel EEG activation map method of this invention to calculate the sensitivity of the activation values of the output feature map, the channels associated with the onset of epileptic seizures can be analyzed more intuitively. Figure 7Brain region activation maps of seven patients during seizure events are presented. Figure 8 shows the multichannel EEG activation map and raw EEG signal waveforms detected by the method of this embodiment. Figure 8(a) shows the first seizure event of the 10th patient, with the seizure starting at 6313 seconds. Figures 8(b) and (c) show two seizure events from the 6th patient, starting at 1723 seconds and 6210 seconds, respectively. Table 1 presents the epilepsy localization results for the seven patients. The second column of Table 1 lists the lesion brain regions of the patients, which were determined by medical experts based on long-term EEG, MRI, and clinical records. The third column of Table 1 lists one or two of the most prominent epileptic lesion brain regions detected by the method of this embodiment for each seizure event of each patient; it can be seen that the method of this embodiment can effectively identify the lesion brain regions of seizures compared with the reference regions in the second column.
[0113] Table 1. Epilepsy localization results of seven patients.
[0114]
[0115]
[0116] Note: T = temporal lobe, F = frontal lobe, O = occipital lobe, P = parietal lobe, C = central lobe.
[0117] Example 2
[0118] In one or more embodiments, a method for detecting and locating epileptic seizures combining temporal convolution and Transformer networks is disclosed, including:
[0119] The multi-channel EEG signal to be tested is acquired by sequentially connecting electrodes, a multi-channel EEG amplifier and an A / D converter, and the multi-channel EEG signal is divided into multiple multi-channel EEG signal segments according to time.
[0120] For each multi-channel EEG signal segment, the time-frequency features of the multi-channel EEG signal segment are extracted by S-transform and then dimensionality reduction is performed.
[0121] The multi-channel EEG signal segments, after dimensionality reduction, are input into a trained TCN-Transformer model to obtain the epileptic seizure detection results. Specifically, the TCN-Transformer model first extracts features along the time dimension from the input multi-channel EEG signal segments using a TCN network, and then calculates the feature vector corresponding to each channel using a Transformer encoder. The feature vectors are then fed into a fully connected layer and passed through a Softmax layer to obtain the epileptic seizure probability score for the corresponding multi-channel EEG signal segment. After smoothing filtering, if the score is greater than a set threshold, the EEG segment is identified as an epileptic seizure segment; otherwise, it is considered a non-seizure segment, thus obtaining the final epileptic seizure detection result.
[0122] When an epileptic seizure is detected, the weight of each channel is calculated based on the seizure probability score, and the final activation vector of each channel is generated based on the weight. The epileptic seizure is then located and visualized based on the activation vector.
[0123] The implementation of each step in the above method is exactly the same as in Example 1.
[0124] Example 3
[0125] In one or more embodiments, a terminal device is disclosed, comprising a processor and a memory, wherein the processor is used to implement instructions; and the memory is used to store multiple instructions adapted to be loaded by the processor and executed by the processor for the method of epileptic seizure detection and localization combining temporal convolution and Transformer networks in Embodiment 2.
[0126] Example 4
[0127] In one or more embodiments, a computer-readable storage medium is disclosed, wherein a plurality of instructions are stored, the instructions being adapted to be loaded by a processor of a terminal device and executed by the method for detecting and locating epileptic seizures combining temporal convolution and Transformer networks as described in Embodiment 2.
[0128] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A seizure detection and localization system that combines time convolution and Transformer networks, characterized in that, The method comprises the following steps: The data acquisition module is configured to acquire the multi-channel electroencephalogram signal to be measured through the electrodes, the multi-channel electroencephalogram amplifier and the A / D converter connected in sequence, and divide the multi-channel electroencephalogram signal into a plurality of multi-channel electroencephalogram signal segments according to time; The data processing module is configured to extract the time-frequency features of the multi-channel electroencephalogram signal segment through S transform for each multi-channel electroencephalogram signal segment, and perform dimension reduction processing; The seizure detection module is configured to input the multi-channel electroencephalogram signal segment subjected to the dimension reduction processing into a trained TCN-Transformer model to obtain a seizure detection result; wherein the TCN-Transformer model firstly extracts features of the input multi-channel electroencephalogram signal segment along the time dimension through a TCN network, then calculates the output of the TCN network through a Transformer encoder to obtain a feature vector corresponding to each channel; the feature vector is sent to a fully connected layer, and a seizure probability score corresponding to the multi-channel electroencephalogram signal segment is obtained after Softmax; after smoothing filtering, if the score is greater than a set threshold, the electroencephalogram signal segment is judged as a seizure segment, otherwise it is a non-seizure segment, and finally the seizure detection result is obtained; The seizure positioning module is configured to calculate the weight of each channel based on the seizure probability score when a seizure is detected, generate a final activation vector of each channel based on the weight, and realize the positioning and visualization of the seizure based on the activation vector.
2. The system for seizure detection and localization combining time convolution and Transformer network according to claim 1, wherein, The time-frequency features of the multi-channel electroencephalogram signal segment are extracted through S transform, specifically: ; wherein, is the original multi-channel EEG signal segment, is the S-transform spectrum of, The specific process of dimension reduction processing is: is the time offset, f is the frequency.
3. The system for seizure detection and localization combining time convolution and Transformer network according to claim 1, wherein, The weight of each channel is calculated based on the seizure probability score, specifically: The time-frequency feature matrix obtained by the S transform is selected in a specific frequency range in the frequency dimension, and the selected frequency range is divided into p sub-frequency bands; in the time dimension, into q sub-time periods; so that the time-frequency feature matrix obtained by the S transform is decomposed into p * q sub-matrices; The values in each sub-matrix are squared and summed to realize feature fusion, and data dimension reduction is realized. Finally, a n dimensional feature vector is obtained. n is the number of brain electrical channels.
4. The system for seizure detection and localization combining time convolution and Transformer network according to claim 1, wherein, The positioning and visualization of the seizure are realized based on the activation vector, specifically: If the Transformer encoder output is denoted by , is an electroencephalography channel, is a time step, denotes the probability scores of the electroencephalography signal segment after the Transformer encoder followed by a fully connected layer and a softmax, then the corresponding channel weights are computed by computing the backpropagated gradients and performing global average pooling over the time steps : ; wherein, is the total number of time steps.
5. The system for seizure detection and localization combining time convolution and Transformer network according to claim 4, wherein, Generating a channel based on weights the final activation vector, in particular: 。 6. The system for seizure detection and localization combining time convolution and Transformer network according to claim 5, wherein, The different positions of the brain region corresponding to each channel are mapped to the brain topological map to show the distribution of the electroencephalogram signal in the spatial dimension, display the activation of different brain regions, realize the positioning and visualization of the seizure. The instructions are suitable for being loaded and executed by the processor to realize the seizure detection and positioning method combining time convolution and Transformer network, which comprises the following steps:
7. A terminal device comprising a processor and a memory, the processor configured to implement instructions; the memory configured to store a plurality of instructions, the terminal device characterized by, Acquire the multi-channel electroencephalogram signal to be measured through the electrodes, the multi-channel electroencephalogram amplifier and the A / D converter connected in sequence, and divide the multi-channel electroencephalogram signal into a plurality of multi-channel electroencephalogram signal segments according to time; Extract the time-frequency features of the multi-channel electroencephalogram signal segment through S transform for each multi-channel electroencephalogram signal segment, and perform dimension reduction processing; The dimension-reduced multi-channel electroencephalogram segment is input into the trained TCN-Transformer model to obtain a seizure detection result; wherein the TCN-Transformer model first extracts features of the input multi-channel electroencephalogram segment along the time dimension through a TCN network, and then calculates the output of the TCN network through a Transformer encoder to obtain a feature vector corresponding to each channel; the feature vector is input into a fully connected layer, and a seizure probability score of the corresponding multi-channel electroencephalogram segment is obtained after Softmax, and after smoothing filtering, if the score is greater than a set threshold, the electroencephalogram segment is judged as a seizure segment, otherwise it is a non-seizure segment, and finally a seizure detection result is obtained; When a seizure is detected, the weight of each channel is calculated based on the seizure probability score, the final activation vector of each channel is generated based on the weight, and the localization and visualization of the seizure are realized based on the activation vector.
8. A computer-readable storage medium having stored therein a plurality of instructions, wherein the instructions, when executed by a processor, cause the processor to perform operations comprising: The instructions are adapted to be loaded and executed by the processor of the terminal device to implement the seizure detection and localization method combining time convolution and Transformer network, which comprises: The multi-channel electroencephalogram to be measured is acquired through the electrodes, the multi-channel electroencephalogram amplifier and the A / D converter connected in sequence, and the multi-channel electroencephalogram is divided into a plurality of multi-channel electroencephalogram segments according to time; For each multi-channel electroencephalogram segment, the time-frequency features of the multi-channel electroencephalogram segment are extracted through S transform and dimension reduction processing is performed; The dimension-reduced multi-channel electroencephalogram segment is input into the trained TCN-Transformer model to obtain a seizure detection result; wherein the TCN-Transformer model first extracts features of the input multi-channel electroencephalogram segment along the time dimension through a TCN network, and then calculates the output of the TCN network through a Transformer encoder to obtain a feature vector corresponding to each channel; the feature vector is input into a fully connected layer, and a seizure probability score of the corresponding multi-channel electroencephalogram segment is obtained after Softmax, and after smoothing filtering, if the score is greater than a set threshold, the electroencephalogram segment is judged as a seizure segment, otherwise it is a non-seizure segment, and finally a seizure detection result is obtained; When a seizure is detected, the weight of each channel is calculated based on the seizure probability score, the final activation vector of each channel is generated based on the weight, and the localization and visualization of the seizure are realized based on the activation vector.
Citation Information
Patent Citations
Epileptic seizure prediction method through electroencephalogram signal on the basis of multi-scale convolution and self-attention network
CN113907706A
Epileptic seizure prediction system based on CNN and self-attention mechanism
CN115381407A