Sleep staging method based on unsupervised field adaptive model
Through the unsupervised domain adaptive model, the sleep staging model is trained using Wasserstein distance and triple loss functions, which solves the problems of field transfer and label missing in clinical applications of existing models, and achieves higher cross-domain adaptability and classification accuracy.
Patent Information
- Application Number
- CN202510355896.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-03-25
AI Technical Summary
The existing sleep staging model faces domain transfer problems and lack of labels in clinical applications, resulting in different performances of models on different data sets and it is difficult to adapt to a diverse clinical environment.
Using an unsupervised domain adaptive model, the feature distribution alignment between the source domain and the target domain is achieved through the Wasserstein distance and triple loss function, and a sleep staging model that can perform well in different fields is trained.
The performance of the sleep staging model in cross-domain classification is improved, the stability and adaptability of the model is enhanced, and the characteristics differences between healthy subjects and patients with sleep difficulties are effectively overcome, as well as the differences in sleep monitoring equipment and collection environment.
Smart Images

Figure CN119989132A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of sleep staging research, and in particular relates to a sleep staging method based on an unsupervised domain adaptive model. Background Art
[0002] Currently, most sleep staging research focuses on developing models or methods that can achieve high-precision classification. Although deep learning technology has made significant progress, there are still obstacles to directly using these technologies in clinical applications. This phenomenon is mainly due to the significant differences between the currently available public training datasets and the data actually collected in clinical practice. Most public datasets are derived from controlled laboratory environments, while clinical data are more complex and are susceptible to multiple factors such as individual differences, environmental noise, and signal acquisition equipment. This leads to a well-known domain transfer problem, that is, model training data and actual test data show different distribution characteristics. This difference between data greatly increases the difficulty of directly applying models trained based on public datasets to clinical scenarios.
[0003] In addition, the lack of labels for clinical data complicates the use of supervised learning methods in this area. In reality, the acquisition of labeled data is not only expensive but also quite scarce, which is particularly prominent in the field of sleep research. The labeling of sleep stages usually requires manual operation by professionals, which is obviously unrealistic when dealing with large-scale clinical data. Therefore, the effectiveness of existing models in practical applications is limited by the lack of sufficient labeled data, which becomes a significant obstacle when generalizing to actual clinical problems. At the same time, the diversity of clinical environments, physiological differences between individuals, and the variability of data under different equipment or environmental conditions further exacerbate the challenges of domain transfer. This means that a model that performs well on a specific dataset may not be directly migrated to a new dataset with a different feature distribution, thereby limiting its applicability and effectiveness in a wider range of clinical environments. Therefore, developing methods that can adapt to data from different fields and maintain good performance under conditions of scarce annotations is crucial to promoting the clinical practical value and widespread application of sleep stage research.
[0004] A common approach to the domain shift problem in automatic sleep classification is to adapt the source model to the target domain. Supervised transfer learning methods are one of the most common settings used by researchers to address the domain shift problem in sleep stage classification. These methods usually adapt a well-trained source model to a labeled target domain by fine-tuning an existing network. In this case, the target domain can be sleep records from a clinical site or sleep records from a specific subject. For example, the study by Phan et al. proposed a deep transfer learning method that first pre-trained the model on a large dataset and then fine-tuned it on a smaller dataset to achieve knowledge transfer. Although transfer learning, especially fine-tuning, is widely used to adapt models trained on public datasets to clinical data, it still has certain limitations. Fine-tuning usually assumes that the data distribution of the source and target domains is similar, but in the context of sleep staging, this assumption does not always hold. In addition, in practical applications, the target domain is likely to be completely unlabeled.
[0005] When faced with a situation where the target domain data is completely unlabeled, unsupervised domain adaptation (UDA) provides an ideal solution framework. As a special transfer learning scenario, UDA aims to solve the distribution inconsistency problem between the source domain and the target domain without relying on the target domain label, and train a model that performs well in both the source domain and the target domain. So far, there is still limited research on UDA in the context of sleep staging. For example, Nasiri et al. proposed a method based on adversarial training and attention mechanism to extract transferable information from different individuals in different datasets. Chambon et al. proposed to use optimal transfer domain adaptation to improve the performance of convolutional neural networks (CNNs) to enhance the feature transferability between the source domain and the target domain. However, these methods still have the following limitations. First, existing methods usually focus on minimizing global distribution differences, but ignore the fact that even if the global distribution is aligned, the same label samples in different domains may still be distributed differently in the feature space, that is, there is a class-level misalignment problem; second, when faced with large distribution differences between the feature representations of the source domain and the target domain, traditional models that use adversarial loss are susceptible to gradient vanishing or collapse, affecting domain adaptation performance. Summary of the invention
[0006] In view of the above-mentioned deficiencies in the prior art, the sleep staging method based on the unsupervised domain adaptive model provided by the present invention solves the problems in the existing related methods that the designed models are difficult to capture time dependence, have high complexity and insufficient ability to suppress noise, thereby affecting the accuracy of the sleep staging task.
[0007] In order to achieve the above-mentioned purpose of the invention, the technical solution adopted by the present invention is: a sleep staging method based on an unsupervised domain adaptive model, comprising the following steps:
[0008] S1, collect single-channel EEG data and construct source domain data set and target domain data;
[0009] The source domain dataset includes a number of labeled samples, and the target domain dataset includes a number of unlabeled samples; wherein the source domain and the target domain share the same label space;
[0010] S2. Build an unsupervised domain adaptation model and train it using the source domain dataset and the target domain dataset to obtain an unsupervised domain adaptation model for sleep staging.
[0011] The unsupervised domain adaptation model includes a feature extractor, a domain discriminator and a classifier; wherein the feature extractor is used to extract key features of a source domain dataset and a target domain dataset, the domain discriminator is used to measure the dissimilarity between key features in the source domain and the target domain and identify their source domains, and the classifier is used to predict the sleep stage labels of unlabeled samples in the target domain; the training of the unsupervised domain adaptation model includes domain-level alignment training and category-level alignment training;
[0012] S3. Use the classifier in the unsupervised domain adaptation model of sleep staging to classify the sleep stages of the single-channel EEG data to be identified in the target domain.
[0013] Furthermore, in step S2, in the unsupervised domain adaptation model, the feature extractor is a multi-scale temporal residual shrinkage network.
[0014] Furthermore, in step S2, the training method of the unsupervised domain adaptation model is specifically:
[0015] Extract key features of the source domain dataset and the target domain dataset through a feature extractor;
[0016] Domain-level alignment training: Based on the extracted key features, the Wasserstein distance between the source domain and the target domain is introduced to conduct adversarial training on the feature extractor and the domain discriminator. During the adversarial training process, the domain discriminator is first optimized and trained to determine the parameters of the domain discriminator. At the same time, the feature extractor is trained. The key features of the source domain dataset are extracted using the trained feature extractor, and the classifier is trained based on the extracted key features.
[0017] Category-level alignment training: In the process of classifier training, a pseudo-label generation mechanism is introduced to construct a triplet loss function, and then the classifier and feature extractor are trained and optimized again to determine the parameters of the classifier and feature extractor, and complete the training of the unsupervised domain adaptation model.
[0018] Furthermore, the Wasserstein distance between the source domain and the target domain is used to perform adversarial training on the feature extractor and the domain discriminator, and the training loss function is for:
[0019]
[0020] In the formula, x s and x t Represent the data samples of the source domain and the target domain respectively, and f g (·) represents the function learned by the feature extractor, f w (·) represents the function learned by the domain discriminator, D s and D t Represent the source domain dataset and the target domain dataset respectively, n s and n t Represents the number of samples in the source domain and the target domain respectively;
[0021] The parameters θ of the domain discriminator d The gradient norm imposes a penalty As a loss function The constraint condition of maximizing the Wasserstein distance between the source domain and the target domain is expressed as:
[0022]
[0023] In the formula, represents a feature set, which includes key features extracted from the source domain dataset and the target domain dataset, as well as randomly sampled points along the straight line between the source domain and target domain feature pairs. Express Find the partial derivative.
[0024] Furthermore, during the training of the feature extractor, the function f learned by the feature extractor g (·) Mapping samples in the source and target domain datasets to parameters θ with feature extractors f The feature representation is then used to train the feature extractor;
[0025] The training target of the feature extractor is the parameter θ of the domain discriminator. d Under the condition of no change, the Wasserstein distance is minimized, which is expressed as:
[0026]
[0027] In the formula, θ f represents the parameters of the feature extractor, θ d represents the parameters of the domain discriminator, represents the training loss function of adversarial training, Represents the parameter θ d The penalty term imposed, ρ represents the weight coefficient.
[0028] Furthermore, in the domain-level alignment training, the training loss function of the classifier is for:
[0029]
[0030] In the formula, N represents the total number of samples, K represents the number of sleep stage categories, k represents the category index, and i represents the sample index. represents the actual category label of the i-th sample, Represents the predicted label for the i-th sample.
[0031] Furthermore, the objective function of the domain-level alignment training process is:
[0032]
[0033] In the formula, θ f represents the parameters of the feature extractor, θ c represents the parameters of the classifier, θ d represents the parameters of the domain discriminator, represents the classification loss of the classifier, represents the adversarial loss of adversarial training, Represents the parameter θ d The penalty term imposed, λ represents the parameter used to balance the relationship between the discriminative ability and transferability of the feature, and ρ is the weight coefficient.
[0034] Furthermore, the method of the category-level alignment training is specifically as follows:
[0035] According to the confidence of the classifier that has completed the domain-level alignment training for classifying samples in the target domain, the predicted labels with high confidence are selected as the pseudo labels of the samples in the target domain dataset;
[0036] Combine the samples of the source domain dataset and the target domain dataset into one, form positive sample pairs with all samples with the same category label, randomly assign a negative sample to each pair of positive samples, and ensure that the distance between each negative sample and the anchor sample is smaller than the distance between the corresponding positive sample and the anchor sample, and then construct a triplet loss function;
[0037] With the goal of minimizing the classification loss of the classifier in the category-level alignment process and maximizing the Wasserstein distance and triplet loss, the classifier and feature extractor are optimized through gradient descent training, the parameters of the classifier and the feature extractor are determined, and the training of the unsupervised domain adaptation model is completed.
[0038] Furthermore, the triple loss function It is expressed as:
[0039]
[0040] Where f(·) represents the domain aligner, and denote anchor samples, positive samples, and negative samples respectively, ∥·∥ represents the L2 norm, m represents a threshold, [·] + represents max(·,0), the subscript i represents the sample index, and N represents the total number of samples.
[0041] Furthermore, the objective function of the category-level alignment training is:
[0042]
[0043] In the formula, θ f represents the parameters of the feature extractor, θ c represents the parameters of the classifier, θ d represents the parameters of the domain discriminator, represents the classification loss of the classifier, represents the training loss of adversarial training, represents the triplet loss, λ1 and λ2 represent the weight coefficients.
[0044] The beneficial effects of the present invention are:
[0045] (1) The present invention proposes an unsupervised domain adaptation model for sleep staging based on Wasserstein distance and triplet loss to improve the cross-domain classification performance based on sleep EEG; the model framework uses adversarial domain adaptation based on Wasserstein metric to complete the alignment of the overall distribution features of the source domain and the target domain, improves the stability of model training, and ensures the comprehensive alignment of feature distribution; at the same time, combined with the use of triplet loss, it further shortens the distance between similar samples in different domains, expands the distance between samples of different categories, and promotes more accurate category-level alignment.
[0046] (2) The unsupervised domain adaptation model for sleep staging proposed in the present invention can effectively overcome the characteristic differences between healthy subjects and patients with sleep difficulties, and can overcome the impact of differences in sleep monitoring equipment and collection environments on domain adaptation. It is suitable for a variety of sleep scenarios and has strong practical application potential. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A flow chart of the sleep staging method based on the unsupervised domain adaptive model provided by the present invention.
[0048] Figure 2 This is a framework diagram of the sleep staging unsupervised domain adaptation model (WSTLDA) provided by the present invention.
[0049] Figure 3 This is an example of a sleep structure diagram migrated to a SC dataset in an embodiment of the present invention.
[0050] Figure 4 This is an example of a sleep structure diagram migrated to an SCD dataset in an embodiment of the present invention.
[0051] Figure 5 This is an example of a sleep structure diagram migrated to an ST dataset in an embodiment of the present invention.
[0052] Figure 6 2 is a comparison of the domain discriminator with Wasserstein distance and adversarial loss in the embodiments of the present invention.
[0053] Figure 7 The following is an analysis of the triplet loss effect in an embodiment of the present invention.
[0054] Figure 8 This is the UMAP feature visualization in the embodiment of the present invention and its performance in domain alignment.
[0055] Fig. 9 This is the UMAP feature visualization in the embodiment of the present invention, and its performance on the classification results. DETAILED DESCRIPTION
[0056] The specific implementation modes of the present invention are described below to facilitate those skilled in the art to understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0057] The embodiment of the present invention provides a sleep staging method based on an unsupervised domain adaptive model, such as Figure 1 As shown, the following steps are included:
[0058] S1, collect single-channel EEG data and construct source domain data set and target domain data;
[0059] S2. Build an unsupervised domain adaptation model and train it using the source domain dataset and the target domain dataset to obtain an unsupervised domain adaptation model for sleep staging.
[0060] S3. Use the classifier in the unsupervised domain adaptation model of sleep staging to classify the sleep stages of the single-channel EEG data to be identified in the target domain.
[0061] In the embodiment of the present invention, the source domain data set includes a number of labeled samples, and the target domain data set includes a number of unlabeled samples; wherein the source domain and the target domain share the same label space;
[0062] Specifically, in this embodiment, the labeled source domain dataset is represented as Contains n s labeled samples with labels, and the unlabeled target domain dataset is represented as Contains n t unlabeled samples; the source domain and the target domain are distributed from the source and target distribution The two distributions are different. Both domains share the same label space Y = {1,2,…K}, where K is the number of categories, i.e., the number of sleep stages. In this paper, the goal of domain adaptation is to transfer the knowledge of labeled data in the source domain to unlabeled data in the target domain. In the context of EEG data, each and is a 30-second EEG segment data, each data point is represented by Wherein T represents the number of time steps, and the number of electrodes / channels is 1, because the present invention uses single-channel EEG data.
[0063] In step S2 of the embodiment of the present invention, the structure of the constructed unsupervised domain adaptation model (WSTLDA) is as follows: Figure 2 As shown in Figure 2, the model achieves coordinated alignment of the source domain and target domain distribution at the domain level and category level. Figure 2 In the figure, Source Signals represents source signals, Target Signals represents target signals, Feature Extractor represents feature extractor, Source Feature represents source feature, Domain Discriminactor represents domain discriminator, TargetFeature represents target feature, Classifier represents classifier, and Class-level Alignment represents category-level alignment.
[0064] Specifically, the unsupervised domain adaptation model includes a feature extractor, a domain discriminator and a classifier; among them, the feature extractor is used to extract the key features of the source domain dataset and the target domain dataset, the domain discriminator is used to measure the differences between the key features in the source domain and the target domain and identify their source domains, and the classifier is used to predict the sleep stage labels of unlabeled samples in the target domain; the training of the unsupervised domain adaptation model includes domain-level alignment training and category-level alignment training; this dual alignment strategy prompts the feature representation learned by the model to aggregate samples of the same category more closely, while clearly separating samples of different categories.
[0065] In the unsupervised domain adaptation model of this embodiment, the feature extractor is a multi-scale temporal residual shrinkage network (MS-TRSN) to extract key features of the two domains respectively.
[0066] In step S2 of the embodiment of the present invention, the training method of the unsupervised domain adaptation model is specifically:
[0067] Extract key features of the source domain dataset and the target domain dataset through a feature extractor;
[0068] Domain-level alignment training: Based on the extracted key features, the Wasserstein distance between the source domain and the target domain is introduced to conduct adversarial training on the feature extractor and the domain discriminator. During the adversarial training process, the domain discriminator is first optimized and trained to determine the parameters of the domain discriminator. At the same time, the feature extractor is trained. The key features of the source domain dataset are extracted using the trained feature extractor, and the classifier is trained based on the extracted key features.
[0069] Category-level alignment training: In the process of classifier training, a pseudo-label generation mechanism is introduced to construct a triplet loss function, and then the classifier and feature extractor are trained and optimized again to determine the parameters of the classifier and feature extractor, and complete the training of the unsupervised domain adaptation model.
[0070] In this embodiment, during the domain alignment training, in the context of domain adaptation, the present invention aims to minimize the Wasserstein distance between the source domain and the target domain so that their data distributions are as similar as possible. and target distribution The goal is to find a mapping T that Map to Make
[0071] In this embodiment, a domain discriminator is used to approximately evaluate the difference between the two distributions. The goal of the domain discriminator is to learn a function f w, which accepts input data and outputs a scalar representing the probability that the data comes from the source domain. Specifically, it is hoped that the domain discriminator can accurately distinguish samples from the source domain and the target domain to promote the feature extractor to learn domain-invariant feature representations. At the same time, the goal of the feature extractor is to deceive the domain discriminator so that it cannot accurately distinguish samples from the source domain and the target domain, thereby achieving data distribution alignment between the two domains.
[0072] Based on this, in this embodiment, the Wasserstein distance between the source domain and the target domain is used to perform adversarial training on the feature extractor and the domain discriminator, thereby transferring knowledge from the source domain to the target domain in an unsupervised manner, and learning domain-invariant feature representations, thereby improving the cross-domain adaptation performance of sleep staging.
[0073] Among them, the training loss function of adversarial training is for:
[0074]
[0075] In the formula, x s and x t Represent the data samples of the source domain and the target domain respectively, and f g (·) represents the function learned by the feature extractor, which maps samples to f The representation of f w (·) represents the function learned by the domain discriminator, D s and D t Represent the source domain dataset and the target domain dataset respectively, n s and n t Represents the number of samples in the source domain and the target domain respectively;
[0076] At the same time, it is crucial to maintain the Lipschitz constraint of the Wasserstein distance to avoid problems such as improper capacity utilization, gradient vanishing or exploding, which will seriously affect the performance of domain adaptation; therefore, in this embodiment, the parameter θ of the domain discriminator is d The gradient norm imposes a penalty As a loss function The constraint condition of maximizing the Wasserstein distance between the source domain and the target domain is expressed as:
[0077]
[0078] In the formula, represents a feature set, which includes key features extracted from the source domain dataset and the target domain dataset, as well as randomly sampled points along the straight line between the source domain and target domain feature pairs. Express Find the partial derivative.
[0079] In this embodiment, during the training of the feature extractor, the function f learned by the feature extractor is g (·) Mapping samples in the source and target domain datasets to parameters θ with feature extractors f The feature representation is then used to train the feature extractor;
[0080] The training goal of feature extraction is opposite to that of the domain discriminator. Its training goal is to d Under the condition of no change, the Wasserstein distance is minimized, which is expressed as:
[0081]
[0082] In the formula, θ f represents the parameters of the feature extractor, θ d represents the parameters of the domain discriminator, represents the training loss function of adversarial training, Represents the parameter θ d The penalty term imposed, ρ represents the weight coefficient, which is set to zero in the minimization process in order to reduce the interference of the gradient penalty on the learning representation process; through the application of adversarial learning, the goal is to make the Wasserstein distance converge, thereby realizing the learning of domain-invariant features.
[0083] In this embodiment, the classifier aims to predict the corresponding label based on the data representation learned by the feature extractor. It includes two fully connected layers and a softmax function, which is used to map the network output to a specific label. In this task, the classifier is trained only with the labeled data of the source domain, without the label information of the target domain, and the trained classifier can be used to predict the target domain data. Based on this, in the domain-level alignment training, the training loss function of the classifier is for:
[0084]
[0085] In the formula, N represents the total number of samples, K represents the number of sleep stage categories, k represents the category index, and i represents the sample index. represents the actual category label of the i-th sample, Represents the predicted label for the i-th sample.
[0086] In this embodiment, based on the classifier training and combined with the loss of the domain discriminator, the objective function of the domain-level alignment training process is obtained as follows:
[0087]
[0088] In the formula, θ f represents the parameters of the feature extractor, θ c represents the parameters of the classifier, θ d represents the parameters of the domain discriminator, represents the classification loss of the classifier, represents the adversarial loss of adversarial training, Represents the parameter θ d The penalty term imposed, λ represents the parameter used to balance the relationship between the discriminative ability and transferability of the feature, ρ is the weight coefficient, and ρ is zero when optimizing the minimum operation.
[0089] In an embodiment of the present invention, the method of category-level alignment training is specifically as follows:
[0090] According to the confidence of the classifier that has completed the domain-level alignment training for classifying samples in the target domain, the predicted labels with high confidence are selected as the pseudo labels of the samples in the target domain dataset;
[0091] Combine the samples of the source domain dataset and the target domain dataset into one, form positive sample pairs with all samples with the same category label, randomly assign a negative sample to each pair of positive samples, and ensure that the distance between each negative sample and the anchor sample is smaller than the distance between the corresponding positive sample and the anchor sample, and then construct a triplet loss function;
[0092] With the goal of minimizing the classification loss of the classifier in the category-level alignment process and maximizing the Wasserstein distance and triplet loss, the classifier and feature extractor are optimized through gradient descent training, the parameters of the classifier and the feature extractor are determined, and the training of the unsupervised domain adaptation model is completed.
[0093] Specifically, on the basis of ensuring global feature consistency, the triple loss function is further used in this embodiment to strengthen the feature alignment at the class level. In practice, the target domain faces the problem of lack of labels, so we introduce a pseudo-label generation mechanism. This mechanism sets a threshold and selects high-confidence predictions as pseudo-labels based on the credibility of the model's classification of target domain samples. The selection of the threshold is adjusted and optimized through experimental verification. Next, the sample batches of the source domain and the target domain are combined into one for constructing triples. In the step of constructing triples, all samples belonging to the same category are formed into positive sample pairs, and a negative sample is randomly assigned to each pair of positive samples. In this process, it is necessary to ensure that the distance between each negative sample and the anchor sample is smaller than the distance between the corresponding positive sample and the anchor sample, thereby optimizing the model's aggregation of samples of the same type and the distinction between samples of different classes.
[0094] This gives the triplet loss function It is expressed as:
[0095]
[0096] Where f(·) represents the domain aligner, and denote anchor samples, positive samples, and negative samples respectively, ∥·∥ represents the L2 norm, m represents a threshold, [·] + represents max(·,0), the subscript i represents the sample index, and N represents the total number of samples.
[0097] Based on the above process, the objective function of the category-level alignment training in this embodiment is:
[0098]
[0099] In the formula, θ f represents the parameters of the feature extractor, θ c represents the parameters of the classifier, θ d represents the parameters of the domain discriminator, represents the classification loss of the classifier, represents the training loss of adversarial training, represents the triplet loss, λ1 and λ2 represent the weight coefficients.
[0100] The embodiment of the present invention provides an experimental example of the sleep staging method described above.
[0101] In this embodiment of the present invention, three datasets are used to evaluate the proposed unsupervised domain adaptation model for sleep staging, namely Sleep-EDF-SC (hereinafter referred to as SC), Sleep-EDF-ST (hereinafter referred to as ST) and a self-collected dataset (Self-Collected Dataset, hereinafter referred to as SCD).
[0102] In order to comprehensively evaluate the performance of the proposed method, precision, recall and F1 score are used to evaluate the performance of each sleep stage. They are calculated for binary classification of a specific category. When this category is regarded as the positive class, the other four categories are regarded as negative classes. Accuracy, kappa coefficient and macro-average F1 score (MF1) are used to evaluate the overall performance.
[0103] In the embodiment, we use Pytorch to implement the proposed sleep staging unsupervised domain adaptation model. The model is trained using the Adam optimizer and the initial learning rate is set to 10 -3 , after 10 epochs, it is reduced to 10 -4 , Adam's weight decay is set to 10 -3The number of training epochs is 100 and the batch size is 128. In this embodiment, the data from the three domains are divided according to the subjects, and are divided into 60%, 20%, and 20% for training, validation, and testing respectively. The training part of the source domain and the target domain are used when training the model, and the validation part and the test part of the target domain are used for validation and testing.
[0104] For the above datasets, only the wakefulness data of the first 30 minutes of the first non-awake sleep stage were retained. Similarly, the last non-awake sleep stage was used as a reference, and only the wakefulness data of the next 30 minutes were retained. According to the AASM standard, the EEG signal is divided into 30-second epoch sequences, sleep is divided into 5 stages, N3 and N4 are merged into one stage, and unknown stages and movement stages that do not belong to any sleep stage are excluded. In addition, since the sampling rate of the SC and ST datasets is 100Hz and the sampling rate of the self-acquired dataset is 250Hz. We downsampled the data of the self-acquired dataset so that the sequence length is the same as that of the SC and ST datasets, that is, 30seconds×100Hz (T=3000). Table 1 shows the distribution of sleep stages of the datasets used.
[0105] Table 1: Distribution of sleep stages in the dataset used
[0106]
[0107] In the experiment, three different domain transfer settings were designed according to different data sets and their characteristics, and each setting contains two transfer scenarios. The first setting is the domain adaptation between health and sleep disorders: it involves the domain adaptation between the sleep data samples of healthy subjects and the data samples of sleep disorder patients with certain difficulty falling asleep. This embodiment uses the SC data set and the ST data set to conduct experiments. The same channels are used in the experiment to represent the health data set and the sleep disorder data set, respectively. The second setting is the adaptation of sleep monitoring equipment differences: it involves the mutual migration between data sets with large differences in sleep monitoring equipment and collection environments. This embodiment uses the SC and SCD data sets to conduct experiments. SCD is a self-collected data set, and the sleep collection equipment, collection channels and collection frequencies used are different from the SC data set. The third setting uses the ST and SCD data sets for mutual migration, which is a more challenging long-distance domain adaptation, indicating that domain adaptation is performed between data sets with different sleep quality, sleep collection equipment, collection channels, and collection frequencies.
[0108] In this experiment, we evaluate the performance of the proposed sleep staging domain adaptation framework by implementing three different domain transfer settings. The classification results for each setting are discussed below.
[0109] (1) Adaptation in the field of healthy and disordered sleep
[0110] In the first setting, we study the domain adaptation problem between healthy people and patients with sleep difficulties. Specifically, our model is specially trained to achieve bidirectional domain adaptation between the SC dataset and the ST dataset, which represent healthy subjects and patients with sleep difficulties, respectively. This means that both the SC and ST datasets have been used as source and target domains, aiming to evaluate the model's adaptation ability in two different transfer directions. In the adaptation experiment with the SC dataset as the source domain and the ST dataset as the target domain, the model achieves an overall accuracy of 81.12%, a Kappa statistic of 0.73, and an F1 score of 75.08% on the ST dataset. In contrast, when the direction of domain adaptation is reversed, that is, the ST dataset is used as the source domain and the SC dataset is used as the target domain, the model exhibits an overall accuracy of 76.07%, a Kappa statistic of 0.67, and an F1 score of 71.44% on the SC dataset, showing that the model has a high overall performance.
[0111] Table 2: Classification performance of SC→ST
[0112]
[0113] Table 3: Classification performance of ST→SC
[0114]
[0115]
[0116] Tables 2 and 3 specifically show the classification performance of each category in the above two migration scenarios. The left side of the table is the confusion matrix of the classification results, and the bold numbers on the main diagonal indicate the number of samples that were correctly classified. The right side of the table shows the performance indicators of each category, including precision, recall, and F1 score. As shown in the table, the F1 score of the model remains above 80% in most sleep stages, showing high classification performance. In particular, in the N2 stage, the F1 score of the model reached 86.49%, which is not only impressive, but also shows that the model has extremely high accuracy and reliability in the classification task of this sleep stage. From Table 4-3, it can be observed that the overall classification performance has decreased in the migration scenario from ST to SC. Nevertheless, we noticed that the classification performance in the N1 stage has increased. This phenomenon may be related to the high proportion of N1 samples in the SC dataset. Since the model is exposed to more N1 samples during training, it shows better performance in the classification task of this stage.
[0117] Figure 3An example of sleep structure migrated from the ST dataset to the SC dataset is shown, where the upper diagram shows the sleep structure manually scored by sleep experts, while the lower diagram shows the sleep structure predicted by the model proposed in this invention. We can see the sleep structure manually annotated by sleep experts based on certain standards and experience. This usually requires expertise and a lot of time to complete, but they provide a reliable benchmark for sleep research. Expert scores are often considered the "gold standard" in sleep research because they are based on a deep understanding of the various stages of the sleep cycle. From the predicted sleep structure in the lower part, it can be seen that this model can automatically identify and classify the various stages of sleep by learning a large amount of sleep data. Comparing the prediction results of the automated model with the manual scoring of the experts, it can be observed that the two are consistent in the division of most sleep stages, which shows that the model has high accuracy and reliability.
[0118] (2) Differential adaptation of sleep monitoring equipment
[0119] In the second scenario setting, we explored in depth the impact of differences between sleep monitoring devices on the model's domain adaptability. The importance of this study lies in the fact that in real applications, sleep monitoring devices may vary due to cost, availability, or personal preference, and these differences may have a significant impact on the quality and characteristics of sleep data. The SC dataset uses a single sleep monitoring device, while the SCD dataset uses different devices and detection channels. This design simulates the device diversity problem that may be encountered in the real world, allowing us to evaluate the performance of the model when adapting to different data collection environments.
[0120] In the domain adaptation experiment from the SC dataset to the SCD dataset, the overall accuracy of the model reached 72.44%, the Kappa statistic was 0.63, and the F1 score was 63.17%. These indicators show that the model still maintains high classification performance in the new device environment. The Kappa statistic of 0.63 indicates a strong consistency between the model prediction and the actual label, while the F1 score reflects that the model has achieved a good balance between precision and recall.
[0121] However, when we reverse the direction of domain adaptation, that is, migrate from the SCD dataset to the SC dataset, the overall accuracy drops slightly to 71%, the Kappa statistic is 0.60, and the F1 score is 64.48%. This result suggests that although the model can adapt to different devices, the differences between devices still have a certain impact on the performance of the model. This may be due to the differences in signal quality, noise level, or feature distribution of the data collected by different devices.
[0122] Table 4: Classification performance of SC→SCD
[0123]
[0124] Table 5: Classification performance of SCD→SC
[0125]
[0126] Table 4 evaluates the classification performance of the model for different sleep stages when migrating from the SC dataset to the SCD dataset. The bold main diagonal numbers in the table not only intuitively show the number of samples correctly classified by the model, but also provide us with the recognition ability of the model in each sleep stage. In the N1 stage, the model's adaptability is not good, which may be related to the significant decrease in the proportion of N1 stage samples in the SCD dataset. The sample proportion is only 4.54%, which means that the model has relatively little training data in this stage, which may lead to the poor classification performance of the model in the N1 stage. This finding suggests that the difference in sample distribution between the source domain and the target domain is an important consideration when performing transfer learning. However, for other sleep stages, the model shows a relatively impressive adaptation performance. This shows that although device differences may have an impact on model performance, the model is still able to learn common features across devices, thereby achieving good classification results on new devices. This is reflected in Table 4, where the classification performance indicators of non-N1 stages, such as precision, recall, and F1 score, all show the robust performance of the model in these stages.
[0127] Table 5 further provides the performance data of the model when migrating the SCD dataset to the SC dataset. This reverse migration provides us with another angle to evaluate the adaptability of the model, and also reveals the challenges that the model may face in migrating data from different devices. By comparing the data in the two tables, we can more comprehensively understand the performance differences of the model in different migration directions.
[0128] Overall, the differences in monitoring devices do have some impact on model performance, especially in sleep stages where samples are unevenly distributed. However, our method still shows a certain degree of adaptability to data collected by different devices.
[0129] Figure 4 It provides us with an intuitive comparison, showing the difference between the sleep structure predicted by the model and the manual classification of experts when migrating the SC dataset to the SCD dataset. Through this visualization, we can deeply understand the performance characteristics and potential challenges of the model when processing data from different devices.
[0130] exist Figure 4Above, we can see the manual staging of sleep architecture by sleep experts based on strict criteria and extensive experience. This staging is often considered the "gold standard" in sleep analysis because it is based on a deep understanding and precise identification of the various stages of the sleep cycle. Figure 4 Below, we show the prediction results of the transfer model for the same sleep structure. By comparing the two figures, we can observe that the model has some fluctuations and ups and downs in the recognition between the N1 stage and the rapid eye movement (REM) stage. These fluctuations indicate that the model has some uncertainty in the boundary recognition between these two stages.
[0131] Stage N1 is a lighter sleep stage in the sleep cycle, similar to the awake state, so manual staging may require more detailed information. The model's difficulty in identifying this stage may be due to the low proportion of stage N1 samples in the SCD dataset, resulting in insufficient training data for the model at this stage. In addition, the signal features collected by different devices may be different, which may also affect the model's ability to identify stage N1.
[0132] (3) Long-distance domain adaptation
[0133] In the last scenario, we explored the problem of long-distance domain adaptation. We conducted experiments using the ST and SCD datasets as each other's source and target domains, which differed in sleep quality, sleep collection devices, collection channels, and collection frequencies, to examine the performance of the model when faced with more significant dataset differences. When the ST dataset plays the role of the source domain and SCD is the target domain, the overall accuracy of the model on SCD is 65.56%, the Kappa statistic is 0.53, and the F1 score is 56.73%. When the SCD dataset is used as the source domain and ST is used as the target domain, the model performance is slightly improved, with an overall accuracy of 68.8%, a Kappa statistic of 0.56, and an F1 score of 61.59%. This performance improvement may be related to the amount of data used as source domain samples.
[0134] Table 6: Classification performance of ST→SCD
[0135]
[0136] Table 7: Classification performance of SCD→ST
[0137]
[0138] Tables 6 and 7 provide detailed classification performance of each sleep stage under the two migration directions. As can be seen from the table, compared with the previous two scene settings, the classification performance of the model in the current scenario has declined in each sleep stage. There may be several reasons for this performance decline. First, the difference between the datasets may be larger, which requires the model to capture more subtle and complex features. Second, if the distribution difference between the source domain and the target domain is large, it may be difficult for the model to learn features that can generalize to the new dataset.
[0139] Figure 5 An example of sleep structure migrated from the SCD dataset to the ST dataset is shown. The upper part is the manual staging by experts, and the lower part is the prediction by the migration model. Due to the difficulty of migration, the structure diagram predicted by the model shows frequent fluctuations.
[0140] When studying different cross-dataset scenario settings, we noticed some interesting results. For example, in the scenario of health and sleep disorder domain adaptation, that is, the bidirectional migration of SC and ST datasets, it showed superior performance, significantly surpassing other scenarios. This phenomenon may be attributed to the fact that although the SC and ST datasets have differences in the sleep health status of the subjects, they are derived from the same larger dataset and share the same signal acquisition equipment and EEG channel configuration, so there is a higher degree of similarity in the feature space. Relatively speaking, the third scenario, that is, the mutual migration of ST and SCD datasets, showed the lowest performance, which reveals the challenges brought by the great differences between the two datasets. These differences include the different sleep health status of the subjects, the diversity of signal acquisition equipment, and the changes in EEG channels, which constitute a typical long-distance domain adaptation problem with high complexity and difficulty. In addition, we also observed that when the amount of source domain data exceeds the amount of target domain data, the model often performs better. For example, the performance in the scenario of migration from SC to ST is better than that in the scenario of migration from ST to SC. This finding emphasizes that sufficient source domain data is crucial for the model to learn the generalization of the inherent laws and features of the data, because this can provide richer information to promote effective knowledge transfer.
[0141] In this embodiment of the present invention, in order to evaluate our proposed sleep staging domain adaptation framework, we compared it with existing advanced domain adaptation models. These models include domain adversarial neural network (DANN), minimum error estimation deep domain adaptation network (MDDA), conditional domain adversarial network (CDAN) and deep sub-domain adaptation network (DSAN). In addition, for a comprehensive evaluation, we also compared two direct transfer sleep staging methods: DeepSleepNet and SleepEEGNet. The direct transfer results of these methods are compared with the direct transfer results using the multi-scale temporal residual shrinkage network (MS-TRSN) as the feature extractor. A brief description of each model is as follows:
[0142] Domain Adversarial Neural Network (DANN): The feature extractor and domain discriminator are jointly trained to reduce the distribution difference between the source and target domains by reversing the gradient of the domain classifier using a gradient reversal layer (GRL).
[0143] Minimum Error Estimation Deep Domain Adaptation Network (MDDA): Maximum Mean Discrepancy (MMD) and Correlation Alignment (CORAL) are applied on multiple classification layers, aiming to minimize the difference between the source and target domains.
[0144] Conditional Domain Adversarial Network (CDAN): Domain adversarial training is implemented to reduce the inter-domain differences by minimizing the cross-covariance between feature representations and classifier predictions.
[0145] Deep Subdomain Adaptation Network (DSAN): Introduced through the subdomain adapter, it learns the differences in feature representations between subdomains and achieves domain adaptation by integrating these subdomain information.
[0146] Table 8: Comparison of accuracy with existing methods
[0147]
[0148] Table 9: Comparison of F1 scores with existing methods
[0149]
[0150]
[0151] By comparing the results in Table 8 and Table 9, we find that all networks based on domain adaptation achieve significant performance improvements over direct transfer methods that do not rely on domain adaptation. Direct transfer experiments on DeepSleepNet, SleepEEGNet, and our proposed MS-TRST model show that the performance is significantly degraded due to the effects of domain shift, including differences in the health status of the subjects and the signal acquisition equipment, so this problem needs to be addressed separately. It is worth noting that our feature extractor MS-TRSN shows better performance in the direct transfer task, which shows that our proposed model is more generalizable and can effectively cope with changes across datasets.
[0152] In addition, compared with other domain adaptation methods, our method performs better in average accuracy and macro F1 score, which are improved by 2.09% to 5.52% and 2.69% to 6.97% respectively. Among the six cross-domain scenarios, four scenarios achieved the best accuracy and F1 score indicators, and two scenarios achieved suboptimal results; this shows that reducing the Wasserstein distance between the source domain and the target domain in an adversarial way can effectively narrow the gap in data distribution between different domains. In addition, by applying the triplet loss, the distance between samples in the same category is reduced, while the interval between samples in different categories is increased, achieving accurate category-level alignment, which helps to improve the performance of the target domain in classification tasks.
[0153] In the embodiment of the present invention, in order to demonstrate the superiority of Wasserstein distance, a comparative experiment was conducted on Wasserstein distance and adversarial loss under the condition of the same feature extractor and classifier. We conducted experiments on three datasets covering six different scenarios. Figure 6 As shown, observing the graphical results, it is found that in most experimental scenarios, Wasserstein distance outperforms adversarial loss under the same conditions, especially in the more difficult long-distance domain adaptation scenario. Specifically, in six different domain adaptation scenarios, Wasserstein distance is 2.78% higher than adversarial loss on average, and only slightly inferior to adversarial loss in the SCD→SC scenario. In more difficult scenarios, such as the ST→SCD scenario, Wasserstein distance is 4.54% higher than adversarial loss; and in the SCD→ST scenario, it is 4.96% higher. These findings show the advantages of Wasserstein distance in the face of domain adaptation challenges.
[0154] In this embodiment of the present invention, in order to further explore the role of triplet loss in unsupervised domain alignment, three other variants of the proposed model are constructed for comparison to analyze the contribution of triplet loss.
[0155] They are:
[0156] (1) Remove the triplet loss and only keep the adversarial domain adaptation method based on Wasserstein metric, denoted as WSDA.
[0157] (2) Only triplet loss is used on source domain data, so no pseudo labels need to be generated, denoted as WSTLDA-S.
[0158] (3) Instead of using triplet loss on the source domain data, pseudo labels are generated to apply triplet loss to the data samples in the target domain, denoted as WSTLDA-T
[0159] We conducted experiments in six domain adaptation scenarios and the results are as follows: Figure 7 As shown in Figure 3, compared with the WSDA method without triplet loss, the other three methods all show higher accuracy, and our approach, which applies triplet loss to both source and target domain data samples, has the most significant improvement. In the WSTLDA-S and WSTLDA-T methods, applying triplet loss only to target domain data samples is better than applying it only to source domain data samples, which may be because the classifier has been fully trained on labeled samples in the source domain.
[0160] In the embodiment of the present invention, UMAP is used to visualize the features learned during the training process for intuitive comparison.
[0161] First, we analyzed the quality of domain alignment. Figure 8 The distribution of source and target domains in the SC→ST scenario is shown. The distribution of source and target domains. In this figure, red dots represent source domain samples and blue dots represent target domain samples. Since the number of source domain samples exceeds the number of target domain samples in this scenario, there are more red dots. Figure 8 (a) shows the results of direct migration using the MS-TRSN model, while Figure 8 (b) shows the results after applying the domain adaptation framework we proposed. By comparison, we can clearly observe that after applying the WSTLDA framework, the overlap of feature distribution in two-dimensional space increases significantly. This result proves that the domain alignment method based on Wasserstein distance proposed in this invention is effective.
[0162] In addition, the present invention further explores the classification performance of the target domain in the above scenario. Fig. 9 This is demonstrated by Fig. 9 (a) in the figure shows the distribution of target domain categories after direct transfer using the MS-TRSN model, while Fig. 9(b) shows the category distribution after the WSTLDA framework is applied to align the samples. Each color point represents a different category of sleep stage. We can observe that in the feature map of direct migration, there are more overlapping samples of different categories, and the distance between different categories is closer, which affects the classification effect of the target domain. In contrast, after adopting the WSTLDA framework, the distance between different categories is significantly increased, and the samples in the same category are more closely clustered, making the boundaries between categories clearer, thereby significantly improving the classification accuracy. This result highlights the key role of triplet loss in our framework, which improves the classification performance by optimizing the distance between and within classes.
[0163] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
[0164] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.
Claims
1. A sleep staging method based on an unsupervised domain adaptive model, characterized in that: The following steps are involved: S1, collect single-channel EEG data and construct source domain data set and target domain data; The source domain dataset includes a number of labeled samples, and the target domain dataset includes a number of unlabeled samples; wherein the source domain and the target domain share the same label space; S2. Build an unsupervised domain adaptation model and train it using the source domain dataset and the target domain dataset to obtain an unsupervised domain adaptation model for sleep staging. The unsupervised domain adaptation model includes a feature extractor, a domain discriminator and a classifier; wherein the feature extractor is used to extract key features of a source domain dataset and a target domain dataset, the domain discriminator is used to measure the dissimilarity between key features in the source domain and the target domain and identify their source domains, and the classifier is used to predict the sleep stage labels of unlabeled samples in the target domain; the training of the unsupervised domain adaptation model includes domain-level alignment training and category-level alignment training; S3. Use the classifier in the unsupervised domain adaptation model of sleep staging to classify the sleep stages of the single-channel EEG data to be identified in the target domain.
2. The sleep staging method based on unsupervised domain adaptive model according to claim 1, characterized in that: In the step S2, in the unsupervised domain adaptation model, the feature extractor is a multi-scale temporal residual shrinkage network.
3. The sleep staging method based on unsupervised domain adaptive model according to claim 1, characterized in that: In step S2, the training method of the unsupervised domain adaptation model is specifically: Extract key features of the source domain dataset and the target domain dataset through a feature extractor; Domain-level alignment training: Based on the extracted key features, the Wasserstein distance between the source domain and the target domain is introduced to perform adversarial training on the feature extractor and the domain discriminator. During the adversarial training process, the domain discriminator is first optimized and then the parameters of the domain discriminator are determined. At the same time, the feature extractor is trained. The trained feature extractor is used to extract key features of the source domain data set, and the classifier is trained based on the extracted key features; Category-level alignment training: In the process of classifier training, a pseudo-label generation mechanism is introduced to construct a triplet loss function, and then the classifier and feature extractor are trained and optimized again to determine the parameters of the classifier and feature extractor, and complete the training of the unsupervised domain adaptation model.
4. The sleep staging method based on supervised domain adaptive model according to claim 3, characterized in that: The feature extractor and domain discriminator are adversarially trained using the Wasserstein distance between the source domain and the target domain, and the training loss function for: In the formula, x s and x t Represent the data samples of the source domain and the target domain respectively, and f g (·) represents the function learned by the feature extractor, f w (·) represents the function learned by the domain discriminator, D s and D t Represent the source domain dataset and the target domain dataset respectively, n s and n t Represents the number of samples in the source domain and the target domain respectively; The parameters θ of the domain discriminator d The gradient norm imposes a penalty As a loss function The constraint condition of maximizing the Wasserstein distance between the source domain and the target domain is expressed as: In the formula, represents a feature set, which includes key features extracted from the source domain dataset and the target domain dataset, as well as randomly sampled points along the straight line between the source domain and target domain feature pairs. Express Find the partial derivative.
5. The sleep staging method based on unsupervised domain adaptive model according to claim 3, characterized in that: During the training of the feature extractor, the function f learned by the feature extractor g (·) Mapping samples in the source and target domain datasets to parameters θ with feature extractors f The feature representation is then used to train the feature extractor; The training target of the feature extractor is the parameter θ of the domain discriminator. d Under the condition of no change, the Wasserstein distance is minimized, which is expressed as: In the formula, θ f represents the parameters of the feature extractor, θ d represents the parameters of the domain discriminator, represents the training loss function of adversarial training, Represents the parameter θ d The penalty term imposed, ρ represents the weight coefficient.
6. The sleep staging method based on unsupervised domain adaptive model according to claim 3, characterized in that: In domain-level alignment training, the training loss function of the classifier is for: In the formula, N represents the total number of samples, K represents the number of sleep stage categories, k represents the category index, and i represents the sample index. represents the actual category label of the i-th sample, Represents the predicted label for the i-th sample.
7. The sleep staging method based on unsupervised domain adaptive model according to claim 3, characterized in that: The objective function of the domain-level alignment training process is: In the formula, θ f represents the parameters of the feature extractor, θ c represents the parameters of the classifier, θ d represents the parameters of the domain discriminator, represents the classification loss of the classifier, represents the adversarial loss of adversarial training, Represents the parameter θ d The penalty term imposed, λ represents the parameter used to balance the relationship between the discriminative ability and transferability of the feature, and ρ is the weight coefficient.
8. The sleep staging method based on unsupervised domain adaptive model according to claim 3, characterized in that: The method of the category-level alignment training is specifically as follows: According to the confidence of the classifier that has completed the domain-level alignment training for classifying samples in the target domain, the predicted labels with high confidence are selected as the pseudo labels of the samples in the target domain dataset; Combine the samples of the source domain dataset and the target domain dataset into one, form positive sample pairs with all samples with the same category label, randomly assign a negative sample to each pair of positive samples, and ensure that the distance between each negative sample and the anchor sample is smaller than the distance between the corresponding positive sample and the anchor sample, and then construct a triplet loss function; With the goal of minimizing the classification loss of the classifier in the category-level alignment process and maximizing the Wasserstein distance and triplet loss, the classifier and feature extractor are optimized through gradient descent training, the parameters of the classifier and the feature extractor are determined, and the training of the unsupervised domain adaptation model is completed.
9. The sleep staging method based on unsupervised domain adaptive model according to claim 8, characterized in that: The triplet loss function It is expressed as: Where f(·) represents the domain aligner, and Represent anchor samples, positive samples and negative samples respectively, ∥·∥ represents L2 norm, m represents a threshold, ,·- + represents max(·,0), the subscript i represents the sample index, and N represents the total number of samples.
10. The sleep staging method based on unsupervised domain adaptive model according to claim 8, characterized in that: The objective function of the category-level alignment training is: In the formula, θ f represents the parameters of the feature extractor, θ c represents the parameters of the classifier, θ d represents the parameters of the domain discriminator, represents the classification loss of the classifier, represents the training loss of adversarial training, represents the triplet loss, λ1 and λ2 represent the weight coefficients.
Citation Information
Patent Citations
Cross-domain target re-identification method based on feature adversarial learning and self-similarity clustering
CN111738172A
Motor imagery electroencephalogram transfer learning method based on Wasserstein distance
CN113010013A
Clustering-based confrontation partial domain adaptive cross-subject EEG emotion recognition method
CN114239652A
Time sequence unsupervised classification method based on confrontation joint maximum mean value difference
CN114638310A
Single-channel electroencephalogram sleep staging method based on semi-supervised learning
CN114841219A