Method and system for seizure detection and automatic annotation based on electroencephalography data
By using the SC-LSTM model to process the spatial and temporal features of EEG data in parallel, the problems of information loss and model inflexibility in existing technologies are solved, enabling efficient and accurate detection and automatic annotation of epileptic seizures, and reducing the workload of doctors.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI JIAOTONG UNIV
- Filing Date
- 2024-05-23
- Publication Date
- 2026-06-02
Smart Images

Figure CN118557150B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of information science of mental illness, neuroscience, medical image processing and artificial intelligence, and specifically to a method and system for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data. Background Technology
[0002] Epilepsy is a common chronic neurological disorder caused by abnormal electrical discharges in the brain. Typically, during a seizure, patients lose consciousness due to transient brain dysfunction, focal or generalized convulsions, and fainting. There are approximately 65 million people with epilepsy worldwide, with about 2 million new cases each year. Furthermore, frequent seizures can cause irreversible brain damage, severely impacting physical function and causing psychological harm. Therefore, timely diagnosis and treatment with antiepileptic drugs are of paramount importance.
[0003] Generally, neurologists detect epilepsy and locate the affected area by analyzing the shape and amplitude of abnormal brainwave bands. However, visual observation, which relies on expert experience and expertise, has several drawbacks. First, visual observation depends heavily on expert experience and expertise. Second, electroencephalogram (EEG) signals are acquired at high frequencies and generate large amounts of data, requiring lengthy visual observation periods. Furthermore, prolonged visual observation can affect the accuracy of neurologists' detection, leading to serious consequences such as misdiagnosis and missed diagnosis. Additionally, EEG signals are susceptible to environmental noise, further complicating visual observation. Therefore, developing computer-aided systems to assist neurologists in detecting epilepsy is necessary.
[0004] Machine learning (ML) was once the most commonly used method for detecting epileptic seizures. However, ML methods require manually designing feature extractors to capture seizure features, making it difficult to extract discriminative features. In recent years, rapid advancements in neural network theory and parallel computing technology have led to significant breakthroughs in deep learning (DL). DL technology has been successfully applied in fields such as image recognition, speech recognition, and emotion recognition. Furthermore, its applications in the medical field are gradually emerging. Deep learning technology originates from machine learning methods, typically possessing a multi-layered structure and enhanced non-linearity through activation functions. DL technology can automatically capture effective features from EEG signals and achieve end-to-end seizure detection. Applying DL technology to seizure detection can reduce the workload of neurologists, improve work efficiency, and enhance detection accuracy. Therefore, this paper is interested in DL-based seizure detection methods. DL-based seizure detection models can be broadly categorized into three types: models based on convolutional neural networks (CNNs), models based on recurrent neural networks (RNNs), and hybrid models.
[0005] CNN-based models extract features from EEG signals through convolution and pooling operations. Various types of CNN networks, including multi-layer CNNs, one-dimensional convolutional neural networks (1DCNNs), and three-dimensional convolutional neural networks (3DCNNs), have been used for seizure detection. Acharya et al. proposed a 13-layer CNN to distinguish between normal EEG signals, epileptic intermittent signals, and seizure signals. Antoniades et al. designed a four-layer CNN to detect epileptiform discharges in intracranial EEGs. Elakkiya et al. developed a seizure detection model based on a 1DCNN model. Wei et al. introduced a 3DCNN for seizure detection using multi-channel EEG signals. Shoji et al. proposed a multi-channel CNN network to detect abnormal patterns in EEG signals. Many deeper network structures based on convolutional neural networks have been developed and used for epilepsy diagnosis, such as AlexNet, VGG, GoogleNet, and ResNet. Taqi et al. used the AlexNet network to diagnose focal seizures. Emami et al. explored the idea of detecting seizures on sEEG signal maps. In the preprocessing step, the signal is segmented into different time windows and classified using VGG-16, effectively detecting small EEG signal changes using small (3×3) convolutional filters. Taqi et al. used this network in their preliminary study to diagnose epileptic seizures. Their model was used to extract features from the Bern-Barcelona dataset and achieved excellent results. Bizopoulos et al. introduced two ResNet and DenseNet architectures to diagnose epileptic seizures and achieved good results.
[0006] RNN-based models are commonly used to process sequential data and are widely used in natural language processing and machine translation. Long Short-Term Memory (LSTM) networks are a variant of RNNs. By introducing a gating mechanism, LSTMs effectively solve the gradient vanishing problem of traditional RNN models and are suitable for handling long-term dependencies. Abbasi et al. developed a two-layer LSTM for seizure detection. Manohar et al. used short-time Fourier transform to preprocess EEG signals and then used a bidirectional LSTM for seizure detection.
[0007] In recent years, researchers have attempted to leverage the advantages of CNN and RNN models. Many hybrid models have been developed. Xu et al. proposed a 1D CNN-LSTM model to identify epileptic seizures, achieving a 5% improvement in F1 score compared to CNN models. Liu et al. proposed a method for epilepsy detection combining CNN and Bi-LSTM, which outperformed four CNN variants and one LSTM model.
[0008] Despite advancements in automated epilepsy testing, existing solutions still have limitations. Firstly, most current methods require complex preprocessing of EEG data, such as removing unwanted electrodes, using a 40Hz low-pass bandpass filter to remove waveform spikes, a 0.1Hz high-pass filter to smooth the waveform, segmentation, and baseline correction. This requires significant signal processing work, hindering automation and efficiency. Secondly, substantial feature engineering is required, such as Fourier transforms to convert difficult-to-process signals into easily analyzable frequency domain signals. Based on this, time-domain and frequency-domain feature extraction is performed. Common EEG time-domain techniques include autoregressive modeling, fractal dimension based on the Higuchi algorithm, statistical features, and detrended fluctuation analysis. Common EEG frequency-domain techniques include Fourier transform (FT), power spectral density (PSD), band power (BP), and Hilbert-Huang transform (HHT). Finally, the extracted features are standardized before being used for prediction.
[0009] In fact, EEG signals are non-linear time series. CNN-based methods excel at extracting local features and exhibit good feature extraction performance for non-stationary and noisy signals, but they face some difficulties in capturing the global correlations of time series data. Long Short-Term Memory (LSTM) is a variant of recurrent neural networks, commonly used to process non-linear features of time series, such as EEG. It considers the long-term dependencies of the time series but ignores local spatial information. Existing methods integrating CNN and RNN models are essentially sequential processing methods, where EEG features processed by CNN are then input into the RNN network for final prediction. The main problems with this approach include: 1. Information loss: In the sequential processing, CNN first extracts spatial information and then inputs it into LSTM for temporal processing. This approach can lead to information loss because CNNs may fail to capture subtle changes related to temporal information, while LSTMs may not utilize all spatial information. This can result in insufficient coupling between the two networks, preventing them from fully leveraging each other's feature representation capabilities. Furthermore, the sequential structure makes the model architecture inflexible, making it difficult to adjust the structure to adapt to different data features or task requirements. Additionally, the interaction between the number of layers in CNNs and LSTMs can lead to gradient explosion or vanishing gradient problems. For example, when the features extracted by the CNN contain a large amount of information, and the LSTM network is shallow, gradient vanishing may occur during backpropagation. This can cause the model to have difficulty converging or to fail to learn effective temporal feature representations.
[0010] First, traditional epilepsy diagnosis requires professional image interpreters to spend a significant amount of time on annotation, and the image interpretation process is relatively subjective and lacks standardized criteria. Therefore, computer-based methods are needed for image interpretation diagnosis. However, existing computer-based epilepsy detection tools often lack sufficient detailed and complete information from their authors to reproduce the results, data is unavailable, code is not shared, and baseline models for comparing model performance are either nonexistent or unavailable. Secondly, all three existing computational methods have certain shortcomings and defects: Convolutional Neural Network (CNN) methods cannot capture the global information of EEG signals as continuous temporal data. At the same time, EEG data segments are often long-range and multi-channel, containing rich spatial and temporal information. Simple convolutional blocks can only use fixed-size kernels to fuse spatial and channel information simultaneously, and the feature maps lack discriminative power. Recurrent Neural Network (RNN) methods cannot capture the spatial characteristics of EEG as a medical image. The CNN-LSTM hybrid method processes EEG data serially to capture spatial correlation and temporal dependence, which causes information loss. At the same time, the serial structure makes the architecture inflexible. The fixed feature dimension extracted by CNN means that the subsequent LSTM can only determine the hyperparameters based on the CNN output, making it difficult to flexibly adjust the model structure to adapt to different data features or task requirements. This limits the performance and applicability of the model. Summary of the Invention
[0011] To address the shortcomings of existing technologies, the purpose of this invention is to provide a method and system for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data.
[0012] The method for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data according to the present invention includes:
[0013] Step 1: Obtain EEG recordings of individuals with a high probability of epileptic seizures and perform preprocessing;
[0014] The preprocessing includes: preliminary screening based on expert opinions; generating bipolar montages and rearranging signals in different EDF files to the same order; downsampling the data; dividing the EEG into EEG segments according to different time window sizes and the number of blocks for evaluation, taking non-overlapping EEG segments as positive samples, and taking the same size and number of EEG segments from the EEG marked as non-occurrence as negative samples.
[0015] Step 2: Build a deep learning-based SC-LSTM model, including two parallel feature extraction modules and one classification module, for feature extraction, feature selection and fusion, and epilepsy detection and classification of EEG.
[0016] The reduced-frequency EEG data is used as input. In the first feature extraction module, a 3-layer 2D convolutional block is used as the basic architecture, and two types of spatial and channel reconstruction convolution SCConv are inserted to extract the spatial and channel features of the EEG data.
[0017] The temporal features of the original data are extracted using a bidirectional long short-term memory network (BiLSTM) in parallel. The spatial and channel features of the extracted EEG data and the temporal features of the original data are unified into a one-dimensional feature vector using a Flatten layer, and a lateral connection operation is performed as the final feature representation.
[0018] The classification module consists of three fully connected layers, using the sigmoid activation function to make the output between (0, 1).
[0019] Preferably, the spatial information of EEG features is extracted using the SCConv neural network, specifically as follows:
[0020] Spatial features of EEG data are extracted based on three two-dimensional convolutional blocks. The two-dimensional convolutional layer performs convolution operations on the input image by sliding a small matrix called a convolution kernel or filter to extract the required feature information. In the two-dimensional convolutional layer, the convolution kernel is a two-dimensional matrix that is multiplied and summed element-wise with the input image to obtain the output feature map. The calculation formula is as follows:
[0021]
[0022] Where out represents the output of the convolution operation, and N represents the batch size. i C represents the i-th batch, and C represents the number of channels. Represents the j-th output channel. This represents the output of the convolution computation for the i-th batch and j-th channel, where bias represents a learnable bias value. C represents the bias of the j-th channel. in This represents the number of input channels, where k is the counting sign from 0 to C. in-1 weight represents the weight value of the convolution kernel. This represents the kernel weights used in the convolution calculation of the feature map of the k-th input channel by the j-th convolutional block; ★ represents 2D cross-correlation operation; input represents the input feature map; input(N i ,k) represents the feature map of the kth channel of the i-th batch.
[0023] Preferably, a self-correcting convolutional block is introduced between the first and second two-dimensional convolutional blocks to expand the convolutional receptive field through intrinsic feature communication, thereby enhancing the diversity of output features;
[0024] Given a set of shapes (C, C, k)h k w The convolution kernel K, where k h and k w Let C represent the spatial height and width, respectively, and C represent the number of channels. We divide them into four parts, each responsible for a different function. Assume C is divisible by 2. The convolutional kernel set is divided into four parts using... This indicates that the shape of each part of the convolution kernel is...
[0025] The workflow of the self-calibrating convolutional block is as follows: First, the input X is evenly divided into two parts {X1, X2}. Then, these two inputs are fed into a feature processing path to collect different types of contextual information. In the first path, X1 is self-calibrated using {K1, K2, K3} to obtain Y1. In the second path, a convolution operation is performed. This operation aims to preserve the original spatial context; then the two intermediate outputs {Y1, Y2} are concatenated together as the output Y.
[0026] For X1, average pooling with filter size r×r and stride r is used to obtain the intermediate feature T1, expressed as:
[0027] T1 = AvgPool r (X1)
[0028] Then, K2 is used to perform feature transformation on T1 to obtain the intermediate feature X′1, which is expressed as:
[0029]
[0030] Up() is a bilinear interpolation operator that maps intermediate references from a small-scale space to the original feature space.
[0031] The calibration procedure is described below:
[0032]
[0033] in, σ is the sigmoid function, and the symbol · indicates element-wise multiplication; then X′1 is used as the residual to form the weights for calibration, and the final output after calibration is:
[0034]
[0035] For X2, Y2 is obtained by performing feature transformation using K2, and the expression is:
[0036]
[0037] in, For convolution operations, Y1 and Y2 are obtained, and then concatenated according to channels to obtain the final output Y of the self-correcting convolution block;
[0038] Spatial and channel reconstruction convolutional blocks are introduced between the second and third two-dimensional convolutional blocks, which include two core units: the spatial reconstruction unit (SRU) and the channel reconstruction unit (CRU). The SRU reduces spatial redundancy through a separation-reconstruction method, while the CRU reduces channel redundancy through a segmentation-transformation-fusion method.
[0039] Separation operation: The purpose is to separate information-rich feature maps from feature maps with less information corresponding to spatial content. The scaling factor in the group normalization layer (GN) is used to evaluate the information content of different feature maps. Specifically, given an intermediate feature map... Where N is the batch axis, C is the channel axis, and H and W are the spatial height and width axes; firstly, the input feature X is standardized by subtracting the mean μ and dividing by the standard deviation σ, as expressed by:
[0040]
[0041] Where μ and σ are the mean and standard deviation of X, ε is a small positive constant added for division stability, and γ and β are trainable affine transformations; using the trainable parameter γ∈R in the GN layer C As a method for measuring the spatial pixel variance of each batch and channel; normalized correlation weights W γ ∈R C The following formula represents the importance of different feature maps:
[0042]
[0043] Then via W γ The reweighted feature map weights are mapped to the (0, 1) range using the sigmoid function and then gated by a threshold. Weights above the threshold are set to 1 to obtain the information weight W1, and those above the threshold are set to 0 to obtain the non-information weight W2. The entire process of obtaining W is represented as follows:
[0044] W = Gate(Sigmoid(W) γ (GN(X))))
[0045] Finally, the input feature X is multiplied by W1 and W2 respectively to obtain two weighted features: the one with higher information content and the one with higher information content. and less information This divides the input features into two parts: Spatial content that is informative and expressive It contains little or no information and is considered redundant;
[0046] Reconstruction operation: This operation adds information-rich features to less information-rich features to generate more information-rich features, thus saving space. This operation uses cross-reconstruction, which fully combines two different information features after weighting, strengthening the information flow between them, and then the cross-reconstructed features are... and By concatenating the features, we obtain the spatial fine-grained feature map X. w ;
[0047] Segmentation operation: For spatial fine features X w First, X w The channels are divided into two parts: αC channels and (1-α)C channels, where 0 < α < 1 is the segmentation ratio. Then, 1×1 convolutions are used to compress the feature map channels to improve computational efficiency. A compression ratio r is introduced to control the feature channels. After segmentation and compression operations, the spatially refined features X are... w Divided into upper X up and lower X low ;
[0048] Conversion operation: X up It is input into the upper transformation stage as a rich feature extractor; in the same X up Perform k×k grouped convolution operations and 1×1 pointwise convolution operations on the top layer, then summarize the outputs to form a merged representative feature map Y1, expressed as:
[0049]
[0050] Among them, M G , X is the learnable weight matrix for grouped convolution and pointwise convolution; up Y1 and Y2 are the upper input and output feature maps, respectively;
[0051] X low The input is fed into the next transformation stage, where a 1×1 element-wise convolution operation is applied to generate feature maps with shallow hidden details, as a supplement to the rich feature extractor; in addition, X is reused. low The features are used to obtain more feature mappings; finally, the generated and reused features are connected to form the output of the next stage Y2, expressed as:
[0052]
[0053] in, It is a learnable weight matrix for element-wise convolution, ∪ represents the connection operation, X low Y1 and Y2 are the input and output feature maps of the lower layer, respectively;
[0054] Fusion Operation: The simplified SKNet method is used to adaptively merge the output features Y1 and Y2 from the up-conversion and down-conversion stages. First, a global average pooling method is used to collect global spatial information and generate channel statistics S. m The expression is:
[0055]
[0056] The global channel descriptors S1 and S2 from the upper and lower layers are stacked together, and channel attention operations are used to generate feature importance vectors β1 and β2, as expressed by:
[0057]
[0058] Finally, guided by the feature importance vectors β1 and β2, the channel reconstruction feature Y is obtained by merging the upper-layer feature Y1 and the lower-layer feature Y2 by channel, and the expression is:
[0059] Y = β1Y1 + β2Y2.
[0060] Preferably, temporal information of EEG features is extracted using a bidirectional long short-term memory network (BiLSTM), specifically as follows:
[0061] BiLSTM, by simultaneously considering both forward and reverse information of sequence data, can more comprehensively understand the context and semantic relationships in the sequence. It consists of two LSTMs, one responsible for transmitting information from the beginning to the end of the sequence and the other responsible for transmitting information from the end to the beginning. The information from these two directions is then fused to obtain a more comprehensive and accurate sequence representation.
[0062] The key technology in BiLSTM is LSTM, which includes the input word x at time t. t Cellular state C t Temporary cell state Hidden layer state h t Forgotten Gate f t Memory gate i t and output gate o t The calculation process of LSTM at time t is as follows: First, based on the hidden layer state h at time t-1... t-1 and the current input x t The process involves using a sigmoid layer to determine which information to discard; this layer is called the forget gate. The next step determines the new information to store in the cell state, which is divided into two parts: first, the sigmoid layer, called the input gate, determines the value to be updated; then, the tanh layer creates a vector of new candidate values. Add to status; the next step is to add the old cell status C. t-1Update to the new cell state C t Finally, based on the new cell state, output the hidden layer state h at time t. t The expression is:
[0063] f t =σ(W f ·[h t-1 x t ]+b f )
[0064] i t =σ(W i ·[h t-1 x t ]+b i )
[0065]
[0066]
[0067] o t =σ(W o [h t-1 x t ]+b o )
[0068] h t =o t *tanh(C t )
[0069] Among them, W f W i W C W o The representation is the feature transformation matrix, with different subscripts representing different feature processing layers. The features processed by BiLSTM are used as the temporal feature representation of EEG data.
[0070] Preferably, the spatial and temporal EEG information extracted by the SCConv neural network and BiLSTM are horizontally concatenated as the final representation. Then, three fully connected layers and a sigmoid activation function are used as a classifier. The number of neurons in the three fully connected layers are 256, 128, and 1, respectively. The sigmoid activation function is used to restrict the output x to the range (0, 1), and its expression is:
[0071]
[0072] The formula for calculating a fully connected layer is:
[0073] y = xA T +b
[0074] Where y is the output of the fully connected layer, x represents the input, and A T represents the transpose of the learnable weights A of the fully connected layer, and b represents the learnable bias value.
[0075] The system for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data according to the present invention includes:
[0076] Module M1: Acquires EEG recordings that suggest a possible epileptic seizure and performs preprocessing;
[0077] The preprocessing includes: preliminary screening based on expert opinions; generating bipolar montages and rearranging signals in different EDF files to the same order; downsampling the data; dividing the EEG into EEG segments according to different time window sizes and the number of blocks for evaluation, taking non-overlapping EEG segments as positive samples, and taking the same size and number of EEG segments from the EEG marked as non-occurrence as negative samples.
[0078] Module M2: Constructs a deep learning-based SC-LSTM model, including two parallel feature extraction modules and one classification module, for feature extraction, feature selection and fusion, and epilepsy detection and classification of EEG.
[0079] The reduced-frequency EEG data is used as input. In the first feature extraction module, a 3-layer 2D convolutional block is used as the basic architecture, and two types of spatial and channel reconstruction convolution SCConv are inserted to extract the spatial and channel features of the EEG data.
[0080] The temporal features of the original data are extracted using a bidirectional long short-term memory network (BiLSTM) in parallel. The spatial and channel features of the extracted EEG data and the temporal features of the original data are unified into a one-dimensional feature vector using a Flatten layer, and a lateral connection operation is performed as the final feature representation.
[0081] The classification module consists of three fully connected layers, using the sigmoid activation function to make the output between (0, 1).
[0082] Preferably, the spatial information of EEG features is extracted using the SCConv neural network, specifically as follows:
[0083] Spatial features of EEG data are extracted based on three two-dimensional convolutional blocks. The two-dimensional convolutional layer performs convolution operations on the input image by sliding a small matrix called a convolution kernel or filter to extract the required feature information. In the two-dimensional convolutional layer, the convolution kernel is a two-dimensional matrix that is multiplied and summed element-wise with the input image to obtain the output feature map. The calculation formula is as follows:
[0084]
[0085] Where out represents the output of the convolution operation, and N represents the batch size. i C represents the i-th batch, and C represents the number of channels. Represents the j-th output channel. This represents the output of the convolution computation for the i-th batch and j-th channel, where bias represents a learnable bias value. C represents the bias of the j-th channel. in This represents the number of input channels, where k is the counting sign from 0 to C. in-1 weight represents the weight value of the convolution kernel. This represents the kernel weights used in the convolution calculation of the feature map of the k-th input channel by the j-th convolutional block; ★ represents 2D cross-correlation operation; input represents the input feature map; input(N j ,k) represents the feature map of the k-th channel of the i-th batch.
[0086] Preferably, a self-correcting convolutional block is introduced between the first and second two-dimensional convolutional blocks to expand the convolutional receptive field through intrinsic feature communication, thereby enhancing the diversity of output features;
[0087] Given a set of shapes (C, C, k) h k w The convolution kernel K, where k h and k w Let C represent the spatial height and width, respectively, and C represent the number of channels. We divide them into four parts, each responsible for a different function. Assume C is divisible by 2. The convolutional kernel set is divided into four parts using... This indicates that the shape of each part of the convolution kernel is...
[0088] The workflow of the self-calibrating convolutional block is as follows: First, the input X is evenly divided into two parts {X1, X2}. Then, these two inputs are fed into a feature processing path to collect different types of contextual information. In the first path, X1 is self-calibrated using {K1, K2, K3} to obtain Y1. In the second path, a convolution operation is performed. This operation aims to preserve the original spatial context; then the two intermediate outputs {Y1, Y2} are concatenated together as the output Y.
[0089] For X1, average pooling with filter size r×r and stride r is used to obtain the intermediate feature T1, expressed as:
[0090] T1 = AvgPool r (X1)
[0091] Then, K2 is used to perform feature transformation on T1 to obtain the intermediate feature X′1, which is expressed as:
[0092]
[0093] Up() is a bilinear interpolation operator that maps intermediate references from a small-scale space to the original feature space.
[0094] The calibration procedure is described below:
[0095]
[0096] in, σ is the sigmoid function, and the symbol · indicates element-wise multiplication; then X′1 is used as the residual to form the weights for calibration, and the final output after calibration is:
[0097]
[0098] For X2, Y2 is obtained by performing feature transformation using K2, and the expression is:
[0099]
[0100] in, For convolution operations, Y1 and Y2 are obtained, and then concatenated according to channels to obtain the final output Y of the self-correcting convolution block;
[0101] Spatial and channel reconstruction convolutional blocks are introduced between the second and third two-dimensional convolutional blocks, which include two core units: the spatial reconstruction unit (SRU) and the channel reconstruction unit (CRU). The SRU reduces spatial redundancy through a separation-reconstruction method, while the CRU reduces channel redundancy through a segmentation-transformation-fusion method.
[0102] Separation operation: The purpose is to separate information-rich feature maps from feature maps with less information corresponding to spatial content. The scaling factor in the group normalization layer (GN) is used to evaluate the information content of different feature maps. Specifically, given an intermediate feature map... Where N is the batch axis, C is the channel axis, and H and W are the spatial height and width axes; firstly, the input feature X is standardized by subtracting the mean μ and dividing by the standard deviation σ, as expressed by:
[0103]
[0104] Where μ and σ are the mean and standard deviation of X, ε is a small positive constant added for division stability, and γ and β are trainable affine transformations; using the trainable parameter γ∈R in the GN layer C As a method for measuring the spatial pixel variance of each batch and channel; normalized correlation weights W γ ∈R CThe following formula represents the importance of different feature maps:
[0105]
[0106] Then via W γ The reweighted feature map weights are mapped to the (0, 1) range using the sigmoid function and then gated by a threshold. Weights above the threshold are set to 1 to obtain the information weight W1, and those above the threshold are set to 0 to obtain the non-information weight W2. The entire process of obtaining W is represented as follows:
[0107] W = Gate(Sigmoid(W) y (GN(X))))
[0108] Finally, the input feature X is multiplied by W1 and W2 respectively to obtain two weighted features: the one with higher information content and the one with higher information content. and less information This divides the input features into two parts: Spatial content that is informative and expressive It contains little or no information and is considered redundant;
[0109] Reconstruction operation: This operation adds information-rich features to less information-rich features to generate more information-rich features, thus saving space. This operation uses cross-reconstruction, which fully combines two different information features after weighting, strengthening the information flow between them, and then the cross-reconstructed features are... and By concatenating the features, we obtain the spatial fine-grained feature map X. w ;
[0110] Segmentation operation: For spatial fine features X w First, X w The channels are divided into two parts: αC channels and (1-α)C channels, where 0 < α < 1 is the segmentation ratio. Then, 1×1 convolutions are used to compress the feature map channels to improve computational efficiency. A compression ratio r is introduced to control the feature channels. After segmentation and compression operations, the spatially refined features X are... w Divided into upper X up and lower X low ;
[0111] Conversion operation: X up It is input into the upper transformation stage as a rich feature extractor; in the same X up Perform k×k grouped convolution operations and 1×1 pointwise convolution operations on the top layer, then summarize the outputs to form a merged representative feature map Y1, expressed as:
[0112]
[0113] Among them, M G , X is the learnable weight matrix for grouped convolution and pointwise convolution; up Y1 and Y2 are the upper input and output feature maps, respectively;
[0114] X low The input is fed into the next transformation stage, where a 1×1 element-wise convolution operation is applied to generate feature maps with shallow hidden details, as a supplement to the rich feature extractor; in addition, X is reused. low The features are used to obtain more feature mappings; finally, the generated and reused features are connected to form the output of the next stage Y2, expressed as:
[0115]
[0116] in, It is a learnable weight matrix for element-wise convolution, ∪ represents the connection operation, X low Y1 and Y2 are the input and output feature maps of the lower layer, respectively;
[0117] Fusion Operation: The simplified SKNet method is used to adaptively merge the output features Y1 and Y2 from the up-conversion and down-conversion stages. First, a global average pooling method is used to collect global spatial information and generate channel statistics S. m The expression is:
[0118]
[0119] The global channel descriptors S1 and S2 from the upper and lower layers are stacked together, and channel attention operations are used to generate feature importance vectors β1 and β2, as expressed by:
[0120]
[0121] Finally, guided by the feature importance vectors β1 and β2, the channel reconstruction feature Y is obtained by merging the upper-layer feature Y1 and the lower-layer feature Y2 by channel, and the expression is:
[0122] Y = β1Y1 + β2Y2.
[0123] Preferably, temporal information of EEG features is extracted using a bidirectional long short-term memory network (BiLSTM), specifically as follows:
[0124] BiLSTM, by simultaneously considering both forward and reverse information of sequence data, can more comprehensively understand the context and semantic relationships in the sequence. It consists of two LSTMs, one responsible for transmitting information from the beginning to the end of the sequence and the other responsible for transmitting information from the end to the beginning. The information from these two directions is then fused to obtain a more comprehensive and accurate sequence representation.
[0125] The key technology in BiLSTM is LSTM, which includes the input word x at time t. t Cellular state C t Temporary cell state Hidden layer state h t Forgotten Gate f t Memory gate i t and output gate o t The calculation process of LSTM at time t is as follows: First, based on the hidden layer state h at time t-1... t-1 and the current input x t The process involves using a sigmoid layer to determine which information to discard; this layer is called the forget gate. The next step determines the new information to store in the cell state, which is divided into two parts: first, the sigmoid layer, called the input gate, determines the value to be updated; then, the tanh layer creates a vector of new candidate values. Add to status; the next step is to add the old cell status C. t-1 Update to the new cell state C t Finally, based on the new cell state, output the hidden layer state h at time t. t The expression is:
[0126] f t =σ(W f ·[h t-1 x t ]+b f )
[0127] i t =σ(W i ·[h t-1 x t ]+b i )
[0128]
[0129]
[0130] o t =σ(W o [h t-1 x t ]+b o )
[0131] h t =o t *tanh(C t )
[0132] Among them, W f W i W C W o The representation is the feature transformation matrix, with different subscripts representing different feature processing layers. The features processed by BiLSTM are used as the temporal feature representation of EEG data.
[0133] Preferably, the spatial and temporal EEG information extracted by the SCConv neural network and BiLSTM are horizontally concatenated as the final representation. Then, three fully connected layers and a sigmoid activation function are used as a classifier. The number of neurons in the three fully connected layers are 256, 128, and 1, respectively. The sigmoid activation function is used to restrict the output x to the range (0, 1), and its expression is:
[0134]
[0135] The formula for calculating a fully connected layer is:
[0136] y = xA T +b
[0137] Where y is the output of the fully connected layer, x represents the input, and A T represents the transpose of the learnable weights A of the fully connected layer, and b represents the learnable bias value.
[0138] Compared with the prior art, the present invention has the following beneficial effects:
[0139] (1) This invention develops an epileptic seizure detection framework SC-LSTM and tests its usability on a real neonatal EEG dataset; it provides source code and output results information, as well as detailed instructions on how to use this tool; the SC-LSTM hybrid model adopts a parallel feature processing architecture of convolutional neural networks and their variants and recurrent neural networks and their variants, which not only improves the ability of the two methods to capture spatial and temporal information of EEG data respectively, but also reduces information loss through parallel processing, fully integrates multi-dimensional information, forms more easily distinguishable feature maps, and makes the architecture more flexible to be applied to different conditions and tasks;
[0140] (2) The BiLSTM used in this invention can more comprehensively understand the context and semantic relationships in the sequence by simultaneously considering the positive and negative information of the sequence data. This bidirectional information transmission mechanism makes BiLSTM perform well in fields such as natural language processing, speech recognition, and time series prediction. In particular, when processing long text, long speech or long sequence data, it can better capture local and global information in the sequence, thereby improving the performance and effectiveness of the model.
[0141] (3) The deep learning technology used in this invention can automatically capture effective features from EEG signals and realize end-to-end epileptic seizure detection. Applying deep learning technology to epileptic seizure detection can reduce the workload of neurologists, improve work efficiency, and enhance detection accuracy. Attached Figure Description
[0142] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0143] Figure 1 A schematic diagram of electrode locations for the International 10-20 system recorded on an electroencephalogram (EEG).
[0144] Figure 2 is a schematic diagram of downsampling;
[0145] Figure 3 A schematic diagram illustrating the segmentation of EEG data;
[0146] Figure 4 Diagram of SC-LSTM hybrid network architecture;
[0147] Figure 5 Diagram of the SCConv neural network architecture;
[0148] Figure 6 Diagram of LSTM architecture;
[0149] Figure 7 The experimental results are shown when the expert is A, the window size is 5, and the block size is 5.
[0150] Figure 8 The experimental results are shown when the expert is A, the window size is 5, and the block size is 5.
[0151] Figure 9 AUC results are plotted under different window sizes and block numbers. Detailed Implementation
[0152] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the scope of protection of the present invention.
[0153] Example
[0154] This invention provides a method for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data, comprising the following steps:
[0155] I. Dataset (Public Dataset) and Preprocessing
[0156] The EEG recordings in the cohort were from the neonatal EEG archive at Helsinki University Hospital, made at the request of the clinical team due to suspected seizures. These recordings were made between 2010 and 2014 and involved most infants admitted to the neonatal intensive care unit. Each EEG recording lasted approximately one hour, with a median recording duration of 74 minutes (IQR: 64 to 96 minutes). Recordings were performed using a NicOne EEG amplifier from Natus (USA), sampling at 256 Hz, and equipped with an EEG cap and sintered Ag / AgCl electrodes from ANT-Neuro (Germany). Figure 1 The 19 electrodes on the cap were arranged according to the international 10-20 positioning standard, and a bipolar montage was generated for annotation, including various recording references such as Fp2-F4, F4-C4, and C4-P4. The EEG files were de-identified and randomized, and then three experienced experts annotated the seizures using Natus' Nicolet Reader software. The annotations included the onset and duration of each seizure and were exported to a text file at a one-second resolution.
[0157] Dataset preprocessing: Individual analysis of data from each expert (A, B, or C) revealed that EEG recordings from 40 newborns were annotated as epileptic seizures by all three experts (EXP3), 22 newborns did not exhibit epileptic seizures (EXP0), and EEG recordings from 17 newborns were excluded from analysis due to disagreement among experts. Next, bipolar montages were generated according to the instructions in the "Input Data" section, and signals from different EDF files were rearranged to the same order. The third step involved downsampling the data, reducing the sampling frequency of the EEG recordings from 256Hz to 64Hz, thus reducing data volume and computational cost, and resulting in smoother EEG waveforms, as shown in Figure 2.
[0158] Finally, to comprehensively evaluate the model's superiority under various data conditions, the EEG was divided into EEG segments according to different time window sizes and the number of blocks for evaluation, such as... Figure 3 For example, a time window of 2 seconds and a block size of 3 blocks means taking 3 non-overlapping EEG segments of 2 seconds each as positive samples from a segment of epileptic seizures, and taking the same number of EEG segments of the same size as negative samples from EEGs marked as non-seizures.
[0159] II. SC-LSTM Hybrid Network (Current Practical Implementation)
[0160] To address the problems of existing computational methods, we constructed a deep learning-based SC-LSTM framework for feature extraction, feature selection and fusion, and epilepsy detection and classification in epileptic EEG. For example... Figure 4 As shown, the proposed model mainly consists of three parts: two parallel feature extraction modules, a final classification module, and a final classification module. First, EEG data, after simple preprocessing (frequency reduction), is used as input. In the first feature extraction module, a 3-layer 2D convolutional block architecture (2D-CNN) is used, and two SCConv methods are inserted to effectively extract spatial and channel features of the EEG data. However, EEG data, as non-linear continuous temporal data, contains rich pattern information that CNNs cannot effectively learn. Therefore, we use a bidirectional long short-term memory network (BiLSTM) in parallel to extract temporal features from the original data. Since the feature dimensions extracted by the two modules do not match (4D after 2D convolution, 3D after BiLSTM), we use a Flatten layer to transform both into one-dimensional feature vectors and perform lateral concatenation as the final feature representation. The classification module consists of three fully connected layers, and finally uses a sigmoid activation function to make the output between (0, 1).
[0161] A. SCConv neural network extracts spatial information of EEG features (current practical implementation method)
[0162] This method extracts spatial features from EEG data based on three two-dimensional convolutional blocks (2D CNN). The 2D convolutional layer performs convolution operations on the input image by sliding a small matrix called the convolution kernel or filter, extracting specific feature information. In the 2D convolutional layer, the convolution kernel is a two-dimensional matrix that is multiplied and summed element-wise with the input image to obtain the output feature map. The main calculation formulas are as follows:
[0163]
[0164] Where out represents the output of the convolution operation, and N represents the batch size. i C represents the i-th batch, and C represents the number of channels. Represents the j-th output channel. This represents the output of the convolution computation for the i-th batch and j-th channel, where bias represents a learnable bias value. C represents the bias of the j-th channel. in This represents the number of input channels, where k is the counting sign from 0 to C. in-1 weight represents the weight value of the convolution kernel. This represents the kernel weights used in the convolution calculation of the feature map of the k-th input channel by the j-th convolutional block; ★ represents 2D cross-correlation operation; input represents the input feature map; input(N i ,k) represents the feature map of the k-th channel of the i-th batch.
[0165] However, the output features of 2D convolutional neural networks are significantly limited by their receptive field, and the learned feature patterns exhibit similarity, leading to insufficient information for recognizing EEG epilepsy features. Therefore, a self-calibrating convolutional block (SCConv) is introduced between the first and second 2D convolutional blocks to expand the convolutional receptive field through intrinsic feature communication, thereby enhancing the diversity of output features. Unlike standard convolutions, the self-calibrating convolutional module adaptively constructs long-range spatial and channel correlations, rather than simply fusing spatial and channel information from small kernels. This characteristic of SCConv helps convolutional neural networks generate more discriminative EEG epilepsy feature representations because it carries richer information.
[0166] The workflow of a self-calibrating convolutional block is as follows: given a set of shapes (C, C, k) h k w The convolution kernel K, where k h and k w Let C represent the spatial height and width, respectively, and C represent the number of channels. First, we divide them into four parts, each responsible for a different function. Without loss of generality, we assume C is divisible by 2. The four parts of the convolutional kernel set are then divided using... This indicates that the shape of each part of the convolution kernel is... The workflow of a self-calibrating convolutional block can be simply described as follows: First, the input X is evenly divided into two parts {X1, X2}, and then these two inputs are fed into a feature processing path to collect different types of contextual information. In the first path, X1 is self-calibrated using {K1, K2, K3} to obtain Y1. In the second path, a simple convolution operation is performed: This operation aims to preserve the original spatial context. The two intermediate outputs {Y1, Y2} are then concatenated to form the output Y. The specific calculation formula and process are as follows, with the symbols appearing in the formula as described above:
[0167] Given an input X, it is split into X1 and X2 according to channels. For X1, average pooling with filter size r×r and stride r is used to obtain the intermediate feature T1, as shown below:
[0168] T1 = AvgPool r (X1)
[0169] Then, K2 is used to perform feature transformation on T1 to obtain the intermediate feature X′1. The calculation process is as follows:
[0170]
[0171] Here, Up() is a bilinear interpolation operator that maps intermediate references from the small-scale space to the original feature space. The calibration operation can now be described as follows:
[0172]
[0173] in σ is the sigmoid function, and the symbol · indicates element-wise multiplication. Then, X′1 is used as the residual to form the weights for calibration. The final calibrated output is:
[0174]
[0175] For X2, Y2 is obtained by performing a feature transformation using K2, as calculated below:
[0176]
[0177] in
[0178] After obtaining Y1 and Y2, they are concatenated according to the channels to obtain the final output Y of the self-calibrating convolution block.
[0179] In addition, due to the large amount of noise in EEG data (such as EEG artifacts and electrode position differences), convolutional layers are prone to extracting redundant features during model learning. Therefore, we introduced a spatial and channel reconstruction convolution between the second and third 2D convolutional blocks, which includes two core units: the Spatial Reconstruction Unit (SRU) and the Channel Reconstruction Unit (CRU). The SRU reduces spatial redundancy through a separation-reconstruction method, while the CRU reduces channel redundancy through a segmentation-transformation-fusion method. These two units work together to reduce redundant information in the features of the CNN and lower computational costs.
[0180] The Spatial Reconstruction Unit (SRU) utilizes separation and reconstruction operations. The purpose of the separation operation is to separate information-rich feature maps from feature maps with less information corresponding to spatial content. A scaling factor in the Group Normalization (GN) layer is used to evaluate the information content of different feature maps. Specifically, given an intermediate feature map... Where N is the batch axis, C is the channel axis, and H and W are the spatial height and width axes. The input feature X is first standardized by subtracting the mean μ and dividing by the standard deviation σ, as shown below:
[0181]
[0182] Where μ and σ are the mean and standard deviation of X, e is a small positive constant added for division stability, and γ and β are trainable affine transformations. The trainable parameters γ∈R in the GN layer are used... C As a method to measure the spatial pixel variance of each batch and channel. Richer spatial information reflects more variations in spatial pixels, and the γ value is therefore larger. Normalized correlation weight W γ ∈R C The following formula represents the importance of different feature maps:
[0183]
[0184] Then via W γ The reweighted feature maps are mapped to the (0, 1) range using a sigmoid function and then gated by a threshold. Weights above the threshold are set to 1 to obtain the information weights W1, and those above the threshold are set to 0 to obtain the non-information weights W2 (the threshold was set to 0.5 in the experiment). The entire process of obtaining W can be represented as:
[0185] W = Gate(Sigmoid(W) γ (GN(X))))
[0186] Finally, the input feature X is multiplied by W1 and W2 respectively to obtain two weighted features: the one with higher information content and the one with higher information content. and less information This successfully splits the input features into two parts: Spatial content that is informative and expressive, and It contains little or no information and is considered redundant.
[0187] To reduce spatial redundancy, a reconstruction operation is further used to add information-rich features to less information-rich features, generating more information-rich features and thus saving space. This operation does not directly add the two parts; instead, it employs a cross-reconstruction operation to fully combine the two weighted, distinct information features, strengthening the information flow between them. Then, the cross-reconstructed features are... and By concatenating the features, we obtain the spatial fine-grained feature map X. w The specific operation process is as follows:
[0188]
[0189] in, It is element-wise multiplication. ∪ represents element-wise multiplication and summation, while ∪ represents concatenation. Applying SRU to the input feature X not only separates informative features from less informative ones but also reconstructs them, enhancing representative features and suppressing redundant features in the spatial dimension. However, the spatially refined feature map Xw remains redundant in the channel dimension.
[0190] To further utilize the channel redundancy of features, a Channel Reconstruction Unit (CRU) is introduced, employing a split-transform-fusion strategy. Typically, multiple standard k×k convolutions are used to extract features, where k is the kernel size, resulting in some relatively redundant feature maps along the channel dimension. Let... Let represent a convolution kernel with c channels and a size of k×k, and These represent the input and convolution output features, respectively. The standard convolution operation can be defined as Y = M. k X. The method to reduce channel redundancy is to replace the standard convolution mentioned above with CRU, which is achieved through three operations—segmentation, transformation, and fusion.
[0191] Segmentation operation: for a given spatial fine feature First, the channels of Xw are divided into two parts: αC channels and (1-α)C channels, where 0 < α < 1 is the segmentation ratio. Then, a 1×1 convolution is used to compress the feature map channels to improve computational efficiency. Here, we introduce a squeezing ratio r to control the feature channels and balance the computational cost of CRU (r = 2 is a typical setting in the experiments). After the segmentation and squeezing operations, we extract the spatially refined features Xw... w Divided into upper X up and lower X low .
[0192] Conversion operation: X upThe data is input to the upper-level transformation stage as a "rich feature extractor." Efficient convolutional operations, such as grouped convolution and pointwise convolution, are used instead of standard k×k convolution to extract high-level representative information and reduce computational costs. Grouped convolution reduces parameters and computation due to sparse convolutional connections, but it cuts off information flow between channel groups. Pointwise convolution, on the other hand, compensates for information loss and helps information flow between functional channels. Therefore, in the same X... up The system performs k×k grouped convolution operations (group size g = 2 in the experiment) and 1×1 pointwise convolution operations. The outputs are then summarized to form a merged representative feature map Y1, which can be expressed as:
[0193]
[0194] in, For the learnable weight matrix of grouped convolution and pointwise convolution, These are the upper input and output feature maps, respectively. In short, the upper-level transformation stage operates on the same feature map X. up The above method combines grouped convolution and pointwise convolution to extract rich and representative features Y1 with less computational cost.
[0195] X low The input is fed into the next-level transformation stage, where a 1×1 element-wise convolution operation is applied to generate feature maps with shallow hidden details, complementing the rich feature extractor. Furthermore, X is reused. low The features were obtained by generating more feature mappings without additional cost. Finally, the generated and reused features were concatenated to form the output of the next stage Y2 as follows:
[0196]
[0197] in It is a learnable weight matrix for element-wise convolution, where ∪ represents the join operation. and These are the input and output feature maps for the lower layer, respectively. In short, the lower-layer transformation stage reuses the previous feature X. low And use inexpensive 1×1 pointwise convolution to obtain feature Y2 with supplementary detailed information.
[0198] Fusion Operation: After transformation, instead of directly concatenating or adding the two types of features, a simplified SKNet method is used to adaptively merge the output features Y1 and Y2 from the upper and lower transformation stages. First, global average pooling is used to collect global spatial information and generate channel statistics. The calculation formula is as follows:
[0199]
[0200] Next, the global channel descriptors S1 and S2 from the upper and lower layers are stacked together, and channel attention operations are used to generate feature importance vectors. The calculation formula is as follows:
[0201]
[0202] Finally, guided by the feature importance vectors β1 and β2, the channel reconstruction feature Y can be obtained by merging the upper-layer feature Y1 and the lower-layer feature Y2 by channel. The specific operation is as follows:
[0203] Y = β1Y1 + β2Y2
[0204] In short, by employing CRU and using a segmentation-transformation-fusion strategy, the spatial refinement of the feature map X along the channel dimension is further reduced. w Redundancy is eliminated. Furthermore, CRU extracts rich, representative features through lightweight convolutional operations, while handling redundant features through inexpensive operations and feature reuse schemes. Overall, CRU can be used alone or in combination with SRU (Spatial Refinement Unit) operations. By arranging SRU and CRU sequentially, the proposed SCConv (Sequential Combination Convolution) structure is established, which is efficient and can replace standard convolutional operations.
[0205] The complete SCConv neural network architecture is as follows: Figure 5 As shown, the features processed by the SCConv neural network, which includes three two-dimensional convolutional blocks interspersed with self-calibrating convolutional blocks and spatial and channel reconstruction modules, serve as the spatial features of the EEG data.
[0206] Modules with the same EEG spatial feature extraction capabilities as the SCConv neural network include ResNet, AlexNet, GoogleNet, DenseNet, and VGG.
[0207] B. Bidirectional Long Short-Term Memory Network (BiLSTM) extracts temporal information from EEG features.
[0208] To extract rich temporal pattern information from EEG data, we used a two-layer bidirectional long short-term memory (BiLSTM) network to process the data. BiLSTM has significant advantages over traditional RNNs (Recurrent Neural Networks) and unidirectional LSTMs (Long Short-Term Memory Networks) in processing sequential data, primarily because it can more effectively capture long-term dependencies and contextual information within the sequence data. Traditional RNNs are prone to gradient vanishing or exploding problems when dealing with long sequences, making it difficult to capture long-distance dependencies; while unidirectional LSTMs can only transmit information in one direction and cannot fully utilize the contextual information in the sequential data.
[0209] BiLSTM, by simultaneously considering both forward and backward information in sequence data, can more comprehensively understand the context and semantic relationships within a sequence. It consists of two directional LSTMs (see diagram). Figure 6 One mechanism, called BiLSTM, is responsible for transmitting information from the beginning to the end of the sequence, while the other is responsible for transmitting information from the end to the beginning. The information from these two directions is then fused to obtain a more comprehensive and accurate sequence representation. This bidirectional information transmission mechanism makes BiLSTM outstanding in fields such as natural language processing, speech recognition, and time series prediction. It is particularly effective when processing long text, long speech, or long sequence data, as it can better capture both local and global information within the sequence, thereby improving the model's performance and effectiveness.
[0210] The key technology in BiLSTM is LSTM, which includes the input word x at time t. t Cellular state C t Temporary cell state Hidden layer state h t Forgotten Gate f t Memory gate i t and output gate o t The calculation process of LSTM at time t can be summarized as follows: First, based on the hidden layer state h at time t-1... t-1 and the current input x t The process involves using a sigmoid layer to determine which information to discard; this layer is called the "forget gate layer." The next step is to determine which new information to store in the cell state. This is done in two parts: first, a sigmoid layer called the "input gate layer" determines which values will be updated; then, a tanh layer creates a vector of new candidate values. It can be added to the status. The next step is to add the old cell status C. t-1 Update to the new cell state C t Finally, based on the new cell state, the hidden layer state h at time t is output. t .
[0211] ft =σ(W f ·[h t-1 x t ]+b f )
[0212] E t =σ(W i ·[h t-1 x t ]+b i )
[0213]
[0214]
[0215] o t =σ(W o [h t-1 x t ]+b o )
[0216] h t =o t *tanh(C t )
[0217] Here, W represents the feature transformation matrix, and different subscripts represent different feature processing layers. The features processed by BiLSTM serve as the temporal feature representation of the EEG data.
[0218] Modules with similar EEG temporal feature extraction capabilities to BiLSTM include RNN, LSTM, and GRU.
[0219] C. Seizure Detection Classifier
[0220] Spatial and temporal EEG information extracted by the SCConv neural network and BiLSTM is horizontally concatenated as the final representation. Then, a classifier is used with three fully connected layers and a sigmoid activation function. The number of neurons in the three fully connected layers are 256, 128, and 1, respectively. The sigmoid activation function is used to restrict the output range to (0, 1). The formula for the sigmoid activation function to restrict the output x range to (0, 1) is:
[0221]
[0222] The formula for calculating a fully connected layer is:
[0223] y = xA T +b
[0224] Where y is the output of the fully connected layer, x represents the input, and A Trepresents the transpose of the learnable weights A of the fully connected layer, and b represents the learnable bias value.
[0225] Alternative modules for classifiers include KNN, SVM, and RF.
[0226] To comprehensively evaluate the superior performance of the method of this invention under various experimental environments and application scenarios (long-range EEG, short-range EEG, different quantities, different scales), the neonatal EEG dataset from Helsinki University Hospital was divided according to the settings mentioned above for different window sizes and block numbers. The possible window sizes are [1, 2, 5, 10, 20] and [1, 2, 5, 10, 20, 10000]. A block number of 10000 indicates the selection of the largest continuous EEG block set. Because there are no continuous seizure segments exceeding 10000 seconds in the data, even when the window size is set to the minimum of 1 second, the entire seizure segment can still be captured (for example, if a seizure segment is 2000 seconds long, with a window size of 1 and a block number of 10000, 2000 positive samples will be extracted from that segment, with no overlap between samples). Using these settings, we generated 30 datasets for the annotation results of three experts (A, B, and C), for a total of 90 datasets.
[0227] For each dataset, we performed five-fold cross-validation, which fully utilizes every sample in the dataset for training and testing, effectively reducing random errors introduced by unreasonable sample partitioning and improving the stability and reliability of model evaluation. Simultaneously, by evaluating the average results of multiple random partitions, we can better reflect the model's generalization ability, thus more accurately evaluating its performance. We compared our method with three state-of-the-art deep learning methods: CNN, ResNet50-CBAM, and CNN-LSTM, using evaluation metrics including ACC (accuracy), AUC (area under the ROC curve), Precision, and Recall.
[0228] Expert A's comments on the comparison results with deep learning methods
[0229]
[0230]
[0231]
[0232]
[0233] Comparison results with deep learning methods as noted by expert B
[0234]
[0235]
[0236]
[0237] Comparison results with deep learning methods as noted by expert C
[0238]
[0239]
[0240]
[0241]
[0242] Compared with advanced deep learning methods, except for a few slightly lower performance metrics under certain parameter conditions (e.g., a slightly lower precision value for CNN with a window size of 5 and a block size of 5), the method of this invention achieves the best experimental results across all evaluation metrics and under different parameter conditions. This demonstrates the superior performance of the method of this invention in epilepsy detection. The experimental results with expert A, a window size of 5, and a block size of 5 are shown below. Figure 7 and Figure 8 .
[0243] To further illustrate the stability and robustness of the method under various experimental conditions, we calculated the variance of the AUC results obtained by the method under different window sizes and block numbers, and visualized it using a violin plot. The smaller the variance, the better the robustness and stability of the method. The results are as follows: Figure 9 As shown.
[0244] Those skilled in the art will understand that, in addition to implementing the system, apparatus, and their modules provided by this invention in purely computer-readable program code, the same program can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system, apparatus, and their modules provided by this invention can be considered a hardware component, and the modules included therein for implementing various programs can also be considered structures within the hardware component; alternatively, modules for implementing various functions can be considered both software programs implementing the method and structures within the hardware component.
[0245] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.
Claims
1. A system for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data, characterized in that, include: Module M1: Acquires EEG recordings that suggest a possible epileptic seizure and performs preprocessing; The preprocessing includes: preliminary screening based on expert opinions; generating bipolar montages and rearranging signals in different EDF files to the same order; downsampling the data; dividing the EEG into EEG segments according to different time window sizes and the number of blocks for evaluation, taking non-overlapping EEG segments as positive samples, and taking the same size and number of EEG segments from the EEG marked as non-occurrence as negative samples. Module M2: Constructs a deep learning-based SC-LSTM model, including two parallel feature extraction modules and one classification module, for feature extraction, feature selection and fusion, and epilepsy detection and classification of EEG. The first feature extraction module is an SCConv neural network, and the second feature extraction module is a bidirectional long short-term memory network BiLSTM. The reduced frequency EEG data is used as input. In the first feature extraction module, a 3-layer 2D convolutional block is used as the basic architecture, and self-correcting convolutional blocks, spatial and channel reconstruction convolutional blocks are inserted to extract the spatial features of the EEG data. The temporal features of the original data are extracted using a bidirectional long short-term memory network (BiLSTM) in parallel. The spatial features of the extracted EEG data and the temporal features of the original data are unified into a one-dimensional feature vector using a Flatten layer, and a lateral connection operation is performed as the final feature representation. The classification module consists of three fully connected layers, using the sigmoid activation function to ensure the output is between (0, 1); Spatial information of EEG features is extracted using the SCConv neural network, specifically: Spatial features of EEG data are extracted based on three two-dimensional convolutional blocks. The two-dimensional convolutional layer performs convolution operations on the input image by sliding a small matrix called a convolution kernel or filter to extract the required feature information. In the two-dimensional convolutional layer, the convolution kernel is a two-dimensional matrix that is multiplied and summed element-wise with the input image to obtain the output feature map. The calculation formula is as follows: in, Represents the output of the convolution operation. Represents batch size, C represents the i-th batch, and C represents the number of channels. Represents the j-th output channel. This represents the output of the convolution computation for the i-th batch and j-th channel, where bias represents a learnable bias value. Represents the bias of the j-th channel. This represents the number of input channels, where k is the counting sign from 0 to... weight represents the weight value of the convolution kernel. This represents the convolution kernel weights used to perform convolution calculations on the feature map of the k-th input channel using the j-th convolution block. This represents a 2D cross-correlation operation, and input represents the input feature map. The feature map representing the k-th channel of the i-th batch; A self-correcting convolutional block is introduced between the first and second two-dimensional convolutional blocks to expand the convolutional receptive field through intrinsic feature communication, thereby enhancing the diversity of output features; Spatial and channel reconstruction convolutional blocks are introduced between the second and third 2D convolutional blocks, including two core units: the Spatial Reconstruction Unit (SRU) and the Channel Reconstruction Unit (CRU). The SRU reduces spatial redundancy through a split-reconstruction method, while the CRU reduces channel redundancy through a segmentation-transformation-fusion method.
2. The system for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data according to claim 1, characterized in that, Given a set of shapes convolution kernel ,in, and These are the space height and width, respectively. Represents the number of channels; they are uniformly divided into four parts, each responsible for a different function, let's assume... Divisible by 2, the convolution kernel set is divided into four parts, using... This indicates that the shape of each part of the convolution kernel is... ; The workflow of a self-calibrating convolutional block is as follows: First, the input is... Divide evenly into two parts Then, these two inputs are fed into separate feature processing paths to collect different types of contextual information. In the first path, using... right Perform a self-calibration operation to obtain In the second path, perform the convolution operation: This operation aims to preserve the original spatial context; then the two intermediate outputs are... Connect them together as output ; for Use filter size Step size is Average pooling yields intermediate features The expression is: Use afterwards right Intermediate features are obtained by performing feature transformations. The expression is: in, It is a bilinear interpolation operator that maps intermediate features from a small-scale space to the original feature space; The calibration procedure is described below: in, , It is the sigmoid function, symbol This indicates element-wise multiplication; it is then used... The residuals are used to form the weights for calibration, and the final output after calibration is: for ,use Perform feature transformation to obtain The expression is: in, , For convolution operations, we get and Then, the output of the self-calibrating convolutional block is obtained by concatenating the channels. ; Spatial and channel reconstruction convolutional blocks are introduced between the second and third two-dimensional convolutional blocks, which include two core units: the spatial reconstruction unit (SRU) and the channel reconstruction unit (CRU). The SRU reduces spatial redundancy through a separation-reconstruction method, while the CRU reduces channel redundancy through a segmentation-transformation-fusion method. Separation operation: The purpose is to separate information-rich feature maps from feature maps with less information corresponding to spatial content, using group normalization layers. The scaling factor is used to evaluate the information content of different feature maps, specifically: given an intermediate feature map... ,in, For batch axis, For channel axis, and For the space's height and width axes; first, by subtracting the average value... Divide by the standard deviation To standardize input features The expression is: in, and yes The mean and standard deviation, It is a small positive number added for the stability of division. and It is a trainable affine transformation; utilizing trainable parameters in the GN layer. As a method for measuring the spatial pixel variance of each batch and channel; normalized correlation weights The following formula represents the importance of different feature maps: Then through The reweighted feature map weights are mapped to the (0,1) range using the sigmoid function and then gated using a threshold; weights above the threshold are set to 1 to obtain the information weights. Weights below the threshold are set to 0, resulting in non-information weights. ; obtain The entire process can be represented as: Finally, input features Multiply by respectively and We obtained two weighted features: those with high information content. and less information This divides the input features into two parts: Spatial content that is informative and expressive It contains little or no information and is considered redundant; Reconstruction operation: This operation adds information-rich features to less information-rich features to generate more information-rich features, thus saving space. This operation uses cross-reconstruction, which fully combines two different information features after weighting, strengthening the information flow between them, and then the cross-reconstructed features are... and By stitching the images together, fine spatial features are obtained. ; Segmentation operation: for fine spatial features First of all The channels are divided into Channels and The passage has two parts, among which The segmentation ratio; subsequently, using Convolution is used to compress the channels of the feature map to improve computational efficiency, introducing a compression ratio. To control the feature channels, after segmentation and compression operations, to refine the spatial features Divided into upper part and lower part ; Conversion operation: It is input into the upper transformation stage as a rich feature extractor; in the same Execution Grouped convolution operations and The pointwise convolution operation is performed, and then the outputs are summarized to form a merged representative feature map. The expression is: in, The learnable weight matrix for grouped convolution and pointwise convolution; These are the upper-layer input and output feature maps, respectively. The input is passed to the next layer of transformation stage, and the application... Element-wise convolution operations are used to generate feature maps with shallow hidden details, complementing the rich feature extractor; furthermore, reuse... The features are analyzed to obtain more feature mappings; finally, the generated and reused features are connected to form the next stage. The output, expressed as: in, It is a learnable weight matrix of element-wise convolution. Indicates a connection operation. and These are the lower-level input and output feature maps, respectively. Fusion operation: Adaptively merge the output features of the upper and lower transformation stages using a simplified SKNet method. and First, a global average pooling method is adopted. Collect global spatial information and generate channel statistics. The expression is: Connect the global channel descriptors of the upper and lower layers. and Stack them together and use channel attention operations to generate feature importance vectors. The expression is: Finally, in the feature importance vector Under the guidance of [the relevant authority], upper-layer features are merged by channel. and lower-level features Obtain channel reconstruction features The expression is: 。 3. The system for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data according to claim 2, characterized in that, Temporal information of EEG features was extracted using the Bidirectional Long Short-Term Memory (BiLSTM) network, specifically: BiLSTM, by simultaneously considering both forward and reverse information of sequence data, can more comprehensively understand the context and semantic relationships in the sequence. It consists of two LSTMs, one responsible for transmitting information from the beginning to the end of the sequence and the other responsible for transmitting information from the end to the beginning. The information from these two directions is then fused to obtain a more comprehensive and accurate sequence representation. Key technologies in BiLSTM include LSTM, including time. Input words Cell state Temporary cell state Hidden layer state Forgotten Gate Memory gate and output gate ; The calculation process of LSTM at time step is as follows: First, based on Hidden layer state at time step and current input ,use The first layer processes the information and decides which information to discard; this layer is called the forget gate layer. The next step determines the new information to store in the cell state, which is divided into two parts, the first of which is called the input gate layer. The layer decides the value to be updated, and then... Vector of new candidate values created by the layer Add to the status; the next step is to add the old cell status. Update to the new cell state Finally, output the current state based on the new cell status. Hidden layer state at time step The expression is: in, , , , The representation is the feature transformation matrix, with different subscripts representing different feature processing layers. The features processed by BiLSTM are used as the temporal feature representation of EEG data.
4. The system for detecting and automatically labeling epileptic seizures based on electroencephalogram (EEG) data according to claim 3, characterized in that, The spatial and temporal information of EEG features extracted by the SCConv neural network and BiLSTM are horizontally concatenated as the final representation. Then, three fully connected layers and a sigmoid activation function are used as a classifier. The number of neurons in the three fully connected layers are 256, 128, and 1, respectively. The sigmoid activation function is used to classify the output... The range is limited to (0, 1), and the expression is: The formula for calculating a fully connected layer is: in, For the output of the fully connected layer, Represents input, Learnable weights representing fully connected layers transpose, This represents the learnable bias value.