A method for quantifying persistent electrical activity in sleep epilepsy based on deep learning and morphology

By combining deep learning and morphological methods, using semantic segmentation networks and Resnet34 networks, the difficult problems of identifying and quantifying epileptic electrical activity in ESES syndrome were solved, and efficient and accurate discharge index quantification and sleep stage identification were achieved, improving the accuracy and applicability of identification.

CN116746948BActive Publication Date: 2025-09-26HANGZHOU DIANZI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310793934.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-30
Publication Date
2025-09-26
Estimated Expiration
2043-06-30

AI Technical Summary

Technical Problem

Existing technologies have the problems of being time-consuming, labor-intensive, inaccurate and costly in identifying and quantifying epileptic electrical activity in ESES syndrome. In particular, the acquisition of long-term EEG data is economical and unacceptable, making it difficult to achieve accurate discharge index quantification.

Method used

Combining deep learning with morphological methods, using the semantic segmentation network U-Net and Resnet34 network, and through dual-channel EEG signal processing, accurate recognition of spike waves and sleep stages is achieved. Morphological filters are combined to determine the candidate areas of spikes and slow waves and calculate the discharge index.

Benefits of technology

It achieves efficient and accurate identification and quantification of epileptic discharges, improves the accuracy of spike wave detection, shortens calculation time, enhances the applicability of the method and the tolerance of the subjects, and provides an automatic detection tool for long-term electroencephalograms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116746948B_ABST
    Figure CN116746948B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for quantifying epileptic electrical activity during sleep based on deep learning and morphology. The method comprises the following steps: 1. performing signal preprocessing operations; 2. inputting the preprocessed T3 channel signal into an improved semantic segmentation network for spike wave identification. The network can identify the location and duration of the patient's spike wave discharge and output a signal with fine-grained labels of spike wave data segments; 3. using the obtained signal with spike wave information as input to a morphological module to judge candidate regions, obtain the number and duration of epileptic spike and slow wave segments, and obtain the total discharge time, thereby calculating the discharge index of each sample; 4. inputting the Cz channel signal into a sleep staging module based on Resnet34 to implement sleep staging for each 30-second sample. The present invention can realize the identification and quantification of epileptic electrical activity during children's sleep.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of EEG signal processing and smart medicine, and relates to a multi-task (semantic segmentation combined with morphology and deep learning) method for identifying, quantifying and staging childhood epileptic electrical activity. Background Art

[0002] ESES syndrome (Epileptic encephalopathy with status epilepticus during sleep), also known as electrical status epilepticus during sleep, is a unique EEG phenomenon characterized by persistent epileptiform discharges induced by sleep. Children with this syndrome often experience adverse reactions such as worsening cognitive function, behavioral, and psychomotor decline. However, the syndrome's clinical manifestations lack consistency and intuitiveness, making identification and diagnosis difficult and leading to delayed diagnosis, treatment, and management of affected children. Effective early diagnosis and treatment tailored to the patient's varying symptoms can help properly manage ESES, control epileptiform discharges, and thus improve patient outcomes.

[0003] ESES is typically characterized by prominent epileptiform activity during non-rapid eye movement (NREM) sleep, with the electroencephalogram (EEG) demonstrating a series of continuous spike and slow wave discharges. The spike-wave index (SWI) measures these abnormal discharges by calculating the percentage of abnormal spike and slow wave discharges in the NREM period, providing a quantitative analysis of the condition and reflecting the progression of the patient's condition. Accurately quantifying the SWI is crucial for clinical diagnosis and prognosis. However, obtaining the SWI requires expert interpretation and manual annotation of long-term EEG data, a time-consuming and labor-intensive process, and the accuracy of the annotations cannot be guaranteed. Furthermore, annotations vary subjectively between experts, resulting in low consistency. More importantly, obtaining long-term EEG data requires patients to wear specialized equipment in designated locations, which is both costly and time-consuming, and has limited acceptability, making it a difficult long-term monitoring method. Therefore, establishing an accurate, efficient, and convenient method for identifying and quantifying ESES patients has significant economic and social value.

[0004] With the development of relevant technologies, some studies have demonstrated the feasibility of accurately quantifying epileptic electrical activity. Existing research focuses on the following areas:

[0005] Template matching-based quantification of epileptic electrical activity: Use predefined spike wave templates to perform spike wave detection and achieve spike wave discharge quantification.

[0006] Quantification of epileptic electrical activity based on signal classification: By extracting EEG features and using a classifier for classification, the signal segment category after slicing can be identified, and then the epileptic discharge quantification operation is performed by combining the category and the slice duration.

[0007] Quantification of epileptic electrical activity based on morphology and medical knowledge: The EEG signals of ESES patients are processed using morphology, and the morphological features are comprehensively analyzed in combination with medical knowledge to achieve quantification.

[0008] All of the above methods have limitations in practical application. Template matching-based methods are highly dependent on the parameters of the selected template and lack the ability to identify slow waves. Signal classification-based methods rely heavily on manual features extracted from experience and lack robustness and generalizability when used on different patients. Methods based on morphology and medical knowledge require manual determination of thresholds to screen for epileptic discharge areas and have limited ability to localize discharge regions.

[0009] With the rapid development of computer hardware and the increasing complexity of real-world problems in recent years, deep learning-based methods have garnered increasing attention. The complex and variable waveforms of electrical status epilepticus during sleep in patients with ESES have prompted us to combine deep learning methods to more accurately and conveniently quantify these electrical status epilepticus. Summary of the Invention

[0010] To address the challenges of previously proposed methods for identifying and quantifying epileptic electrical activity during sleep, this paper combines deep learning with morphological methods and introduces a sleep staging module to propose a method for identifying and quantifying epileptic electrical activity during sleep based on deep learning and morphology. This method can simultaneously identify and quantify epileptic discharges and the current sleep stage, offering improved applicability and economic value.

[0011] In the present invention, the research subjects are patients with BECT syndrome, which is a type of ESES and the most common focal epilepsy in childhood. First, the dual-channel EEG signals are preprocessed, 0.5-70Hz bandpass filtering, 50Hz notch filtering and detrending operations are performed to obtain signals with less interference. The data is then segmented, and the data between 30 minutes before sleep and 30 minutes after waking up are selected. The selected data are then uniformly divided into signal segments of 30s length, and each data segment is labeled with sleep phase and spike wave segment for subsequent training of deep networks. The signal channels used are Cz and the channels of the central temporal region (T3 channels are uniformly selected in the present invention). Since the Cz channel signal has fewer spike and slow wave discharges and has less interference with sleep staging, it is used as the input of Resnet34 for sleep staging. The signal of the T3 channel is used as the input of the semantic segmentation network. The network is developed based on the U-Net structure, and Resnet is used as the encoder to replace the downsampling path of the original U-Net structure. The downsampling path utilizes four encoding modules, each consisting of two basic modules: an identity block and a down-sample block. Each of these four encoding modules is formed by a differentiated combination of an identity block and a down-sample block. Each step in the upsampling path consists of a transposed convolutional layer of feature maps, which are concatenated with the corresponding features from the downsampling path. Due to the characteristics of the EEG waveform of epileptic electrical persistence during sleep, the semantic segmentation model performs well for identifying spikes but poorly for identifying slow waves. Therefore, the signal processed by semantic segmentation serves as the input to the morphological module. The morphological module uses spike location information to further identify candidate spike and slow wave regions, thereby improving recognition accuracy. The signal identified by the semantic segmentation model contains information about the location and duration of spikes. The spike location and a certain range following it are considered candidate identification ranges for spike and slow wave (epileptic discharge) identification, and morphological identification of the candidate regions is performed. Morphological filtering is used to locate the peaks and pits of the local signal. The combination order determines whether the current spike and slow wave candidate region represents a spike and slow wave discharge. Based on the number and duration of spike-wave regions, the total discharge duration and the discharge index for each sample can be calculated. Finally, a sleep staging module based on ResNet-34 is used to identify the patient's sleep state. The model outputs wake, non-rapid eye movement (NREM), and rapid eye movement (REM).

[0012] The technical solution of the present invention mainly includes the following steps:

[0013] Step 1: Preprocess the signal. Segment the preprocessed EEG signal, select the data segment containing complete sleep, and then perform equal length segmentation to obtain samples. Each sample is labeled with the sleep stage and spike segment for subsequent deep network training;

[0014] Step 2: The preprocessed T3 channel signal is input into an improved semantic segmentation network for spike wave recognition. The network can identify the location and duration of the patient's spike wave discharge and output a signal with fine-grained labels of the spike wave data segments;

[0015] Step 3: The obtained spike-wave signal is used as the input of the morphological module. The morphological module combines the spike wave position information output by the semantic segmentation network to make further judgments on the candidate regions, ultimately obtaining the number and duration of epileptic spike and slow wave segments, and the total discharge time, thereby calculating the discharge index of each sample.

[0016] Step 4: Input the Cz channel signal into the sleep staging module based on Resnet34 to implement sleep staging for each 30s length sample;

[0017] Step 5: Combine the outputs of steps 3 and 4 to achieve identification and quantification of epileptic electrical activity during sleep in children;

[0018] Furthermore, the specific process of step 1 is as follows:

[0019] 1-1. Preprocess the original signal: 0.5-70 Hz bandpass filtering, 50 Hz notch filtering, and detrending operation to obtain a signal with less interference.

[0020] 1-2. Simultaneously, the preprocessed signal is segmented, selecting data from 30 minutes before sleep and 30 minutes after wakefulness. This data is then divided into 30-second samples. Each data segment is labeled with sleep phases and spike / slow wave segments for subsequent deep network training. Sleep phases are labeled as Wake, NREM, and REM. Spike / slow wave labels are a combination of the start timestamp and duration.

[0021] Furthermore, step 2 uses the T3 channel signal and spike wave labels as input to the semantic segmentation model. During the input process, the spike wave labels are converted into fine-grained labels. Specifically, the combination of the original spike wave start timestamp and duration is converted into 0 and 1 labels. Here, 0 corresponds to no spike wave, and 1 corresponds to the presence of a spike wave. A 0 and 1 character vector of length 1*15000 is formed and used to match the signal vector. The length of a single sample signal is 30s and the sampling rate is 500Hz, so the vector is 1*15000. The specific process is as follows:

[0022] 2-1. The preprocessed T3 channel signal is input into the semantic segmentation network together with the spike and slow wave labels. First, 64 7*1 convolution kernels are used to perform convolution with a step size of 3 to obtain a new feature matrix. After ReLu and Maxpool, the downsampling path is input. The downsampling path uses the typical feature extraction network Resnet, which consists of four encoding blocks. The encoding block consists of a standard block I, or a standard block I and a standard block D. Each standard block contains two convolutions and two BN blocks; the first encoding block consists of two standard blocks I, and the remaining three encoding blocks are all composed of a standard block D and a standard block I. After each downsampling operation, the length of the feature is halved, but the number of channels of the feature is doubled. After four downsampling operations, the feature size changes from (1*5000*64) to (1*625*512).

[0023] 2-2. In the upsampling path, ConvTranspose1d is used at each step to double the input size and halve the feature channels. The corresponding feature maps from the output downsampling path are concatenated and fed into the previous layer. In the final layer, ConvTranspose1d with a kernel size of 1*7 is used to convert the output from 64 channels to 32 channels. A 1*1 convolution is then used to convert the 32-length vector into the required two-category labels. Finally, batch normalization and ReLU are performed to obtain the final output: labels 0 and 1 of size 1*15000.

[0024] 2-3. The loss of the model during training uses classification loss. Since both the true label and the model output label use fine-grained labels of 0 and 1, the loss uses binary cross entropy loss:

[0025]

[0026] where y i is the true binary label value 0 or 1, represents the actual output value, and n represents the number of labels.

[0027] 2-4. After obtaining the output of the semantic segmentation network, the output is post-processed based on the signal characteristics of the spike wave. Specifically: Since the length of the spike wave is between 20 milliseconds and 70 milliseconds, combined with the data sampling rate, the average sample point length of the spike wave is 10-40 sample points. Therefore, in order to reduce misjudgment, the network output with a length of less than 10 points and more than 40 points in the semantic segmentation network output is filtered out, and only the output with a length within the spike wave range is retained. On this basis, the candidate area of ​​epileptic spike and slow waves is obtained. The processed spike wave label information is input into the morphological module to further determine the candidate area of ​​epileptic spike and slow waves;

[0028] Furthermore, the specific process of step 3 is as follows:

[0029] 3-1. The obtained candidate area and the pre-processed T3 channel signal are used as the input of the morphological filter. According to the position information of the candidate area, the detection area of ​​the morphological filter is selected. Specifically, since the length of the spike wave is 20-70 milliseconds and the subsequent slow wave part is 200-500 milliseconds, the length of the spike-slow wave complex should be between 220-570 milliseconds, and the corresponding sampling point length is 110-285 points. Taking into account the shape changes of the spike and slow waves, the candidate area is extended at both ends, that is, the left end of the candidate area obtained in step 2 is extended to the left by another 20 sampling points, and using this as the starting point, the right end of the candidate area is extended to the right by another 15 sampling points. 330 sampling points are regarded as a complete candidate spike and slow wave emission data segment, and then detected using the morphological filter;

[0030] 3-2. Use morphological filters to detect and identify candidate spike and slow wave data segments to determine whether the data segments belong to spike and slow wave data segments. The specific process is as follows:

[0031] First, a morphological filter is used to locate the peak and pit regions of the candidate spike and slow wave data segments. The main operations of the morphological filter are divided into the following four categories:

[0032] corrosion:

[0033]

[0034] Expansion:

[0035]

[0036] Open operation:

[0037]

[0038] Closing operation:

[0039]

[0040] Wherein, f(n) represents the signal input of the candidate region with a length of N, g(n) represents the used structural element, which is defined as shown in Formula 6, and its length M<N.

[0041]

[0042] In practice, opening and closing operations move the structuring element below and above the signal, respectively. Opening eliminates isolated signal points, suppresses positive noise, and smoothes the signal. Closing fills signal troughs and suppresses negative noise. The signal components actually filtered out depend on the structuring element used in the operation. For example, if the width of the structuring element is M and the width of a peak or trough in the signal is N, the target signal is filtered out if N is less than M; otherwise, the target signal is retained.

[0043] In this paper, a dome-shaped structuring element is used to better fit the spike and slow wave characteristics of epileptiform discharge waveforms in BECT patients. In Equation 6, W represents the width of the structuring element g(n). Furthermore, the height of g(n) is represented by h. Based on experimental results, h is empirically set to 2.85 and α to 1.05.

[0044] According to the principle of opening and closing operations, the peak and pit identification operation of the waveform is performed. First, the peak detector (KD) is constructed, as shown in Formula 7

[0045]

[0046] Among them, f(n) is the signal input of the candidate region length N, that is, N = 1, 2, ... 330. The structural elements g1 and g2 used here are both formula (6), and only the width M is different. When using the peak area detector KD, first use a structural element g1 with a smaller width to perform an opening operation. Its width is selected to be 15, which is slightly larger than the minimum continuous point number of the spike wave 10 points. After the opening operation by g1, the signal I with a width greater than the length of the structural element in the positive signal is retained, and the pits are suppressed at the same time. After this operation, the positive spike wave, slow wave part and a certain background wave part in the signal can be extracted. Then use a structural element g2 with a larger width to open the signal after the opening operation. Perform a closing operation and select a structuring element length of 50. After closing, signals with a width less than 50 sample points are filtered out, resulting in Signal II, which has all spikes removed and retains only the background waveform and a certain amount of slow wave components. Finally, subtract Signal II from Signal I to obtain Signal III, which contains spikes and a small number of deformed, low-amplitude slow wave protrusions.

[0047] Similarly, the pit detector (TD) of the signal is constructed as shown in formula 8

[0048]

[0049] Among them, the structural elements g3 and g4 are also modified only in width. First, the structural element g3 is used to perform a closing operation on the signal (fΘg3)(n) to remove the peak of the signal and obtain the preliminary pit area signal. Here, the length of g3 is set to 40, which is the maximum width of the spike wave, and then g4 is used for opening operation. The background wave is extracted to obtain the background wave signal, and the width of g4 is set to 16. Finally, the background wave signal is subtracted from the preliminary pit area signal to obtain the negative pit area signal after removing the background wave.

[0050] 3-3. Superimpose the acquired signal III with the pit region signal to restore the complete spike-wave waveform. Each data segment is still 330 sampling points long, corresponding to a data segment length of 0.66 seconds. Then, local extrema are determined for each data segment. Based on the characteristics of the spike-wave pattern, determine whether the extrema of the data segment satisfies the sequence of minimum, maximum, minimum, maximum, minimum (pit, peak, pit, peak, pit). To eliminate interference, the amplitude of the first maximum must be above 75 microvolts before the sequence is considered. By determining whether the current signal segment satisfies the aforementioned sequence rules, determine whether the data segment represents an epileptic spike-wave pattern.

[0051] 3-4. After obtaining the number of spike-wave bursts and their duration, calculate the discharge index (SWI) for the 30-second sample signal. SWI is a parameter used to quantify ESES and is defined as the total duration of all spike-wave bursts divided by the total duration of NREM sleep, multiplied by 100. The SWI calculation formula for a single 30-second sample signal is as follows:

[0052]

[0053] Where N is the number of spike-wave segments contained in a 30-second segment of the sample signal, L is the length of each spike-wave segment, and Duration is the duration of non-rapid sleep. SWI is measured in units of 30 seconds, so Duration is a constant 30 seconds.

[0054] 3-5. Use time estimation error and event detection error to measure the effect. Time estimation error refers to the actual SWI of a single 30s sample signal segment. _L The difference between the SWI_pre estimated by the method is calculated as follows:

[0055] SWI Error =|SWI _L -SWI_pre| (10)

[0056] Among them, SWI _LRefers to the actual discharge index, SWI_pre refers to the discharge index predicted by this method, and the absolute value of the difference between the two is taken as the discharge index error SWI Error The percentage of SWI error within X%, PCT (X%) is used to measure different levels of SWI. Error The proportion of X represents different error levels. If SWI Error If the proportion of samples with less than 5% of the total samples is 10%, then the value of PCT(5%) is 10%, and so on. Then, Precision and Recall are used to evaluate the effect of event detection. The formula is as follows:

[0057]

[0058]

[0059] Among them, FN (False Negative) means that the signal segment is judged as a negative sample, but is actually a positive sample, that is, the 0.66s signal segment is originally a discharge sample, but is mistakenly judged as a no-discharge sample. TN (True Negative) means that the sample judged by the model is a negative sample, and in fact it is a negative sample; TP (True Positive) means that the sample judged by the model is a positive sample, and in fact it is a positive sample. Precision represents the accuracy rate, which represents the proportion of truly correct samples to all predicted positive samples; Recall represents the recall rate, which represents the proportion of truly correct samples to all actually positive samples. The higher the value, the lower the missed detection rate.

[0060] In this step, it is necessary to measure the matching of each 0.66s signal segment and the original label. Since the original label uses continuous labeling for similar spikes and slow waves (within 0.5s), that is, a spike and slow wave label may contain multiple spikes and slow waves, corresponding adjustments need to be made in the matching of the 0.66s signal. In the actual matching process, the results are matched in two cases, namely, events where the labeled label contains only one spike and slow wave and events where the labeled label contains multiple spikes and slow waves. For the former, the full intersection over union (IoU) is used for measurement. Assuming that the spike and slow wave event position of label Y is y∈[y1, y2], and the predicted spike and slow wave event position X is x∈[x1, x2], then IoU is defined as:

[0061]

[0062] Length(X∩Y) and Length(X∪Y) represent the intersection length and union length of the label and the output event, respectively. If x2<y2, then Length(X∩Y)=x2-y1, otherwise it is y2-x1. At this time, if IoU>0.5, it is considered that the event detected by this method and the labeled spike and slow wave event are successfully matched, and the TP value is increased by one. If IoU<0.5, it is considered that the match with the real event is not successful, and FP is increased by one. This method is also used for events marked as non-spike and slow waves. In addition, for real labels with multiple spike and slow wave events, according to the position of the predicted event, the predicted labels whose start time is within the range of the real label are uniformly regarded as a detection event. After merging the lengths of these events, IoU matching is performed, and the threshold of 0.5 is also used for judgment. If IoU>0.5, it is considered that this long spike and slow wave event is detected, and TP is increased by one;

[0063] Furthermore, the specific steps of step 4 are as follows:

[0064] 4-1. The original Cz signal is used as the input of Resnet34 for training. First, in the first convolution layer, the convolution kernel size is set to 7, the number of convolution kernels is set to 64, the stride is set to 3, the padding is set to 3, all 0 padding is used, and batch normalization and Relu function are performed. Then, after a series of residual modules, there are 4 residual structures in Resnet34, and each residual structure has the following number of residual units, namely 3 in the first layer, 4 in the second layer, 6 in the third layer, and 3 in the fourth layer. After passing through the 4 residual structures, a 512*1875 feature matrix is ​​formed. Then, after passing through an AdaptiveAvgPool1d layer, the data output by the upper layer is converted into one-dimensional data, and a 512*1 feature is obtained. Then, after passing through a fully connected (FC) structure, it contains three linear layers with 128, 32, and 3 neurons respectively.

[0065] 4-2. The loss function is set as follows:

[0066]

[0067] in, is the actual output value, y i is the tag value.

[0068] 4-3. Model results are measured using Accuracy, Precision, and Recall, which will not be detailed here.

[0069] Furthermore, the specific process of step 5 is as follows:

[0070] 5-1. Combining the results of steps 3 and 4, the sleep stage category and discharge index of all samples can be obtained, thereby achieving quantitative analysis of the patient's epileptic electrical activity during sleep and providing a tool for studying the evolution of epileptic discharges in different patients at different sleep stages.

[0071] The beneficial effects of the present invention are as follows:

[0072] This method uses a deep learning-based morphological analysis approach to identify and quantify persistent epileptic electrical activity during sleep. Its key advantages include: 1) Using the semantic segmentation network (U-NET) algorithm, it can precisely detect spike locations within the signal, even across complex EEG data from diverse patients. This robustness improves spike detection accuracy. 2) Using morphological analysis combined with semantic segmentation, spike location information is used to delineate candidate regions for spike and slow wave discharges, further narrowing the range the algorithm must examine. Morphological filtering is used to identify the waveforms within candidate regions and determine whether they represent spike and slow wave discharges. This leverages the advantages of morphological and medical knowledge to achieve more accurate spike and slow wave location and duration identification. 3) Using the ResNet34 network, sleep staging is performed for BECT patients, enabling simultaneous sleep state identification and discharge index calculation within signal segments, streamlining the sleep discharge index process. 4) Using dual-channel Cz and T3 data, compared to the 10-20 system, the algorithm requires less data and improves computational speed. In addition, using only two channels for data acquisition can improve the subjects' tolerance and make the method more applicable.

[0073] The present invention intercepts the dual-channel EEG data of patients from 30 minutes before sleep to 30 minutes after waking up, and performs pre-processing operations such as filtering on the original signal. The semantic segmentation network is used to perform fine-grained recognition of the spike wave position and accurately find the spike wave position in the signal. On this basis, the morphological method is applied to realize the recognition of the existence of spike and slow wave segments, and finally the Resnet34 network is used to identify the sleep stage of the signal segment. Studies have shown that when using this method to perform epileptic discharge identification and quantification tasks, the average SWI Error The accuracy can reach 6.04%, the recall can reach 87.37%, and the precision is 56.11%. PCT (1%), PCT (5%), and PCT (10%) can reach 15.2%, 64.6%, and 85.3%, respectively. In the sleep staging task, the accuracy can reach 92.75%, the precision can reach 90.81%, and the recall is 82.5%. Experimental results show that this method can effectively identify and quantify epileptiform discharges during sleep in ESES syndrome and realize the identification of sleep stages.

[0074] On this basis, we can establish an accurate and efficient automatic sleep epileptiform discharge identification and quantification system for ESES syndrome patients. This will help provide long-term EEG monitoring for ESES syndrome patients, thus providing the possibility for patients to receive treatment as soon as possible. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] Figure 1 : Flowchart of the present invention.

[0076] Specific implementation method

[0077] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0078] A method for identifying and quantifying persistent epileptic electrical activity during sleep, based on deep learning combined with morphological analysis, is innovative in the following ways: 1) It uses a semantic segmentation network (U-NET) algorithm to precisely detect spike locations within the signal, enabling accurate identification even across complex EEG data from diverse patients. This robust approach improves spike detection accuracy. 2) It uses morphological analysis combined with semantic segmentation to delineate candidate regions for spike and slow wave discharges, further narrowing the range the algorithm must examine. Morphological filtering is employed to identify the waveforms within candidate regions and determine whether they represent spike and slow wave discharges. This leverages the strengths of morphological and medical knowledge to achieve more accurate spike and slow wave location and duration identification. 3) By using a ResNet34 network, it implements sleep staging for BECT patients, enabling simultaneous sleep state identification and discharge index calculation within signal segments, streamlining the sleep discharge index process. 4) It utilizes dual-channel Cz and T3 data, requiring less data than a 10-20 system, improving computational speed. In addition, using only two channels for data acquisition can improve the subjects' tolerance and make the method more applicable.

[0079] like Figure 1 As shown, the implementation steps of the method for quantifying persistent electrical activity in sleep epilepsy based on deep learning and morphology have been described in detail in the content of the invention, that is, the technical solution of the present invention mainly includes the following steps:

[0080] Step 1: Preprocess the signal. Segment the preprocessed EEG signal, select the data segment containing complete sleep, and then perform equal length segmentation to obtain samples. Each sample is labeled with the sleep stage and spike segment for subsequent deep network training;

[0081] Step 2: Input the preprocessed T3 channel signal into the semantic segmentation network for spike wave recognition. The network can identify the location and duration of the patient's spike wave discharge and output an output with fine-grained labels of the spike wave data segments;

[0082] Step 3: The obtained spike-wave signal is used as the input of the morphological module. The morphological module further judges the candidate region based on the spike wave position information obtained by semantic segmentation, and finally obtains the number and duration of epileptiform discharge (spike and slow wave) segments, and the total discharge time, thereby calculating the discharge index of each sample.

[0083] Step 4: Input the Cz channel signal into the sleep staging module based on Resnet34 to implement sleep staging for each 30s length sample;

[0084] Step 5: Combine the outputs of steps 3 and 4 to achieve identification and quantification of epileptic electrical activity during sleep in children;

[0085] Furthermore, the specific process of step 1 is as follows:

[0086] 1-1. Preprocess the original signal: 0.5-70 Hz bandpass filtering, 50 Hz notch filtering, and detrending operation to obtain a signal with less interference.

[0087] 1-2. Simultaneously, the preprocessed signal is segmented, selecting data from 30 minutes before sleep and 30 minutes after waking. This data is then divided into 30-second samples. Each data segment is labeled with sleep phases and spike / slow wave segments for subsequent deep network training. Sleep phases are labeled as wake, non-rapid eye movement (NREM), and rapid eye movement (REM). Spike wave labels are a combination of the start timestamp and duration.

[0088] Furthermore, the specific process of step 2 is as follows:

[0089] 2-1. The T3 channel signal and labels are used as input to the semantic segmentation model. During this input process, the spike and wave labels are converted into fine-grained labels. Specifically, the original spike and wave onset timestamp and duration combination is converted into a 0 and 1 label. Here, 0 corresponds to the absence of spikes, and 1 corresponds to the presence of spikes. This creates a 1*15000 character vector of 0 and 1 characters to match the signal vector. A single sample signal has a duration of 30 seconds and a sampling rate of 500 Hz, so the vector is 1*15000.

[0090] 2-2. Input the processed signal into the semantic segmentation network. First, use 64 7*1 convolution kernels to perform convolution with a stride of 3 to obtain a new feature matrix. After ReLu and Maxpool, input the downsampling path. The downsampling path uses the typical feature extraction network Resnet, which consists of four encoding blocks. The encoding block consists of basic block I and basic block D, which contains two convolutions and two BN blocks. Only the first encoding block consists of two basic blocks I, and the rest are composed of basic blocks D and basic blocks I. After each downsampling operation, the length of the feature is halved, but the number of channels of the feature will double. After four downsampling operations, the feature size changes from (1*5000*64) to (1*625*512).

[0091] 2-3. In the upsampling path, ConvTranspose1d is used at each step to double the input size and halve the number of feature channels. The corresponding feature maps from the output downsampling path are concatenated and fed into the previous layer. In the final layer, ConvTranspose1d with a kernel size of 1*7 is used to convert the output from 64 channels to 32 channels. A 1*1 convolution is then used to convert the 32-length vector into the required two-category labels. Finally, after batch normalization and ReLU, the final output is 1*15000 labels of size 0 and 1.

[0092] Furthermore, the loss of the model during training uses classification loss. Since both the true label and the model output use fine-grained labels of 0 and 1, the loss uses binary cross entropy loss:

[0093]

[0094] where y i is a binary label value 0 or 1, Indicates the actual output value.

[0095] After obtaining the output of the semantic segmentation network, the output is post-processed based on the signal characteristics of the spike wave. Specifically, since the length of the spike wave is between 20 milliseconds and 70 milliseconds, combined with the data sampling rate, the average sample point length of the spike wave is 10-40 sample points. Therefore, in order to reduce misjudgment, the network output with a length of less than 10 points and more than 40 points is filtered out, and only the output with a length within the spike wave range is retained. On this basis, the candidate area of ​​epileptic discharge (spike and slow wave) is obtained. The processed signal of the spike wave label information is input into the morphological module for further judgment of each candidate area;

[0096] Furthermore, the specific process of step 3 is as follows:

[0097] 3-1. The obtained spike position information and signal are used as input to the morphological filter. Based on the position information, the detection area of ​​the morphological filter is selected. Specifically, since the spike length is 20-70 milliseconds and the subsequent slow wave portion is 200-500 milliseconds, the length of the spike-slow wave complex should be between 220-570 milliseconds, corresponding to a sampling point length of 110-285 points. Taking into account the shape changes of the spike and slow waves, the candidate area is extended at both ends, that is, the left end of the spike position obtained in step 2 is extended to the left by another 20 sampling points, and this is used as the starting point. The total of 330 sampling points thereafter are regarded as a complete candidate spike-slow wave emission data segment, and then detected using the morphological filter;

[0098] 3-2. Use morphological filters to detect and identify the signal and determine whether the data segment belongs to spike and slow wave emission. The specific process is as follows.

[0099] First, use the morphological filter to locate the peak area and pit area of ​​the signal. The main operations of the morphological filter are divided into the following four:

[0100] corrosion:

[0101]

[0102] Expansion:

[0103]

[0104] Open operation:

[0105]

[0106] Closing operation:

[0107]

[0108] Among them, f(n) represents the signal input of length n, g(n) represents the structural element used and its definition is as follows

[0109] As shown in Formula 6, its length M<N.

[0110]

[0111] In practice, opening and closing operations move the structuring element below and above the signal, respectively. Opening eliminates isolated signal points, suppresses positive noise, and smoothes the signal. Closing fills signal troughs and suppresses negative noise. The signal components actually filtered out depend on the structuring element used in the operation. For example, if the width of the structuring element is M and the width of a peak or trough in the signal is N, the target signal is filtered out if N is less than M; otherwise, the target signal is retained.

[0112] In this paper, a dome-shaped structuring element is used to better fit the spike and slow wave characteristics of epileptiform discharge waveforms in BECT patients. In Equation 6, W represents the width of the structuring element g(n). Furthermore, the height of g(n) is represented by h. Based on experimental results, h is empirically set to 2.85 and α to 1.05.

[0113] According to the principle of opening and closing operations, the peak and pit identification operation of the waveform is performed. First, the peak detector (KD) is constructed, as shown in Formula 7

[0114]

[0115] Wherein, f(n) is the signal input of the candidate region length N, that is, N = 1, 2, ... 330; the structural elements g1 and g2 used here are both formula (6), and only the width M is different; when using the peak area detector KD, the structural element g1 is first used for opening operation, and its width is selected as 15, which is slightly larger than the minimum duration of the spike wave 10 points (corresponding to 20 milliseconds); after the opening operation of g1, the signal I with a width greater than the length of the structural element in the positive signal is retained, and the pits are suppressed at the same time. After this operation, the positive spike wave, slow wave part and a certain background wave part in the signal can be extracted; then the structural element g2 is used to open the signal after the opening operation Perform a closing operation and select a structural element g2 with a width of 50. After the closing operation, the signals of sample points with a width less than 50 will be filtered out, that is, all spikes are filtered out of the signal II, and the signal I1 only retains the background waveform and a certain slow wave component. Finally, subtract the signal II from the signal I to obtain the desired signal III, which contains spikes and a small amount of deformed low-amplitude slow wave protrusions.

[0116] Similarly, the pit detector TD of the signal is constructed as shown in formula 8

[0117]

[0118] Among them, the structural elements g3 and g4 are also modified only in width; first, the structural element g3 is used to perform a closing operation on the signal (fΘg3)(n) to remove the peak of the signal and obtain the preliminary pit area signal. Here, the length of g3 is set to 40, which is the maximum width of the spike wave, and then g4 is used for opening operation. The background wave is extracted to obtain the background wave signal, and the width of g4 is set to 16. Finally, the background wave signal is subtracted from the preliminary pit area signal to obtain the pit area signal after the negative background wave is removed.

[0119] 3-3. Superimpose the two acquired signals to restore the complete spike-wave waveform. Each data segment is still 330 sampling points long, corresponding to a data segment length of 0.66 seconds. Then, local extrema are determined for each data segment. Based on the characteristics of the spike-wave pattern, determine whether the extrema of the data segment meet the sequence of minimum, maximum, minimum, maximum, minimum (pit, peak, pit, peak, pit). To eliminate any interference, the amplitude of the first maximum must be above 75 microvolts before the sequence is considered. By determining whether the current signal segment meets these sequence rules, determine whether the data segment is an epileptic discharge (spike-wave discharge).

[0120] 3-4. After obtaining the number of spike-wave discharge data segments detected and their duration, the spike-wave index (SWI) of the sample signal (30s) can be calculated. SWI is a parameter used to quantify ESES and is defined as the total duration of all spike-wave discharges divided by the total duration of non-rapid eye movement sleep (NREM), multiplied by 100. The SWI calculation formula for a single 30s sample is as follows:

[0121]

[0122] Wherein, N represents the number of spike-wave segments contained in the 30-second signal segment, L represents the length of each spike-wave segment (fixed at 0.66 seconds in the present invention), and Duration represents the duration of non-rapid sleep. In the present invention, SWI is measured in units of 30 seconds, so Duration is constant at 30 seconds.

[0123] 3-5. The effectiveness of this method is measured using the time estimation error and event detection error. The time estimation error refers to the difference between the actual SWI of a single 30-second signal segment and the SWI estimated by the method, and is calculated as follows:

[0124] SWI Error =|SWI _L -SWI_pre| (10)

[0125] Among them, SWI L Refers to the actual discharge index, SWI_pre refers to the discharge index predicted by this method, and the absolute value of the difference between the two is taken as the discharge index error SWI Error The percentage of SWI error within X%, PCT (X%) is used to measure different levels of SWI. Error The proportion of X represents different error levels. If SWI ErrorIf the proportion of samples with less than 5% of the total samples is 10%, then the value of PCT(5%) is 10%, and so on. Then, Precision and Recall are used to evaluate the effect of event detection. The formula is as follows:

[0126]

[0127]

[0128] Among them, FN (False Negative) means that the signal segment is judged as a negative sample, but is actually a positive sample, that is, the 0.66s signal segment is a discharge sample, but is mistakenly judged as a non-discharge sample. TN (True Negative) means that it is judged as a negative sample by the model and is actually a negative sample; TP (True Positive) means that it is judged as a positive sample by the model and is actually a positive sample. Precision represents the accuracy rate, which represents the proportion of truly correct samples to all predicted positives; Recall represents the recall rate, which represents the proportion of truly correct samples to all actually positive samples. The higher the value, the lower the missed detection rate.

[0129] In this step, it is necessary to measure the matching of each 0.66s signal segment and the original label. Since the original label uses continuous labeling for similar spikes and slow waves (within 0.5s), that is, a spike and slow wave label may contain multiple spikes and slow waves, corresponding adjustments need to be made in the matching of the 0.66s signal. In the actual matching process, the results are matched in two cases, namely, events where the labeled label contains only one spike and slow wave and events where the labeled label contains multiple spikes and slow waves. For the former, the full intersection over union (IoU) is used for measurement. Assuming that the spike and slow wave event position of label Y is y∈[y1, y2], and the predicted spike and slow wave event position X is x∈[x1, x2], then IoU is defined as:

[0130]

[0131] Length(X∩Y) and Length(X∪Y) represent the intersection length and union length of the events of the label and the output respectively. If x2 < y2, then Length(X∩Y) = x2 - y1; otherwise, it is y2 - x1. At this time, if IoU > 0.5, it is considered that the event detected by this method and the labeled spike and slow wave event are successfully matched, and the TP value is incremented by one. If IoU < 0.5, it is considered that the match with the true event is not successful, and FP is incremented by one. This method is also used for the events labeled as non-spike and slow wave. In addition, for the true label with multiple spike and slow wave events, according to the position of the predicted event, the predicted labels whose start time is within the range of the true label are uniformly considered as one detected event. After merging the lengths of these events, IoU matching is performed, and the threshold of 0.5 is also used for determination. If IoU > 0.5, it is considered that this long spike and slow wave event is detected, and TP is incremented by one;

[0132] Further, the specific steps of step 4 are as follows:

[0133] 4-1. Use the original Cz signal as the input of Resnet34 for training. First, in the first convolutional layer, set the convolutional kernel size to 7, the number of convolutional kernels to 64, the stride to 3, the padding to 3, use all-0 padding and go through batch normalization and the Relu function. Then go through a series of residual modules. In Resnet34, there are 4 residual structures in total, and each residual structure has the following number of residual units, that is, 3 in the first layer, 4 in the second layer, 6 in the third layer, and 3 in the fourth layer. After going through 4 residual structures, a feature matrix of 512 * 1875 is formed. Then go through an AdaptiveAvgPool1d layer, and the data output from the upper layer is converted into one-dimensional data, obtaining a feature of 512 * 1. Then go through a fully connected (FC) structure, which includes three linear layers Linear, and the number of neurons is 128, 32, and 3 respectively.

[0134] 4-2. The loss function is set as follows:

[0135]

[0136] where, is the actual output value, and y i is the label value.

[0137] 4-3. The model results are measured using Accuracy, Precision, and Recall, which will not be elaborated here.

[0138] The sleep epilepsy electro-continuous activity quantification system based on deep learning and morphology specifically includes a preprocessing module, a spike recognition module, a morphology module, and a sleep staging module.

[0139] The preprocessing module performs preprocessing operations on the signal. The preprocessed EEG signal is segmented, and the data segments containing complete sleep are selected. Then, the samples are segmented into equal lengths. Each sample is labeled with sleep phase and spike wave segment for subsequent deep network training.

[0140] The spike wave recognition module inputs the preprocessed T3 channel signal into the semantic segmentation network for spike wave recognition. The network can identify the location and duration of the patient's spike wave discharge and output an output with fine-grained labels of the spike wave data segments.

[0141] The morphological module uses the obtained signal with spike information as the input of the morphological module. The morphological module combines the spike position information of semantic segmentation to further judge the candidate area, and finally obtains the number and duration of epileptic-like discharge (spike and slow wave) segments, and the total discharge time, thereby calculating the discharge index of each sample.

[0142] The sleep staging module inputs the Cz channel signal into the sleep staging module based on Resnet34 to implement sleep staging for each 30s length sample.

[0143] The present invention intercepts the dual-channel EEG data of patients from 30 minutes before sleep to 30 minutes after waking up, and performs pre-processing operations such as filtering on the original signal. The semantic segmentation network is used to perform fine-grained recognition of the spike wave position and accurately find the spike wave position in the signal. On this basis, the morphological method is applied to realize the recognition of the existence of spike and slow wave segments, and finally the Resnet34 network is used to identify the sleep stage of the signal segment. Studies have shown that when using this method to perform epileptic discharge identification and quantification tasks, the average SWI Error The accuracy can reach 6.04%, the recall can reach 87.37%, and the precision is 56.11%. PCT (1%), PCT (5%), and PCT (10%) can reach 15.2%, 64.6%, and 85.3%, respectively. In the sleep staging task, the accuracy can reach 92.75%, the precision can reach 90.81%, and the recall is 82.5%. Experimental results show that this method can effectively identify and quantify epileptiform discharges during sleep in ESES syndrome and realize the identification of sleep stages.

[0144] On this basis, we can establish an accurate and efficient automatic sleep epileptiform discharge identification and quantification system for ESES syndrome patients. This will help provide long-term EEG monitoring for ESES syndrome patients, thus providing the possibility for patients to receive treatment as soon as possible.

Claims

1. A method for quantifying persistent electrical activity in sleep epilepsy based on deep learning and morphology, characterized by The steps include: Step 1: Preprocess the signal; segment the preprocessed EEG signal, select the data segment containing complete sleep, and then perform equal-length segmentation to obtain samples. Each sample is labeled with the sleep stage and spike segment for subsequent deep network training; Step 2: The preprocessed T3 channel signal is input into an improved semantic segmentation network for spike wave recognition. The network can identify the location and duration of the patient's spike wave discharge and output a signal with fine-grained labels of the spike wave data segments; Step 3: The obtained spike-wave signal is used as the input of the morphological module. The morphological module combines the spike wave position information output by the semantic segmentation network to make further judgments on the candidate regions, ultimately obtaining the number and duration of epileptic spike and slow wave segments, and the total discharge time, thereby calculating the discharge index of each sample. Step 4: Input the Cz channel signal into the sleep staging module based on Resnet34 to implement sleep staging for each 30s length sample; Step 5: Combine the outputs of steps 3 and 4 to achieve the identification and quantification of epileptic electrical activity during children's sleep.

2. The method for quantifying sleep epilepsy electrical activity based on deep learning and morphology according to claim 1, characterized in that The specific process of step 1 is as follows: 1-1. Preprocess the original signal: 0.5-70Hz bandpass filtering, 50Hz notch filtering and detrending operation to obtain a signal with less interference; 1-2. At the same time, the pre-processed signal is segmented, and data between 30 minutes before sleep and 30 minutes after waking are selected. The selected data are then uniformly divided into data samples of 30 seconds in length, and each data segment is labeled with sleep period and spike and slow wave segment for subsequent deep network training; sleep period is labeled as wake, non-rapid eye movement (NREM), and rapid eye movement (REM); spike and slow wave labels are labeled as a combination of start timestamp and duration.

3. The method for quantifying sleep epilepsy electrical activity based on deep learning and morphology according to claim 1, characterized in that Step 2 uses the T3 channel signal and spike / wave labels as input to the semantic segmentation model. During the input process, the spike / wave labels are converted into fine-grained labels. Specifically, the original combination of the spike / wave onset timestamp and duration is converted into 0 and 1 labels. Here, 0 corresponds to no spike / wave and 1 corresponds to the presence of a spike / wave. A 0 and 1 character vector of length 1*15000 is formed and used to match the signal vector. The length of a single sample signal is 30s and the sampling rate is 500Hz, so the vector is 1*15000. The specific process is as follows: 2-1. The preprocessed T3 channel signal and spike / slow wave labels are input into the semantic segmentation network together. First, 64 7*1 convolution kernels are used for convolution with a stride of 3 to obtain a new feature matrix. After ReLu and Maxpool, the new feature matrix is ​​input into the downsampling path. The downsampling path uses the typical feature extraction network Resnet, which consists of four encoding blocks. The encoding block consists of a standard block I, or a standard block I and a standard block D. Each standard block contains two convolutions and two batch normalization blocks. The first encoding block consists of two standard blocks I, and the remaining three encoding blocks are all composed of a standard block D and a standard block I. After each downsampling operation, the length of the feature is halved, but the number of channels of the feature is doubled. After four downsampling operations, the feature size changes from 1*5000*64 to 1*625*512. 2-2. In the upsampling path, ConvTranspose1d is used at each step to double the input size and halve the feature channels. At the same time, the feature maps corresponding to the output downsampling path are concatenated and input to the previous layer. In the last layer, ConvTranspose1d with a convolution kernel size of 1*7 is used to convert the output from 64 channels to 32 channels. A 1*1 convolution is then used to convert the 32-length vector into the required two-category labels. Finally, batch normalization and ReLU are performed to obtain the final output, which is a 0 and 1 label of size 1*15000. 2-3. The loss of the model during training uses classification loss. Since both the true label and the model output label use fine-grained labels of 0 and 1, the loss uses binary cross entropy loss: where y i is the true binary label value 0 or 1, represents the actual output value, and n represents the number of labels; 2-4. After obtaining the output of the semantic segmentation network, the output is post-processed based on the signal characteristics of the spike wave. Specifically, since the length of the spike wave ranges from 20 milliseconds to 70 milliseconds, combined with the data sampling rate, the average sample point length of the spike wave is 10-40 sample points. Therefore, to reduce misjudgments, the network output of the semantic segmentation network with a length of less than 10 points and greater than 40 points is filtered out, retaining only the output with a length within the spike wave range. On this basis, candidate regions for epileptic spike and slow waves are obtained. The processed spike wave label information is input into the morphological module for further determination of the candidate regions for epileptic spike and slow waves.

4. The method for quantifying sleep epilepsy electrical activity based on deep learning and morphology according to claim 3, characterized in that The specific process of step 3 is as follows: 3-1. The obtained candidate region and the preprocessed T3 channel signal are used as inputs to the morphological filter. Based on the location information of the candidate region, the detection region of the morphological filter is selected. Specifically, since the spike wave length is 20-70 milliseconds and the subsequent slow wave portion is 200-500 milliseconds, the length of the spike-slow wave complex should be between 220-570 milliseconds, corresponding to a sampling point length of 110-285 points. Taking into account the shape changes of the spike and slow waves, the candidate region is extended at both ends. That is, the left end of the candidate region obtained in step 2 is extended to the left by another 20 sampling points, and with this as the starting point, the right end of the candidate region is extended to the right by another 15 sampling points. The 330 sampling points are regarded as a complete candidate spike-slow wave emission data segment, and then detected using the morphological filter. 3-2. Use morphological filters to detect and identify candidate spike and slow wave data segments to determine whether the data segments belong to spike and slow wave data segments. The specific process is as follows: First, a morphological filter is used to locate the peak and pit regions of the candidate spike and slow wave data segments. The main operations of the morphological filter are divided into the following four categories: corrosion: forn=1,2,...N-M+1 Expansion: for n=M,M+1,...,N Open operation: Closing operation: Where f(n) is the signal input of the candidate region length N, g(n) represents the structure element used, which is defined as shown in formula (6) and its length M<N; In formula (6), W represents the width of the structural element g(n); in addition, the height of g(n) is represented by h. Based on experimental results, h is empirically set to 2.85 and α is set to 1.

05. According to the principle of opening and closing operations, the waveform peak and pit identification operation is performed; first, the peak area detector KD is constructed, as shown in Formula 7 Wherein, f(n) is the signal input of the candidate region length N, that is, N = 1, 2, ... 330; the structural elements g1 and g2 used here are both formula (6), and only the width M is different; when using the peak area detector KD, the structural element g1 is first used to perform an opening operation, and its width is selected as 15; after the opening operation of g1, the signal I with a width greater than the length of the structural element is retained in the positive signal, and the pits are suppressed at the same time. After this operation, the positive spike wave, slow wave part and a certain background wave part in the signal can be extracted; then the structural element g2 is used to open the signal after the opening operation Perform a closing operation and select a structural element g2 width of 50. After the closing operation, the signals of sample points with a width less than 50 will be filtered out, that is, all spikes are filtered out of Signal II, and Signal II only retains the background waveform and a certain slow wave component. Finally, subtract Signal II from Signal I to obtain the desired Signal III, which contains spikes and a small amount of deformed low-amplitude slow wave protrusions. Similarly, the pit detector TD of the signal is constructed as shown in formula 8 Among them, the structural elements g3 and g4 are also modified only in width; first, the structural element g3 is used to perform a closing operation on the signal (fΘg3)(n) to remove the peak of the signal and obtain the preliminary pit area signal. Here, the length of g3 is set to 40, which is the maximum width of the spike wave, and then g4 is used for opening operation. The background wave is extracted to obtain the background wave signal, and the width of g4 is set to 16. Finally, the background wave signal is subtracted from the preliminary pit area signal to obtain the pit area signal after the negative background wave is removed. 3-3. Superimpose the obtained signal III and the pit region signal to restore the complete spike-wave waveform. The length of each data segment is still 330 sampling points, corresponding to a data segment of 0.66 seconds. Then, the local extreme value of each data segment is obtained. Based on the characteristics of the spike-wave, determine whether the extreme value of the data segment satisfies the sequence of minimum, maximum, minimum, maximum, and minimum. At the same time, to eliminate any interference, the amplitude of the first maximum value must be above 75 microvolts before the sequence is determined. By determining whether the current signal segment satisfies the above sequence rules, determine whether the data segment is an epileptic spike-wave discharge. 3-4. After obtaining the number of spike-wave bursts and their duration, calculate the discharge index (SWI) for the 30-second sample signal. SWI is a parameter used to quantify ESES and is defined as the total duration of all spike-wave bursts divided by the total duration of non-rapid eye movement (NREM) sleep, multiplied by 100. The SWI calculation formula for a single 30-second sample signal is as follows: Where N represents the number of spike-wave segments in a 30-second segment of the sample signal, L represents the length of each spike-wave segment, and Duration represents the duration of non-rapid sleep. SWI is measured in units of 30 seconds, so Duration is always 30 seconds. 3-5. Use time estimation error and event detection error to measure the effect; time estimation error refers to the actual SWI of a single 30s sample signal segment. I The difference between the SWI_pre estimated by the method is calculated as follows: SWI Error =|SWI_ L -SWI_pre| (10) Among them, SWI_ I Refers to the actual discharge index, SWI_pre refers to the predicted discharge index, and the absolute value of the difference between the two is taken as the discharge index error SWI Error ; and use the discharge index error PCT (X%) within the range to measure different levels of SWI Error The proportion of X represents different error levels. If SWI Error If the proportion of samples with less than 5% of the total samples is 10%, then the value of PCT(5%) is 10%, and so on. Then, Precision and Recall are used to evaluate the effect of event detection. The formula is as follows: Among them, FN means that the signal segment was judged as a negative sample, but was actually a positive sample, that is, the 0.66s signal segment was originally a discharge sample, but was mistakenly judged as a no-discharge sample; TN means that the model judged it to be a negative sample, and it was actually a negative sample; TP means that the model judged it to be a positive sample, and it was actually a positive sample; Precision represents the precision rate, which represents the proportion of truly correct samples to all predicted positive samples; Recall represents the recall rate, which represents the proportion of truly correct samples to all actually positive samples. The higher the value, the lower the missed detection rate. In the actual matching process, the results are matched in two cases, namely, events with only one spike wave in the annotated label and events with multiple spike waves in the annotated label. For the former, the intersection over union (IoU) is used for measurement. Assuming that the position of the spike wave event of label Y is y∈[y1, y2], and the predicted position of the spike wave event X is x∈[x1, x2], the IoU is defined as: Length(X∩Y) and Length(X∪Y) represent the intersection length and union length of the label and the output event, respectively; if x2<y2, then Length(X∩Y)=x2-y1, otherwise it is y2-x1; at this time, if IoU≥0.5, the detected event is considered to be successfully matched with the labeled spike and slow wave event, and the TP value is increased by one; if IoU<0.5, it is considered that the match with the real event is not successful, and FP is increased by one; this method is also used for events marked as non-spike and slow wave; in addition, for real labels with multiple spike and slow wave events, according to the position of the predicted event, the predicted labels whose start time is within the range of the real label are uniformly regarded as a detection event, and the lengths of these events are merged before IoU matching, and the threshold of 0.5 is also used for judgment. If IoU>0.5, it is considered that this long spike and slow wave event is detected, and TP is increased by one.

5. The method for quantifying sleep epilepsy electrical activity based on deep learning and morphology according to claim 3 or 4, characterized in that The specific steps of step 4 are as follows: 4-1. Use the original Cz signal as the input of Resnet34 for training; First, input the first convolutional layer, set the convolution kernel size to 7, the number of convolution kernels to 64, the stride to 3, the padding to 3, use all 0 padding and pass batch normalization and ReLU function; Then, after a series of residual modules, in Resnet34, there are 4 residual structures, each of which has the following number of residual units: 3 in the first layer, 4 in the second layer, 6 in the third layer, and 3 in the fourth layer; after 4 residual structures, a 512*1875 feature matrix is ​​formed; The feature matrix is ​​then converted into one-dimensional data through an AdaptiveAvgPoolld layer, resulting in a 512*1 feature matrix. This matrix then passes through a fully connected structure consisting of three linear layers with 128, 32, and 3 neurons, respectively, to predict the sleep stage category of the current sample. 4-2. The loss function is set as follows: in, is the actual output value, y i is the tag value; 4-3. Model results are measured using Accuracy, Precision, and Recall, which will not be detailed here.

Citation Information

Patent Citations

  • Method and device for detecting epileptic discharge

    CN114869301A

  • Sleep epilepsy electrical persistence state ratchet slow wave index automatic quantification method

    CN116269439A