Sleep staging method and system, computer-readable storage medium, and electronic device
By migrating heterogeneous domain adaptive models from EEG signals to sleep data staging tasks on devices such as ECG, the problems of low efficiency of manual sleep staging and cumbersome data collection are solved, and efficient and accurate sleep staging is achieved.
Patent Information
- Application Number
- CN202210611158.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-05-31
AI Technical Summary
Existing sleep staging methods rely on manual inspection, which is inefficient and highly subjective. In addition, devices based on new sensing principles require a cumbersome data collection process, making it difficult to achieve efficient sleep monitoring.
A heterogeneous domain adaptive model is used to learn knowledge through EEG signals and transfer it to the sleep data staging task of devices such as ECG, piezoelectric ceramics, and millimeter-wave radar. The heterogeneous domain adaptive model is used to extract domain-independent features and separate shared features, and the attention mechanism is combined for feature separation and training to achieve automatic sleep staging of unlabeled target domain data.
It avoids the tedious data collection process, improves the timeliness and convenience of sleep monitoring, and improves the accuracy of sleep staging results.
Smart Images

Figure CN114983343B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sleep monitoring, and in particular to a sleep staging method and system thereof, a computer-readable storage medium, and an electronic device. Background Art
[0002] Sleep staging is an important diagnostic tool for diagnosing sleep disorders or assessing sleep quality. It primarily records physiological parameter signals generated during sleep and analyzes the characteristics of these signals to identify sleep stages, which primarily include wakefulness, stage 1 (N1), stage 2 (N2), stage 3 (N3), stage 4 (N4), and rapid eye movement (REM). Manual sleep staging typically relies on human experts visually inspecting physiological parameter signals recorded by polysomnography (PSG). However, this is an inefficient and highly subjective task, making automated sleep staging a hot research topic.
[0003] In recent years, with the development of microelectronics technology, many portable and wearable devices with new sensing principles have emerged. Based on these devices, researchers have proposed a large number of new sleep staging methods, such as models based on single-channel electrocardiogram signals, or models based on non-sensing sleep monitoring methods such as piezoelectric ceramics and millimeter-wave radar. However, most of these models are supervised learning methods, which generally require the use of devices and sleep polygraphs to synchronously record the subject's physiological parameter data during sleep stages, and use EEG signals as a reference to complete the manual labeling of sleep tags. However, data collection is an extremely time-consuming and costly process, which is difficult to implement in some application scenarios. Summary of the Invention
[0004] (1) Purpose of the invention
[0005] The purpose of the present invention is to provide a sleep staging method and its system, computer-readable storage medium, and electronic device. The heterogeneous domain adaptive model can transfer the knowledge learned from EEG signals to the sleep data staging task based on electrocardiogram, piezoelectric ceramics, millimeter wave radar and other equipment. The trained model can realize sleep staging of the target domain data to be tested. This method avoids the tedious data collection process and improves the timeliness and convenience of sleep monitoring work.
[0006] (2) Technical solution
[0007] A first aspect of the present invention provides a sleep staging method, comprising: obtaining sleep data having a first sleep physiological signal as a source domain dataset; obtaining sleep data having a second sleep physiological signal as a target domain dataset; preprocessing the source domain dataset and the target domain dataset to obtain a preprocessed source domain dataset and a preprocessed target domain dataset; training a heterogeneous domain adaptive model based on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain a trained sleep stage classification model; and obtaining a target sleep staging based on the target domain data to be tested and the trained sleep stage classification model.
[0008] Furthermore, the heterogeneous domain adaptive model is trained according to the source domain dataset and the target domain dataset to obtain a trained sleep stage classification model, including: performing domain-independent feature extraction on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of the first dimension; performing shared feature extraction on the feature data of the first dimension to obtain a shared feature map; and performing feature separation based on the attention mechanism on the shared feature map to obtain a domain-shared feature map and a domain-independent feature map.
[0009] Furthermore, domain-independent feature extraction is performed on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of the first dimension, including: the preprocessed source domain dataset includes labeled source domain data, and the labeled source domain data is the sleep data with the first sleep physiological signal with sleep stages labeled; the preprocessed target domain dataset includes labeled target domain data and unlabeled target domain data, and the labeled target domain data is the sleep data with the second sleep physiological signal with sleep stages labeled; the unlabeled target domain data is the sleep data with the second sleep physiological signal without sleep stages labeled; domain-independent feature extraction is performed on the labeled source domain data to obtain first feature data of the first dimension; and domain-independent feature extraction is performed on the labeled target domain data and the unlabeled target domain data to obtain second feature data of the first dimension.
[0010] Furthermore, the feature separation based on the attention mechanism is performed on the shared feature map to obtain the domain-shared feature map and the domain-independent feature map, including: inputting the shared feature map into the channel attention model for processing to obtain the channel attention feature map; wherein the conditional formula of the channel attention model is:
[0011] A c (f)=σ(MLP(AvgPool(f))+MLP(MaxPool(f)))
[0012] Where A C(f) represents channel attention; AvgPool(·) and MaxPool(·) represent global average pooling and global maximum pooling operations, respectively; σ(·) is the activation function; MLP(·) is a shared convolutional network;
[0013] The channel attention feature map is input into the spatial attention model for processing to obtain the attention map; the conditional formula of the spatial attention model is:
[0014] A s (f)=σ(Conv([AvgPool(f);MaxPool(f)]))
[0015] Where A s (f) represents spatial attention; Conv(·) is a single convolutional layer;
[0016] The conditional formula of the attention map is:
[0017] A(f)=A s (A c (f))
[0018] The attention map is divided into domain-shared feature maps and domain-independent feature maps.
[0019] Furthermore, the heterogeneous domain adaptive model is trained according to the source domain dataset and the target domain dataset to obtain a trained sleep period classification model, which also includes: inputting the labeled source domain data and the labeled target domain data in the domain shared feature map into the sleep period classification model for training to obtain a trained sleep period classification model.
[0020] Furthermore, the heterogeneous domain adaptive model is trained according to the source domain dataset and the target domain dataset to obtain a trained sleep stage classification model, which also includes: calculating the total loss value, and adjusting the parameters of the heterogeneous domain adaptive model according to the total loss value to constrain and optimize the heterogeneous domain adaptive model; wherein, the trained sleep stage classification model is input into the domain shared feature map to obtain the expected sleep stage classification data; the sleep stage classification loss value is calculated according to the expected sleep stage classification data; the domain shared feature map is input into the marginal distribution discriminant model to achieve distribution alignment of different domain features in the domain shared feature map, and the marginal distribution loss value is calculated according to the output result of the marginal distribution discriminant model; the domain shared feature map and the sleep classification data output by the sleep stage classification model are input into the conditional distribution discriminant model to achieve distribution alignment of the domain shared feature map. The distribution of different domain features is aligned, and the conditional distribution loss value is calculated according to the output result of the conditional distribution discriminant model; the labeled source domain data in the domain shared feature map is input into the center loss function to constrain the labeled source domain data, so that the discrete degree of samples of the same category in the labeled source domain data is reduced, and the discrete degree of samples of different categories in the labeled source domain data is increased, and the center loss value is obtained according to the output result of the center loss function; the domain independent feature map is input into the domain independent feature difference loss function to maximize the independent feature difference between the labeled source domain data and the labeled target domain data, and the domain independent feature difference loss value is obtained according to the output result of the domain independent feature difference loss function; the total loss value is calculated according to the sleep period classification loss value, marginal distribution loss value, conditional distribution loss value, center loss value and domain independent feature difference loss value.
[0021] Furthermore, a target sleep stage is obtained based on the target domain data to be tested and the trained sleep stage classification model, including: performing domain-independent feature extraction on the target domain data to be tested to obtain feature data to be tested of a first dimension; performing shared feature extraction on the feature data to be tested of the first dimension to obtain a learned shared feature map to be tested; performing feature separation based on the attention mechanism on the learned shared feature map to be tested to obtain a domain-shared feature map to be tested; and inputting the domain-shared feature map to be tested into the trained sleep stage classification model to obtain the target sleep stage.
[0022] Furthermore, the source domain dataset and the target domain dataset are preprocessed to obtain a preprocessed source domain dataset and a preprocessed target domain dataset, including: pre-filtering the source domain dataset and the target domain dataset to eliminate baseline interference and noise interference; segmenting the pre-filtered source domain dataset and the target domain dataset according to a set time length to obtain sleep physiological signals of multiple segments; and normalizing the sleep physiological signals of the multiple segments to obtain multiple standardized sleep physiological signals.
[0023] A second aspect of the present invention provides a sleep staging system, comprising: a first acquisition module, which is used to acquire sleep data having a first sleep physiological signal as a source domain dataset; a second acquisition module, which is used to acquire sleep data having a second sleep physiological signal as a target domain dataset; a preprocessing module, which is used to preprocess the source domain dataset and the target domain dataset to obtain a preprocessed source domain dataset and a preprocessed target domain dataset; a training module, which is used to train a heterogeneous domain adaptive model based on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain a trained sleep stage classification model; and a target sleep staging module, which is used to obtain a target sleep stage based on the target domain data to be tested and the trained sleep stage classification model.
[0024] Furthermore, the training module includes: a domain-independent feature extractor, which is used to perform domain-independent feature extraction on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of the first dimension; a shared feature extractor, which is used to perform shared feature extraction on the feature data of the first dimension to obtain a shared feature map; and a feature separator based on an attention mechanism, which is used to perform feature separation based on the attention mechanism on the shared feature map to obtain a domain-shared feature map and a domain-independent feature map.
[0025] Furthermore, the feature separator based on the attention mechanism includes: a channel attention submodule, which is used to input the shared feature map into the channel attention model for processing to obtain a channel attention feature map; wherein the conditional formula of the channel attention model is:
[0026] A c (f)=σ(MLP(AvgPool(f))+MLP(MaxPool(f)))
[0027] Where A C (f) represents channel attention; AvgPool(·) and MaxPool(·) represent global average pooling and global maximum pooling operations, respectively; σ(·) is the activation function; MLP(·) is a shared convolutional network;
[0028] The spatial attention submodule is used to input the channel attention feature map into the spatial attention model for processing to obtain the attention map; wherein, the conditional formula of the spatial attention model is:
[0029] A s (f)=σ(Conv([AvgPool(f);MaxPool(f)]))
[0030] Where A s (f) represents spatial attention; Conv(·) is a single convolutional layer;
[0031] The conditional formula of the attention map is:
[0032] A(f)=A s (A c (f))
[0033] The partitioning submodule is used to divide the attention map into domain-shared feature maps and domain-independent feature maps.
[0034] Furthermore, the training module also includes: a training submodule, which is used to input the labeled source domain data and the labeled target domain data in the domain shared feature map into the sleep stage classification model for training to obtain a trained sleep stage classification model.
[0035] Furthermore, the training module further includes: an optimizer, which is used to calculate the total loss value and adjust the parameters of the heterogeneous domain adaptive model according to the total loss value to constrain and optimize the heterogeneous domain adaptive model; wherein the scope of the optimizer includes:
[0036] The sleep period classifier is used to input the domain shared feature map into the trained sleep period classification model to obtain the expected sleep period classification data; the sleep period classification loss value is calculated based on the expected sleep period classification data; the marginal distribution discriminator is used to input the domain shared feature map into the marginal distribution discriminant model to achieve distribution alignment of different domain features in the domain shared feature map, and calculate the marginal distribution loss value based on the output result of the marginal distribution discriminant model; the conditional distribution discriminator is used to input the domain shared feature map and the expected sleep period classification data into the conditional distribution discriminant model to achieve distribution alignment of different domain features in the domain shared feature map, and calculate the conditional distribution loss value based on the output result of the conditional distribution discriminant model; the central loss function submodule is used to convert the labeled source domain data in the domain shared feature map into the central loss function. According to the input center loss function, the labeled source domain data is constrained to reduce the discrete degree of samples of the same category in the labeled source domain data and increase the discrete degree of samples of different categories in the labeled source domain data, and the center loss value is obtained according to the output result of the center loss function; the domain independent feature difference loss submodule is used to input the domain independent feature map into the domain independent feature difference loss function to maximize the independent feature difference between the labeled source domain data and the labeled target domain data, and the domain independent feature difference loss value is obtained according to the output result of the domain independent feature difference loss function; the total loss function submodule is used to calculate the total loss value based on the sleep period classification loss value, marginal distribution loss value, conditional distribution loss value, center loss value and domain independent feature difference loss value.
[0037] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0038] A fourth aspect of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements the steps of the above method when executing the computer program.
[0039] (3) Beneficial effects
[0040] The above technical solution of the present invention has the following beneficial technical effects:
[0041] 1. The heterogeneous domain adaptive model in the embodiments of the present invention can achieve semi-supervised functions. This model uses EEG signals as source domain data and ECG or cardiac shock signals collected by devices such as ECG, piezoelectric ceramics, and millimeter-wave radar as target domain data. Combined with a small number of labeled target domain data samples, it can automatically classify sleep stages for unlabeled target domain data. Specifically, the model first constructs feature extractors for heterogeneous domain data sources from different domains. Then, a feature separator with an attention mechanism is used to separate domain-shared features from domain-independent features. On the one hand, the domain-shared branch aligns the hidden layer features of feature data from different domains by constructing marginal distributions and conditional distribution adaptation terms. In addition, the center loss is used to add constraints to the source domain data to reduce the distance within the sleep stage category and increase the distance between categories. On the other hand, the domain-independent branch can extract domain-independent features through feature difference loss. This heterogeneous domain adaptive model can provide an effective and reliable sleep staging algorithm strategy for sleep stage classification models based on novel sensing principles.
[0042] 2. The source domain dataset and the target domain dataset come from different signal sources and are very different. The heterogeneous domain adaptive model can transfer the knowledge learned from EEG signals to the sleep data staging task based on electrocardiogram, piezoelectric ceramics, millimeter-wave radar and other equipment, thereby achieving sleep staging for the target domain data to be tested, avoiding the tedious data collection process and improving the timeliness and convenience of sleep monitoring.
[0043] 3. The technical solution of the embodiment of the present invention can improve the accuracy of sleep staging results by sequentially performing domain-independent feature extraction, shared feature extraction, attention mechanism-based feature separation, and processing with a trained sleep stage classification model on the target domain data to be tested. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is a flowchart of a sleep staging method according to a first embodiment of the present invention;
[0045] Figure 2 is a schematic structural diagram of a sleep staging system according to a second embodiment of the present invention;
[0046] Figure 3 2 is a schematic diagram of the overall framework structure of a heterogeneous domain adaptive model according to a third embodiment of the present invention;
[0047] Figure 4 2 is a schematic diagram of the working principle of the feature separator based on the attention mechanism according to the fourth embodiment of the present invention. DETAILED DESCRIPTION
[0048] To make the objectives, technical solutions, and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings. It should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present invention.
[0049] Numerous EEG-based sleep staging datasets already exist, allowing for the discovery of correlations between EEG features and sleep stages. Furthermore, leveraging EEG sleep staging capabilities to assist sleep monitoring devices using novel sensing principles in performing sleep staging would be a research direction with significant practical significance and application value. However, when comparing EEG signals with signals from novel sensing principles, there are differences in signal sources and sampling rates, and the target domain data is often unlabeled or has only a few labels. Therefore, designing a suitable and effective heterogeneous transfer model is a major challenge.
[0050] To solve the above problems, the first aspect of the present invention provides a sleep staging method, such as Figure 1 As shown, the method specifically includes the following steps:
[0051] Step S100, obtaining sleep data having a first sleep physiological signal as a source domain dataset;
[0052] Step S200 , obtaining sleep data having a second sleep physiological signal as a target domain dataset;
[0053] Step S300, preprocessing the source domain dataset and the target domain dataset to obtain a preprocessed source domain dataset and a preprocessed target domain dataset;
[0054] Step S400 , training a heterogeneous domain adaptive model based on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain a trained sleep stage classification model;
[0055] Step S500 : obtaining target sleep stages according to the target domain data to be tested and the trained sleep stage classification model.
[0056] In some embodiments, the first sleep physiological signal may be an electroencephalogram (EEG) signal, and public sleep datasets such as the Sleep-EDF Database, Montreal Archive of Sleep Studies (MASS), and the MIT-BIH Polysomnographic Database may be obtained as source domain datasets. The second sleep physiological signal may be an electrocardiogram (ECG) signal or a ballistocardiogram (BCP) signal, and sleep datasets may be collected using devices based on novel sensing principles as target domain datasets. Devices based on novel sensing principles include, but are not limited to, devices based on ECG, piezoelectric ceramics, and millimeter-wave radar signals. The preprocessed source domain dataset and the preprocessed target domain dataset eliminate baseline interference and high-frequency noise and can be used as training samples to better train heterogeneous domain adaptive models. A heterogeneous domain adaptive model can be established to conduct end-to-end model training. The trained sleep stage classification model is then applied to the target domain data to be tested, achieving sleep stage classification for the target domain data. The source domain dataset and the target domain dataset come from different signal sources, such as EEG and ECG, which have different signal sources and large differences. This heterogeneous domain adaptive model can transfer the knowledge learned from EEG signals to sleep data staging tasks based on ECG, piezoelectric ceramics, millimeter-wave radar and other equipment, avoiding the tedious dataset collection process, that is, avoiding the need to use equipment and sleep polygraphs to synchronously record the subject's physiological parameter data during sleep stages, and can improve the timeliness and convenience of sleep monitoring work; therefore, this heterogeneous domain adaptive model can provide an effective and reliable sleep staging algorithm strategy for the sleep stage classification model based on the new sensing principle.
[0057] In some embodiments, step S300, preprocessing the source domain dataset and the target domain dataset to obtain a preprocessed source domain dataset and a preprocessed target domain dataset, includes:
[0058] Step S310: pre-filtering the source domain dataset and the target domain dataset to eliminate baseline interference and noise interference;
[0059] Step S320, segmenting the pre-filtered source domain dataset and target domain dataset according to a set time length to obtain sleep physiological signals of multiple segments;
[0060] Step S330 , performing normalization processing on the sleep physiological signals of the plurality of segments to obtain a plurality of normalized sleep physiological signals.
[0061] In an exemplary embodiment, a finite impulse response filter, an infinite impulse response filter, or a wavelet method is used to pre-filter the sleep physiological signal to eliminate baseline interference and high-frequency noise. The original sleep physiological signal is then segmented into 30-second segments. The input sleep physiological signal is then normalized using the Z-Score method, that is, the mean μ and standard deviation σ of the sleep physiological signal are calculated. The normalized sleep physiological signal is:
[0062] In some embodiments, step S400, training the heterogeneous domain adaptive model based on the source domain dataset and the target domain dataset to obtain a trained sleep stage classification model, includes:
[0063] Step S410: performing domain-independent feature extraction on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of a first dimension;
[0064] Step S420, performing shared feature extraction on the feature data of the first dimension to obtain a shared feature map;
[0065] In step S430, feature separation based on the attention mechanism is performed on the shared feature map to obtain a domain-shared feature map and a domain-independent feature map.
[0066] In some embodiments, the preprocessed source domain dataset includes labeled source domain data, wherein the labeled source domain data is sleep data having a first sleep physiological signal with sleep stages labeled; the preprocessed target domain dataset includes labeled target domain data and unlabeled target domain data, wherein the labeled target domain data is sleep data having a second sleep physiological signal with sleep stages labeled; and the unlabeled target domain data is sleep data having a second sleep physiological signal without sleep stages labeled. Step S410: Domain-independent feature extraction is performed on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of a first dimension, including:
[0067] Step S411, performing domain-independent feature extraction on the labeled source domain data to obtain first feature data of a first dimension;
[0068] Step S412: Perform domain-independent feature extraction on the labeled target domain data and the unlabeled target domain data to obtain second feature data of the first dimension.
[0069] In some embodiments, step S430, performing feature separation based on the attention mechanism on the shared feature map to obtain the domain-shared feature map and the domain-independent feature map, includes:
[0070] Step S431: Input the shared feature map into the channel attention model for processing to obtain a channel attention feature map; wherein the conditional formula of the channel attention model is:
[0071] A c (f)=σ(MLP(AvgPool(f))+MLP(MaxPool(f)))
[0072] Where A C (f) represents channel attention; AvgPool(·) and MaxPool(·) represent global average pooling and global maximum pooling operations, respectively; σ(·) is the activation function; MLP(·) is a shared convolutional network;
[0073] Step S432: Input the channel attention feature map into the spatial attention model for processing to obtain an attention map; wherein the conditional formula of the spatial attention model is:
[0074] A s (f)=σ(Conv([AvgPool(f);MaxPool(f)]))
[0075] Where A s (f) represents spatial attention; Conv(·) is a single convolutional layer;
[0076] The conditional formula of the attention map is:
[0077] A(f)=A s (A c (f))
[0078] In step S433, the attention map is divided into a domain-shared feature map and a domain-independent feature map.
[0079] In some embodiments, step S400 of training a heterogeneous domain adaptation model based on a source domain dataset and a target domain dataset to obtain a trained sleep stage classification model further includes:
[0080] Step S440 : Input the labeled source domain data and the labeled target domain data in the domain-shared feature map into the sleep stage classification model for training, thereby obtaining a trained sleep stage classification model.
[0081] In some embodiments, step S400 of training a heterogeneous domain adaptation model based on a source domain dataset and a target domain dataset to obtain a trained sleep stage classification model further includes:
[0082] Step S450: Calculate the total loss value and adjust the parameters of the heterogeneous domain adaptive model according to the total loss value to constrain and optimize the heterogeneous domain adaptive model. Specifically, the following steps are included:
[0083] Step S451: Input the domain-shared feature map into the trained sleep stage classification model to obtain expected sleep stage classification data; calculate the sleep stage classification loss value based on the expected sleep stage classification data;
[0084] Step S452: Input the domain shared feature map into the edge distribution discriminant model to achieve distribution alignment of different domain features in the domain shared feature map, and calculate the edge distribution loss value based on the output result of the edge distribution discriminant model;
[0085] Step S453: Input the domain-shared feature map and the sleep classification data output by the sleep stage classification model into a conditional distribution discriminant model to achieve distribution alignment of different domain features in the domain-shared feature map. Calculate the conditional distribution loss value based on the output of the conditional distribution discriminant model.
[0086] Step S454: Input the labeled source domain data in the domain shared feature map into a center loss function to constrain the labeled source domain data, thereby reducing the dispersion of samples of the same category in the labeled source domain data and increasing the dispersion of samples of different categories in the labeled source domain data. A center loss value is obtained based on the output of the center loss function.
[0087] Step S455: Input the domain-independent feature map into the domain-independent feature difference loss function to maximize the independent feature difference between the labeled source domain data and the labeled target domain data, and obtain a domain-independent feature difference loss value according to the output result of the domain-independent feature difference loss function;
[0088] Step S456 , calculating a total loss value based on the sleep period classification loss value, the marginal distribution loss value, the conditional distribution loss value, the central loss value, and the domain independent feature difference loss value.
[0089] In an exemplary embodiment, the marginal distribution discriminant model and the conditional distribution discriminant model may be composed of a multi-layer deep neural network model, including but not limited to a convolutional neural network and a fully connected network.
[0090] In some embodiments, step S500, obtaining a target sleep stage based on the target domain data to be measured and the trained sleep stage classification model, includes:
[0091] Step S510, performing domain-independent feature extraction on the target domain data to be measured to obtain feature data to be measured in the first dimension;
[0092] Step S520, extracting shared features from the feature data to be tested in the first dimension to obtain a learned and shared feature map to be tested;
[0093] Step S530, performing feature separation based on the attention mechanism on the learned shared feature map to be tested, to obtain a domain-shared feature map to be tested;
[0094] Step S540 : Input the domain-shared feature map to be tested into the trained sleep stage classification model to obtain the target sleep stage.
[0095] A second aspect of the present invention provides a sleep staging system, such as Figure 2 As shown, it includes: a first acquisition module 10, which is used to acquire sleep data with a first sleep physiological signal as a source domain dataset; a second acquisition module 20, which is used to acquire sleep data with a second sleep physiological signal as a target domain dataset; a preprocessing module 30, which is used to preprocess the source domain dataset and the target domain dataset to obtain a preprocessed source domain dataset and a preprocessed target domain dataset; a training module 40, which is used to train a heterogeneous domain adaptive model according to the preprocessed source domain dataset and the preprocessed target domain dataset to obtain a trained sleep stage classification model; a target sleep staging module 50, which is used to obtain a target sleep stage according to the target domain data to be tested and the trained sleep stage classification model.
[0096] In some embodiments, the training module 40 includes: a domain-independent feature extractor 41, which is used to perform domain-independent feature extraction on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of the first dimension; a shared feature extractor 42, which is used to perform shared feature extraction on the feature data of the first dimension to obtain a shared feature map; and an attention mechanism-based feature separator 43, which is used to perform attention mechanism-based feature separation on the shared feature map to obtain a domain-shared feature map and a domain-independent feature map.
[0097] In some embodiments, the domain-independent feature extractor 41 includes: a source domain feature extractor 411, which is used to perform domain-independent feature extraction on labeled source domain data to obtain first feature data of a first dimension; a target domain feature extractor 412, which is used to perform domain-independent feature extraction on labeled target domain data and unlabeled target domain data to obtain second feature data of the first dimension.
[0098] In some embodiments, the attention-based feature separator 43 includes a channel attention submodule 431, which is used to input the shared feature map into the channel attention model for processing to obtain a channel attention feature map; wherein the conditional formula of the channel attention model is:
[0099] A c (f)=σ(MLP(AvgPool(f))+MLP(MaxPool(f)))
[0100] Where A C (f) represents channel attention; AvgPool(·) and MaxPool(·) represent global average pooling and global maximum pooling operations, respectively; σ(·) is the activation function; MLP(·) is a shared convolutional network;
[0101] The spatial attention submodule 432 is used to input the channel attention feature map into the spatial attention model for processing to obtain an attention map; wherein the conditional formula of the spatial attention model is:
[0102] A s (f)=σ(Conv([AvgPool(f);MaxPool(f)]))
[0103] Where A s (f) represents spatial attention; Conv(·) is a single convolutional layer;
[0104] The conditional formula of the attention map is:
[0105] A(f)=A s (A c (f))
[0106] The partitioning submodule is used to divide the attention map into domain-shared feature maps and domain-independent feature maps.
[0107] In some embodiments, the training module further includes: a training submodule configured to input labeled source domain data and labeled target domain data in the domain-shared feature map into the sleep stage classification model for training to obtain a trained sleep stage classification model.
[0108] In some embodiments, the training module further includes an optimizer configured to calculate a total loss value and adjust parameters of the heterogeneous domain adaptation model based on the total loss value to constrain and optimize the heterogeneous domain adaptation model. The optimizer may be used to:
[0109] A sleep period classifier is used to input the domain-shared feature map into the trained sleep period classification model to obtain expected sleep period classification data; a sleep period classification loss value is calculated based on the expected sleep period classification data; a marginal distribution discriminator is used to input the domain-shared feature map into the marginal distribution discriminant model to achieve distribution alignment of different domain features in the domain-shared feature map, and calculate the marginal distribution loss value based on the output result of the marginal distribution discriminant model; a conditional distribution discriminator is used to input the domain-shared feature map and the expected sleep period classification data into the conditional distribution discriminant model to achieve distribution alignment of different domain features in the domain-shared feature map, and calculate the conditional distribution loss value based on the output result of the conditional distribution discriminant model; a center loss function submodule is used to input the labeled source domain data in the domain-shared feature map into the center loss function to constrain the labeled source domain data so as to reduce the discrete degree of samples of the same category in the labeled source domain data and increase the discrete degree of samples of different categories in the labeled source domain data, and obtain the center loss value based on the output result of the center loss function; a domain-independent feature difference loss submodule is used to input the domain-independent feature map into the domain-independent feature difference loss function, In order to maximize the independent feature difference between the labeled source domain data and the labeled target domain data, the domain independent feature difference loss value is obtained according to the output result of the domain independent feature difference loss function; the total loss function submodule is used to calculate the total loss value based on the sleep period classification loss value, marginal distribution loss value, conditional distribution loss value, center loss value and domain independent feature difference loss value.
[0110] The following is a detailed description of the process of training the heterogeneous domain adaptive model with reference to the accompanying figures. The overall framework of the model is as follows: Figure 3 As shown, it can be trained end-to-end.
[0111] 1. Definition: The labeled source dataset can be defined as The labeled source dataset is, for example, an EEG signal dataset for sleep staging; where x represents the EEG signal and y represents the sleep staging label that has been annotated by human experts; the unlabeled target dataset is a definable The unlabeled target dataset is, for example, an ECG signal or a cardiac shock signal dataset for sleep staging, which means that the dataset is not labeled with sleep staging labels. The labeled target domain data can be defined as The labeled target domain data is, for example, an ECG signal or a heartbeat signal dataset used for sleep staging, where x represents the EEG signal and y represents the sleep staging label that has been annotated by human experts. Since labeling these signals is a time-consuming and costly task, in practice, only a small number of target domain data signals are labeled, and a large number of other signals are unlabeled. s , n l and nu is the number of labeled source domain data, labeled target domain data, and unlabeled target domain data samples. Generally, in real application scenarios, the number of labeled target domain data samples is much smaller than the number of unlabeled target domain data samples, and also smaller than the number of labeled source domain data samples, i.e., n l <<n u <n s The label spaces of source domain data samples and target domain data samples are consistent, but because the source domain data samples and target domain data samples come from different signal sources, such as EEG signals and ECG signals, their signal sources are different and their physiological generation mechanisms are different, so their original feature spaces are different. The purpose of the embodiment of the present invention is to use labeled source domain data and a small amount of labeled target domain data as training samples to input the model to obtain a trained model, so that sleep staging can be implemented for unlabeled data in the target domain, that is, to implement sleep staging recognition for unlabeled ECG signals or cardiac shock signals, and identify them as one of the label categories of Wake, N1, N2, N3, N4, and REM.
[0112] 2. Domain-Independent Feature Extractor: Parameters of sleep physiological signals from different signal sources often suffer from inconsistent sampling rates. For example, an EEG signal might have a sampling rate of 500Hz, while an ECG signal might only have a sampling rate of 250Hz. Resampling is a common method to address this data sampling rate inconsistency, but it inevitably alters the original signal information. Furthermore, due to the different data types in the source and target domains, the mapping functions used to map sleep physiological signals to the same feature space can also differ. To address this issue, embodiments of the present invention first utilize a domain-independent feature extractor to map the source and target domain data to a feature space of the same dimensionality through differential mapping. A feature space is a higher-dimensional abstraction of the original data. For sleep physiological signals such as EEG, ECG, and heart rate, a waveform is displayed, but to classify them, patterns within the sleep physiological signals need to be identified. The feature space is the dimension at which these patterns reside. Furthermore, due to the aforementioned sampling rate inconsistency, the source and target domain data inputs are processed separately through differential mapping to ensure consistent dimensionality, for example, a three-dimensional matrix of 128*25*15. The domain-independent feature extractor can be composed of a multi-layer deep neural network model, including but not limited to a convolutional neural network and a fully connected network.
[0113] 3. Shared Feature Extractor: The feature data from the source and target domains are fed into a shared feature extractor E(·) (which can be understood as a model or function) to learn a shared feature representation. The shared feature extractor can be constructed using a convolutional neural network or a fully connected network. The input dimensions are unified before the feature data enters the shared feature extractor. The input to the shared feature extractor can be viewed as a multidimensional vector. For example, raw EEG or ECG signals may have different lengths, but before entering the shared feature extractor, they are transformed into a three-dimensional matrix of a specific size (e.g., 128*25*15), thus achieving a unified input dimension. This three-dimensional matrix is also called a "feature map" in neural networks.
[0114] 4. Feature separator based on attention mechanism: The embodiment of the present invention uses a feature separator based on attention mechanism to generate domain-shared features and domain-independent features. The working principle of the feature separator based on attention mechanism is as follows: Figure 4 As shown, for the input feature map where C is the number of convolution kernels in the last convolutional layer of E(·), H is the number of EEG signal channels, and W is the width of the feature map.
[0115] 1) Calculate channel attention:
[0116] A c (f)=σ(MLP(AvgPool(f))+MLP(MaxPool(f)))
[0117] In the formula, AvgPool(.) and MaxPool(.) represent global average pooling and global maximum pooling operations respectively, which are used to transform the feature map so that the original feature map is compressed in the H and W dimensions to generate a feature map of size C×1×1, which means a multi-dimensional vector of size C×1×1. Global average pooling and global maximum pooling focus on different information. Combining the two modules helps to improve the feature representation ability of the model. Afterwards, the output result will be input into a shared convolutional network MLP(·), which consists of two layers of convolutional layers. The first layer can compress the number of convolution kernels to prevent overfitting, and the second layer restores the number of original convolution kernels. Finally, the two feature maps are added element-wise; that is, if the two feature maps are the same size, for example, they are both three-dimensional matrices of size 128*25*15, then the numbers of the elements in their corresponding positions can be added and sent to the activation function σ(·). The activation function is generally a sigmoid(·) function, so the output channel attention The element values will be distributed in the range of 0 to 1.
[0118] 2) Calculating spatial attention:
[0119] A s (f)=σ(Conv([AvgPool(f);MaxPool(f)]))
[0120] Here, AvgPool(·) and MaxPool(·) are similarly global average pooling and global maximum pooling operations, but in the spatial attention mechanism, they target dimension C. They compress the original feature map along dimension C, generating a feature map of size 1 × H × W. This allows the model to learn which regions of data deserve more attention. After performing global average pooling and global maximum pooling on the input, the results are concatenated and then fed into a single convolutional layer with a kernel size of 1 × 3. Finally, the result is fed into the activation function σ(·).
[0121] First, the original feature map can be input into the channel attention module, and then the obtained feature map is further input into the spatial attention module. The attention map can finally be expressed as:
[0122] A(f)=A s (A c (f))
[0123] Using the generated attention map A(f), the network (“network” can refer to a neural network, or can be understood as a model or function) can be further divided into domain-shared branches and domain-independent branches, corresponding to the domain-shared feature map f c and domain-independent feature map f s (Each branch passes a feature map) so that f = f c +f s :
[0124]
[0125]
[0126] Where, This is an element-wise multiplication operation. The separated feature maps are fed into Network 1 (I1(·)) and Network 2 (I2(·)) for further processing. Network 1 and Network 2 consist of fully connected layers, primarily used to reduce the dimensionality of the outputs of the preceding networks. This reduces computational effort and prevents overfitting caused by excessive parameter counts.
[0127] For heterogeneous signals from different domains, the introduction of domain-shared and domain-independent features allows both source and target domain data to learn better shared features while also ensuring feature integrity. The output of "Network 1" in the domain-shared branch is further input into the marginal distribution discriminator, conditional distribution discriminator, sleep phase classifier, and center loss function modules.
[0128] 5. Sleep classifier: After the “Network 1” of the domain sharing branch, two fully connected layers are connected to form the classifier C(·; θ C ) is applied to source domain data samples and some labeled target domain data samples to achieve training and learning for sleep stage classification. The sleep stage classifier requires signals and labels, so unlabeled target domain data samples do not need to participate in training. The sleep stage classification loss function is:
[0129]
[0130] Among them L WCE is the weighted cross entropy loss function, n s is the number of samples of labeled source domain data, n l is the number of samples of labeled target domain data, and are the labels of the sleep stage categories of the labeled source domain data and a small number of labeled target domain data samples. In addition, E SH (·)=I1(E(·)), which means that the output of feature extractor E(·) is further reduced in dimension through "network 1".
[0131] 6. Marginal distribution discriminator and conditional distribution discriminator: Using marginal distribution discriminator D g (·) and C conditional distribution discriminators align the distributions of features from different domains. Because feature maps from the source and target domains each have their own distributions, distribution alignment aims to make their distributions as similar as possible, allowing the model to generate feature representations that are not specific to the input signal type while retaining information related to sleep stages. This allows the source and target domain data to be classified using the same sleep stage classifier. The marginal distribution discriminator and conditional distribution discriminator can be implemented using convolutional neural networks or fully connected neural networks.
[0132] 1) The marginal distribution loss function is:
[0133]
[0134] Where, and d i They are input samples x iDomain-independent feature extraction function and domain label, if the input is source domain data, the domain label is 1, and If the input is target domain data, the domain label is 0, and n s and n t are the number of labeled source domain samples and the number of labeled target domain samples, L BCE (·) is the binary cross entropy loss function.
[0135] However, using only marginal distribution alignment cannot achieve more accurate distribution alignment at the sleep stage classification level, which may result in insufficient performance of heterogeneous transfer tasks. Therefore, the present invention establishes C discriminators to align the distribution of source domain feature maps and target domain feature maps for each category. The sleep stage classification sample x is obtained by the sleep stage classifier. i The probability of belonging to a certain category k is The discriminator for category k is It can be implemented using a convolutional neural network or a fully connected neural network, so the conditional distribution loss function is:
[0136]
[0137] Where C is the number of categories.
[0138] 7. Center Loss Function Module: The above process aligns the marginal distribution and conditional distribution. To further reduce the dispersion of samples in the same sleep stage category and increase the dispersion of different categories, for example, if there are 5 samples in the EEG signal belonging to the Wake stage and 3 samples belonging to the N2 stage, then the intra-category dispersion of the sleep stage category of these 5 Wake stage samples should be minimized. In addition, the intra-category dispersion of the 3 N2 stage samples should also be minimized. However, the category dispersion between the 5 Wake stage samples and the 3 N2 stage samples should be maximized, because they do not belong to the same category. To achieve this goal, a center loss function module is proposed to constrain the source domain data:
[0139]
[0140] Where c j is the centroid of the feature vector of category j, which serves as the parameter θ to be trained center Added to the overall model, the center loss L center Relative to x i The gradient of is:
[0141]
[0142] Ideally, c jIt should be calculated from all samples of a particular category in the training set, but in order to improve the efficiency of the algorithm, we update it in each training batch. The update equation is:
[0143]
[0144] Where δ(·) is:
[0145]
[0146] 8. Domain-independent feature difference loss module: In the domain-independent branch, in order to maximize the difference between independent features from different domains, for example, if the source domain data is EEG signals and the target domain data is ECG or cardiac shock signals, it is necessary to introduce a difference measure. Increasing the difference loss will encourage the network to generate domain-independent features with large differences. This embodiment of the present invention measures the size of the difference through the maximum mean difference (MMD). This formula is also calculated based on the feature map, such as Figure 2 As shown in Figure 2, since MMD is a parameter-free method, its parameters do not need to be trained, and the domain-independent feature difference loss function is:
[0147]
[0148] In the formula, φ(·) maps the samples of the source and target domains to the kernel k(x i , x j )=φ(x i ) T φ(x j ) associated Hilbert space In the example above, we can use Gaussian kernel function to solve the mean difference.
[0149] 9. Overall loss function and optimization: Based on the above modules, the total loss function is:
[0150]
[0151] Where α, β, and η are the balance parameters that need to be adjusted, and the optimization goal is a minimum-maximum process:
[0152]
[0153]
[0154] In the first equation, the marginal distribution discriminator and the conditional distribution discriminator are to maximize the distinction between feature maps of different domains. Therefore, they try to minimize L g and L cond , that is, maximize Ltotal In the second equation, the feature extractor attempts to generate features that are difficult for the marginal distribution discriminator and the conditional distribution discriminator to discriminate. Therefore, it maximizes L g and L cond , that is, minimize L total The purpose of the sleep stage classifier is to accurately predict the sleep stage, so its goal is to minimize L total In addition, the center loss function should minimize L total , in order to reduce the discreteness of samples of the same sleep stage category and increase the discreteness of samples of different sleep stage categories; and the domain independent feature difference loss function is to maximize L total , because this allows the unique feature maps of the source domain data and the target domain data to be separated. During the model training process, the above processes can be performed alternately to complete the optimization, and the optimizer can use the stochastic gradient descent algorithm.
[0155] After the model training in step 400, the parameters of the entire heterogeneous domain adaptive model have been determined. At this point, the model has the ability to classify sleep stages. It can be applied to the unlabeled target domain dataset to classify sleep stages for these samples. Figure 3 , the direction of the unlabeled target domain data to be tested is "target domain feature extractor → shared feature extractor → network 1 → sleep stage classifier", and finally outputs the target sleep stage result.
[0156] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0157] A fourth aspect of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements the steps of the above method when executing the computer program.
[0158] It should be understood that the above-described specific embodiments of the present invention are merely illustrative or illustrative of the principles of the present invention and do not constitute limitations of the present invention. Therefore, any modifications, equivalent substitutions, improvements, etc. made without departing from the spirit and scope of the present invention should be included within the scope of protection of the present invention. In addition, the appended claims are intended to cover all variations and modifications that fall within the scope and metes and bounds of the appended claims, or equivalents thereof.
[0159] Those skilled in the art will appreciate that all or part of the steps in the above-described method embodiments can be accomplished by instructing related hardware through a program. The program can be stored in a computer-readable storage medium. When executed, the program includes the following process steps of the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0160] The steps in the method of the embodiment of the present invention can be adjusted in order, combined, or deleted according to actual needs. The modules in the system of the embodiment of the present invention can be combined, divided, or deleted according to actual needs.
Claims
1. A sleep staging method, characterized in that: include: Acquiring sleep data having a first sleep physiological signal as a source domain dataset; Acquiring sleep data with a second sleep physiological signal as a target domain dataset; Preprocessing the source domain dataset and the target domain dataset to obtain a preprocessed source domain dataset and a preprocessed target domain dataset; Training the heterogeneous domain adaptation model based on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain a trained sleep stage classification model, including: performing domain-independent feature extraction on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of the first dimension; Perform shared feature extraction on the feature data of the first dimension to obtain a shared feature map; perform feature separation based on the attention mechanism on the shared feature map to obtain a domain-shared feature map and a domain-independent feature map; The target sleep stage is obtained based on the target domain data to be tested and the trained sleep stage classification model.
2. The sleep staging method according to claim 1, wherein: Perform domain-independent feature extraction on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of the first dimension, including: The pre-processed source domain data set includes labeled source domain data, where the labeled source domain data is sleep data having the first sleep physiological signal and has sleep stages annotated thereon; The preprocessed target domain data set includes labeled target domain data and unlabeled target domain data, wherein the labeled target domain data is the sleep data with the second sleep physiological signal that has been labeled with sleep stages; the unlabeled target domain data is the sleep data with the second sleep physiological signal that has not been labeled with sleep stages; Perform domain-independent feature extraction on the labeled source domain data to obtain first feature data of the first dimension; Domain-independent feature extraction is performed on the labeled target domain data and the unlabeled target domain data to obtain second feature data of the first dimension.
3. The sleep staging method according to claim 2, characterized in that: The feature separation based on the attention mechanism is performed on the shared feature map to obtain the domain-shared feature map and the domain-independent feature map, including: The shared feature map is input into the channel attention model for processing to obtain the channel attention feature map; wherein, the conditional formula of the channel attention model is: A c (f)=σ(MLP(AvgPool(f))+MLP(MaxPool(f))) Where A c (f) represents channel attention; f represents the shared feature map, where where C is the number of convolution kernels in the last convolutional layer of E(·), H is the number of EEG signal channels, and W is the width of the shared feature map; AvgPool(·) and MaxPool(·) represent global average pooling and global maximum pooling operations, respectively; σ(·) is the activation function; MLP(·) is the shared convolutional network; The channel attention feature map is input into the spatial attention model for processing to obtain the attention map; the conditional formula of the spatial attention model is: A s (f)=σ(Conv([AvgPool(f);MaxPool(f)])) Where A s (f) represents spatial attention; Conv(·) is a single convolutional layer; The conditional formula of the attention map is: A(f)=A s (A c (f)) The attention map is divided into domain-shared feature maps and domain-independent feature maps.
4. The sleep staging method according to claim 3, characterized in that: The heterogeneous domain adaptation model is trained based on the source domain dataset and the target domain dataset to obtain a trained sleep stage classification model, which also includes: The labeled source domain data and the labeled target domain data in the domain shared feature map are input into the sleep stage classification model for training to obtain a trained sleep stage classification model.
5. The sleep staging method according to claim 4, characterized in that: The heterogeneous domain adaptation model is trained based on the source domain dataset and the target domain dataset to obtain a trained sleep stage classification model, which also includes: Calculate the total loss value and adjust the parameters of the heterogeneous domain adaptive model according to the total loss value to constrain and optimize the heterogeneous domain adaptive model; Inputting the domain-shared feature map into the sleep stage classification model to obtain expected sleep stage classification data; calculating the sleep stage classification loss value based on the expected sleep stage classification data; The domain shared feature map is input into the marginal distribution discriminant model to achieve distribution alignment of different domain features in the domain shared feature map, and the marginal distribution loss value is calculated according to the output result of the marginal distribution discriminant model; The domain-shared feature map and the sleep classification data output by the sleep stage classification model are input into the conditional distribution discriminant model to achieve distribution alignment of different domain features in the domain-shared feature map. The conditional distribution loss value is calculated based on the output of the conditional distribution discriminant model. The labeled source domain data in the domain shared feature map is input into the center loss function to constrain the labeled source domain data so that the discrete degree of samples of the same category in the labeled source domain data is reduced and the discrete degree of samples of different categories in the labeled source domain data is increased. The center loss value is obtained according to the output result of the center loss function. The domain-independent feature map is input into the domain-independent feature difference loss function to maximize the independent feature difference between the labeled source domain data and the labeled target domain data, and the domain-independent feature difference loss value is obtained according to the output result of the domain-independent feature difference loss function; The total loss value is calculated based on the sleep period classification loss value, marginal distribution loss value, conditional distribution loss value, central loss value and domain-independent feature difference loss value.
6. The sleep staging method according to claim 4, characterized in that: Based on the target domain data to be tested and the trained sleep stage classification model, the target sleep stage is obtained, including: Perform domain-independent feature extraction on the target domain data to be tested to obtain the feature data to be tested in the first dimension; Extracting shared features from the feature data to be measured in the first dimension to obtain a shared feature map to be measured; Perform feature separation based on the attention mechanism on the shared feature map to be tested to obtain the domain shared feature map to be tested; The domain-shared feature map to be tested is input into the trained sleep stage classification model to obtain the target sleep stage.
7. The sleep staging method according to claim 1, wherein: Preprocessing the source domain dataset and the target domain dataset to obtain a preprocessed source domain dataset and a preprocessed target domain dataset includes: Pre-filtering the source domain dataset and the target domain dataset to eliminate baseline interference and noise interference; Segmenting the pre-filtered source domain dataset and target domain dataset according to a set time length to obtain sleep physiological signals of multiple segments; The sleep physiological signals of the multiple segments are normalized to obtain multiple normalized sleep physiological signals.
8. A sleep staging system, characterized in that: include: A first acquisition module, configured to acquire sleep data having a first sleep physiological signal as a source domain dataset; a second acquisition module, configured to acquire sleep data having a second sleep physiological signal as a target domain dataset; A preprocessing module, configured to preprocess the source domain dataset and the target domain dataset to obtain a preprocessed source domain dataset and a preprocessed target domain dataset; A training module, which is used to train the heterogeneous domain adaptive model based on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain a trained sleep stage classification model, includes: a domain-independent feature extractor, which is used to perform domain-independent feature extraction on the preprocessed source domain dataset and the preprocessed target domain dataset to obtain feature data of the first dimension; a shared feature extractor, which is used to perform shared feature extraction on the feature data of the first dimension to obtain a shared feature map; and a feature separator based on the attention mechanism, which is used to perform feature separation based on the attention mechanism on the shared feature map to obtain a domain-shared feature map and a domain-independent feature map; The target sleep stage module is used to obtain the target sleep stage based on the target domain data to be tested and the trained sleep stage classification model.
9. The sleep staging system according to claim 8, characterized in that: The feature separator based on the attention mechanism includes: The channel attention submodule is used to input the shared feature map into the channel attention model for processing to obtain the channel attention feature map; wherein, the conditional formula of the channel attention model is: A c (f)=σ(MLP(AvgPool(f))+MLP(MaxPool(f))) Where A c (f) represents channel attention; f represents the shared feature map, where where C is the number of convolution kernels in the last convolutional layer of E(·), H is the number of EEG signal channels, and W is the width of the shared feature map; AvgPool(·) and MaxPool(·) represent global average pooling and global maximum pooling operations, respectively; σ(·) is the activation function; MLP(·) is the shared convolutional network; The spatial attention submodule is used to input the channel attention feature map into the spatial attention model for processing to obtain the attention map; wherein, the conditional formula of the spatial attention model is: A s (f)=σ(Conv([AvgPool(f);MaxPool(f)])) Where A s (f) represents spatial attention; Conv(·) is a single convolutional layer; The conditional formula of the attention map is: A(f)=A s (A c (f)) The partitioning submodule is used to divide the attention map into domain-shared feature maps and domain-independent feature maps.
10. The sleep staging system according to claim 8, characterized in that: The training module also includes: The training submodule is used to input the labeled source domain data and the labeled target domain data in the domain shared feature map into the sleep stage classification model for training to obtain a trained sleep stage classification model.
11. The sleep staging system according to claim 8, characterized in that: The training module also includes: An optimizer is used to calculate the total loss value and adjust the parameters of the heterogeneous domain adaptive model according to the total loss value to constrain and optimize the heterogeneous domain adaptive model; wherein the scope of the optimizer includes: a sleep stage classifier, which is used to input the domain-shared feature map into the trained sleep stage classification model to obtain expected sleep stage classification data; and calculate the sleep stage classification loss value based on the expected sleep stage classification data; The marginal distribution discriminator is used to input the domain shared feature map into the marginal distribution discriminant model to achieve distribution alignment of different domain features in the domain shared feature map, and calculate the marginal distribution loss value according to the output result of the marginal distribution discriminant model; A conditional distribution discriminator is used to input the domain shared feature map and the expected sleep stage classification data into a conditional distribution discriminant model to achieve distribution alignment of different domain features in the domain shared feature map, and calculate the conditional distribution loss value based on the output result of the conditional distribution discriminant model; The center loss function submodule is used to input the labeled source domain data in the domain shared feature map into the center loss function to constrain the labeled source domain data so as to reduce the dispersion of samples of the same category in the labeled source domain data and increase the dispersion of samples of different categories in the labeled source domain data. The center loss value is obtained according to the output of the center loss function. The domain-independent feature difference loss submodule is used to input the domain-independent feature map into the domain-independent feature difference loss function to maximize the independent feature difference between the labeled source domain data and the labeled target domain data, and obtain the domain-independent feature difference loss value according to the output result of the domain-independent feature difference loss function; The total loss function submodule is used to calculate the total loss value based on the sleep period classification loss value, marginal distribution loss value, conditional distribution loss value, center loss value and domain independent feature difference loss value.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
13. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory, wherein when the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Sleep staging method and device
CN113951821A