Sleep staging method and device, electronic device and storage medium

By acquiring and processing the user's heartbeat signal and breathing signal in non-professional scenarios, and using multi-head patch encoders and Transformer classifiers, it solves the problem of limited acquisition capabilities of home equipment and achieves flexible and accurate sleep stage detection.

CN118177740BActive Publication Date: 2024-10-11BEIJING WUJI MEDICAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410591523.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-13
Publication Date
2024-10-11
Estimated Expiration
2044-05-13

Smart Images

  • Figure CN118177740B_ABST
    Figure CN118177740B_ABST
Patent Text Reader

Abstract

The present application provides a sleep staging method and device, an electronic device and a storage medium, the method comprising: obtaining a heartbeat signal and a breathing signal after the user clock is aligned; preprocessing the heartbeat signal and the breathing signal to obtain a heartbeat interval sequence and a breathing waveform of a specific frequency band; dividing the heartbeat interval sequence and the breathing waveform of the specific frequency band by a first duration as a division unit, and obtaining multiple groups of data to be processed, wherein each group of data to be processed includes a heartbeat interval sequence data of a first duration and a breathing waveform data of a first duration; inputting the multiple groups of data to be processed into a multi-head patch encoder for encoding, and obtaining a token sequence corresponding to each group of data to be processed; inputting the multiple token sequences corresponding to the multiple groups of data to be processed into a Transformer-based classifier; and obtaining a sleep staging prediction result output by the Transformer-based classifier.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of sleep staging, and in particular to a sleep staging method and device, an electronic device, and a storage medium. Background Art

[0002] In recent years, sleep staging methods have primarily replaced polysomnography (PSG) with more accessible data types as input, including electrocardiogram (ECG) and respiratory input. However, reliable results still rely on training with labeled datasets, with PSG being the sole source of labels. ECG and respiratory signals are integral components of PSG and therefore offer the advantage of abundant labeled data. However, common home monitoring devices have limited ability to acquire a user's ECG and respiratory signals, significantly limiting sleep staging in non-professional settings, such as at home. Summary of the Invention

[0003] The sleep staging method provided by the embodiments of the present application can reduce the dependence on using a large amount of labeled data of PSG for training by using cross-modal signals, and reduce the limitations of users in performing sleep staging detection in non-professional scenarios.

[0004] The embodiments of the present application provide a sleep staging method and apparatus, an electronic device, and a storage medium. This method can at least solve the aforementioned problem of users being limited in performing sleep staging detection in non-professional scenarios (such as home scenarios).

[0005] In a first aspect, an embodiment of the present application provides a sleep staging method, comprising: obtaining a heartbeat signal and a respiratory signal after the user clock is aligned; preprocessing the heartbeat signal and the respiratory signal to obtain a heartbeat interval sequence and a respiratory waveform of a specific frequency band; dividing the heartbeat interval sequence and the respiratory waveform of the specific frequency band based on a first time length as a division unit to obtain multiple groups of data to be processed, wherein each group of data to be processed includes a heartbeat interval sequence data of a first time length and a respiratory waveform data of a first time length; inputting the multiple groups of data to be processed into a multi-head patch encoder for encoding to obtain a token sequence corresponding to each group of data to be processed; inputting multiple token sequences corresponding to the multiple groups of data to be processed into a Transformer-based classifier; and obtaining the sleep staging prediction results output by the Transformer-based classifier.

[0006] In one possible implementation, the preprocessing of the heartbeat signal and the respiratory signal to obtain a heartbeat interval sequence and a respiratory waveform of a specific frequency band includes: extracting the corresponding heartbeat interval sequence based on the heartbeat signal, wherein the heartbeat signal includes an ECG signal or a BCG signal, and the heartbeat interval sequence includes an RRI sequence or a JJI sequence; filtering the respiratory signal based on a specific frequency band to obtain the respiratory waveform of the specific frequency band.

[0007] In a possible implementation, the respiratory signal and the BCG signal are both acquired based on a home monitoring device including a piezoelectric sensor or an optical fiber sensor.

[0008] In one possible implementation, after filtering the respiratory signal based on a specific frequency band to obtain the respiratory waveform of the specific frequency band, it also includes: downsampling the respiratory waveform of the specific frequency band to a set sampling frequency that is the same as the RRI sequence; and normalizing the downsampled respiratory waveform to a standard score.

[0009] In one possible implementation, the preprocessing of the heartbeat signal and the respiratory signal to obtain a heartbeat interval sequence and a respiratory waveform in a specific frequency band includes: performing data enhancement processing on the heartbeat signal and the respiratory signal; wherein the data enhancement processing includes at least one of amplitude modulation and signal speed change processing.

[0010] In one possible implementation, the multiple groups of data to be processed are input into a multi-head patch encoder for encoding, and obtaining a token sequence corresponding to each group of data to be processed includes: obtaining the input heartbeat interval sequence data through the first single channel of the multi-head patch encoder; obtaining the input respiratory waveform data of a specific frequency band through the second single channel of the multi-head patch encoder; obtaining the input mixed data through the dual channels of the multi-head patch encoder, wherein the mixed data is data obtained by mixing the heartbeat interval sequence data and the respiratory waveform data of a specific frequency band; encoding the heartbeat interval sequence data, the respiratory waveform data of a specific frequency band, and the mixed data through the multi-head patch encoder to obtain a token sequence corresponding to each group of data to be processed.

[0011] In one possible implementation, the multi-head patch encoder includes a residual network.

[0012] In one possible implementation, a 128-dimensional first feature is extracted from the heartbeat interval sequence data through the residual network; a 256-dimensional second feature is extracted from the mixed data through the residual network; a 128-dimensional third feature is extracted from the respiratory waveform data through the residual network; the first feature, the second feature, and the third feature are concatenated to obtain a 512-dimensional token sequence.

[0013] In a possible implementation, the Transformer-based classifier includes: a Transformer encoder and a multi-layer perceptron.

[0014] In a possible implementation, obtaining the sleep stage prediction result output by the Transformer-based classifier includes: generating probability distribution information of the sleep stage corresponding to the token sequence by the Transformer-based classifier.

[0015] In a possible implementation, the specific frequency band is 0.1-0.35 Hz.

[0016] In a second aspect, an embodiment of the present application further provides a sleep staging device, comprising: a processor and a memory, wherein the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the sleep staging method provided in the first aspect is implemented.

[0017] In a third aspect, an embodiment of the present application further provides an electronic device, which includes the sleep staging device provided in the second aspect.

[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the sleep staging method provided in the first aspect.

[0019] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program or instructions, which implements the sleep staging method provided in the first aspect when the computer program or instructions are executed by a processor.

[0020] The above technical solution uses a Transformer to predict a user's sleep stage based on cross-modal signals, bridging the gap between hospital and home device data. This provides a feasible solution for home sleep stage prediction, increasing the flexibility and diversity of sleep stage detection in non-professional scenarios, and improving the user's detection experience. Furthermore, the algorithm provided by the technical solution of this application can accurately determine a user's sleep stage based on their heartbeat and respiratory signals. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0022] Figure 1 A schematic diagram of an ECG signal waveform provided in one embodiment of the present application;

[0023] Figure 2 A schematic diagram of a BCG signal waveform provided in one embodiment of the present application;

[0024] Figure 3 A schematic diagram of a sleep staging model framework provided in one embodiment of the present application;

[0025] Figure 4 A schematic diagram showing a comparison of data distribution after data enhancement provided in one embodiment of the present application;

[0026] Figure 5 A schematic diagram of obtaining a token sequence based on an encoder architecture provided in one embodiment of the present application;

[0027] Figure 6 A flowchart of a sleep staging method provided in one embodiment of the present application;

[0028] Figure 7 A schematic diagram of the structure of a sleep staging device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0029] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0030] In order to better understand the solutions of the embodiments of the present application, the following first introduces the relevant terms and concepts that may be involved in the embodiments of the present application. It should be understood that the interpretation of the relevant concepts may be limited by the specific circumstances of the embodiments of the present application, but it does not mean that the present application is limited to the specific circumstances. The specific circumstances of different embodiments may also vary, which is not specifically limited here.

[0031] BCG is a weak vibration signal generated by changes in external pressure on the human body caused by heartbeats and blood circulation in the aorta. Specifically, the BCG signal itself is a mechanical vibration signal. With each heartbeat, blood is ejected from the heart into the blood vessels, and this ejection process exerts an extremely subtle force on the human body. In healthcare scenarios, by detecting the weak vibrations transmitted to the body surface by heartbeats, information indirectly reflecting the heart's working state, namely the BCG signal, can be obtained.

[0032] ECG: Electrocardiogram (ECG). An ECG signal is an electrical signal. During each cardiac cycle, the pacemaker, atria, and ventricles are excited sequentially, accompanied by changes in bioelectricity. This is then recorded on the body surface by an electrocardiogram (ECG). During the heart's contraction, current is generated in the myocardium before contraction. The changes in myocardial current are called ECGs.

[0033] RRI: Reference Figure 2 The waveform shown in Figure 1 is a complete ECG signal. The solid line represents a heartbeat waveform with complete band components, including the P wave, PR band, QRS complex, ST band, and T wave. For ECG signals, the time interval between two adjacent R waves is the RR interval (RRI), which represents the heartbeat rhythm information. After acquiring an ECG signal of a certain length, the RRI can be extracted from each complete ECG signal, thereby obtaining the RRI sequence of the ECG signal.

[0034] CNN: A deep neural network with a convolutional architecture. It is a deep learning architecture, which uses machine learning algorithms to perform multiple levels of learning at different levels of abstraction. As a deep learning architecture, CNN is a feed-forward artificial neural network in which individual neurons respond to overlapping regions in the input image.

[0035] RNN is a special neural network structure based on the idea that human cognition is based on past experience and memory. Unlike CNN, it not only considers the previous input but also provides the network with a "memory" of previous content. RNN is called a recurrent neural network because the current output of a sequence is related to the previous output. Specifically, the network remembers previous information and applies it to the calculation of the current output. This means that the nodes in the hidden layers are no longer disconnected but connected, and the hidden layer input includes not only the output of the input layer but also the output of the previous hidden layer.

[0036] Transformer: is a deep learning model based on the self-attention mechanism, which includes at least the following parts:

[0037] Encoder: Responsible for converting the input sequence into a high-dimensional feature representation. The encoder typically consists of multiple self-attention layers and feed-forward neural network layers. Each self-attention layer uses the self-attention mechanism to assign a weight to each position in the input sequence and then calculates a weighted sum based on these weights, thereby capturing long-range dependencies in the input sequence.

[0038] The advantage of the Transformer model lies in its parallel computation capability, as it allows the representation of each position to consider the entire input sequence simultaneously.

[0039] As people's health awareness continues to rise, their attention to sleep quality is also increasing. Sleep quality is crucial to human health. Sleep quality is usually analyzed using physiological signals, which are not only related to physiological functions but also have different patterns. Although there are multiple standards for sleep staging, the most common four-category sleep stage includes wakefulness, light sleep, deep sleep, and rapid eye movement (REM) sleep. For example, deep sleep helps the body's metabolism and wound healing, while dreaming mostly occurs during REM sleep. Accurate sleep staging is important for sleep structure and, in turn, for diagnosing and resolving sleep disorders.

[0040] Traditionally, sleep staging relies on polysomnography (PSG), which involves collecting PSG data and manually annotating it through experts. PSG is a collection of physiological signals, including EEG, ECG, EOG, EMG, and respiratory signals. However, sleep staging based on PSG is time-consuming and laborious, and requires specialized equipment and laboratories to obtain PSG data. In addition, experts with certain professional capabilities are required to analyze and annotate the acquired PSG data. In other words, sleep staging based on PSG is limited by many factors, such as specialized equipment, laboratories, and experts.

[0041] In order to overcome the above-mentioned problems of sleep staging based on PSG, the embodiments of the present application use user data that is easier to obtain as input data to perform sleep staging detection on the user when performing sleep staging detection. In one embodiment, the user can be monitored by a home monitoring device or other portable device to obtain the user's breathing signal and heartbeat signal, so that the easily obtained breathing signal and heartbeat signal can replace the PSG data, thereby reducing the limitations of devices and scenarios when obtaining user-related data. Furthermore, the user's breathing signal and heartbeat signal that can be obtained can be cross-modal signals, that is, using cross-modal signals as input, a cross-modal data provider is implemented to extract and enhance these signals to improve their generalization ability. Furthermore, a multi-head patch encoder can be used to mark the user's breathing signal and heartbeat signal and then use Transformer to predict sleep staging, which can reduce the limitations on expert factors and thus increase the possibility of users achieving sleep staging detection in non-professional scenarios.

[0042] In the embodiment of the present application, there is no limitation on the specific type of model used for sleep staging. Any of the neural network models described above or their combination can be used as the initial neural network model in the embodiment of the present application, as long as it can achieve the above-mentioned sleep staging prediction function after training.

[0043] The following is a detailed description of the training process of the sleep staging model provided in the embodiments of the present application.

[0044] According to the AASM standard, sleep stages can be divided into five stages, including the wakefulness stage, the rapid eye movement stage, and three non-rapid eye movement sleep stages, specifically non-rapid eye movement sleep N1 stage, non-rapid eye movement sleep N2 stage, and non-rapid eye movement sleep N3 stage.

[0045] In other embodiments, the sleep stages can be divided into four stages. Specifically, the N1 and N2 stages in the above-mentioned non-rapid eye movement sleep stages (N1, N2 and N3) can be merged into one stage and called the "light" sleep stage, and the above-mentioned N3 stage can be called the "deep" sleep stage. Furthermore, "W / L / D / R" can be used to represent the wakefulness stage, rapid eye movement stage, "light" sleep stage and "deep" sleep stage respectively.

[0046] In other embodiments, the sleep stage may be divided into three stages, namely, the wakefulness stage, the rapid eye movement stage, and the non-rapid eye movement sleep stage, and may be represented by “W / N / R”.

[0047] It should be noted that the embodiment of the present application does not limit the way of dividing sleep stages.

[0048] In some embodiments, the first type of training sample data set used for model training may include respiratory signals, RRI sequences obtained based on ECG signals, and sleep staging results.

[0049] In some embodiments, the training sample data set can be obtained through publicly available open source data, and large-scale open source data sets can be used to train the model. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0050] In some embodiments, model training can be performed using three different datasets. Specifically, the National Sleep Research Resource (NSRR) and Human Sleep Project (HSP) datasets can be used for training. The NSSR dataset is a repository provided by the National Heart, Lung, and Blood Institute (NHLBI) for sharing large amounts of sleep data from multiple cohorts, clinical trials, and other data sources. Furthermore, the BCGSSD (BCG Sleep Staging Dataset) dataset can be used for zero-shot external testing.

[0051] In one embodiment, the NSRR dataset may include seven datasets: the Sleep Health Heart Study (SHHS), MESA, the Cleveland Family Study (CFS), the CCSHS, the MrOS, the CHAT, and the HomePAP. During training, these seven datasets are used as a whole. The NSRR dataset can be used to obtain the user's respiratory signal, ECG signal, and sleep staging results. Furthermore, the corresponding RRI sequence can be extracted based on the ECG signal.

[0052] In some embodiments, the BCGSSD dataset is a self-collected dataset, which can specifically record BCG signals and PSG signals obtained through contactless devices, wherein PSG monitors indicators such as continuous breathing, electrocardiogram (ECG), heart rate, and sleep stages at night, thereby obtaining corresponding PSG signals.

[0053] It should be noted that ECG stands for electrocardiogram. An ECG signal is an electrical signal. During each cardiac cycle, the pacemaker, atria, and ventricles are excited sequentially, accompanied by changes in bioelectricity. This is reflected on the surface of the body by an electrocardiogram (ECG). During the heart's contraction and beating process, current is generated within the myocardium before contraction. The changes in myocardial current are the ECG.

[0054] Figure 1 A schematic diagram of an ECG signal waveform provided for one embodiment of the present application.

[0055] Reference Figure 1 As shown in FIG, the waveform is a complete ECG signal, wherein the solid line represents a heartbeat waveform with complete band components, including P wave, PR band, QRS complex, ST band and T wave. Figure 2 As shown in Figure 1, for ECG signals, the time interval between two adjacent R waves is the RR interval (RRI), which represents the heart rhythm information. After acquiring an ECG signal of a certain duration, the RRI of each complete ECG signal can be extracted, thereby obtaining the RRI sequence of the ECG signal.

[0056] In other embodiments, model training may also be performed using a second type of training sample data set, and the second type of training sample data set may include respiratory signals, RRI sequences obtained based on BCG signals, and sleep staging results.

[0057] It should be noted that the BCG signal is a weak vibration signal generated by changes in external pressure on the human body caused by heartbeats and blood circulation in the aorta. Specifically, the BCG signal itself is a mechanical vibration signal. With each heartbeat, blood is ejected from the heart into the blood vessels, and during this ejection process, an extremely subtle force is exerted on the human body. In medical and health scenarios, information indirectly reflecting the working state of the heart, namely the BCG signal, can be obtained by detecting the weak vibrations transmitted to the body surface by the heartbeat.

[0058] Figure 2 A schematic diagram of a BCG signal waveform provided in one embodiment of the present application.

[0059] Reference Figure 2 As shown, in some embodiments, the BCG signal waveform can be divided into ballistic waves F, G, H, I, J, K, L, M, and N according to different stages. Figure 3 As shown, there are 6 complete BCGs in the BCG signal waveform diagram, some of which contain 8 ballistic waves from G to N, and other BCGs only contain 6 ballistic waves from G to L.

[0060] For example, a template composed of six ballistic waves (still represented by G, H, I, J, K, and L) can be used to detect BCG. Peaks (maxima) and troughs (minima) can be extracted from the BCG signal waveform. A detection template is then constructed using the following "trough-peak-trough-peak-trough-peak" pattern. Ballistocardial signals can then be detected using a matching method based on this detection template. The BCG ballistic J wave (also known as the J peak) within the time window can be marked based on the detection results.

[0061] In some embodiments, reference Figure 2 As shown, for BCG signals, the time interval between two adjacent J peaks is referred to as "JJ interval (JJI)". After obtaining a BCG signal of a certain length, the JJI in each complete BCG signal can be extracted, thereby obtaining the JJI sequence of the BCG signal. It should be noted that since the input heartbeat signal is a BCG signal, the corresponding JJI sequence can be extracted based on the BCG signal. In order to obtain the corresponding RRI sequence based on the BCG signal, the corresponding JJI sequence extracted based on the BCG signal can be mapped to the corresponding RRI sequence based on the mapping relationship between the RRI sequence and the JJI sequence.

[0062] Any of the above training sample data sets includes multiple training samples.

[0063] In some embodiments, the training sample dataset can be a first-category training sample dataset or a second-category training sample dataset. The training set is primarily used to train the initial model; the validation set is primarily used to evaluate the model's performance and optimize the model by adjusting hyperparameters; the test set primarily evaluates the model's performance using a series of evaluation metrics, such as accuracy, recall, and F1. The validation set is optional; if hyperparameter adjustment is not required, the validation set can be omitted and the test set can be used directly to evaluate the performance.

[0064] In one embodiment, a combination of an NSRR dataset and an HSP dataset can be used as a training sample dataset for training. The training sample dataset can be divided into K (K is an integer greater than 1) sub-datasets, and the sub-datasets can be divided into a training set, a validation set, and a test set according to a certain ratio. For example, the ratio of the training set, validation set, and test set to the training sample dataset (K sub-datasets) can be 8:1:1. For example, if the training sample dataset includes 1000 samples and K is 10, the 1000 samples can be divided into 10 sub-datasets. These 10 sub-datasets are the first sub-dataset, the second sub-dataset, the third sub-dataset, ..., the ninth sub-dataset, and the tenth sub-dataset. Any one of these 10 sub-datasets can be selected as the test set, and the remaining sub-datasets, excluding the test dataset, can be used as the training set and validation set. For example, the first sub-dataset can be selected as the test set, the second, third, fourth, ..., seventh, eighth, and ninth sub-datasets can be selected as the training set, and the tenth sub-dataset can be selected as the test set.

[0065] In some embodiments, the model may be trained multiple times based on the multiple divided training sets, thereby obtaining multiple first models. For example, the second, third, ..., eighth, and ninth subsets of the dataset are used as training sets, and the model may be trained six times based on each of the training sets, thereby obtaining six first models.

[0066] In some embodiments, during the training process, the data in the validation set can also be verified. On the other hand, the model output results can also be classified to calculate the loss, thereby adjusting the model weights accordingly.

[0067] In some embodiments, when the model is trained using respiratory signals and heartbeat signals acquired based on PSG data, the model may be trained using respiratory waveforms and heartbeat interval sequences acquired based on BCG signals.

[0068] In some embodiments, the output results of multiple first models may be evaluated for effectiveness, thereby obtaining the optimal hyperparameters based on the evaluation results.

[0069] In some embodiments, a comprehensive suite of performance metrics was employed to evaluate our models, including Cohen's kappa, accuracy, macro F1 score, and weighted macro F1 score. Cohen's kappa coefficient, κ (KAPPA), is a key metric in our analysis. It accounts for the likelihood of agreement occurring by chance, making it a reliable measure of inter-rater reliability. κ values ​​are interpreted as follows: κ > 0.4 indicates moderate agreement, κ > 0.6 indicates substantial agreement, and κ > 0.8 indicates almost perfect agreement (Landis & Koch, 1977). Accuracy (ACC) is a simple metric calculated as the ratio of correctly predicted labels to the total number of segments, with one label for each segment. Macro F1 provides a balanced measure of precision and recall, calculated by averaging the F1 scores of each class without considering its frequency. This makes it particularly useful in imbalanced datasets. Weighted F1 adjusts the macro F1 calculation by weighting the contribution of each class based on the number of 30-second data segments it contains. In other embodiments, the evaluation may be performed in other ways, and this application does not limit the type of evaluation.

[0070] In some embodiments, different sleep staging models can be trained using different training sample data sets. For example, when the input training data is a respiratory waveform and a RRI sequence (the RRI sequence can be extracted from a pre-acquired ECG signal, or a JJI sequence can be extracted from a pre-acquired BCG signal, and the RRI sequence is obtained by mapping the RRI and JJI), the trained sleep staging model has the ability to predict sleep stages based on the respiratory waveform and RRI sequence.

[0071] In some embodiments, considering the differences in user age distribution within the training sample datasets, for example, the SHHS training dataset has users all over 40 years old, while the HSP training dataset has a more balanced age distribution across all age groups. To account for this imbalance in data across different age groups, each age group can be weighted inversely proportional to the number of times it appears in the training sample dataset.

[0072] Figure 3 A schematic diagram of the sleep staging model framework provided in one embodiment of the present application.

[0073] Reference Figure 3 As shown, the model framework may specifically include a data provider 41, an encoder 42, and a Transformer-based classifier 43.

[0074] Reference Figure 3As shown, the model provided by the embodiment of the present application can predict the user's sleep stage results based on the respiratory signal and heartbeat interval sequence.

[0075] In some embodiments, the data provider 41 may include a data encoder, and the data provider 41 may serve as a data input terminal to obtain initial data for sleep stage prediction, and the initial data may include the user's heartbeat signal and respiratory signal. In one embodiment, the heartbeat signal may specifically be a BCG signal or an ECG signal. Furthermore, after obtaining the user's heartbeat signal and respiratory signal, the data provider 41 may obtain a corresponding heartbeat interval sequence based on the heartbeat signal, and the heartbeat interval sequence may include an RRI sequence or a JJI sequence. Specifically, when the heartbeat signal is an ECG signal, the corresponding RRI sequence may be directly extracted from the ECG signal; when the heartbeat signal is a BCG signal, the corresponding JJI sequence may be extracted from the BCG signal in advance, and the corresponding RRI sequence may be obtained based on the mapping relationship between RRI and JJI. That is, the data provider 41 may output a corresponding heartbeat interval sequence and respiratory signal based on the input user's heartbeat signal and respiratory signal.

[0076] In some application scenarios, users may not be able to obtain high-quality respiratory and heartbeat signals based on professional equipment (such as respiratory signals and RRI sequences obtained based on PSG), but instead obtain respiratory and heartbeat signals through some home monitoring equipment or other non-professional equipment (for example, respiratory signals and heartbeat interval sequences based on BCG signals, such as RRI sequences or JJI sequences). In order to reduce the difference between the RRI and respiratory signals from PSG and the RRI and respiratory signals extracted from BCG signals, the data provider 41 can preprocess the input data to overcome the impact of the difference between the above data. In one embodiment, the preprocessing may include data enhancement and normalization.

[0077] About normalization

[0078] Since professional equipment and non-professional equipment (home monitoring equipment) use different frequencies for data collection, and the sampling frequency of professional equipment is much higher than that of non-professional equipment, in order to improve the generalization ability of the sleep staging model, the data with high sampling frequency can be downsampled. Among them, the heartbeat signal obtained based on PSG is generally an ECG signal, and the sampling frequency of ECG is at least 125HZ. Therefore, when the input data contains data with high sampling frequency (RRI obtained based on PSG), downsampling can be performed. For example, the sampling frequency of non-professional equipment (home monitoring equipment) is 4HZ, then the high sampling frequency data can be downsampled to 4HZ. It should be noted that this application does not limit the frequency after downsampling, and can be customized based on user needs.

[0079] It should also be noted that due to the differences between the data collected by professional equipment and non-professional equipment, specifically, with regard to respiratory signals, the respiratory signals obtained based on PSG are not completely consistent with the data of the respiratory signals obtained based on BCG. The embodiments provided in this application have shown through a large number of experiments that the respiratory signals obtained based on PSG are consistent with the BCG signals within a specific frequency band. In some embodiments, the specific frequency band can be 0.1Hz to 0.35Hz, that is, the respiratory signal from PSG is consistent with the BCG signal within the frequency band of 0.1Hz to 0.35Hz. By extracting the respiratory signal in a specific frequency band, the respiratory signal obtained based on PSG and the respiratory signal obtained based on BCG have a strong consistency, which can maintain a consistent correlation between the data, so that the sleep staging model can be deeply learned through the above-mentioned data with strong mutual consistency, thereby improving the accuracy of the model's sleep staging prediction.

[0080] In some embodiments, in order to obtain the respiratory signal of the specific frequency band, after the respiratory signal is obtained based on the BCG signal, the acquired respiratory signal can be filtered by a filter to obtain the respiratory signal of the specific frequency band. Specifically, the respiratory waveform of the specific frequency band can be obtained by filtering. Exemplarily, the respiratory waveform of the specific frequency band can be implemented by a third-order Bessel bandpass filter. It should be noted that in other embodiments, filtering can also be implemented by other methods, and this application does not limit the method of filtering the respiratory signal.

[0081] In some embodiments, the filtered respiratory signal can be further downsampled to the same set sampling frequency as the heartbeat interval sequence. For example, when the heartbeat interval sequence is an RRI sequence with a sampling frequency of 4 Hz, the filtered respiratory signal (respiratory waveform) can be downsampled to 4 Hz to align with the RRI sequence. Finally, the downsampled respiratory signal is normalized to a z-score (standard score) to remove the constant factor introduced by the different modalities, thereby generating a cross-modal respiratory channel.

[0082] About Data Augmentation

[0083] A notable characteristic of physiological signals is their inherent variability across different populations, different devices (professional or non-professional), and different acquisition modes. To improve the generalization of the model, data augmentation can be performed on the input data. During training, the training sample datasets obtained may come from different populations and be acquired using different (professional or non-professional) devices using different acquisition modes. Therefore, data augmentation can be performed on the input data to improve the generalization of the trained model.

[0084] In some embodiments, the data enhancement process may be implemented based on at least one of amplitude modulation and signal speed variation processing.

[0085] Figure 4 A schematic diagram showing a comparison of data distribution after data enhancement provided in one embodiment of the present application.

[0086] Reference Figure 4 Figure 2 shows a t-SNE visualization of sleep data from various datasets. The original distributions of the NSRR (blue) and BCGSSD (red) data are distinct. After data augmentation, they cluster closer together (green and yellow), effectively eliminating the differences between the two datasets. Specifically, in this visualization, blue points represent the original data from the NSRR dataset, and red points represent the original data from the BCGSSD dataset. Green points represent the distribution of the NSRR data after data augmentation, and yellow points represent the distribution of the BCGSSD data after data augmentation.

[0087] It is important to note that BCGSSD contains low-quality BCG data collected by home monitoring devices, while NSRR contains high-quality PSG data, resulting in a significant gap between them. Initially, the red and blue points are clearly separated, indicating a clear difference in data distribution between the two datasets. However, after data augmentation, we observe a significant convergence of high- and low-quality data points, with the augmented NSRR (yellow) and augmented BCGSSD (green) data clusters merging more closely. This visualization illustrates the effectiveness of data augmentation strategies in bridging the gap between datasets, promoting a more unified data representation, and thus potentially enhancing the model's generalization ability across different datasets and modalities.

[0088] In some embodiments, the data provider 41 can also divide the output heartbeat interval sequence (RRI sequence or JJI sequence) and respiratory signal into multiple groups of data to be processed, wherein each group of data to be processed includes respiratory data of a first duration and RRI data of a first duration. Exemplarily, the first duration can be 30 seconds, and the heartbeat interval sequence is an RRI sequence. That is, the data output by the data provider 41 to the encoder 42 each time is 30 seconds of RRI data and 30 seconds of respiratory data. It should be noted that this application does not limit the specific time length value of the first duration, and can be adjusted based on user needs.

[0089] In some embodiments, the encoder 42 can perform data encoding conversion based on the input data (i.e., the data to be processed output by the data provider 41), and output the corresponding token sequence to provide to the Transformer-based classifier 43 for sleep stage prediction. Wherein, the input data is cross-modal data (i.e., a heartbeat interval sequence and a respiratory waveform in a specific frequency band). The encoder 42 provided in the embodiment of the present application can be a multi-head patch encoder. In one embodiment, the multi-head patch encoder can process the data of the input channel through three heads, and the three heads are respectively Figure 4 The first, second, and third magnetic heads are shown. The first and third magnetic heads are single-channel heads that can independently process data from one input channel, while the second head is a dual-channel head that can simultaneously process data from two input channels. For example, the first head can receive and process heartbeat interval sequence data from one input channel (the first single channel), while the third head can receive and process respiratory waveform data of a specific frequency band from another input channel (the second single channel). The second head can then simultaneously receive and process mixed data resulting from the combination of the heartbeat interval sequence data and respiratory waveform data of a specific frequency band from both channels (the dual channel).

[0090] In some embodiments, the encoder 42 may perform data conversion based on each set of data to be processed to obtain a corresponding token sequence. The specific implementation method is described in detail below with reference to the accompanying drawings.

[0091] Figure 5 A schematic diagram of obtaining a token sequence based on an encoder architecture provided in one embodiment of the present application.

[0092] Reference Figure 5 As shown, the encoder 42 provided in the embodiment of the present application can be a multi-head patch encoder based on a neural network. In one embodiment, the neural network can be a residual network (ResNet34), that is, the encoder 42 can be a multi-head patch encoder based on a residual network (ResNet34). The encoder 42 can extract 128-dimensional features from each single signal, and extract a 256-dimensional feature from the signal mixed from the two single signals, and concatenate the three sets of features (i.e., two 128-dimensional features and one 256-dimensional feature) to obtain a corresponding 512-dimensional token sequence. Specifically, the encoder 42 can perform data conversion based on each set of data to be processed through the following steps to obtain the corresponding token sequence:

[0093] S1: Obtain input heartbeat interval sequence data through the first single channel of the multi-head patch encoder;

[0094] S2: Obtain the input respiratory waveform data of a specific frequency band through the second single channel of the multi-head patch encoder;

[0095] S3: The dual channels of the multi-head patch encoder are used to obtain the input mixed data, which is a mixture of heartbeat interval sequence data and respiratory waveform data in a specific frequency band.

[0096] S4: encoding the heartbeat interval sequence data, the respiratory waveform data of a specific frequency band, and the mixed data through a multi-head patch encoder to obtain a token sequence corresponding to each group of data to be processed.

[0097] It should be noted that S1 to S3 can be executed in parallel, thereby improving the efficiency of data acquisition.

[0098] In some embodiments, the heartbeat interval sequence data, the respiratory waveform data of a specific frequency band, and the mixed data are encoded and processed by a multi-head patch encoder to obtain a token sequence corresponding to each group of data to be processed, including: extracting a 128-dimensional first feature based on the heartbeat interval sequence data input by a first single channel through a residual network; extracting a 256-dimensional second feature based on the mixed data input by a dual channel through a residual network; extracting a 128-dimensional third feature based on the respiratory waveform data of a specific frequency band input by a residual network. It should be noted that the steps of extracting the first feature, the second feature, and the third feature through the residual network can be performed in parallel, thereby improving the efficiency of feature extraction. Furthermore, the first feature, the second feature, and the third feature can be spliced ​​together by a multi-head patch encoder to obtain a 512-dimensional token sequence corresponding to the first feature, the second feature, and the third feature.

[0099] Reference Figure 3 As shown, the patch sequence output by the encoder 42 serves as input data of the Transformer-based classifier 43, and the Transformer-based classifier 43 can then perform sleep stage prediction based on the received token sequence and output a prediction result.

[0100] Transformer is used to solve the sequence classification problem, that is, the sequence classification problem is solved by a Transformer-based classifier 43. During the application process, low-quality data can be used as user information input, specifically including a heartbeat interval sequence and a respiratory waveform in a specific frequency band. There is an intrinsic correlation between the sleep data provided by the user (the heartbeat interval sequence and the respiratory waveform in a specific frequency band), and this intrinsic correlation is captured by the Transformer of the sleep staging model trained with a large amount of data, wherein the Transformer-based classifier 43 may include a multi-layer perceptron (MLP) for classification, exemplarily, a 4-layer MLP, and then the 4-layer MLP can be used to divide the user's sleep into 4 stages based on the user's respiratory signal and RRI sequence. That is, the patch sequence output by the encoder 42 is processed by the multi-layer MLP to generate the final predicted probability distribution of the sleep stage, that is, the probability distribution of the predicted sleep staging.

[0101] Figure 7 This is a flowchart of a sleep staging method provided in one embodiment of the present application.

[0102] Reference Figure 7 As shown, the method may include the following steps:

[0103] S701: Acquire the heartbeat signal and breathing signal of the user after clock alignment.

[0104] In some embodiments, the user's heartbeat signal and breathing signal may be obtained separately or based on the same data source.

[0105] When the user's heartbeat signal and breathing signal are obtained separately, the user's heartbeat signal and breathing signal can be obtained separately through different related detection devices. For example, the user can be monitored simultaneously for a certain period of time by a breathing monitoring device and a heartbeat monitoring device, and the user's breathing signal and heartbeat signal during the time period can be obtained.

[0106] When the user's heartbeat signal and breathing signal are extracted based on the same data source, user-related sensor data can be obtained through detection by corresponding detection equipment, and the user's heartbeat signal and breathing signal can be extracted from the user-related sensor data.

[0107] In one embodiment, a user's sleep stage prediction can be implemented throughout the user's sleep. In this embodiment, a sensor device for acquiring user-related sensor data can be placed in a mattress or headrest within the sleeping environment. Thus, when the user lies on the mattress or headrest to sleep, the sensors therein can acquire the user's heartbeat and breathing signals.

[0108] The sensor types for obtaining the user's heartbeat signal and breathing signal may include at least one of a piezoelectric sensor, a piezoresistive sensor, a fiber optic sensor, an audio sensor, an ECG electrode, a nasal pressure sensor, a motion sensor, and an accelerometer. In other words, the user-related sensor data obtained is not limited to piezoelectric signals, piezoresistive signals, photoelectric signals, and other signals.

[0109] In some embodiments, the breathing signal and the heartbeat signal can be obtained by the same sensor. In other embodiments, the breathing signal and the heartbeat signal can be obtained by different sensors respectively. For example, the breathing signal can be obtained by a chest belt or nasal breath flow sensing device, and the heartbeat signal can be obtained by a piezoelectric sensor or an optical fiber sensor or an ECG electrode attached to the user's body.

[0110] Among them, the respiratory signal is a variety of physiological signals containing respiratory information, which can be a respiratory waveform, or information related to breathing such as respiratory rate. Since the respiratory waveform contains information such as respiratory rate and other information, it may also contain other information such as respiratory amplitude. The amount of information is more comprehensive and more conducive to accurately and comprehensively reflecting the body's condition. Therefore, it is preferred to use the respiratory waveform as a specific implementation of the respiratory signal; the heartbeat signal is various signals containing heartbeat information, such as ECG signal, BCG signal, etc. It is preferred to use ECG signal or BCG signal as a specific implementation of the heartbeat signal.

[0111] In some embodiments, the acquired heartbeat signal and respiratory signal may be misaligned. To improve the consistency of the data in the time dimension, the acquired heartbeat signal and respiratory signal may be clock-aligned heartbeat signal and respiratory signal. After the user's respiratory signal and heartbeat signal are clock-aligned, the model is trained using a large number of clock-aligned heartbeat signals and respiratory signals, so that the model can learn the correlation between the respiratory signal and the heartbeat signal. This allows the trained model to more accurately output the user's sleep stage prediction results based on the respiratory signal and heartbeat signal input by the user.

[0112] In one embodiment, when a BCG signal is acquired from sensor data, the user's respiratory signal and heartbeat signal can be extracted from the BCG signal. The extracted respiratory signal can be a respiratory waveform, and the extracted heartbeat signal can be a heartbeat interval sequence. Specifically, the heartbeat interval sequence can be a JJI sequence, i.e., the JJI sequence can be extracted from the BCG signal. Furthermore, the clock-aligned respiratory and heartbeat signals can be input into a preset sleep staging model (i.e., a trained sleep staging model). The preset sleep staging model can map the received JJI sequence into a corresponding RRI sequence. The preset sleep staging model then predicts sleep staging based on the respiratory waveform and RRI sequence.

[0113] In some embodiments, after obtaining the BCG signal from the sensor, the BCG signal can also be mapped into an ECG signal, and then the respiratory signal and the mapped ECG signal are input into a preset sleep staging model for sleep staging prediction. There are many ways to map the BCG signal to the ECG signal. For example, through AI model training, training can be performed based on the BCG signal and ECG signal collected at the same time, so as to obtain a data mapping model through training. The data mapping model obtained after the training can output the corresponding ECG signal based on the input BCG signal mapping. For example, through signal processing, in some embodiments, the BCG waveform is used as input, and the output ECG waveform is obtained by multiplying it by a correlation coefficient or by a function. The specific function can adopt any signal processing method in the prior art that realizes the correlation operation between the two, and the embodiments of the present application do not limit this. After the ECG signal is mapped, the corresponding respiratory signal and heartbeat interval sequence can be extracted based on the ECG signal. Specifically, the heartbeat interval sequence can be an RRI sequence, and then the preset sleep staging model predicts sleep staging based on the respiratory waveform and the RRI sequence.

[0114] S702: Preprocess the heartbeat signal and the respiratory signal to obtain a heartbeat interval sequence and a respiratory waveform of a specific frequency band.

[0115] In some embodiments, preprocessing the heartbeat signal and the respiratory signal to obtain a heartbeat interval sequence and a respiratory waveform of a specific frequency band includes: extracting a corresponding heartbeat interval sequence based on the heartbeat signal, wherein the heartbeat signal includes an ECG signal or a BCG signal, and the heartbeat interval sequence includes an RRI sequence or a JJI sequence; filtering the respiratory signal based on a specific frequency band to obtain a respiratory waveform of a specific frequency band. In some application scenarios, the respiratory signal obtained based on PSG is consistent with the BCG signal in the frequency band of 0.1Hz to 0.35Hz. In order to improve data consistency, the obtained respiratory signal can be filtered to obtain a respiratory waveform of a specific frequency band. For example, filtering the respiratory signal can be achieved by a third-order Bessel bandpass filter.

[0116] In some embodiments, after completing the filtering operation on a specific frequency band of the respiratory signal, the respiratory waveform of the specific frequency band can be downsampled to the same set sampling frequency as the RRI sequence; and the downsampled respiratory waveform is normalized to a standard score. Exemplarily, the filtered respiratory waveform is downsampled to 4 Hz to achieve alignment with the sampling frequency of the RRI sequence. Furthermore, the downsampled respiratory waveform can be normalized to a z score (standard score) to remove the constant factor introduced by different modalities, thereby obtaining a respiratory waveform of a specific frequency across modalities.

[0117] In some embodiments, data enhancement can also be performed on the heartbeat signal and respiratory signal of the user after clock alignment. In other embodiments, data enhancement can also be performed on the respiratory waveform and heartbeat interval sequence of a specific frequency band after normalization. Figure 4 The data enhancement processing method provided in the illustrated embodiment will not be described in detail here.

[0118] After the above preprocessing, the heartbeat interval sequence and the respiratory waveform of a specific frequency band can be obtained.

[0119] S703: Divide the heartbeat interval sequence and the respiratory waveform of a specific frequency band according to the first duration as a division unit to obtain multiple groups of data to be processed, wherein each group of data to be processed includes respiratory waveform data of the first duration and heartbeat interval sequence data of the first duration.

[0120] In some embodiments, the first duration may be 30 seconds.

[0121] It should be noted that, in other embodiments, the first duration may be other time lengths, and this application does not impose any limitation on this.

[0122] S704: Input multiple groups of data to be processed into the multi-head patch encoder for encoding to obtain a token sequence corresponding to each group of data to be processed.

[0123] In some embodiments, after the data provider 41 extracts the user's respiratory signal (respiratory waveform of a specific frequency) and heartbeat interval sequence (such as an RRI sequence), the divided data of multiple first durations (including respiratory waveform data of the first duration and heartbeat interval sequence data of the first duration) can be input into the encoder 42, such as a multi-head patch encoder. The multi-head structure of the encoder 42 can process the dual-channel input of the user-provided signal, that is, the input of respiratory waveform data and heartbeat interval data. The multi-head structure of the encoder 42 may include two single-channel heads and one dual-channel head. Each single-channel head independently processes the input of one input channel (processes respiratory waveform data or heartbeat interval data), while the dual-channel head processes the input of two channels simultaneously (processes the respiratory waveform data and the heartbeat interval sequence data to obtain mixed data).

[0124] In some embodiments, the encoder 42 can process the input first time-length data based on the residual network (ResNet34). Specifically, a 128-dimensional first feature is extracted based on the heartbeat interval sequence data through the residual network; a 256-dimensional second feature is extracted based on the mixed data through the residual network; a 128-dimensional third feature is extracted based on the respiratory waveform data through the residual network; and the first feature, the second feature, and the third feature are spliced ​​together to obtain a 512-dimensional token sequence. The specific implementation method of obtaining the token sequence can be referred to. Figure 3 The token sequence acquisition method provided by the encoder 42 is not described in detail here.

[0125] S705: Input multiple token sequences corresponding to the multiple groups of data to be processed into the Transformer-based classifier; obtain the sleep stage prediction result output by the Transformer-based classifier.

[0126] In some embodiments, the token sequence output by the encoder 42 can be used as input data of the transform, and then the Transformer-based classifier outputs corresponding probability distribution information of the sleep stage based on the input multiple token sequences.

[0127] The sleep staging method provided in the embodiment of the present application predicts the user's sleep stage based on cross-modal signals through Transformer, bridging the gap between hospital and home device data and providing a feasible solution for home sleep stage prediction. In addition, it is easier to obtain the user's heartbeat and respiratory signals through home monitoring devices. Even if the data obtained through home monitoring devices is low-quality data with a low sampling rate, the sleep staging model provided by this application can be used to predict the user's sleep stage, thereby improving the generalization ability of the model and helping users to achieve sleep stage prediction in home scenarios or other non-professional scenarios.

[0128] The sleep staging method provided in this application embodiment is a Transformer-based cross-modal sleep staging (TCM) method. First, data augmentation is performed on heartbeat interval sequences and respiratory signals to improve their ability in zero-shot generalization scenarios. Second, a multi-head patch encoder is used to extract corresponding token sequences based on the heartbeat interval sequences and respiratory signals. Finally, the token sequences are input into a Transformer-based classifier for sleep staging. We conducted comprehensive experiments on two large-scale datasets and a self-collected BCG test dataset to fully evaluate our method. For five-stage classification, TCM achieved a kappa of 0.701 on the combined NSRR and HSP datasets and 0.601 in a zero-shot cross-modal test on the BCG dataset, surpassing the 0.067 (10.2%) and 0.093 (18.3%) achieved by existing sleep staging methods, respectively.

[0129] The following diagrams illustrate the effects of the sleep staging method provided in the embodiments of the present application.

[0130] Table 1

[0131]

[0132] Refer to Table 1 for the results of three baselines (YL22, MG22, and NS20) and TCM for 5-stage classification on the test set (Test) and the BCG dataset (BCGSSD).

[0133] The second to fifth rows show the results on the internal test set, and the sixth to ninth rows show the BCGSSD results on the external test set. In a row-by-row comparison, the baseline model achieved the best results on the internal test set for metrics such as ACC, Kappa, Macro F1, and Weighted F1 of 0.755, 0.654, 0.705, and 0.744, respectively. In comparison, the method provided in the examples of this application achieved results of 0.785, 0.701, 0.716, and 0.779, surpassing the highest baseline performance by 0.030 (4.0%), 0.047 (7.2%), 0.011 (1.6%), and 0.035 (4.7%), respectively.

[0134] For the external test set, the highest baseline results for ACC, Kappa, macro F1, and weighted F1 were 0.631, 0.508, 0.567, and 0.609, respectively. The method provided in the examples of this application achieved results of 0.705, 0.601, 0.630, and 0.677, respectively, which were 0.074 (11.7%), 0.093 (18.3%), 0.122 (21.5%), and 0.063 (10.3%) higher than the best baseline results. It can be seen that the model provided in this application significantly outperformed the best baseline for all eight metrics in both internal and external testing, particularly in the external testing results.

[0135] In summary, in rows 2 to 5, all models are trained on the combined NSRR and HSP datasets and tested on the test set. In rows 6 to 9, zero-shot cross-modal evaluation on BCGSSD is reported without fine-tuning. On both datasets, TCM significantly outperforms the best baseline in all 8 metrics.

[0136] Figure 7 A schematic diagram of the structure of a sleep staging device provided in one embodiment of the present application.

[0137] Reference Figure 7 As shown, the apparatus may include a processor 801 and a memory 802, wherein the memory 802 is configured to store at least one instruction, and when the instruction is loaded and executed by the processor 801, the sleep staging method provided in any embodiment of the present application is implemented. In one embodiment, Figure 7 The sleep staging device provided in the illustrated embodiment may be a chip or a chip module, and the sleep staging method provided in the embodiment of the present application may be pre-burned into the chip or chip module.

[0138] The embodiment of the present application also provides an electronic device, which may include Figure 7The sleep staging device provided in the illustrated embodiment. In one embodiment, the electronic device may be a sleep staging detection device or a sleep state detection device. In one embodiment, the electronic device may be a non-contact detection device, illustratively, it may be a smart air cushion or a smart headrest. In one embodiment, the electronic device may have a built-in sensor, and obtain user-related sensor data through the built-in sensor, wherein a piezoelectric sensor, a piezoresistive sensor or an optical fiber sensor may be built-in. In other embodiments, the sensor used to obtain user-related sensor data in the electronic device may also be other types of sensors, and this application does not limit this. In another embodiment, the electronic device may also obtain user-related sensor data provided by external sensors, such as breathing signals and heartbeat signals, in a wireless or wired manner.

[0139] In some embodiments, the electronic device obtains the user's breathing signal and heartbeat signal in a manner including contact measurement and non-contact measurement, wherein the contact measurement method may include measurement by wearing a breathing belt, bracelet, watch and other devices. The non-contact measurement method may include air cushion monitoring and microwave radar monitoring. Among them, through air cushion monitoring, a pressure sensor is used to measure the human body's breathing, heartbeat and body movement, thereby identifying various types of breathing disorders. This method is a non-contact method, the tester's experience is comfortable, and it is suitable for users to use at home, but its range of action is small, and its reliability is affected by temperature and humidity. In some embodiments, in the scenario of air cushion monitoring, the electronic device can be a smart headrest or a smart air cushion, and the smart headrest or smart air cushion can have a built-in piezoelectric sensor, piezoresistive sensor or optical fiber sensor.

[0140] Microwave radar respiration monitoring uses micro-movements of the chest and abdomen during breathing to generate radar echo signals. By analyzing the radar transmission and echo signals, the respiratory signal is extracted with high accuracy. The microwave radar device is placed at a certain vertical height from the body, such as at the headboard or bedside. It eliminates the need for direct contact with the person and can penetrate blankets and clothing, providing a wide range and millimeter-level measurement accuracy. While maintaining comfort, the microwave radar method offers superior measurement precision and accuracy to mattress-based respiration monitoring, making it the preferred method for non-contact measurement of respiration type.

[0141] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the sleep staging method provided in any embodiment of the present application is implemented.

[0142] An embodiment of the present application further provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the sleep staging method provided in any embodiment of the present application.

[0143] The detection device and training device provided in the embodiments of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit, etc. The processing unit may execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the image enhancement method described in the above embodiment, or so that the chip in the training device executes the image enhancement method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.

[0144] It should be noted that the terminals involved in the embodiments of the present application may include but are not limited to personal computers (PCs), personal digital assistants (PDAs), wireless handheld devices, tablet computers, mobile phones, MP3 players, MP4 players, etc.

[0145] It is understandable that the application may be an application program (nativeApp) installed on the terminal, or may be a web page program (webApp) of a browser on the terminal, and this embodiment of the present application does not limit this.

[0146] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0147] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, which may be electrical, mechanical or other forms.

[0148] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0149] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0150] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform some of the steps of the method described in each embodiment of this application. The aforementioned storage medium includes: USB flash drives, mobile hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media that can store program code.

[0151] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A sleep staging method, characterized in that: The method comprises: Obtain the heartbeat signal and breathing signal after the user's clock is aligned; Preprocessing the heartbeat signal and the respiratory signal to obtain a heartbeat interval sequence and a respiratory waveform of a specific frequency band; Dividing the heartbeat interval sequence and the respiratory waveform of the specific frequency band using the first duration as a division unit to obtain multiple groups of data to be processed, wherein each group of data to be processed includes heartbeat interval sequence data of the first duration and respiratory waveform data of the first duration; Input the multiple groups of data to be processed into a multi-head patch encoder for encoding to obtain a token sequence corresponding to each group of data to be processed; Inputting multiple token sequences corresponding to the multiple groups of data to be processed into a Transformer-based classifier; Obtaining a sleep stage prediction result output by the Transformer-based classifier; The multiple groups of data to be processed are input into a multi-head patch encoder for encoding, and the token sequence corresponding to each group of data to be processed is obtained, which includes: Acquire the input heartbeat interval sequence data through the first single channel of the multi-head patch encoder; Acquire the respiratory waveform data of the input specific frequency band through the second single channel of the multi-head patch encoder; Acquiring input mixed data through dual channels of the multi-head patch encoder, wherein the mixed data is data obtained by mixing the heartbeat interval sequence data and the respiratory waveform data of a specific frequency band; The heartbeat interval sequence data, the respiratory waveform data of a specific frequency band, and the mixed data are encoded by the multi-head patch encoder to obtain a token sequence corresponding to each group of data to be processed.

2. The method according to claim 1, characterized in that The preprocessing of the heartbeat signal and the respiratory signal to obtain a heartbeat interval sequence and a respiratory waveform of a specific frequency band includes: Extracting the corresponding heartbeat interval sequence based on the heartbeat signal, wherein the heartbeat signal includes an ECG signal or a BCG signal, and the heartbeat interval sequence includes an RRI sequence or a JJI sequence; The respiratory signal is filtered based on a specific frequency band to obtain a respiratory waveform in the specific frequency band.

3. The method according to claim 2, characterized in that The respiratory signal and the BCG signal are both collected based on a home monitoring device including a piezoelectric sensor or an optical fiber sensor.

4. The method according to claim 2, characterized in that After filtering the respiratory signal based on the specific frequency band to obtain the respiratory waveform of the specific frequency band, the method further includes: Downsampling the respiratory waveform of the specific frequency band to the same set sampling frequency as the RRI sequence; The downsampled respiratory waveforms were normalized to a standard score.

5. The method according to claim 1, wherein The preprocessing of the heartbeat signal and the respiratory signal to obtain a heartbeat interval sequence and a respiratory waveform of a specific frequency band includes: Data enhancement processing is performed on the heartbeat signal and the respiratory signal, wherein the data enhancement processing includes at least one of amplitude modulation and signal speed change processing.

6. The method according to claim 1, wherein The multi-head patch encoder includes a residual network.

7. The method according to claim 6, characterized in that Extracting a 128-dimensional first feature based on the heartbeat interval sequence data input by the first single channel through the residual network; Extracting a 256-dimensional second feature based on the mixed data of the dual-channel input through the residual network; Extracting a 128-dimensional third feature based on the respiratory waveform data input by the second single channel through the residual network; The first feature, the second feature, and the third feature are concatenated to obtain a 512-dimensional token sequence.

8. The method according to claim 1, characterized in that The Transformer-based classifier includes: a Transformer encoder and a multi-layer perceptron.

9. The method according to claim 8, characterized in that The obtaining of the sleep stage prediction result output by the Transformer-based classifier includes: The Transformer-based classifier generates probability distribution information of the sleep stages corresponding to the token sequence.

10. The method according to any one of claims 1 to 9, characterized in that The specific frequency band is 0.1-0.35 Hz.

11. A sleep staging device, characterized in that: The device comprises: A processor and a memory, wherein the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the sleep staging method according to any one of claims 1 to 10 is implemented.

12. An electronic device, characterized in that: The electronic device includes the sleep staging device according to claim 11.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the sleep staging method according to any one of claims 1 to 10 is implemented.