Epilepsy early warning method and system based on electroencephalogram signals
Through the deep learning model of less-channel EEG signal acquisition and time-frequency feature fusion, the problems of complex equipment and complex computing in the existing technology are solved, and efficient and portable epilepsy warning is achieved, suitable for home and mobile medical scenarios.
Patent Information
- Application Number
- CN202510357525.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-07-11
AI Technical Summary
The existing scalp EEG early warning methods are complex, inconvenient to wear, and complex multi-channel data processing and calculation, making it difficult to meet the real-time prediction needs.
Using few-channel EEG signal acquisition, combined with the adaptive overlapping data slicing method of sliding window and the deep learning model of time-frequency feature fusion, an early warning model is built to realize three-classification tasks, reduce equipment complexity and wear burden, and improve portability and user comfort.
In the case of reducing the amount of data, key physiological information is retained to achieve efficient epilepsy warning, significantly reduce hardware costs and computing resource requirements, and is suitable for multi-scenario applications.
Smart Images

Figure CN120296656A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of the nervous system, and specifically provides an epilepsy early warning method and system based on electroencephalogram signals. Background Technique
[0002] Epilepsy is the second most common neurological disease globally, affecting approximately 1% of the global population. It is mainly characterized by recurrent and externally unpredictable abnormal electroencephalogram activities. Research shows that the seizure cycle of epilepsy can be divided into the interictal period, pre-ictal period, and ictal period. The interictal period refers to the relatively stable period between two epileptic seizures. At this time, the electroencephalogram activity is not significantly abnormal, and patients usually have no clinical symptoms. The pre-ictal period refers to the transitional stage before an epileptic seizure, usually lasting from a few minutes to dozens of minutes. During this period, the electroencephalogram activity of the patient gradually becomes abnormal. The ictal period is the actual stage of an epileptic seizure.
[0003] The main task of epilepsy early warning is to detect the appearance of pre-ictal signals. Therefore, if effective prediction can be made before a patient has an epileptic seizure, a warning can be issued in a timely manner, and appropriate protective measures can be taken, the burden on the patient and the physical damage caused by epilepsy can be greatly reduced.
[0004] Existing scalp electroencephalogram epilepsy early warning methods generally require EEG (Electroencephalogram) signals of more than 16 channels to record the electrical wave changes generated during the activity of brain neurons. However, the equipment has high complexity and is inconvenient to wear, making it difficult to be applied in home or mobile scenarios. In addition, the algorithm calculation complexity of multi-channel data processing and complex models, such as three-dimensional convolutional neural networks, significantly increases the hardware cost and inference delay, making it difficult to meet the real-time prediction requirements. Summary of the Invention
[0005] The purpose of the present invention is to provide an epilepsy early warning method and system based on electroencephalogram signals to solve the problems raised in the above background technique.
[0006] To solve the above technical problems, the present invention provides the following technical solution: An epilepsy early warning method based on electroencephalogram signals, including the following content:
[0007] S1: Determine the positions for collecting few-channel electroencephalogram signals, collect electroencephalogram signal data, and mark the time nodes where the start and end positions of epileptic seizures are located.
[0008] S2: Divide the electroencephalogram signal data, determine the model training set and model test set, record the total number N of epileptic seizure events, and define the interictal period, pre-ictal period, and ictal period.
[0009] S3: Perform data denoising, and use a slicing method based on a sliding window with adaptive overlapping data to dynamically adjust the overlapping ratio of the data window to complete the preprocessing process.
[0010] S4: Construct and train an early warning model based on a deep learning model for time-frequency feature fusion, and use the parallel time-domain branch and frequency-domain branch for fusion and classification to achieve a three-classification task;
[0011] S5: After the training of the early warning model is completed, model testing is required to verify the training effect of the model, and at the same time, calculate the sensitivity and false alarm rate of the early warning model on the test set;
[0012] S6: After the model training is completed, the system will enter the real-time inference stage for predicting the epileptic seizure time.
[0013] The present invention further explains that the seizure data for the model training set accounts for 66.7%-80% of the total number of epileptic seizure events.
[0014] The present invention further explains that the time interval between two adjacent epileptic seizure events is set to C minutes. When C is less than 30, the two events are combined and regarded as one seizure event.
[0015] The present invention further explains that S3 includes:
[0016] S3.1, Use a notch filter to filter power frequency noise, and use a low-pass filter to remove the DC component below the set frequency;
[0017] S3.2, Use the sliding window method to segment the original EEG signal, set the window length to T seconds, and dynamically adjust the overlapping ratio of the sliding window according to the signal category and duration; the overlapping ratio used for the interictal data is less than the overlapping ratio used for the ictal data; the pre-ictal data dynamically determines the overlapping ratio according to the predefined time interval;
[0018] S3.3, Save the preprocessed data for direct call in the subsequent steps.
[0019] The present invention further explains that S4 includes:
[0020] S4.1, Establish a time-domain feature extraction branch and a frequency-domain feature extraction branch, extract time-domain features and frequency-domain features, and perform classification through a multi-layer fully connected network after feature splicing to output the final prediction result;
[0021] S4.2, Introduce a focal loss function to dynamically adjust the sample weights;
[0022] S4.3, Combine the adaptive learning rate optimizer Adam for model training;
[0023] S4.4, Adopt an early stopping strategy during training to prevent overfitting.
[0024] The present invention is further described as follows. The time-domain feature extraction branch is composed of a multi-scale one-dimensional convolutional structure, a bidirectional LSTM layer, and a flattening layer;
[0025] The convolution operation is performed using the multi-scale one-dimensional convolutional structure. The relationship between the output data and the input data after convolution, batch normalization, and activation function is expressed as:
[0026]
[0027] where Y is the output data of the convolutional structure, X is the input data of the multi-scale one-dimensional residual convolutional structure, W is the convolutional kernel weight, b is the bias term, μ and σ 2 are respectively the mean and variance of the batch data, γ and β are the learnable scaling and translation parameters in batch normalization, and ε is the numerical stability constant;
[0028] The output data obtained by the convolutional kernels of each scale are concatenated, and a residual connection structure is introduced. Its expression is:
[0029] P = Concat(Y3, Y5, Y7) * W 1*1 + X
[0030] where P represents the output data after concatenation, Y3, Y5, and Y7 respectively represent the output data of the convolutional structures with convolutional kernel sizes of 1×3, 1×5, and 1×7, W 1*1 represents the downsampling convolutional kernel weight in the residual connection structure to ensure the same number of channels, X represents the input data of the multi-scale one-dimensional residual convolutional structure, and Concat represents the concatenation operation;
[0031] The features extracted by the multi-scale one-dimensional convolutional structure are input into the bidirectional LSTM layer, which can capture the forward and backward dependencies of the signal simultaneously;
[0032] After passing through the bidirectional LSTM layer, the obtained time-domain feature vector is input into the flattening layer for flattening.
[0033] The present invention is further described as follows. The frequency-domain feature extraction branch is composed of a short-time Fourier transform, a multi-scale two-dimensional convolutional structure, and a flattening layer;
[0034] The short-time Fourier transform is used to generate the time-frequency spectrogram. The signal is segmented using the Hanning window. The mathematical expression of the Hanning window is as follows:
[0035]
[0036] N represents the window length, and n takes integers from 0 to N - 1.
[0037] The Fourier transform is performed on the signal x m (t) within each window using the following formula:
[0038]
[0039] Where X m (f) is the frequency domain representation of the mth window, f is the frequency index, and j is the imaginary unit;
[0040] The frequency domain representation of each window is arranged in time order, and the generated time-frequency spectrum is logarithmically processed. The formula is as follows:
[0041] S log (t,f)=log(1+|X m (f)| 2 )
[0042] The multi-scale two-dimensional convolution in the frequency domain branch is different from the one-dimensional convolution in the time domain feature extraction. Here, two-dimensional convolution is used to extract the frequency band energy distribution.
[0043] After three multi-scale two-dimensional convolution structures, the obtained frequency domain feature vector is input into the flattening layer for flattening;
[0044] After concatenating the features extracted from the time domain branch and the frequency domain branch, a vector of (K, M) dimension is obtained. The model outputs each category through a fully connected layer structure, and the final output results of the three categories are obtained. Finally, the category with the highest probability is selected as the inference result of the model.
[0045] The present invention further illustrates that in S6, in order to warn of epileptic seizures, the system records the inference results within a period of time, which are specifically divided into the following situations;
[0046] In case 1, if the proportion of the pre-ictal period exceeds the set threshold, a yellow light alarm is triggered to indicate that an epileptic seizure is about to occur, and the alarm is automatically lifted after a certain period of time;
[0047] In the second case, if the model outputs the seizure results for multiple times in a row, a red light alarm will be triggered, indicating that the patient is in an epileptic seizure state until the seizure signal disappears;
[0048] In the third case, if the red light warning is not triggered during the yellow light alarm, it is considered a false alarm. The system will use the relevant data as new interictal data to retrain the model to improve model performance.
[0049] The present invention further describes an epilepsy early warning system based on EEG signals, which is applied to the above-mentioned epilepsy early warning method based on EEG signals, comprising:
[0050] An information acquisition module, used to determine the location of collecting few-channel EEG signals and collect EEG signal data;
[0051] The data division module is used to first divide the continuous EEG signal data of the patient into several seizure data to record the total number of epileptic seizure events, and then divide the inter-ictal period, pre-ictal period, and ictal period for each seizure cycle data according to the seizure onset time of each seizure, and then divide the training set and the test set;
[0052] The data preprocessing module is used for data denoising, and adopts a slicing method of adaptive overlapping data based on a sliding window to dynamically adjust the overlapping ratio of the data window, and complete the preprocessing process to alleviate the problem of data imbalance;
[0053] The model training module is used to construct and train an early warning model based on a deep learning model of time-frequency feature fusion to achieve a three-classification task of the inter-ictal period, pre-ictal period, and ictal period; after the training of the early warning model is completed, model testing is required to verify the training effect of the model;
[0054] The real-time inference module, after the model training is completed, the system will enter the real-time inference stage, which is used to predict the epileptic seizure time.
[0055] The present invention further illustrates that the system further includes a false alarm feedback module, which is signal-connected to the real-time inference module and the data division module, and is used to use the data from the end of the most recent epileptic seizure before the false alarm occurs to the triggering of the yellow light alarm as the inter-ictal period data, and return it to the data division module again, regarded as new data to retrain the model.
[0056] Compared with the prior art, the beneficial effects achieved by the present invention are:
[0057] The present invention adopts EEG signal acquisition including but not limited to four channels, which significantly reduces the complexity of the device and the wearing burden. By combining the slicing method of adaptive overlapping data of the sliding window and the deep learning processing technology of time-frequency feature fusion, while reducing the data volume, key physiological information can be retained, and efficient epileptic early warning can be realized. Therefore, compared with the traditional multi-channel system, while ensuring the prediction performance, the portability and user comfort of the system are greatly improved, and it is suitable for multi-scenario applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The drawings are used to provide a further understanding of the present invention, and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention, and do not constitute a limitation to the present invention. In the drawings:
[0059] Figure 1 is a schematic diagram of the modules of the system of the present invention;
[0060] Figure 2 is a schematic diagram of the overall process of the method of the present invention;
[0061] Figure 3It is a schematic diagram of the division of continuous EEG data of the present invention;
[0062] Figure 4 It is a schematic diagram of the distribution of scalp EEG signal acquisition electrodes of the international 10-20 standard of the present invention;
[0063] Figure 5 It is a schematic diagram of the overlapping situation of the sliding window during different seizure periods when slicing the data of the present invention;
[0064] Figure 6 It is a schematic diagram of the model structure of the present invention;
[0065] Figure 7 It is a flow chart of time-frequency feature splicing and classification in the model of the present invention. Detailed implementation manners
[0066] The technical solution of the present invention will be further described in detail and non-limitingly below in conjunction with the preferred embodiments and their accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without making creative efforts belong to the scope of protection of the present invention.
[0067] Embodiment 1, please refer to Figure 1 The present invention provides a technical solution: an epilepsy warning system based on EEG signals, which can reduce the amount of data while retaining key physiological information to achieve efficient epilepsy warning. Therefore, compared with the traditional multi-channel system, the portability and user comfort of the system are greatly improved while ensuring the prediction performance. Specifically, it includes an information acquisition module, a data division module, a data preprocessing module, a model training module, and a real-time inference module;
[0068] The information acquisition module is used to determine the positions for collecting multi-channel EEG signals and collect EEG signal data;
[0069] The data division module is used to first divide the continuous EEG signal data of the patient into several seizure data to record the total number of epilepsy seizure events, and then, according to the seizure start time of each seizure, divide the interictal period, preictal period, and ictal period for each seizure cycle data, and then divide the training set and the test set;
[0070] The data preprocessing module is used for data denoising and adopts a slicing method of adaptive overlapping data based on a sliding window to dynamically adjust the overlapping ratio of the data window to complete the preprocessing process to alleviate the problem of data imbalance;
[0071] The model training module is used to build and train the early warning model based on the deep learning model of time-frequency feature fusion to achieve the three-classification task of interictal period, preictal period and ictal period. After the early warning model training is completed, the model needs to be tested to verify the model training effect.
[0072] Real-time reasoning module: After completing model training, the system will enter the real-time reasoning stage, which is used to predict the time of epileptic seizures; set the triggering of a yellow light alarm to indicate that an epileptic seizure is about to occur, and automatically release the alarm after a certain period of time; set the triggering of a red light alarm to indicate that the patient is in an epileptic seizure state, until the seizure signal disappears; if the red light alarm is not triggered during the yellow light alarm period, it is considered a false alarm;
[0073] The system also includes a false alarm feedback module, which is connected to the real-time reasoning module and the data partitioning module by signal. It is used to return the data from the end of the most recent epileptic seizure before the false alarm to the triggering of the yellow light alarm as interictal data to the data partitioning module and treat it as new data to retrain the model.
[0074] Example 2, please refer to Figure 2 Based on the method of implementing the above-mentioned epilepsy early warning system in Example 1, the specific steps are as follows:
[0075] S1: Determine the location for collecting few-channel EEG signals, collect EEG signal data, and mark the time nodes of the start and end of the epileptic seizure;
[0076] The electrode collection position of the four-channel EEG signal is preferably near the forehead and behind the ear. Figure 3 ,According to the international 10-20 EEG electrode position standard lead system, EEG signals at four positions, FP1, FP2, P7, and P8, were collected.
[0077] S2: Divide the EEG signal data and determine the model training set and model test set;
[0078] The total number of epileptic seizure events was recorded, and the patient's continuous EEG signal data was divided into several seizure data, and the training set and test set were divided; for each epileptic seizure event, the interictal period, preictal period and seizure period were defined, corresponding to different time interval signals; in addition, if the interval between two adjacent epileptic seizure events was short, the two events were combined and regarded as one seizure event;
[0079] Specifically, S2.1, assume that the collected EEG signal data contains a total of N epileptic seizure events, and the time point of each epileptic seizure of the patient is recorded;
[0080] First, the collected EEG signal data of the patient is divided on the time axis according to the epileptic seizure event. The signal from the start of data collection to the end of the first seizure is recorded as the first seizure data, and the signal from the end of the first seizure to the end of the second seizure is recorded as the second seizure data, and so on, until the signal from the end of the N-1 seizure to the end of the N seizure is recorded as the Nth seizure data;
[0081] Then the model training set and the model test set are divided. If N≤5, the first N-1 seizure data are used for model training; if N>5, the first N-2 seizure data are used for model training; the remaining data are used for model testing; in addition, the proportion of seizure data used for model training in the N seizure data is preferably 66.7%-80%;
[0082] S2.2, for a complete epileptic seizure event of a patient, define the interictal period, preictal period and ictal period according to the time point;
[0083] The interictal period is the signal before the onset of epilepsy A1 hour and after the end of epilepsy A2 hours; the preictal period is the signal from Z minutes before the onset of epilepsy to the onset of epilepsy; the ictal period is the signal from the onset of epilepsy to the end of epilepsy; for example, refer to Figure 4 The interictal period is the signal 2 hours before the onset of epileptic seizure and 2 hours after the end of epileptic seizure; the preictal period is the signal 30 minutes before the onset of epileptic seizure to the beginning of epileptic seizure; the ictal period is the signal from the beginning of epileptic seizure to the end of epileptic seizure;
[0084] S2.3, appropriately merge the seizure events. If the interval between two consecutive epileptic seizures of the patient is short, they will be merged into one epileptic seizure event, which is usually set to less than 30 minutes.
[0085] S3: Perform data denoising and use an adaptive overlapping data slicing method based on a sliding window to dynamically adjust the overlapping ratio of the data window to complete the preprocessing process to alleviate the data imbalance problem;
[0086] Exemplarily, S3.1, a notch filter is used to filter the power frequency noise of 50 Hz and 60 Hz, and a low-pass filter is used to remove the DC component below 1 Hz;
[0087] S3.2, the original EEG signal is processed by segmentation using the sliding window method, and the window length is set to T seconds, T is generally 10, refer to Figure 5 , and dynamically adjust the overlapping ratio of the sliding window according to the signal category and duration;
[0088] Among them, ① for the interictal data, a medium overlapping ratio is adopted, and a 90% window overlap can be used; ② for the ictal data, a high overlapping ratio is adopted, and a 99% window overlap can be used; ③ for the pre-ictal data, the overlapping ratio is dynamically determined according to a predefined time interval. Assuming that the duration of the pre-ictal period is defined as P minutes, the corresponding window overlap ratio can be found according to Table 1;
[0089] Table 1 Setting table of pre-ictal duration and corresponding window overlap ratio
[0090] Pre-onset duration P (min) Window overlap ratio (%) 5≤P<10 98 10≤P<20 95 20≤P<40 90 40≤P<60 80
[0091] In the data acquisition of EEG signals, the ictal and pre-ictal periods are minority samples, and the interictal period is the majority sample. Therefore, there will be a problem of unbalanced sample categories. This method dynamically adjusts the overlapping ratio of the data window according to the sample category: for minority samples, a high overlapping ratio is adopted to increase sample diversity; for majority samples, a medium overlapping ratio is adopted to reduce redundancy; through this adaptive strategy, the problem of data imbalance is effectively alleviated, and the learning ability of the model for minority samples is improved;
[0092] S3.3, Save the preprocessed data for direct call in subsequent steps.
[0093] S4: Build and train an early warning model based on a deep learning model with time-frequency feature fusion to achieve a three-classification task and support epilepsy early warning and epilepsy detection functions, where the three-classification includes the interictal period, the pre-ictal period, and the ictal period;
[0094] Exemplarily, S4.1, Extract the time-domain features and frequency-domain features of the early warning model, and after feature splicing, classify through a multi-layer fully connected network to output the final prediction result;
[0095] The early warning model is divided into two branches: the time-domain feature extraction branch and the frequency-domain feature extraction branch;
[0096] As Figure 6 shown, specifically:
[0097] S4.1.1, The time-domain feature extraction branch consists of a multi-scale one-dimensional convolutional structure, a bidirectional LSTM layer, and a flattening layer; the multi-scale one-dimensional convolutional structure is used to extract the local waveform features of the signal, and the bidirectional LSTM (Long Short-Term Memory) layer is combined to capture the time-domain dependence relationship;
[0098] First, design a multi-scale one-dimensional residual convolution structure. Use three different-sized convolutional kernels (1×3, 1×5, 1×7) to perform convolution operations on the original input signal. The stride of the convolutional kernel is (1, 1), and the padding scale is (0, k / / 2), where k is the horizontal size of the convolutional kernel; each convolutional kernel extracts local waveform features of different scales to capture short-term and long-term dependencies in the signal;
[0099] After each convolutional layer, use a batch normalization layer, a ReLU activation function layer, and a pooling layer; the batch normalization layer makes the distribution of the data more stable, reduces internal covariate shift, the activation function layer introduces non-linear characteristics, enhances the expressive power of the model, and the pooling layer can reduce the dimension of the feature map, retain important features, and reduce the computational amount; the relationship between the output data and the input data after convolution, batch normalization, and activation function is expressed as:
[0100]
[0101] where Y is the output data of the convolutional structure, X is the input data of the multi-scale one-dimensional residual convolution structure, W is the convolutional kernel weight, b is the bias term, μ and σ 2 are the mean and variance of the batch data respectively, γ and β are the learnable scaling and translation parameters in batch normalization, and ε is a numerical stability constant, usually taking 1e-5.
[0102] Secondly, concatenate the output data obtained by each scale of convolutional kernel, and introduce a residual connection structure to alleviate the problem of gradient disappearance. Its expression is:
[0103] P = Concat(Y3, Y5, Y7) * W 1*1 + X
[0104] where P represents the output data after concatenation, Y3, Y5, and Y7 respectively represent the output data of the above 1×3, 1×5, and 1×7 convolutional structures, W 1*1 represents the weight of the dimensionality reduction convolutional kernel in the residual connection structure to ensure the same number of channels, X represents the input data of the multi-scale one-dimensional residual convolution structure, and Concat represents the concatenation operation;
[0105] After that, input the features extracted by the multi-scale one-dimensional convolutional structure into a bidirectional LSTM layer. Among them, the bidirectional LSTM layer can capture the forward and backward dependencies of the signal at the same time, so as to understand the time-domain features more comprehensively. The specific parameter settings are: input dimension 256, hidden state dimension 128;
[0106] Finally, after passing through the bidirectional LSTM layer, input the obtained time-domain feature vector into a flattening layer for flattening.
[0107] S4.1.2. The frequency-domain feature extraction branch consists of a short-time Fourier transform, a multi-scale two-dimensional convolutional structure, and a flattening layer. The short-time Fourier transform is used to generate a time-frequency spectrogram, and the multi-scale two-dimensional convolutional structure is used to extract the frequency-band energy distribution.
[0108] First, the short-time Fourier transform is used to generate a time-frequency spectrogram. The signal is segmented using a Hanning window, and the mathematical expression of the Hanning window is as follows:
[0109]
[0110] N represents the window length, which is the number of sampling points corresponding to a 1s signal (when the sampling rate is 256Hz, N = 256), and the window overlap is 50%.
[0111] Second, the following formula is used to perform a Fourier transform on the signal x m (t) within each window:
[0112]
[0113] where X m (f) is the frequency-domain representation of the m-th window, and f is the frequency index;
[0114] After that, the frequency-domain representations of each window are arranged in chronological order, and the generated time-frequency spectrogram is logarithmically processed to prevent its numerical value from exceeding the pixel value range. The formula is as follows:
[0115] S log (t,f) = log(1 + |X m (f)| 2 )
[0116] It should be noted that the multi-scale two-dimensional convolution in the frequency-domain branch is different from the one-dimensional convolution in the time-domain feature extraction. Here, a two-dimensional convolution is used to extract the frequency-band energy distribution, that is, the sizes of the convolution kernels are 3×3, 5×5, and 7×7, and the corresponding padding scales are 1×1, 2×2, and 3×3, respectively. The stride is still (1, 1), and other structures are similar to the above multi-scale one-dimensional residual convolution structure.
[0117] Finally, after passing through three multi-scale two-dimensional convolutional structures, the obtained frequency-domain feature vectors are input into the flattening layer for flattening;
[0118] S4.1.3. After concatenating the features extracted from the time-domain branch and the frequency-domain branch, a vector of (K, M) dimensions is obtained, where K is the number of samples input to the model each time, and M is the total dimension after concatenating the time-domain and frequency-domain features. Then, the output of the model for each category is obtained through a fully connected layer structure; as Figure 7As shown in the figure, the specific structure of the fully connected layer is as follows: the input dimension of the first fully connected layer is 1280, the output dimension is 256, the activation function is ReLU, and it is processed by a Dropout layer; the input dimension of the second fully connected layer is 256, the output dimension is 32, the activation function is ReLU, and it is processed by a Dropout layer; the input dimension of the third fully connected layer is 32, and the output dimension is 3, that is, the final output results of three categories are obtained; finally, the category with the highest probability is selected as the inference result of the model.
[0119] S4.2, introducing the focal loss function to dynamically adjust the sample weights; the specific formula of the focal loss function is:
[0120] L FL = -α t (1 - p t ) γ log(p t )
[0121] where α t represents the class weight coefficient, which is used to adjust the contribution of different classes to the total loss and alleviate the class imbalance problem; p t represents the predicted probability of the model for the true class; γ is an adjustable modulation factor, which is used to make the model pay more attention to difficult-to-classify samples and improve the learning effect for minority classes;
[0122] Because the above slicing method of adaptive overlapping data of the sliding window cannot completely eliminate the class imbalance problem, the conventional cross-entropy loss function is replaced with the focal loss function. The focal loss function dynamically adjusts the sample weights by introducing a modulation factor, reduces the contribution of multi-sample classes to the loss function, and at the same time enhances the weights of few-sample classes.
[0123] S4.3, combining the adaptive learning rate optimizer Adam for model training; by adopting the adaptive learning rate optimizer Adam and combining the weight decay strategy, overfitting of the model is prevented. The initial learning rate is set to 1e-4, and the weight decay coefficient is 1e-2.
[0124] S4.4, adopting an early stopping strategy during training to prevent overfitting; training a patient-specific model to capture their unique seizure patterns; using all training data in each round of training during the training process, setting the maximum number of training rounds to 20, and using the early stopping method to prevent overfitting. When the model does not observe performance improvement for 10 consecutive rounds on the validation set, training is terminated in advance.
[0125] S5: After the training of the warning model is completed, model testing is required to verify the training effect of the model;
[0126] Specifically, the test set data is input into the trained early warning model, and the sensitivity and false alarm rate of the early warning model on the test set are calculated; wherein, sensitivity refers to the ratio of the number of epileptic seizures successfully predicted by the system to the total number of actual seizures, which is used to evaluate the ability of the early warning model to successfully predict epileptic seizures; false alarm rate refers to the ratio of the number of alarms issued by the system in error to the total test time, usually expressed as the number of false alarms per hour, which is used to measure the frequency of false alarms issued by the early warning model; if the early warning model shows high sensitivity and reasonable false alarm rate on the test set, the model parameters are saved; the calculation method is as follows:
[0127]
[0128]
[0129] In the calculation formula of sensitivity, True Positives (TP) represents the number of attacks that the system successfully predicts, and False Negatives (FN) represents the number of attacks that the system fails to predict; in the calculation formula of false alarm rate, False Positives (FP) represents the number of alarms that the system mistakenly issues;
[0130] If the sensitivity is high and the false alarm rate is within a reasonable range, it means that the warning model has a relatively ideal effect on the test set and can basically successfully predict epileptic seizure events in the test set, then the model parameters will be saved.
[0131] S6: After completing the model training, the system will enter the real-time reasoning stage to predict the time of epileptic seizures;
[0132] First, the system intercepts and saves the EEG signal segments collected in real time at a fixed frequency, filters them and inputs them into the trained model. The model outputs the probability values of the three states of interictal, preictal and ictal, and takes the maximum value of the probability values as the inference result of the current signal segment. The fixed frequency is, for example, once per second. The EEG signal segments collected in real time can be the signal segments of the last 10 seconds.
[0133] Secondly, in order to warn of epileptic seizures, the system records the inference results over a period of time, which are divided into the following situations:
[0134] In case 1, if the proportion of the pre-ictal period exceeds the set threshold, a yellow light alarm is triggered to indicate that an epileptic seizure is about to occur, and the alarm is automatically lifted after a certain period of time;
[0135] In the second case, if the model outputs the seizure results for multiple times in a row, a red light alarm will be triggered, indicating that the patient is in an epileptic seizure state until the seizure signal disappears;
[0136] In Case 3, if the red light warning is not triggered during the yellow light alarm, it is regarded as a false alarm, and the system will retrain the model with the relevant data as new interictal data to improve the model performance;
[0137] Exemplarily, in order to predict epileptic seizures, the system will automatically record the model inference results in the most recent 10 minutes; since the warning model generates an inference result every second, 600 inference results will be accumulated within 10 minutes;
[0138] If among these 600 results, more than 90% of the inference results are in the pre-ictal stage, the system will trigger a yellow light alarm to warn the patient that an epileptic seizure is about to occur. After the yellow light alarm is triggered, the system will maintain the yellow light alarm status within the next 30 minutes and will not trigger a new yellow light alarm again; after 30 minutes, the yellow light alarm will be automatically cancelled, and the warning system will return to the normal working state and continue to monitor and infer in real time;
[0139] When the system detects that the output results of the warning model are in the seizure stage for 5 consecutive times, the system will immediately trigger a red light warning, indicating that the patient is currently in an epileptic seizure state, providing a clear emergency status reminder for the patient and their caregivers; the red light warning will end after the system confirms that the seizure stage signal has disappeared;
[0140] If during the duration of the yellow light alarm status, the patient does not have an epileptic seizure, that is, the state of the red light warning does not appear, then this yellow light alarm will be regarded as a false alarm; once a false alarm occurs, the system will use the data from 2 hours after the end of the most recent epileptic seizure to before the yellow light alarm is triggered as interictal data and return it to the previous step, regarded as new data to retrain the model to enhance the model's ability.
[0141] Therefore, this model can not only predict the pre-ictal stage of epileptic seizures, but also detect the signals in the seizure stage in real time, that is, the system continuously monitors the EEG signals through a sliding window, and makes a comprehensive judgment not only based on the model inference results of the current time window, but also combined with the prediction results of the previous time window, ensuring the reliability and practicality of the warning results, and continuously training the model in real time to enhance the warning ability of the model.
[0142] Experiments show that, referring to Table 2, it illustrates the influence differences of multi-channel EEG signal acquisition and other channel settings;
[0143] Table 2 Statistical table of the results of the present invention on the Boston Children's EEG dataset
[0144] Method Number of channels Average sensitivity (%) Average false alarm rate ( / h) Time-frequency model + the strategy of the present invention 4 86.2 0.11 Time-frequency model + the strategy of the present invention 18 91.4 0.10 Single-input model + no special strategy 18 79.7 0.12
[0145] As can be seen from the table, when the number of EEG signal channels is different and other conditions are the same, the present invention achieves an average sensitivity of 86.2% on the Boston Children's EEG dataset CHB-MIT, which is only about 5% lower than the 18-channel signal containing more information and still remains at a level within the available range. If the strategies such as data partitioning and time-frequency combination model mentioned in the present invention are not used, although the input signal is still 18 channels, the average sensitivity is only 79.7%, which fails to reach the available level, fully demonstrating the effectiveness of the system proposed by this technical solution;
[0146] Therefore, the easily wearable EEG signal epilepsy warning system based on time-frequency feature fusion proposed by the present invention can achieve a prediction performance comparable to that of a multi-channel system by only using the EEG channels near the forehead and behind the ears. At the same time, it significantly reduces the hardware cost and computational resource requirements, improves the convenience, and provides a feasible solution for the application of epilepsy warning technology in multi-scenarios such as home monitoring and mobile medical scenarios.
[0147] Finally, it should be pointed out that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An epilepsy early warning method based on electroencephalogram signals, characterized in that: It includes the following contents: S1: Determine the acquisition positions of the few-channel EEG signals and acquire the EEG signal data, and mark the time nodes where the start and end positions of the epileptic seizure are located; S2: Divide the EEG signal data, determine the model training set and the model test set, record the total number N of epileptic seizure events, and define the interictal period, preictal period and ictal period; S3: Perform data denoising, and use the slicing method of adaptive overlapping data based on a sliding window to dynamically adjust the overlapping ratio of the data window to complete the preprocessing process; S4: Build and train an early warning model based on a deep learning model for time-frequency feature fusion, and use the parallel time-domain branch and frequency-domain branch for fusion and classification to achieve a three-classification task; S5: After the training of the early warning model is completed, model testing is required to verify the training effect of the model, and at the same time calculate the sensitivity and false alarm rate of the early warning model on the model test set; S6: After the training of the early warning model is completed, the system will enter the real-time inference stage for predicting the epileptic seizure time.
2. The epilepsy early warning method based on electroencephalogram signals according to claim 1, wherein: The seizure data used for the model training set accounts for 66.7%-80% of the total number of epileptic seizure events.
3. A method for epilepsy early warning based on electroencephalogram signals according to claim 1 or 2, characterized in that: Set the interval time between two adjacent epileptic seizure events to C minutes. When C is less than 30, the two events are combined and regarded as one seizure event.
4. The epilepsy warning method based on electroencephalogram signals according to claim 1, wherein: The said S3 includes: S3.1, Use a notch filter to filter power frequency noise, and use a low-pass filter to remove the DC component below the set frequency; S3.2, Use the sliding window method to segment the original EEG signal, set the window length to T seconds, and dynamically adjust the overlapping ratio of the sliding window according to the signal category and duration; the overlapping ratio used for the interictal data is less than the overlapping ratio used for the ictal data; the overlapping ratio of the preictal data is dynamically determined according to the predefined time interval; S3.3, Save the preprocessed data for direct calling in subsequent steps.
5. The epilepsy warning method based on electroencephalogram signals according to claim 4, characterized in that: The said S4 includes: S4.1, Establish a time-domain feature extraction branch and a frequency-domain feature extraction branch, extract time-domain features and frequency-domain features, and perform classification through a multi-layer fully connected network after feature splicing to output the final prediction result; S4.2, Introduce a focal loss function to dynamically adjust the sample weights; S4.3, Combine the adaptive learning rate optimizer Adam for model training; S4.4, Adopt an early stopping strategy during the training process to prevent overfitting.
6. The epilepsy warning method based on electroencephalogram signals according to claim 5, characterized in that: The time-domain feature extraction branch consists of a multi-scale one-dimensional convolutional structure, a bidirectional LSTM layer and a flattening layer; Use the multi-scale one-dimensional convolutional structure to perform convolutional operations, splice the output data obtained by each scale of convolutional kernel, and introduce a residual connection structure. Input the features extracted by the multi-scale one-dimensional convolutional structure into the bidirectional LSTM layer to be able to capture the forward and backward dependencies of the signal at the same time; after passing through the bidirectional LSTM layer, input the obtained time-domain feature vector into the flattening layer for flattening.
7. A method for epilepsy warning based on electroencephalogram signals according to claim 5 or 6, characterized in that: The frequency-domain feature extraction branch consists of a short-time Fourier transform, a multi-scale two-dimensional convolutional structure and a flattening layer; The short-time Fourier transform is used to generate a time-frequency spectrum, the signal is segmented using a Hanning window, and then the signal in each window is subjected to a Fourier transform: the frequency domain representations of each window are arranged in time order, and the generated time-frequency spectrum is logarithmically processed; The multi-scale two-dimensional convolution in the frequency domain branch is different from the one-dimensional convolution in the time domain feature extraction. The two-dimensional convolution is used in the frequency domain branch to extract the frequency band energy distribution. After passing through three multi-scale two-dimensional convolution structures, the obtained frequency domain feature vector is input into the flattening layer for flattening.
8. A method for epilepsy warning based on electroencephalogram signals according to claim 7, characterized in that: In S6, for early warning of epileptic seizures, the system records the inference results within a period of time, which are specifically divided into the following situations; In case 1, if the proportion of the pre-ictal period exceeds the set threshold, a yellow light alarm is triggered to indicate that an epileptic seizure is about to occur, and the alarm is automatically lifted after a certain period of time; In the second case, if the model outputs the seizure results for multiple times in a row, a red light alarm will be triggered, indicating that the patient is in an epileptic seizure state until the seizure signal disappears; In the third case, if the red light warning is not triggered during the yellow light alarm, it is considered a false alarm. The system will use the relevant data as new interictal data to retrain the model to improve model performance.
9. An epilepsy early warning system based on electroencephalogram signals, applied to an epilepsy early warning method based on electroencephalogram signals as claimed in claim 8, characterized in that: include: An information acquisition module, used to determine the location of collecting few-channel EEG signals and collect EEG signal data; The data division module is used to first divide the patient's continuous EEG signal data into several seizure data to record the total number of epileptic seizure events, and then divide each seizure cycle data into interictal period, preictal period and seizure period according to the onset time of each seizure, and then divide it into training set and test set; The data preprocessing module is used for data denoising and adopts an adaptive overlapping data slicing method based on a sliding window to dynamically adjust the overlapping ratio of the data window and complete the preprocessing process to alleviate the problem of data imbalance. The model training module is used to build and train the early warning model based on the deep learning model of time-frequency feature fusion to achieve the three-classification task of interictal period, preictal period and ictal period. After the early warning model training is completed, the model needs to be tested to verify the model training effect. Real-time reasoning module,After completing the model training, the system will enter the real-time reasoning stage, which is used to predict the time of epileptic seizures.
10. The epilepsy early warning system based on electroencephalogram signals according to claim 9, characterized in that: The system also includes a false alarm feedback module, which is signal-connected to the real-time reasoning module and the data partitioning module, and is used to return the data from the end of the most recent epileptic seizure before the false alarm to the triggering of the yellow light alarm as interictal data to the data partitioning module, and regard it as newly added data to retrain the model.
Citation Information
Cited By
Method and system for removing artifacts of mixed signal, terminal and storage medium
CN120859516A
Method for adjusting model parameters based on electroencephalogram signals and epilepsy treatment equipment
CN122141120A