A sleep staging method and system based on a fragment-sequence two-stage training framework

By using the fragment-sequence two-stage training framework in the sleep staging method, using the CNN and CNN-RNN network models to process single-channel EEG data, the problem of difficulty in effectively monitoring and staging sleep quality in non-professional scenarios is solved, and more efficient sleep quality evaluation is achieved.

CN114903440BActive Publication Date: 2025-05-06NANJING UNIV +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210524128.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-13
Publication Date
2025-05-06
Estimated Expiration
2042-05-13

AI Technical Summary

Technical Problem

It is difficult for the prior art to effectively monitor and installment sleep quality in non-professional scenarios through single-channel EEG data, especially in scenarios such as home or community hospitals. The monitoring effect of bracelets and other devices is not as good as EEG data.

Method used

A sleep staging method based on a fragment-sequence two-stage training framework is proposed. By smoothing the single-channel EEG data, fragmentation and multi-channel expansion, the CNN network model based on EEG fragments and the "CNN-RNN" network model based on EEG fragments is trained to improve the effect of sleep staging.

Benefits of technology

Through the two-stage training framework, the accuracy and effectiveness of single-channel EEG data in sleep staging is significantly improved, and sleep quality can be monitored and evaluated more effectively in non-professional scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114903440B_ABST
    Figure CN114903440B_ABST
Patent Text Reader

Abstract

The present invention is oriented to single-channel EEG data, and proposes a sleep staging method and system based on a fragment-sequence two-stage training framework, which belongs to the field of intelligent application of deep learning algorithms. The single-channel EEG data is smoothed, fragmented, and multi-channel generated, and the EEG data is trained using a CNN network model based on EEG fragments to obtain an EEG feature representation method. The "CNN-RNN" network model based on EEG fragment-sequence is used to enhance learning between sleep sequences, and the sleep staging effect of the model is improved through a two-stage training framework, thereby improving the effect of using single-channel EEG data for sleep quality assessment. Compared with the CNN network model staging based on EEG fragments, this method has a greatly improved effect. By verifying it on the single-channel Fpz-Cz EEG data of the data set Sleep_EDFx 39, the present invention improves the accuracy of sleep staging from 80% to 87%.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of intelligent application of deep learning algorithms, and in particular relates to a sleep staging method and system based on a fragment-sequence two-stage training framework. Background Art

[0002] Sleep occupies about 1 / 3 of a person's life. It is a process in which the human body's tissues, organs and nervous system rest, and plays an important role in a person's physical and mental health. However, 27% of people worldwide have sleep disorders, and the proportion of sleep disorder patients in my country is also increasing. Sleep disorders can easily cause health problems, increase the risk of obesity, diabetes, and cardiovascular diseases, and easily induce psychological diseases. The basis for judging sleep disorders and sleep quality is usually sleep staging.

[0003] According to the staging standards of the American Academy of Sleep Medicine (AASM) in 2007, sleep stages can be divided into five periods: wakefulness (W), light sleep 1 (N1), light sleep 2 (N2), deep sleep (N3), and rapid eye movement (REM). Sleep has certain rhythmic characteristics, and the normal cycle is generally 90 to 100 minutes. About 20 minutes after falling asleep, you will enter the latent sleep stage, go through moderate sleep, and enter the deep sleep stage about 30 to 45 minutes later, then gradually return to moderate sleep and light sleep, and enter the rapid eye movement stage.

[0004] In hospitals, a sleep monitor (PSG) is usually used to monitor the patient's sleep bioelectric signals. The monitored signals include electroencephalogram (EEG), electrooculogram (EOG), electrocardiogram (ECG), electromyography (EMG), etc. The patient's sleep staging results are analyzed through electrical signals, and the patient's sleep quality is diagnosable based on the results of sleep staging. However, in other scenarios, such as home and community hospitals, it is difficult to monitor sleep quality through professional PSG equipment, and ECG-based sleep monitoring such as bracelets is not as effective as EEG data. Therefore, the demand for sleep staging monitoring using single-channel EEG data is growing. Summary of the invention

[0005] Purpose of the invention: To propose a sleep staging method based on a fragment-sequence two-stage training framework, to perform sleep staging based on single-channel EEG data, and to improve the staging effect of the model through two-stage training, and further propose a system for implementing the above method to solve the above problems existing in the prior art.

[0006] Technical solution: First, a sleep staging method based on a two-stage training framework of fragments and sequences is proposed, which includes the following steps:

[0007] Step 1: Process the single-channel EEG data file, remove the awake period data of a predetermined length at the beginning and end, retain only the monitoring data of the sleep stage, and store them uniformly as EDF files;

[0008] Step 2: Divide the single-channel EEG data EDF file into two parts according to the ratio. The first part P is used for training and verification of the EEG segment model and the EEG sequence model, and the second part R is used for testing the EEG segment model and the EEG sequence model.

[0009] Step 3, read the single-channel EEG monitoring data with labels in P, perform data movement smoothing processing, and obtain P';

[0010] Step 4: fragment and multi-channel expand the P' data to form the EEG segment data set T1;

[0011] Step 5, divide the EEG segment data set T1 into an EEG segment training set M1 and an EEG segment verification set V1 in proportion;

[0012] Step 6: Randomly shuffle the order of the EEG segment training set M1 to train the CNN network model based on the EEG segment, and select the best EEG segment model structure and model parameters through the EEG segment verification set V1;

[0013] Step 7, storing the optimal CNN network model structure and model parameters of the EEG segment as an EEG segment model file F1 with the suffix ".pth";

[0014] Step 8, dividing the EEG segment data set T1 without disrupting the segment order in step 4 according to the time step t to form an EEG sequence data set T2;

[0015] Step 9, dividing the EEG sequence data set T2 into an EEG sequence training set M2 and an EEG sequence verification set V2 according to the proportion;

[0016] Step 10, read the EEG segment model file F1 to obtain the segment model and its parameters, connect the sequence model, randomly disrupt the sequence order of the EEG sequence training set M2, use it to train the "CNN-RNN" network model based on EEG segment-sequence, and select the best model structure and parameters through the EEG sequence verification set V2;

[0017] Step 11, store the optimal EEG "CNN-RNN" network model structure and model parameters as an EEG fragment-sequence model file F2 with the suffix ".pth";

[0018] Step 12: read the EEG segment-sequence model file F2, use the EEG test set R in step 2, and perform sleep stage sequence classification on the single-channel EEG data files in the test set R.

[0019] Furthermore, in step 3, the single-channel EEG monitoring data with labels in P is read, and data movement smoothing is performed to obtain P'; the smoothing method is as follows:

[0020] For each file in P, read the single-channel EEG monitoring data list {x1, x2, ..., x n}, each data in the EEG monitoring data list is moved and smoothed to obtain the smoothed data {x'1,x'2,...,x' n}, the smoothed data are combined to form P'. Different smoothing effects can be obtained according to the size of the sliding window (denoted as K). Assuming that the smoothing window size K = 2s+1, the moving smoothed x' t The calculation formula is: in,

[0021] t=1,2,...,n。

[0022] Furthermore, in step 4, the p' data is fragmented and multi-channel expanded to form an EEG fragment data set T1; the specific operation steps are as follows:

[0023] Step 4.1, divide the monitoring data according to the fragment length represented by the label (assuming the length is L), and standardize it according to the fragment length to form channel A1;

[0024] Step 4.2, standardize the monitoring data as a whole, and then divide it according to the segment length L to form channel B1;

[0025] Step 4.3: After merging channel A1 and channel B1, a segment-based EEG segment dataset T1 is formed.

[0026] Furthermore, in step 6, the order of the EEG segment training set M1 is randomly disrupted to train the CNN network model based on the EEG segment, and the optimal EEG segment model structure and model parameters are selected through the EEG segment verification set V1; the specific process is as follows:

[0027] Step 6.1: Perform two-branch convolution on the fragment channel A1 and the fragment channel B1 in the shuffled EEG fragment training set M1. The convolution of the two branches of the fragment channel A1 are CNN1 and CNN2, and the convolution of the two branches of the fragment channel B1 are CNN3 and CNN4. Among them, the convolution parameters of CNN1, CNN2, CNN3, and CNN4 are different, but the structure is the same. The specific structure is shown in the attached figure. Figure 3b As shown;

[0028] Step 6.2, merge the results of the four branches of CNN1, CNN2, CNN3, and CNN4 and fully connect them;

[0029] Step 6.3: After performing dropout processing on the result of step 6.2, connect the output of 5 output units;

[0030] Step 6.4: Perform softmax processing on the output results of step 6.3 and output them by category.

[0031] Furthermore, in step 6.1, the convolution parameters of CNN1, CNN2, CNN3, and CNN4 are different, but the structure is the same. The specific process is as follows:

[0032] Step 6.1.1, after convolution of the channel, use the activation function Swish for activation;

[0033] Step 6.1.2, connect the maxpooling layer P1;

[0034] Step 6.1.3, connect the dropout layer D1;

[0035] Step 6.1.4, connect the attention mechanism layer S1;

[0036] Step 6.1.5: Continuously connect three convolutional layers and the combination of activation function Swish;

[0037] Step 6.1.6, connect the maxpooling layer P2;

[0038] Step 6.1.7. Connect the attention mechanism layer S2.

[0039] Further, in step 10, the EEG segment model file F1 is read to obtain the segment model and its parameters, the sequence model is connected, and the sequence order of the EEG sequence training set M2 is randomly disrupted to train the "CNN-RNN" network model based on the EEG segment-sequence, and the optimal model structure and parameters are selected through the EEG sequence verification set V2; the specific process is as follows:

[0040] Step 10.1, the sequences in the shuffled EEG sequence training set M2 are input into the EEG segment-based CNN network model according to the time step to extract features;

[0041] Step 10.2: Input the extracted features into the bidirectional LSTM unit to learn the bidirectional recurrent neural network and learn the long-term and short-term dependencies of the EEG sequence;

[0042] Step 10.3: After merging the results of the bidirectional LSTM units, connect the conditional random field module CRF to learn the state transition relationship between sequence labels.

[0043] Secondly, a sleep staging system is proposed, which at least includes a data preprocessing module, a single-channel EEG data ratio division module, an EEG segment data set construction module, an EEG segment data set ratio division module, an EEG segment training set shuffling module, an EEG segment model file generation module, an EEG sequence data set generation module, a sequence model connection module, an EEG segment-sequence model file storage module and a sleep staging sequence classification module.

[0044] The data preprocessing module is used to process the single-channel EEG data file, remove the awake period data of a predetermined length at the beginning and end, retain only the monitoring data of the sleep stage, and store them uniformly as EDF files;

[0045] The single-channel EEG data ratio division module is used to divide the single-channel EEG data EDF file in the data preprocessing module into two parts according to the ratio. The first part P is used for training and verification of the EEG segment model and the EEG sequence model, and the second part R is used for testing the EEG segment model and the EEG sequence model.

[0046] The EEG segment dataset construction module is used to read the single-channel EEG monitoring data with labels in the first part P, perform data movement smoothing processing to obtain P', and perform segmentation and multi-channel expansion on the P' data to form the EEG segment dataset T1;

[0047] The EEG segment data set ratio division module is used to divide the EEG segment data set T1 into an EEG segment training set M1 and an EEG segment verification set V1 in proportion;

[0048] The EEG segment training set shuffling module is used to randomly shuffle the segment order of the EEG segment training set M1, train the CNN network model based on the EEG segment, and select the best EEG segment model structure and model parameters through the EEG segment verification set V1;

[0049] The EEG segment model file generation module is used to store the optimal CNN network model structure and model parameters of the EEG segment, and save the EEG segment model file F1 with the suffix ".pth";

[0050] The EEG sequence data set generation module is used to divide the EEG segment data set T1 whose segment order is not disrupted in the EEG segment data set construction module according to the time step t to form an EEG sequence data set T2; divide the EEG sequence data set T2 into an EEG sequence training set M2 and an EEG sequence verification set V2 according to the proportion;

[0051] The sequence model connection module is used to read the EEG segment model file F1 to obtain the segment model and its parameters, connect the sequence model, randomly disrupt the sequence order of the EEG sequence training set M2, and use it to train the "CNN-RNN" network model based on EEG segment-sequence, and select the best model structure and parameters through the EEG sequence verification set V2;

[0052] The EEG segment-sequence model file storage module is used to store the EEG optimal "CNN-RNN" network model structure and model parameters, and save them as an EEG segment-sequence model file F2 with the suffix ".pth";

[0053] The sleep stage sequence classification module is used to read the EEG segment-sequence model file F2, and use the EEG test set R in the single-channel EEG data ratio division module to perform sleep stage sequence classification on the single-channel EEG data files in the test set R.

[0054] In a third aspect, a sleep staging device is proposed, comprising at least one processor and a memory; the memory stores computer-executable instructions; at least one processor executes the computer-executable instructions stored in the memory, so that at least one processor executes the sleep staging method described in the first aspect.

[0055] In a fourth aspect, a readable storage medium is proposed, wherein the readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the sleep staging method described in the first aspect is implemented.

[0056] Beneficial effects: The present invention proposes a sleep staging method and system based on a two-stage training framework of fragments and sequences for single-channel EEG data. The single-channel EEG data is smoothed, fragmented, and multi-channel generated. The EEG data is trained using a CNN network model based on EEG fragments to obtain an EEG feature representation method. The learning between sleep sequences is enhanced through a "CNN-RNN" network model based on EEG fragments-sequences. The sleep staging effect of the model is improved through a two-stage training framework, thereby improving the effect of using single-channel EEG data for sleep quality assessment. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 The present invention relates to a sleep staging method.

[0058] Figure 2 This is a diagram showing the effect of smoothing single-channel EEG data using different moving smoothing windows.

[0059] Figure 3a This is a structural diagram of the network model based on EEG fragments.

[0060] Figure 3bThis is a diagram of the CNN branch structure of the network model based on EEG fragments.

[0061] Figure 4 This is a structural diagram of the network model based on EEG fragments and sequences.

[0062] Figure 5 This is the confusion matrix diagram of the cross-validation of the network model based on EEG fragments and sequences on the Sleep_EDFx39 dataset.

[0063] Figure 6 This is a comparison chart of the results of sleep staging based on the "network model of EEG fragments" and the "network model of EEG 'fragment-sequence'". DETAILED DESCRIPTION

[0064] In the following description, a large number of specific details are provided to provide a more thorough understanding of the present invention. However, it is apparent to those skilled in the art that the present invention can be implemented without one or more of these details. In other examples, in order to avoid confusion with the present invention, some technical features well known in the art are not described.

[0065] The applicant believes that the existing sleep staging methods are difficult to monitor sleep quality through professional PSG equipment in other scenarios, such as home and community hospitals. ECG-based sleep monitoring such as bracelets is not as effective as EEG data. Therefore, the demand for sleep staging monitoring through single-channel EEG data is becoming increasingly strong.

[0066] To this end, the applicant proposes a sleep staging method and system based on a two-stage training framework of segment-sequence. Figure 1-Figure 6 As shown, the first aspect includes: a sleep staging method based on a fragment-sequence two-stage training framework, comprising the following steps:

[0067] The single-channel Fpz-Cz EEG data of the dataset Sleep_EDFx 39 were selected. The single-channel Fpz-Cz EEG data were first labeled according to the AASM 2007 sleep standard to form a data file, and then the sleep staging method based on the fragment-sequence two-stage training framework in this paper was used for sleep staging.

[0068] Step 1: Process the single-channel Fpz-Cz EEG data file, remove the awake period data of a predetermined length at the beginning and end, retain only the monitoring data of the sleep stage, and store them uniformly as EDF files;

[0069] Step 2: Divide the single-channel Fpz-Cz EEG data EDF file into two parts according to the ratio. The first part P is used for training and verification of the EEG segment model and the EEG sequence model, and the second part R is used for testing the EEG segment model and the EEG sequence model.

[0070] Step 3, read the single-channel EEG monitoring data with labels in P, perform data movement smoothing processing, and obtain P';

[0071] Step 4: fragment and multi-channel expand the P' data to form the EEG segment data set T1;

[0072] Step 5, divide the EEG segment data set T1 into an EEG segment training set M1 and an EEG segment verification set V1 in proportion;

[0073] Step 6: Randomly shuffle the order of the EEG segment training set M1 to train the CNN network model based on the EEG segment, and select the best EEG segment model structure and model parameters through the EEG segment verification set V1. The CNN network model of the EEG segment is shown in the attached figure. Figure 3a and attached Figure 3b As shown;

[0074] Step 7: Store the optimal CNN network model structure and model parameters of the EEG segment as the EEG segment model file “cnn.pth”;

[0075] Step 8, dividing the EEG segment data set T1 whose segment order is not disrupted in step 4 according to time step 64 to form an EEG sequence data set T2;

[0076] Step 9, dividing the EEG sequence data set T2 into an EEG sequence training set M2 and an EEG sequence verification set V2 according to the proportion;

[0077] Step 10, read the EEG segment model file "cnn.pth" to obtain the segment model and its parameters, connect the sequence model, randomly disrupt the sequence order of the EEG sequence training set M2, and use it to train the "CNN-RNN" network model based on EEG segment-sequence, and select the best model structure and parameters through the EEG sequence verification set V2. Among them, the structure of the "CNN-RNN" network model based on EEG segment-sequence is as shown in the attached figure. Figure 4 As shown;

[0078] Step 11, store the optimal EEG "CNN-RNN" network model structure and model parameters and save them as the model file "cnn_rnn.pth";

[0079] Step 12: Read the EEG segment-sequence model file "cnn_rnn.pth", use the EEG test set R in step 2, and perform sleep stage sequence classification on the single-channel EEG data file in the test set R.

[0080] Among them, Figure 5The confusion matrix of the Sleep_EDFx39 dataset is shown in Figure 2. Figure 6 The comparison chart shows the results of sleep staging for an untrained sleep instance in the Sleep_EDFx39 dataset based on the "network model of EEG fragments" and the "network model of EEG 'fragment-sequence'".

[0081] In a further embodiment, in step 3, the single-channel EEG monitoring data with labels in P is read, and data movement smoothing is performed to obtain P'; the smoothing method is as follows:

[0082] For each file in P, read the single-channel EEG monitoring data list {x1, x2, ..., x n}, each data in the EEG monitoring data list is moved and smoothed to obtain the smoothed data {x'1,x'2,...,x' n}, and the smoothed data are combined to form P'. Different smoothing effects can be obtained according to the size of the sliding window (denoted as K), as shown in the following figure. Figure 2 As shown. Assuming the smoothing window size K = 2s + 1, the moving smoothed x' t The calculation formula is: Where t=1,2,...,n.

[0083] In a further embodiment, in step 4, the P' data is segmented and multi-channel expanded to form an EEG segment data set T1; the specific operation steps are as follows:

[0084] Step 4.1, divide the monitoring data according to the fragment length represented by the label (assuming the length is L), and standardize it according to the fragment length to form channel A1;

[0085] Step 4.2, standardize the monitoring data as a whole, and then divide it according to the segment length L to form channel B1;

[0086] Step 4.3: After merging channel A1 and channel B1, a segment-based EEG segment dataset T1 is formed.

[0087] In a further embodiment, in step 6, the EEG segment training set M1 is randomly shuffled in segment order to train a CNN network model based on EEG segments, and the best EEG segment model structure and model parameters are selected through the EEG segment verification set V1; the CNN network model structure based on EEG segments is shown in the attached figure. Figure 3a As shown, the specific process is as follows:

[0088] Step 6.1: Perform two-branch convolution on the fragment channel A1 and the fragment channel B1 in the shuffled EEG fragment training set M1. The convolution of the two branches of the fragment channel A1 is CNN1 and CNN2, and the convolution of the two branches of the fragment channel B1 is CNN3 and CNN4. The parameters of the convolution of CNN1, CNN2, CNN3, and CNN4 are different, but the structure is the same. The specific structure is shown in the attached figure. Figure 3b As shown;

[0089] Step 6.2, merge the results of the four branches of CNN1, CNN2, CNN3, and CNN4 and fully connect them;

[0090] Step 6.3: After performing dropout processing on the result of the previous step, connect the 5 output units to output;

[0091] Step 6.4: Perform softmax processing on the output of the previous step and then output the category.

[0092] In a further embodiment, in step 6.1, the convolution parameters of CNN1, CNN2, CNN3, and CNN4 are different, but the structures are the same. The specific structures are as shown in the attached Figure 3b The specific process is as follows:

[0093] Step 6.1.1, after convolution of the channel, use the activation function Swish for activation;

[0094] Step 6.1.2, connect the maxpooling layer P1;

[0095] Step 6.1.3, connect the dropout layer D1;

[0096] Step 6.1.4, connect the attention mechanism layer S1;

[0097] Step 6.1.5: Continuously connect three convolutional layers and the combination of activation function Swish;

[0098] Step 6.1.6, connect the maxpooling layer P2;

[0099] Step 6.1.7. Connect the attention mechanism layer S2.

[0100] In a further embodiment, in step 10, the EEG segment model file F1 is read to obtain the segment model and its parameters, the sequence model is connected, and the sequence order of the EEG sequence training set M2 is randomly disrupted to train the "CNN-RNN" network model based on the EEG segment-sequence, and the best model structure and parameters are selected through the EEG sequence verification set V2; the "CNN-RNN" network model structure based on the EEG segment-sequence is as shown in the attached figure. Figure 4As shown, the specific process is as follows:

[0101] Step 10.1, the sequences in the shuffled EEG sequence training set M2 are input into the EEG segment-based CNN network model according to the time step to extract features;

[0102] Step 10.2: Input the extracted features into the bidirectional LSTM unit to learn the bidirectional recurrent neural network and learn the long-term and short-term dependencies of the EEG sequence;

[0103] Step 10.3: After merging the results of the bidirectional LSTM units, connect the conditional random field module CRF to learn the state transition relationship between sequence labels.

[0104] Secondly, a sleep staging system is proposed, which at least includes a data preprocessing module, a single-channel EEG data ratio division module, an EEG segment data set construction module, an EEG segment data set ratio division module, an EEG segment training set shuffling module, an EEG segment model file generation module, an EEG sequence data set generation module, a sequence model connection module, an EEG segment-sequence model file storage module and a sleep staging sequence classification module.

[0105] The data preprocessing module is used to process the single-channel EEG data file, remove the awake period data of a predetermined length at the beginning and end, retain only the monitoring data of the sleep stage, and store them uniformly as EDF files;

[0106] The single-channel EEG data ratio division module is used to divide the single-channel EEG data EDF file in the data preprocessing module into two parts according to the ratio. The first part P is used for training and verification of the EEG segment model and the EEG sequence model, and the second part R is used for testing the EEG segment model and the EEG sequence model.

[0107] The EEG segment dataset construction module is used to read the single-channel EEG monitoring data with labels in the first part P, perform data movement smoothing processing to obtain P', and perform segmentation and multi-channel expansion on the P' data to form the EEG segment dataset T1;

[0108] The EEG segment data set ratio division module is used to divide the EEG segment data set T1 into an EEG segment training set M1 and an EEG segment verification set V1 in proportion;

[0109] The EEG segment training set shuffling module is used to randomly shuffle the segment order of the EEG segment training set M1, train the CNN network model based on the EEG segment, and select the best EEG segment model structure and model parameters through the EEG segment verification set V1;

[0110] The EEG segment model file generation module is used to store the optimal CNN network model structure and model parameters of the EEG segment, and save the EEG segment model file F1 with the suffix ".pth";

[0111] The EEG sequence data set generation module is used to divide the EEG segment data set T1 whose segment order is not disrupted in the EEG segment data set construction module according to the time step t to form an EEG sequence data set T2; divide the EEG sequence data set T2 into an EEG sequence training set M2 and an EEG sequence verification set V2 according to the proportion;

[0112] The sequence model connection module is used to read the EEG segment model file F1 to obtain the segment model and its parameters, connect the sequence model, randomly disrupt the sequence order of the EEG sequence training set M2, and use it to train the "CNN-RNN" network model based on EEG segment-sequence, and select the best model structure and parameters through the EEG sequence verification set V2;

[0113] The EEG segment-sequence model file storage module is used to store the EEG optimal "CNN-RNN" network model structure and model parameters, and save them as an EEG segment-sequence model file F2 with the suffix ".pth";

[0114] The sleep stage sequence classification module is used to read the EEG segment-sequence model file F2, and use the EEG test set R in the single-channel EEG data ratio division module to perform sleep stage sequence classification on the single-channel EEG data files in the test set R.

[0115] In a third aspect, a sleep staging device is proposed, comprising at least one processor and a memory; the memory stores computer-executable instructions; and at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the sleep staging method of the first aspect.

[0116] In a fourth aspect, a readable storage medium is provided, wherein the readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the sleep staging method of the first aspect is implemented.

[0117] The embodiments of the present invention are described in detail above; however, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all belong to the protection scope of the present invention.

Claims

1. A sleep staging method based on a two-stage training framework of fragments and sequences, characterized in that: The steps include: Step 1: Process the single-channel EEG data file, remove the awake period data of a predetermined length at the beginning and end, retain only the monitoring data of the sleep stage, and store them uniformly as EDF files; Step 2: Divide the single-channel EEG data EDF file in step 1 into two parts according to the ratio. The first part P is used for training and verification of the EEG segment model and the EEG sequence model, and the second part R is used for testing the EEG segment model and the EEG sequence model. Step 3: read the single-channel EEG monitoring data with labels in the first part P, perform data movement smoothing processing, and obtain P'; Step 4: fragment and multi-channel expand the P' data to form the EEG segment data set T1; Step 5, dividing the EEG segment data set T1 into an EEG segment training set M1 and an EEG segment verification set V1 in proportion; Step 6: Randomly shuffle the order of the EEG segment training set M1 to train the CNN network model based on the EEG segment, and select the best EEG segment model structure and model parameters through the EEG segment verification set V1; Step 7, storing the optimal CNN network model structure and model parameters of the EEG segment as an EEG segment model file F1 with the suffix ".pth"; Step 8, dividing the EEG segment data set T1 without disrupting the segment order in step 4 according to the time step t to form an EEG sequence data set T2; Step 9, dividing the EEG sequence data set T2 into an EEG sequence training set M2 and an EEG sequence verification set V2 according to the proportion; Step 10, read the EEG segment model file F1 to obtain the segment model and its parameters, connect the sequence model, randomly disrupt the sequence order of the EEG sequence training set M2, use it to train the "CNN-RNN" network model based on EEG segment-sequence, and select the best model structure and parameters through the EEG sequence verification set V2; Step 11, store the optimal EEG "CNN-RNN" network model structure and model parameters as an EEG fragment-sequence model file F2 with the suffix ".pth"; Step 12: read the EEG segment-sequence model file F2, use the EEG test set R in step 2, and perform sleep stage sequence classification on the single-channel EEG data files in the test set R.

2. The sleep staging method according to claim 1, characterized in that: In step 3, the specific smoothing method for obtaining P' is as follows: For each file in P, read the single-channel EEG monitoring data list {x1, x2, ..., x n }, each data in the EEG monitoring data list is moved and smoothed to obtain the smoothed data {x'1,x'2,...,x' n }, the smoothed data are combined to form P'. Different smoothing effects can be obtained according to the size of the sliding window, denoted as K. Assuming that the smoothing window size K = 2s+1, the moving smoothed x' t The calculation formula is: Where t=1,2,...,n.

3. The sleep staging method according to claim 1, characterized in that: In step 4, the specific steps of forming the EEG segment data set T1 are as follows: Step 4.1, dividing the monitoring data according to the fragment length L represented by the label, and performing standardization processing according to the fragment length L to form channel A1; Step 4.2, standardize the monitoring data as a whole, and then divide it according to the segment length L to form channel B1; Step 4.3: After merging channel A1 and channel B1, a segment-based EEG segment dataset T1 is formed.

4. The sleep staging method according to claim 3, characterized in that: The specific process of step 6 is as follows: Step 6.1, perform two-branch convolution on the fragment channel A1 and the fragment channel B1 in the shuffled EEG fragment training set M1, the convolution of the two branches of the fragment channel A1 are CNN1 and CNN2, and the convolution of the two branches of the fragment channel B1 are CNN3 and CNN4; Step 6.2, merge the results of the four branches of CNN1, CNN2, CNN3, and CNN4 and fully connect them; Step 6.3: After performing dropout processing on the result of step 6.2, connect the output of 5 output units; Step 6.4: Perform softmax processing on the output results of step 6.3 and output them by category.

5. The sleep staging method according to claim 4, characterized in that: In step 6.1, the convolution parameters of CNN1, CNN2, CNN3, and CNN4 are different, but the structures are the same. The specific process is as follows: Step 6.1.1, after convolution of the channel, use the activation function Swish for activation; Step 6.1.2, connect the maxpooling layer P1; Step 6.1.3, connect the dropout layer D1; Step 6.1.4, connect the attention mechanism layer S1; Step 6.1.5: Continuously connect three convolutional layers and the combination of activation function Swish; Step 6.1.6, connect the maxpooling layer P2; Step 6.1.

7. Connect the attention mechanism layer S2.

6. The sleep staging method according to claim 1, characterized in that: The specific process of step 10 is as follows: Step 10.1, the sequences in the shuffled EEG sequence training set M2 are input into the EEG segment-based CNN network model according to the time step to extract features; Step 10.2: Input the extracted features into the bidirectional LSTM unit to learn the bidirectional recurrent neural network and learn the long-term and short-term dependencies of the EEG sequence; Step 10.3: After merging the results of the bidirectional LSTM units, connect the conditional random field module CRF to learn the state transition relationship between sequence labels.

7. A sleep staging system, characterized in that: include: The data preprocessing module is used to process the single-channel EEG data file, remove the awake period data of a predetermined length at the beginning and end, retain only the monitoring data of the sleep stage, and store them uniformly as EDF files; The single-channel EEG data ratio division module is used to divide the single-channel EEG data EDF file in the data preprocessing module into two parts according to the ratio. The first part P is used for training and verification of the EEG segment model and the EEG sequence model, and the second part R is used for testing the EEG segment model and the EEG sequence model. The EEG segment data set construction module is used to read the single-channel EEG monitoring data with labels in the first part P, perform data movement smoothing processing to obtain P', and perform segmentation and multi-channel expansion on the P' data to form the EEG segment data set T1; An EEG segment data set ratio division module, used for dividing the EEG segment data set T1 into an EEG segment training set M1 and an EEG segment verification set V1 in proportion; The EEG segment training set shuffling module is used to randomly shuffle the segment order of the EEG segment training set M1, train the CNN network model based on the EEG segment, and select the best EEG segment model structure and model parameters through the EEG segment verification set V1; The EEG segment model file generation module is used to store the optimal CNN network model structure and model parameters of the EEG segment and save the EEG segment model file F1 with the suffix ".pth"; An EEG sequence data set generation module is used to divide the EEG segment data set T1 whose segment order is not disrupted in the EEG segment data set construction module according to the time step t to form an EEG sequence data set T2; The EEG sequence data set T2 is divided into an EEG sequence training set M2 and an EEG sequence verification set V2 according to the proportion; The sequence model connection module is used to read the EEG segment model file F1 to obtain the segment model and its parameters, connect the sequence model, randomly disrupt the sequence order of the EEG sequence training set M2, and use it to train the "CNN-RNN" network model based on EEG segment-sequence, and select the best model structure and parameters through the EEG sequence verification set V2; The EEG segment-sequence model file storage module is used to store the EEG optimal "CNN-RNN" network model structure and model parameters as an EEG segment-sequence model file F2 with the suffix ".pth"; The sleep stage sequence classification module is used to read the EEG segment-sequence model file F2, use the EEG test set R in the single-channel EEG data ratio division module, and perform sleep stage sequence classification on the single-channel EEG data files in the test set R.

8. A sleep staging device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; At least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the sleep staging method according to any one of claims 1 to 6.

9. A readable storage medium, characterized in that: The readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the sleep staging method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Novel automated machine learning algorithms based system for sleep staging features analysis

    AU2020102907A4

  • Automatic sleep staging method of single-lead electroencephalogram

    CN107495962A