A method and system for sleep staging using bayesian uncertainty

By using Bayesian sleep networks and uncertainty quantification, selectively labeling samples and fusing network weights, the generalization and labeling dependency problems of deep learning models in sleep staging are solved, achieving efficient and accurate automated sleep staging.

CN121587666BActive Publication Date: 2026-06-23SOUTH CHINA UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SOUTH CHINA UNIV OF TECH
Filing Date
2025-10-24
Publication Date
2026-06-23

Smart Images

  • Figure CN121587666B_ABST
    Figure CN121587666B_ABST
Patent Text Reader

Abstract

The application discloses a method and system for realizing sleep staging by using Bayesian uncertainty, comprising: obtaining electroencephalogram signal data and preprocessing to obtain an unlabeled data set; using the data set to preliminarily train a Bayesian sleep network comprising two Bayesian sleep sub-networks with the same structure, outputting Bayesian uncertainty quantification results according to Bayesian entropy; selecting part of important samples according to the quantification results to label sleep staging labels, which are used for fine-tuning the network; passing the remaining samples which are not labeled through the two fine-tuned Bayesian sleep sub-networks respectively, outputting predicted sleep staging results, calculating Bayesian uncertainty quantification results, assigning weights to the predicted sleep staging results according to the quantification results and fusing the results to obtain overall predicted sleep staging results, selecting part of samples to correct the results and outputting final sleep staging results. The application can effectively reduce the dependence on sleep staging label labeling and improve sleep staging accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical fields of electroencephalogram (EEG) signals and deep learning, and in particular to a method, system, storage medium, and computing device for sleep staging using Bayesian uncertainty. Background Technology

[0002] Sleep is crucial for maintaining physical and mental health, and sleep staging is a core component of the diagnosis and treatment of sleep disorders. Polysomnography (PSG), as the gold standard for sleep assessment, can simultaneously record multiple physiological signals such as electroencephalograms (EEGs), electrooculograms (EOGs), electromyograms (EMGs), and electrocardiograms (ECGs). These signals are segmented into 20- or 30-second segments and manually annotated by experts according to established standards. However, manual sleep staging is extremely labor-intensive, often taking up to two hours per record, and exhibits significant variability depending on the annotator, leading to inconsistent results. This underscores the profound significance of using machine learning methods for sleep staging.

[0003] In recent years, deep learning has demonstrated significant potential in the field of automated sleep staging. Many models have achieved performance comparable to human experts while significantly reducing analysis time. These models typically employ convolutional neural networks to extract features and combine them with recurrent neural networks to capture the temporal dependencies between sleep stages. Furthermore, an increasing number of sleep staging studies incorporate attention mechanisms into the network, allowing the model to "focus" on the most important parts of the sequence, further improving model performance, especially when dealing with complex or atypical sleep patterns. While these deep learning methods perform well on labeled datasets, they often struggle to generalize to new subjects or data collected under different conditions. Obtaining labeled data for each new subject is both costly and impractical, preventing these methods from being truly applied clinically. Therefore, improving the model's generalization ability and reducing reliance on manual annotation without sacrificing performance are the core challenges in sleep staging research. Summary of the Invention

[0004] The primary objective of this invention is to provide a method for sleep staging using Bayesian uncertainty. This method quantifies Bayesian uncertainty through Bayesian entropy, ensuring network performance with a limited number of labels and enabling selective labeling of sleep staging. This approach minimizes reliance on manual labeling while maintaining high classification accuracy.

[0005] The second objective of this invention is to provide a system for sleep staging that utilizes Bayesian uncertainty.

[0006] A third objective of this invention is to provide a storage medium.

[0007] A fourth objective of this invention is to provide a computing device.

[0008] The first objective of this invention is achieved through the following technical solution: a method for sleep staging using Bayesian uncertainty, comprising the following steps:

[0009] S1: Acquire single-channel EEG signal data and preprocess it, i.e., first resample to the same frequency, then divide it into EEG segments of fixed length to form a preprocessed dataset without sleep stage labels;

[0010] S2: The Bayesian sleep network, which contains two structurally identical Bayesian sleep sub-networks, is initially trained using samples from a dataset without labeled sleep stage. The Bayesian uncertainty quantification result is then output based on the designed Bayesian entropy. The Bayesian sleep sub-network includes a Bayesian convolutional block, a temporal feature extractor, and an output layer. The Bayesian convolutional block is used to extract features in the spatial dimension. It consists of stacked convolutional and pooling layers with weights following a Gaussian distribution. Posterior sampling is performed during training, and a loss function is constructed based on the KL divergence between the weight distribution and the true posterior distribution. The temporal feature extractor extracts features in the temporal dimension using a long short-term memory network. The output layer maps the extracted features to a low dimension and outputs the predicted sleep stage result.

[0011] S3: Sort the samples in the dataset in ascending order according to the Bayesian uncertainty quantification result. The Bayesian uncertainty quantification result is negatively correlated with the reliability of the sleep stage prediction result of the Bayesian sleep network. That is, the larger the Bayesian uncertainty quantification result of a sample, the less reliable the predicted sleep stage result of the sample is. This allows for the evaluation of the importance of the sample. Then, select some important samples to label them with sleep stage labels for fine-tuning the Bayesian sleep network trained in step S2, so as to improve the performance of the Bayesian sleep network in sleep stage.

[0012] S4: The remaining samples from step S3 that have not been labeled with sleep stage tags are passed through two Bayesian sleep sub-networks in the fine-tuned Bayesian sleep network to output the predicted sleep stage results and calculate the Bayesian uncertainty quantification results. Then, the sleep stage results predicted by the two Bayesian sleep sub-networks are weighted according to the Bayesian uncertainty quantification results and fused to obtain the overall predicted sleep stage results. Next, samples with high Bayesian uncertainty are selected for sleep stage tagging to correct the overall predicted sleep stage results and obtain the final sleep stage results for the entire dataset.

[0013] Further, in step S1, firstly, the acquired EEG signal data is resampled to a fixed sampling rate. Then, to remove noise, a Butterworth filter is used to limit the EEG signal frequency to the range of 0.25Hz-40Hz. Next, the filtered EEG signal data is segmented into fixed-length EEG segments to form a preprocessed dataset without sleep stage labels. , where the dataset Samples in Represented as: , , Indicates sample The A segment, It is a sample The total number of segments that were divided.

[0014] Furthermore, step S2 includes the following steps:

[0015] S21: In order for the Bayesian sleep network to learn features from different parts of the data distribution, two disjoint subsets D1 and D2 are sampled from the preprocessed dataset D;

[0016] S22: Two disjoint subsets D1 and D2 are input into two identical Bayesian sleep sub-networks E1 and E2 for feature extraction and to predict sleep staging results. The Bayesian sleep sub-networks implement feature extraction and prediction through Bayesian convolutional blocks, a temporal feature extractor, and an output layer as follows:

[0017] Bayesian convolution blocks:

[0018] First, the data is expanded into multiple feature maps through convolution, as follows:

[0019] ;

[0020] In the formula, This represents the expanded feature map obtained initially by passing the data through a convolutional network. This represents the convolution operation. ReLU represents batch normalization, and ReLU represents the ReLU activation function.

[0021] Then, in order to downsample the expanded feature map and retain key information while reducing computational cost, the feature map is next subjected to pooling operation, as follows:

[0022] ;

[0023] In the formula, This represents the feature map after the initial pooling. This represents the operation of randomly discarding some neurons during each forward propagation, used to alleviate overfitting; This indicates max pooling;

[0024] Since shallow convolutional networks can only learn low-level features of the input data and obtain preliminary feature maps, multi-layer convolution and pooling are used to further learn features and expand the receptive field of the feature maps. The details are as follows:

[0025] ;

[0026] ;

[0027] In the formula, This represents the advanced feature map after multi-layer convolution processing. This represents the spatial feature map obtained after max pooling.

[0028] Temporal Feature Extractor:

[0029] The spatial features of the input data are learned through stacked convolutional and pooling layers. Next, to learn the temporal features, a Long Short-Term Memory (LSTM) network is used to capture temporal dependencies, resulting in a temporal-spatial feature map, as shown below:

[0030] ;

[0031] In the formula, This represents a time-space feature map, which is obtained by extracting features from the input data from both spatial and temporal dimensions. express layer;

[0032] Output layer:

[0033] After obtaining the time-space feature map, the sleep staging results are predicted through the output layer, as follows:

[0034] ;

[0035] In the formula, This indicates the predicted sleep stage results. , Indicates sample The Middle The sleep staging results corresponding to each segment; express Activation function; Indicates a fully connected layer; This represents a flattening operation that unfolds the feature map;

[0036] S23: To ensure accurate predictions of sleep stage results, T random forward propagations are required for training to approximate the posterior prediction distribution. The Bayesian sleep sub-network is trained using a dataset without sleep stage labels. Its core training objective is to find a variational posterior distribution that minimizes the KL divergence between the variational posterior distribution and the prior distribution. Therefore, the training aims to both encourage the network to fit the training data and minimize the variational posterior distribution. With prior distribution The KL divergence between them is used to train the loss function via the Monte Carlo method. Approximately:

[0037] ;

[0038] In the formula, This represents the preprocessed dataset without labeled sleep stages. Indicates a variable parameter. This represents the total number of Monte Carlo samplings. This indicates the current round of Monte Carlo sampling. , Represents the logarithmic function. Indicates network weights, Indicates the first one drawn The weights of each Monte Carlo sample. express The corresponding variational posterior distribution, express The corresponding prior distribution, This indicates that the result was obtained through Bayes' theorem. The corresponding posterior distribution;

[0039] Minimize using stochastic gradient descent Train the Bayesian sleep subnetworks E1 and E2 to obtain... Minimum network weight;

[0040] S24: After training in step S23, the mean probability and variance of each sleep stage category can be obtained, as follows:

[0041] ;

[0042] ;

[0043] In the formula, Indicates the index of the Bayesian sleep subnetwork. ; Indicates output The values ​​are used to classify EEG segments into five categories: Wake, N1, N2, N3, and REM, corresponding to sleep stages. ,when When =0, it corresponds to the awakening stage tag Wake. When =1, it corresponds to the stage I label N1 of non-rapid eye movement sleep (NREM). When =2, it corresponds to the stage II label N2 of non-rapid eye movement sleep NREM, when =3 corresponds to stage III label N3 in non-rapid eye movement sleep NREM (NREM). =4 corresponds to the REM (Rapid Eye Movement) sleep stage label; Indicates the first A Bayesian sleep subnetwork, Indicates input sample on the network Below, output equal The probability of; This represents the mean, or expected value. This represents the total number of forward propagations during training. Indicates the current forward propagation round. ; yes The mean, or expectation; yes Standard deviation;

[0044] S25: Since no sleep stage labels are provided as a reference, Bayesian uncertainty is needed to measure the reliability of the predicted sleep stage results. To integrate mean and variance information, and inspired by Shannon entropy, an uncertainty quantification method—Bayesian entropy—is proposed. The Bayesian entropy of a Bayesian sleep subnetwork is defined as:

[0045] ;

[0046] In the formula, Indicates the first Bayesian entropy of a Bayesian sleep subnetwork Indicates output The value of ; , is a parameter used to control the degree of influence of the mean and standard deviation on the results. When it approaches 0, To occupy a dominant position, when When it approaches 1, To occupy a dominant position;

[0047] S26: Combining the Bayesian entropy of the two Bayesian sleep subnetworks E1 and E2, the sample The Bayesian uncertainty quantification results are as follows:

[0048] ;

[0049] In the formula, Indicates sample The Bayesian uncertainty quantification results; Describes the Bayesian entropy of E1. Let E2 be the Bayesian entropy.

[0050] Furthermore, step S3 includes the following steps:

[0051] S31: Based on the Bayesian uncertainty quantification results obtained in step S2, sort all samples in ascending order;

[0052] S32: Sampling is performed on the arranged samples at fixed intervals to select a portion of the samples, ensuring that the selected samples cover the entire range of uncertainty;

[0053] S33: Label the selected samples with sleep staging results;

[0054] S34: Using the labeled samples, fine-tune the Bayesian sleep network trained in step S2 to reduce uncertainty and improve the accuracy of sleep staging in the remaining data.

[0055] Furthermore, step S4 includes the following steps:

[0056] S41: For the remaining samples in step S3 that have not been labeled with sleep stage tags, pass them through the two Bayesian sleep subnetworks of the fine-tuned Bayesian sleep network to obtain the predicted sleep stage results, and recalculate their Bayesian entropy. and The Bayesian uncertainty quantification result is obtained; weights are assigned to the two Bayesian sleep subnetworks E1 and E2 using the Bayesian uncertainty quantification result, and the sleep stage prediction results of E1 and E2 are fused to obtain the overall sleep stage prediction result of the Bayesian sleep network:

[0057] ;

[0058] In the formula, This represents the overall predicted sleep stage results. , Indicates sample The Middle The predicted sleep stage results corresponding to each segment; Indicates assignment to the first A Bayesian sleep subnetwork Dynamic weights; Represents the Bayesian sleep subnetwork Expected predictions; Represents the Bayesian sleep subnetwork Expected predictions;

[0059] S42: Sort the remaining unlabeled sleep stage samples in ascending order according to the Bayesian uncertainty quantification results recalculated in step S41. Select the samples with high Bayesian uncertainty quantification results, whose sleep stage results are considered unreliable and require further labeling to correct the overall sleep stage prediction results of the Bayesian sleep network. Finally, for manually labeled samples, the sleep stage results are based on the manually labeled results, while for the remaining samples, the sleep stage results are based on the overall predicted sleep stage results output in step S41.

[0060] The second objective of this invention is achieved through the following technical solution: a system for sleep staging using Bayesian uncertainty, used to implement the above-mentioned method for sleep staging using Bayesian uncertainty, comprising:

[0061] The data acquisition and preprocessing module is used to acquire single-channel EEG signal data and perform preprocessing, that is, first resample to the same frequency, then divide into EEG segments of fixed length to form a preprocessed dataset without sleep stage labels.

[0062] The initial training module uses samples from a dataset without labeled sleep stage to initially train a Bayesian sleep network containing two structurally identical Bayesian sleep sub-networks, and outputs the Bayesian uncertainty quantification result based on the designed Bayesian entropy. The Bayesian sleep sub-network includes a Bayesian convolutional block, a temporal feature extractor, and an output layer. The Bayesian convolutional block is used to extract features in the spatial dimension; it consists of stacked convolutional and pooling layers with weights following a Gaussian distribution, enabling posterior sampling during training. A loss function is constructed based on the KL divergence between the weight distribution and the true posterior distribution. The temporal feature extractor extracts features in the temporal dimension using a long short-term memory network. The output layer maps the extracted features to a low dimension and outputs the predicted sleep stage result.

[0063] The fine-tuning module is used to sort the samples in the dataset in ascending order according to the Bayesian uncertainty quantification result. The Bayesian uncertainty quantification result is negatively correlated with the reliability of the sleep stage prediction result of the Bayesian sleep network. That is, the larger the Bayesian uncertainty quantification result of a sample, the less reliable the predicted sleep stage result of the sample is. This allows for the evaluation of the importance of the samples. Then, some important samples are selected for sleep stage labeling, which is used to fine-tune the Bayesian sleep network trained by the initial training module to improve the performance of the Bayesian sleep network in sleep stage.

[0064] The prediction module takes the remaining unlabeled sleep stage samples from the fine-tuning module and passes them through two Bayesian sleep sub-networks in the fine-tuned Bayesian sleep network. It outputs predicted sleep stage results and calculates the Bayesian uncertainty quantification result. Then, it assigns weights to the sleep stage prediction results of the two Bayesian sleep sub-networks based on the Bayesian uncertainty quantification result and merges them to obtain the overall predicted sleep stage result. Next, it selects the samples with high Bayesian uncertainty and labels them with sleep stage labels to correct the overall predicted sleep stage result, thus obtaining the final sleep stage result for the entire dataset.

[0065] The third objective of this invention is achieved through the following technical solution: a storage medium storing a program, which, when executed by a processor, implements the above-mentioned method for sleep staging using Bayesian uncertainty.

[0066] The fourth objective of this invention is achieved through the following technical solution: a computing device, including a processor and a memory for storing processor-executable programs, wherein when the processor executes the program stored in the memory, it implements the above-mentioned method for sleep staging using Bayesian uncertainty.

[0067] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0068] 1. This invention constructs a Bayesian sleep network for sleep staging, which can extract features in the temporal and spatial dimensions. By applying a probability distribution to the network weights, it provides the possibility of quantifying Bayesian uncertainty, which can significantly improve the performance of sleep staging and enhance the generalization performance of the network.

[0069] 2. This invention combines Bayesian uncertainty estimation with selective labeling. By selecting some important samples, the amount of labeling work is reduced, which can greatly reduce the dependence on manual labeling while ensuring the accuracy of sleep staging.

[0070] 3. This invention assigns dynamic weights based on the Bayesian uncertainty quantification results to fuse two Bayesian sleep sub-networks. It utilizes independently trained Bayesian sleep sub-networks to complement each other in performance, while reducing the variance of individual Bayesian sleep sub-networks, providing more stable uncertainty estimates, and further improving the robustness of the entire Bayesian sleep network in sleep staging tasks. Attached Figure Description

[0071] Figure 1 This is an overall framework diagram of the method of the present invention.

[0072] Figure 2 This is a structural diagram of a Bayesian sleep network.

[0073] Figure 3 This is a structural diagram of the Bayesian sleep subnetwork.

[0074] Figure 4 This is a flowchart of the method of the present invention.

[0075] Figure 5 This is an architecture diagram of the system of the present invention. Detailed Implementation

[0076] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.

[0077] Example 1

[0078] like Figures 1 to 4 As shown in the figure, this embodiment discloses a method for sleep staging using Bayesian uncertainty, the specific details of which are as follows:

[0079] S1: Acquire single-channel EEG signal data and preprocess it, i.e., first resample to the same frequency, then divide it into fixed-length EEG segments to form a preprocessed dataset without sleep stage labels, as follows:

[0080] First, the acquired EEG signal data was resampled to a fixed sampling rate. Then, to remove noise, a Butterworth filter was used to limit the EEG signal frequency to the range of 0.25Hz-40Hz. Next, the filtered EEG signal data was segmented into fixed-length EEG segments to form a preprocessed dataset without sleep stage labels. , where the dataset Samples in Represented as: , , Indicates sample The A segment, It is a sample The total number of segments that were divided.

[0081] S2: A Bayesian sleep network containing two structurally identical Bayesian sleep sub-networks is initially trained using samples from a dataset without labeled sleep stage information. The Bayesian uncertainty quantification result is then output based on the designed Bayesian entropy. The Bayesian sleep sub-network includes a Bayesian convolutional block, a temporal feature extractor, and an output layer. The Bayesian convolutional block extracts features in the spatial dimension; it consists of stacked convolutional and pooling layers with weights following a Gaussian distribution, enabling posterior sampling during training. A loss function is constructed based on the KL divergence between the weight distribution and the true posterior distribution. The temporal feature extractor extracts features in the temporal dimension using a Long Short-Term Memory (LSTM) network. The output layer maps the extracted features to a low dimension and outputs the predicted sleep stage result. This includes the following steps:

[0082] S21: In order for the Bayesian sleep network to learn features from different parts of the data distribution, two disjoint subsets D1 and D2 are sampled from the preprocessed dataset D;

[0083] S22: Two disjoint subsets D1 and D2 are input into two identical Bayesian sleep sub-networks E1 and E2 for feature extraction and to predict sleep staging results. The Bayesian sleep sub-networks implement feature extraction and prediction through Bayesian convolutional blocks, a temporal feature extractor, and an output layer as follows:

[0084] Bayesian convolution blocks:

[0085] First, the data is expanded into multiple feature maps through convolution, as follows:

[0086] ;

[0087] In the formula, This represents the expanded feature map obtained initially by passing the data through a convolutional network. This represents the convolution operation. ReLU represents batch normalization, and ReLU represents the ReLU activation function.

[0088] Then, in order to downsample the expanded feature map and retain key information while reducing computational cost, the feature map is next subjected to pooling operation, as follows:

[0089] ;

[0090] In the formula, This represents the feature map after the initial pooling. This represents the operation of randomly discarding some neurons during each forward propagation, used to alleviate overfitting; This indicates max pooling;

[0091] Since shallow convolutional networks can only learn low-level features of the input data and obtain preliminary feature maps, multi-layer convolution and pooling are used to further learn features and expand the receptive field of the feature maps. The details are as follows:

[0092] ;

[0093] ;

[0094] In the formula, This represents the advanced feature map after multi-layer convolution processing. This represents the spatial feature map obtained after max pooling.

[0095] Temporal Feature Extractor:

[0096] The spatial features of the input data are learned through stacked convolutional and pooling layers. Next, to learn the temporal features, a Long Short-Term Memory (LSTM) network is used to capture temporal dependencies, resulting in a temporal-spatial feature map, as shown below:

[0097] ;

[0098] In the formula, This represents a time-space feature map, which is obtained by extracting features from the input data from both spatial and temporal dimensions. express layer;

[0099] Output layer:

[0100] After obtaining the time-space feature map, the sleep staging results are predicted through the output layer, as follows:

[0101] ;

[0102] In the formula, This indicates the predicted sleep stage results. , Indicates sample The Middle The sleep staging results corresponding to each segment; express Activation function; Indicates a fully connected layer; This represents a flattening operation that unfolds the feature map;

[0103] S23: To ensure accurate predictions of sleep stage results, T random forward propagations are required for training to approximate the posterior prediction distribution. The Bayesian sleep sub-network is trained using a dataset without sleep stage labels. Its core training objective is to find a variational posterior distribution that minimizes the KL divergence between the variational posterior distribution and the prior distribution. Therefore, the training aims to both encourage the network to fit the training data and minimize the variational posterior distribution. With prior distribution The KL divergence between them is used to train the loss function via the Monte Carlo method. Approximately:

[0104] ;

[0105] In the formula, This represents the preprocessed dataset without labeled sleep stages. Indicates a variable parameter. This represents the total number of Monte Carlo samplings. This indicates the current round of Monte Carlo sampling. , Represents the logarithmic function. Indicates network weights, Indicates the first one drawn The weights of each Monte Carlo sample. express The corresponding variational posterior distribution, express The corresponding prior distribution, This indicates that the result was obtained through Bayes' theorem. The corresponding posterior distribution;

[0106] Minimize using stochastic gradient descent Train the Bayesian sleep subnetworks E1 and E2 to obtain... Minimum network weight;

[0107] S24: After training in step S23, the mean probability and variance of each sleep stage category can be obtained, as follows:

[0108] ;

[0109] ;

[0110] In the formula, Indicates the index of the Bayesian sleep subnetwork. ; Indicates output The values ​​are used to classify EEG segments into five categories: Wake, N1, N2, N3, and REM, corresponding to sleep stages. ,when When =0, it corresponds to the awakening stage tag Wake. When =1, it corresponds to the stage I label N1 of non-rapid eye movement sleep (NREM). When =2, it corresponds to the stage II label N2 of non-rapid eye movement sleep NREM, when =3 corresponds to stage III label N3 in non-rapid eye movement sleep NREM (NREM). =4 corresponds to the REM (Rapid Eye Movement) sleep stage label; Indicates the first A Bayesian sleep subnetwork, Indicates input sample on the network Below, output equal The probability of; This represents the mean, or expected value. This represents the total number of forward propagations during training. Indicates the current forward propagation round. ; yes The mean, or expectation; yes Standard deviation;

[0111] S25: Since no sleep stage labels are provided as a reference, Bayesian uncertainty is needed to measure the reliability of the predicted sleep stage results. To integrate mean and variance information, and inspired by Shannon entropy, an uncertainty quantification method—Bayesian entropy—is proposed. The Bayesian entropy of a Bayesian sleep subnetwork is defined as:

[0112] ;

[0113] In the formula, Indicates the first Bayesian entropy of a Bayesian sleep subnetwork Indicates output The value of ; , is a parameter used to control the degree of influence of the mean and standard deviation on the results. When it approaches 0, To occupy a dominant position, when When it approaches 1, To occupy a dominant position;

[0114] S26: Combining the Bayesian entropy of the two Bayesian sleep subnetworks E1 and E2, the sample The Bayesian uncertainty quantification results are as follows:

[0115] ;

[0116] In the formula, Indicates sample The Bayesian uncertainty quantification results; Describes the Bayesian entropy of E1. Let E2 be the Bayesian entropy.

[0117] S3: Sort the samples in the dataset in ascending order according to the Bayesian uncertainty quantification result. The Bayesian uncertainty quantification result is negatively correlated with the reliability of the sleep stage prediction result of the Bayesian sleep network. That is, the larger the Bayesian uncertainty quantification result of a sample, the less reliable the predicted sleep stage result of the corresponding sample is. This allows for the evaluation of the importance of the samples. Then, select some important samples for sleep stage labeling to fine-tune the Bayesian sleep network trained in step S2, so as to improve the performance of the Bayesian sleep network in sleep stage. This includes the following steps:

[0118] S31: Based on the Bayesian uncertainty quantification results obtained in step S2, sort all samples in ascending order;

[0119] S32: Sampling is performed on the arranged samples at fixed intervals to select a portion of the samples, ensuring that the selected samples cover the entire range of uncertainty;

[0120] S33: Label the selected samples with sleep staging results;

[0121] S34: Using the labeled samples, fine-tune the Bayesian sleep network trained in step S2 to reduce uncertainty and improve the accuracy of sleep staging in the remaining data.

[0122] S4: The remaining samples from step S3 that have not been labeled with sleep stage classification are passed through two Bayesian sleep sub-networks in the fine-tuned Bayesian sleep network to output the predicted sleep stage results. The Bayesian uncertainty quantification result is calculated, and then the sleep stage results predicted by the two Bayesian sleep sub-networks are weighted according to the Bayesian uncertainty quantification result and fused to obtain the overall predicted sleep stage result. Then, samples with high Bayesian uncertainty are selected for sleep stage classification labeling to correct the overall predicted sleep stage result, resulting in the final sleep stage result for the entire dataset. This includes the following steps:

[0123] S41: For the remaining samples in step S3 that have not been labeled with sleep stage tags, pass them through the two Bayesian sleep subnetworks of the fine-tuned Bayesian sleep network to obtain the predicted sleep stage results, and recalculate their Bayesian entropy. and The Bayesian uncertainty quantification result is obtained; weights are assigned to the two Bayesian sleep subnetworks E1 and E2 using the Bayesian uncertainty quantification result, and the sleep stage prediction results of E1 and E2 are fused to obtain the overall sleep stage prediction result of the Bayesian sleep network:

[0124] ;

[0125] In the formula, This represents the overall predicted sleep stage results. , Indicates sample The Middle The predicted sleep stage results corresponding to each segment; Indicates assignment to the first A Bayesian sleep subnetwork Dynamic weights; Represents the Bayesian sleep subnetwork Expected predictions; Represents the Bayesian sleep subnetwork Expected predictions;

[0126] S42: Sort the remaining unlabeled sleep stage samples in ascending order according to the Bayesian uncertainty quantification results recalculated in step S41. Select the samples with high Bayesian uncertainty quantification results, whose sleep stage results are considered unreliable and require further labeling to correct the overall sleep stage prediction results of the Bayesian sleep network. Finally, for manually labeled samples, the sleep stage results are based on the manually labeled results, while for the remaining samples, the sleep stage results are based on the overall predicted sleep stage results output in step S41.

[0127] Example 2

[0128] This embodiment discloses a system for sleep staging using Bayesian uncertainty, used to implement the method for sleep staging using Bayesian uncertainty described in Embodiment 1, such as... Figure 5 As shown, the system includes the following functional modules:

[0129] The data acquisition and preprocessing module is used to acquire single-channel EEG signal data and perform preprocessing, that is, first resample to the same frequency, then divide into EEG segments of fixed length to form a preprocessed dataset without sleep stage labels.

[0130] The initial training module uses samples from a dataset without labeled sleep stage to initially train a Bayesian sleep network containing two structurally identical Bayesian sleep sub-networks, and outputs the Bayesian uncertainty quantification result based on the designed Bayesian entropy. The Bayesian sleep sub-network includes a Bayesian convolutional block, a temporal feature extractor, and an output layer. The Bayesian convolutional block is used to extract features in the spatial dimension; it consists of stacked convolutional and pooling layers with weights following a Gaussian distribution, enabling posterior sampling during training. A loss function is constructed based on the KL divergence between the weight distribution and the true posterior distribution. The temporal feature extractor extracts features in the temporal dimension using a long short-term memory network. The output layer maps the extracted features to a low dimension and outputs the predicted sleep stage result.

[0131] The fine-tuning module is used to sort the samples in the dataset in ascending order according to the Bayesian uncertainty quantification result. The Bayesian uncertainty quantification result is negatively correlated with the reliability of the sleep stage prediction result of the Bayesian sleep network. That is, the larger the Bayesian uncertainty quantification result of a sample, the less reliable the predicted sleep stage result of the sample is. This allows for the evaluation of the importance of the samples. Then, some important samples are selected for sleep stage labeling, which is used to fine-tune the Bayesian sleep network trained by the initial training module to improve the performance of the Bayesian sleep network in sleep stage.

[0132] The prediction module takes the remaining unlabeled sleep stage samples from the fine-tuning module and passes them through two Bayesian sleep sub-networks in the fine-tuned Bayesian sleep network. It outputs predicted sleep stage results and calculates the Bayesian uncertainty quantification result. Then, it assigns weights to the sleep stage prediction results of the two Bayesian sleep sub-networks based on the Bayesian uncertainty quantification result and merges them to obtain the overall predicted sleep stage result. Next, it selects the samples with high Bayesian uncertainty and labels them with sleep stage labels to correct the overall predicted sleep stage result, thus obtaining the final sleep stage result for the entire dataset.

[0133] Example 3

[0134] This embodiment discloses a storage medium storing a program. When the program is executed by a processor, it implements the method for sleep staging using Bayesian uncertainty as described in Embodiment 1.

[0135] The storage medium in this embodiment can be a disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), USB flash drive, portable hard drive, etc.

[0136] Example 4

[0137] This embodiment discloses a computing device, including a processor and a memory for storing processor-executable programs. When the processor executes the program stored in the memory, it implements the method for sleep staging using Bayesian uncertainty as described in Embodiment 1.

[0138] The computing device described in this embodiment may be a desktop computer, laptop computer, smartphone, PDA handheld terminal, tablet computer, programmable logic controller (PLC), or other terminal device with processor function.

[0139] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A method for sleep staging using Bayesian uncertainty, characterized in that, Includes the following steps: S1: Acquire single-channel EEG signal data and preprocess it, i.e., first resample to the same frequency, then divide it into EEG segments of fixed length to form a preprocessed dataset without sleep stage labels; S2: The Bayesian sleep network, which contains two structurally identical Bayesian sleep sub-networks, is initially trained using samples from a dataset without labeled sleep stage. The Bayesian uncertainty quantification result is then output based on the designed Bayesian entropy. The Bayesian sleep sub-network includes a Bayesian convolutional block, a temporal feature extractor, and an output layer. The Bayesian convolutional block is used to extract features in the spatial dimension. It consists of stacked convolutional and pooling layers with weights following a Gaussian distribution. Posterior sampling is performed during training, and a loss function is constructed based on the KL divergence between the weight distribution and the true posterior distribution. The temporal feature extractor extracts features in the temporal dimension using a long short-term memory network. The output layer maps the extracted features to a low dimension and outputs the predicted sleep stage result. S3: Sort the samples in the dataset in ascending order according to the Bayesian uncertainty quantification result. The Bayesian uncertainty quantification result is negatively correlated with the reliability of the sleep stage prediction result of the Bayesian sleep network. That is, the larger the Bayesian uncertainty quantification result of a sample, the less reliable the predicted sleep stage result of the sample is. This allows for the evaluation of the importance of the sample. Then, select some important samples to label them with sleep stage labels for fine-tuning the Bayesian sleep network trained in step S2, so as to improve the performance of the Bayesian sleep network in sleep stage. S4: The remaining samples from step S3 that have not been labeled with sleep stage tags are passed through two Bayesian sleep sub-networks in the fine-tuned Bayesian sleep network to output the predicted sleep stage results and calculate the Bayesian uncertainty quantification results. Then, the sleep stage results predicted by the two Bayesian sleep sub-networks are weighted according to the Bayesian uncertainty quantification results and fused to obtain the overall predicted sleep stage results. Next, samples with high Bayesian uncertainty are selected for sleep stage tagging to correct the overall predicted sleep stage results and obtain the final sleep stage results for the entire dataset.

2. The method for sleep staging using Bayesian uncertainty as described in claim 1, characterized in that, In step S1, firstly, the acquired EEG signal data is resampled to a fixed sampling rate. Then, to remove noise, a Butterworth filter is used to limit the EEG signal frequency to the range of 0.25Hz-40Hz. Next, the filtered EEG signal data is segmented into fixed-length EEG segments to form a preprocessed dataset without sleep stage labels. , where the dataset Samples in Represented as: , , Indicates sample The A segment, It is a sample The total number of segments that were divided.

3. The method for sleep staging using Bayesian uncertainty as described in claim 2, characterized in that, Step S2 includes the following steps: S21: In order for the Bayesian sleep network to learn features from different parts of the data distribution, two disjoint subsets D1 and D2 are sampled from the preprocessed dataset D; S22: Two disjoint subsets D1 and D2 are input into two identical Bayesian sleep sub-networks E1 and E2 for feature extraction and to predict sleep staging results. The Bayesian sleep sub-networks implement feature extraction and prediction through Bayesian convolutional blocks, a temporal feature extractor, and an output layer as follows: Bayesian convolution blocks: First, the data is expanded into multiple feature maps through convolution, as follows: ; In the formula, This represents the expanded feature map obtained initially by passing the data through a convolutional network. This represents the convolution operation. ReLU represents batch normalization, and ReLU represents the ReLU activation function. Then, in order to downsample the expanded feature map and retain key information while reducing computational cost, the feature map is next subjected to pooling operation, as follows: ; In the formula, This represents the feature map after the initial pooling. This represents the operation of randomly discarding some neurons during each forward propagation, used to alleviate overfitting; This indicates max pooling; Since shallow convolutional networks can only learn low-level features of the input data and obtain preliminary feature maps, multi-layer convolution and pooling are used to further learn features and expand the receptive field of the feature maps. The details are as follows: ; ; In the formula, This represents the advanced feature map after multi-layer convolution processing. This represents the spatial feature map obtained after max pooling. Temporal Feature Extractor: The spatial features of the input data are learned through stacked convolutional and pooling layers. Next, to learn the temporal features, a Long Short-Term Memory (LSTM) network is used to capture temporal dependencies, resulting in a temporal-spatial feature map, as shown below: ; In the formula, This represents a time-space feature map, which is obtained by extracting features from the input data from both spatial and temporal dimensions. express layer; Output layer: After obtaining the time-space feature map, the sleep staging results are predicted through the output layer, as follows: ; In the formula, This indicates the predicted sleep stage results. , Indicates sample The Middle The sleep staging results corresponding to each segment; express Activation function; Indicates a fully connected layer; This represents a flattening operation that unfolds the feature map; S23: To ensure accurate predictions of sleep stage results, T random forward propagations are required for training to approximate the posterior prediction distribution. The Bayesian sleep sub-network is trained using a dataset without sleep stage labels. Its core training objective is to find a variational posterior distribution that minimizes the KL divergence between the variational posterior distribution and the prior distribution. Therefore, the training aims to both encourage the network to fit the training data and minimize the variational posterior distribution. With prior distribution The KL divergence between them is used to train the loss function via the Monte Carlo method. Approximately: ; In the formula, This represents the preprocessed dataset without labeled sleep stages. Indicates a variable parameter. This represents the total number of Monte Carlo samplings. This indicates the current round of Monte Carlo sampling. , Represents the logarithmic function. Indicates network weights, Indicates the first one drawn The weights of each Monte Carlo sample. express The corresponding variational posterior distribution, express The corresponding prior distribution, This indicates that the result was obtained through Bayes' theorem. The corresponding posterior distribution; Minimize using stochastic gradient descent Train the Bayesian sleep subnetworks E1 and E2 to obtain... Minimum network weight; S24: After training in step S23, the mean probability and variance of each sleep stage category can be obtained, as follows: ; ; In the formula, Indicates the index of the Bayesian sleep subnetwork. ; Indicates output The values ​​are used to classify EEG segments into five categories: Wake, N1, N2, N3, and REM, corresponding to sleep stages. ,when When =0, it corresponds to the awakening stage tag Wake. When =1, it corresponds to the stage I label N1 of non-rapid eye movement sleep (NREM). When =2, it corresponds to the stage II label N2 of non-rapid eye movement sleep NREM, when =3 corresponds to stage III label N3 in non-rapid eye movement sleep NREM (NREM). =4 corresponds to the REM (Rapid Eye Movement) sleep stage label; Indicates the first A Bayesian sleep subnetwork, Indicates input sample on the network Below, output equal The probability of; This represents the mean, or expected value. This represents the total number of forward propagations during training. Indicates the current forward propagation round. ; yes The mean, or expectation; yes Standard deviation; S25: Since no sleep stage labels are provided as a reference, Bayesian uncertainty is needed to measure the reliability of the predicted sleep stage results. To integrate mean and variance information, and inspired by Shannon entropy, an uncertainty quantification method—Bayesian entropy—is proposed. The Bayesian entropy of a Bayesian sleep subnetwork is defined as: ; In the formula, Indicates the first Bayesian entropy of a Bayesian sleep subnetwork Indicates output The value of ; , is a parameter used to control the degree of influence of the mean and standard deviation on the results. When it approaches 0, To occupy a dominant position, when When it approaches 1, To occupy a dominant position; S26: Combining the Bayesian entropy of the two Bayesian sleep subnetworks E1 and E2, the sample The Bayesian uncertainty quantification results are as follows: ; In the formula, Indicates sample The Bayesian uncertainty quantification results; Describes the Bayesian entropy of E1. Let E2 be the Bayesian entropy.

4. The method for sleep staging using Bayesian uncertainty as described in claim 3, characterized in that, Step S3 includes the following steps: S31: Based on the Bayesian uncertainty quantification results obtained in step S2, sort all samples in ascending order; S32: Sampling is performed on the arranged samples at fixed intervals to select a portion of the samples, ensuring that the selected samples cover the entire range of uncertainty; S33: Label the selected samples with sleep staging results; S34: Using the labeled samples, fine-tune the Bayesian sleep network trained in step S2 to reduce uncertainty and improve the accuracy of sleep staging in the remaining data.

5. The method for sleep staging using Bayesian uncertainty as described in claim 4, characterized in that, Step S4 includes the following steps: S41: For the remaining samples in step S3 that have not been labeled with sleep stage tags, pass them through the two Bayesian sleep subnetworks of the fine-tuned Bayesian sleep network to obtain the predicted sleep stage results, and recalculate their Bayesian entropy. and The Bayesian uncertainty quantification result is obtained; weights are assigned to the two Bayesian sleep subnetworks E1 and E2 using the Bayesian uncertainty quantification result, and the sleep stage prediction results of E1 and E2 are fused to obtain the overall sleep stage prediction result of the Bayesian sleep network: ; In the formula, This represents the overall predicted sleep stage results. , Indicates sample The Middle The predicted sleep stage results corresponding to each segment; Indicates assignment to the first A Bayesian sleep subnetwork Dynamic weights; Represents the Bayesian sleep subnetwork Expected predictions; Represents the Bayesian sleep subnetwork Expected predictions; S42: Sort the remaining unlabeled sleep stage samples in ascending order according to the Bayesian uncertainty quantification results recalculated in step S41. Select the samples with high Bayesian uncertainty quantification results, whose sleep stage results are considered unreliable and require further labeling to correct the overall sleep stage prediction results of the Bayesian sleep network. Finally, for manually labeled samples, the sleep stage results are based on the manually labeled results, while for the remaining samples, the sleep stage results are based on the overall predicted sleep stage results output in step S41.

6. A system for sleep staging using Bayesian uncertainty, characterized in that, The method for implementing sleep staging using Bayesian uncertainty as described in any one of claims 1 to 5 comprises: The data acquisition and preprocessing module is used to acquire single-channel EEG signal data and perform preprocessing, that is, first resample to the same frequency, then divide into EEG segments of fixed length to form a preprocessed dataset without sleep stage labels. The initial training module uses samples from a dataset without labeled sleep stage to initially train a Bayesian sleep network containing two structurally identical Bayesian sleep sub-networks, and outputs the Bayesian uncertainty quantification result based on the designed Bayesian entropy. The Bayesian sleep sub-network includes a Bayesian convolutional block, a temporal feature extractor, and an output layer. The Bayesian convolutional block is used to extract features in the spatial dimension; it consists of stacked convolutional and pooling layers with weights following a Gaussian distribution, enabling posterior sampling during training. A loss function is constructed based on the KL divergence between the weight distribution and the true posterior distribution. The temporal feature extractor extracts features in the temporal dimension using a long short-term memory network. The output layer maps the extracted features to a low dimension and outputs the predicted sleep stage result. The fine-tuning module is used to sort the samples in the dataset in ascending order according to the Bayesian uncertainty quantification result. The Bayesian uncertainty quantification result is negatively correlated with the reliability of the sleep stage prediction result of the Bayesian sleep network. That is, the larger the Bayesian uncertainty quantification result of a sample, the less reliable the predicted sleep stage result of the sample is. This allows for the evaluation of the importance of the samples. Then, some important samples are selected for sleep stage labeling, which is used to fine-tune the Bayesian sleep network trained by the initial training module to improve the performance of the Bayesian sleep network in sleep stage. The prediction module takes the remaining unlabeled sleep stage samples from the fine-tuning module and passes them through two Bayesian sleep sub-networks in the fine-tuned Bayesian sleep network. It outputs predicted sleep stage results and calculates the Bayesian uncertainty quantification result. Then, it assigns weights to the sleep stage prediction results of the two Bayesian sleep sub-networks based on the Bayesian uncertainty quantification result and merges them to obtain the overall predicted sleep stage result. Next, it selects the samples with high Bayesian uncertainty and labels them with sleep stage labels to correct the overall predicted sleep stage result, thus obtaining the final sleep stage result for the entire dataset.

7. A storage medium storing a program, characterized in that, When the program is executed by the processor, it implements the method for sleep staging using Bayesian uncertainty as described in any one of claims 1 to 5.

8. A computing device, comprising a processor and a memory for storing a processor-executable program, characterized in that, When the processor executes the program stored in the memory, it implements the method for sleep staging using Bayesian uncertainty as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • CN117942038A

  • US20140297600A1