A method and device for automatically detecting sleep apnea
The double residual neural network model is used to extract and optimize the RR interval sequence of the electrocardiogram (ECG) signal, which solves the problems of insufficient real-time and accuracy of sleep apnea detection in the existing technology and achieves more efficient sleep state prediction.
Patent Information
- Application Number
- CN202210716821.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-23
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-06-23
AI Technical Summary
In the existing technology, the real-time and accuracy of sleep apnea detection are insufficient, especially because the high sampling frequency of ECG signals leads to a long single sample length, which limits the depth and performance of the neural network.
A dual residual neural network model is used to extract the features of the RR interval sequence in the electrocardiogram (ECG) signal. The time domain and frequency domain information are captured through two residual networks with different structures. The gradient reversal layer and label classifier are combined to optimize the model parameters to improve the accuracy and real-time performance of detection.
The accuracy and real-time performance of sleep apnea detection are improved, the generalization ability of the model is enhanced, and more efficient sleep state prediction is achieved.
Smart Images

Figure CN115295143B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of sleep monitoring, and in particular relates to a method and device for automatically detecting sleep apnea. Background Art
[0002] Sleep apnea syndrome (SAS) is a sleep disorder in which breathing stops during sleep. The most common cause is upper airway obstruction, often culminating in loud snoring, body twitching, or arm flailing. It can lead to health problems such as sleep deprivation, daytime napping, fatigue, and bradycardia or arrhythmia. Preventing and treating SAS requires accurate detection.
[0003] In existing technologies, sleep apnea detection typically involves monitoring electrocardiogram (ECG) signals and then processing them to analyze sleep states. ECG signal processing typically employs classifiers such as the K-nearest neighbor algorithm (KNN) and support vector machines (SVM). Deep neural networks are also employed for automatic feature extraction and classification. However, the high sampling frequency of ECG signals results in long individual sample lengths, which limits the depth and performance of the neural network. Consequently, sleep apnea detection still falls short of meeting practical requirements in terms of real-time performance and accuracy. Summary of the Invention
[0004] In view of the above problems, embodiments of the present invention provide a method and apparatus for automatic detection of sleep apnea. By extracting the RR interval sequence from the electrocardiogram (ECG) signal and analyzing this sequence based on the gradient reversal layer in a residual neural network, it is determined whether apnea occurs, thereby improving the real-time performance and accuracy of SAS detection.
[0005] In order to achieve the above objectives, the embodiments of the present invention adopt the following technical solutions:
[0006] In a first aspect, an embodiment of the present invention provides a method for automatically detecting sleep apnea, the method comprising the following steps:
[0007] Step S1, collecting the ECG signal of the human body during sleep, and extracting the time interval between adjacent R waves as RR interval data based on the R wave in the five waves of the electrocardiogram cycle PQRST, to generate a heartbeat interval time series;
[0008] Step S2, using a dual residual neural network model including two residual networks RN with different structures to extract features from the heartbeat interval time series, where one residual network is used to capture time domain information and the other is used to capture frequency domain information, thereby converting the heartbeat interval time series into two heart rate interval features of the same dimension;
[0009] Step S3, fusing the two heart rate interval features to obtain a fused heart rate feature;
[0010] Step S4: After removing the unlabeled generalized domain data from the fused heart rate features, the features are input into a label classifier, and the parameters of the double residual neural network model and the label classifier are updated according to the output of the label classifier;
[0011] Step S5: The fused heart rate features are passed through a gradient reversal layer and then input into a domain classifier. The parameters of the dual residual neural network model and the domain classifier are updated according to the output of the domain classifier to obtain a mature dual residual neural network model.
[0012] Step S6: input the heartbeat interval time series into a trained mature double residual neural network model, then input the output features into a label classifier, and then determine whether apnea occurs based on the results and the set threshold.
[0013] As a preferred embodiment of the present invention, step S5 implements the reversal of the sign of the gradient during back propagation through a gradient reversal layer. The output of the gradient reversal layer in forward propagation is equal to the input, and affine propagation is performed. During back propagation, a negative factor of -1 is multiplied on the gradient to reverse the gradient, thereby achieving gradient subtraction.
[0014] As a preferred embodiment of the present invention, the two residual networks RN with different structures are distinguished by the size of the structure, one of which is a large RN structure for capturing frequency domain information; and the other is a small RN structure for capturing time domain information.
[0015] As a preferred embodiment of the present invention, the dual residual neural network model includes two residual networks with different residual block lengths; wherein the large RN structure has 8 residual blocks and the small RN structure has 4 residual blocks;
[0016] After the heart rate interval time series is input, it is first divided into two groups of data of the same length and enters two different residual networks respectively; each group of data first undergoes 5 one-dimensional convolutional layers of size 1*20, followed by a batch normalization layer for normalization and a ReLU function layer for activation, and then average pooling through a 1*2 average pooling layer; followed by 4 or 8 identical residual blocks connected in sequence. Each residual block passes the incoming feature map through 2 one-dimensional convolutional layers of size 1*3, 2 BN layers, and 2 ReLU function layers, and then adds it to itself. The short-circuit connection is used to add the input and output of the residual block; finally, it passes through a 1*3 convolutional layer and an average pooling layer, and finally the two residual networks extract two groups of heart rate interval features.
[0017] As a preferred embodiment of the present invention, the one-dimensional convolutional layer is the core of the CNN. In the convolutional layer, a weight vector W with a fixed size is multiplied by the input data one by one, which is a convolution operation. The convolution result plus the bias term B constitutes the input vector of the activation function h; the output of the activation function h will be the input of the next layer. Let the input vector be X, then the output Y of the l-th convolutional layer is:
[0018]
[0019] In formula (1), It is a convolution calculation, B is the bias matrix, and W is a weight vector with a fixed size.
[0020] As a preferred embodiment of the present invention, the ReLU function in the convolutional layer is:
[0021] h RelU (x) = max(0, x) (2)
[0022] Normalize the input vector X to get
[0023]
[0024] In formula (3), E(x) and Var(x) are the expectation and deviation of x, x is the input sample, and ∈ is a smoothing term used to avoid division by zero;
[0025] In the 4 or 8 residual blocks of the residual neural network, each residual block consists of two one-dimensional convolutional layers, two BN layers and two ReLU function layers, using the input vector X to define the output Y:
[0026] Y=F(X,{W}) (4)
[0027] In formula (4), F represents the mapping of the block, and the set {W} represents all the weighted vectors in the block, and the output Y of the residual block is obtained r for:
[0028] Y r =Y+X=F(X,{W})+X (5)
[0029] In the 4 or 8 residual blocks, a short-circuit connection is established to add the input of the residual block to its output, and projection is performed in the short-circuit connection so that the input size matches the output size.
[0030] As a preferred embodiment of the present invention, in step S4, updating the parameters of the dual residual neural network model and the label classifier according to the output result of the label classifier specifically includes:
[0031] The output of the label classifier is the probability p of apnea, and the manually labeled label is y; the cross-entropy loss function L = -y log(p) - (1-y) log(1-p) is calculated, and then the calculated loss value is used to update the weights of the residual network and the label classifier through the gradient backpropagation algorithm.
[0032] As a preferred embodiment of the present invention, in step S5, the fused heart rate features are input into the domain classifier after passing through the gradient reversal layer to determine whether the features of the training domain and the generalization domain cannot be distinguished, thereby optimizing the generalization ability of the dual residual neural network model; the gradient reversal layer reduces the training distribution DS by optimizing X With the test distribution DT X H divergence d between H (DS X , DT X ), optimize the generalization ability of the double residual neural network model;
[0033] The calculation method of H divergence is:
[0034]
[0035] Where η(x) is the optimized classification prediction label of sample x, Pr[η(x)=1] is the probability that the prediction label of x is 1, and sup is the upper limit;
[0036] Optimizing the generalization ability of the dual residual neural network model is equivalent to optimizing the following objective loss function:
[0037]
[0038] Among them, G d (·) is a domain classifier used to distinguish data x i From the training domain or the test domain, G f (·) is the representation function, which is realized by using the hidden layer output before the neural network classification output, d i is the true label of the sample source domain. If the data comes from the training distribution, it is 0, and if it comes from the test distribution, it is 1;
[0039] Implementing domain classifier G using neural network d (·) and represents the function G f (·), the stochastic gradient descent method is used to update the parameters; during the propagation process, the error calculated by formula (7) is used to update the domain classifier G d The parameter θ of (·) d , represents the function G f The parameter θ of (·) f and the final label output classifier Gf The parameter θ of (·) y , the update formula is
[0040]
[0041]
[0042]
[0043] Where μ is the learning rate, is the updated representation function G f The parameters of (·), is the representation function G before update f The parameter θ of (·) f , Represents the loss function value of the i-th mini-batch, and so on; λ is the weight factor.
[0044] As a preferred embodiment of the present invention, the threshold value is set to 0.5 in step S6. If p<0.5, it is determined that apnea has not occurred; if p≥0.5, it is determined that apnea has occurred.
[0045] In a second aspect, an embodiment of the present invention further provides an automatic sleep apnea detection device, comprising: an ECG signal acquisition module, a heartbeat interval information generation module, a double residual neural network module, a feature fusion module, a label classifier module, a domain classifier module, and a sleep apnea judgment module; wherein,
[0046] The ECG signal acquisition module is used to collect ECG signals of the human body during sleep;
[0047] The heartbeat interval information generation module acquires the heartbeat interval information according to the R wave in the electrocardiogram cycle, further generates a heartbeat interval time series, and sends it to the double residual neural network module;
[0048] The dual residual neural network module is used to extract features from the heartbeat interval time series using a dual residual neural network model comprising two residual networks with different structures, and convert the heartbeat interval time series into two heart rate interval features of the same dimension;
[0049] The feature fusion module is used to fuse the two heart rate interval features to obtain a fused heart rate feature;
[0050] The label classifier module is used to remove the unlabeled generalized domain data from the fused heart rate features and input them into the label classifier, and update the parameters of the double residual neural network model and the label classifier according to the output results of the label classifier;
[0051] The domain classifier module is used to input the fused heart rate features into the domain classifier after passing through the gradient reversal layer, and update the parameters of the double residual neural network model and the domain classifier according to the output of the domain classifier to obtain a mature double residual neural network model, and save it to the sleep apnea judgment module;
[0052] The sleep apnea judgment module is used to read the heartbeat interval time series after receiving the mature double residual neural network model, and input it into the mature double residual neural network model, and then input the features output by the model into the label classifier, and judge whether apnea occurs based on the output result of the label classifier and the set threshold.
[0053] As can be seen from the above technical solutions, the automatic sleep apnea detection method provided in this embodiment is based on a heartbeat time series dataset, uses a dual residual neural network for feature extraction, and then performs two types of classification. The model parameters are optimized through a label classifier and a domain classifier. The classifier optimizes the model so that the model cannot distinguish between training domain and generalization domain data, thereby improving the model's generalization ability. After obtaining a mature dual residual neural network model, the generated time series is input into the model, and the output result is then input into the label classifier. The sleep state is judged based on the result of the label classifier, thereby improving the accuracy of sleep prediction.
[0054] Of course, it is not necessary to achieve all of the advantages described above simultaneously in order to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments.
[0056] Figure 1 Schematic diagram of the process of the automatic detection method of sleep apnea according to an embodiment of the present invention;
[0057] Figure 2 Schematic diagram of the structure of an automatic sleep apnea detection device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0058] Below, by referring to exemplary embodiments, technical problems, technical solutions and advantages of the present invention are explained in detail. The exemplary embodiments described below are only used to explain the present invention and are not to be construed as limiting the present invention. It will be appreciated by those skilled in the art that, unless otherwise defined, All terms (including technical terms and scientific terms) used herein have the same meaning as those generally understood by those of ordinary skill in the art to which the present invention belongs. It should also be understood that, such as those defined in general dictionaries, should be understood to have a meaning consistent with the meaning in the context of the prior art, and unless defined here, will not be interpreted with an idealized or overly formal meaning.
[0059] The present invention extracts the RR intervals representing adjacent R waves from the electrocardiogram (ECG) signal corresponding to sleep, and places this data in a double residual neural network model for feature extraction. The extracted features are then used to determine whether apnea occurs, thereby automatically detecting it. The double residual neural network model uses two residual network (RN) structures, including a large RN structure and a small RN structure. The small RN structure is used to capture time domain information, and the large RN structure is used to capture frequency domain information to complete feature extraction. Finally, the extracted features are placed in two different classifiers, where the label classifier is used to classify sleep apnea, and the domain classifier is used to classify the data source. Before being input into the domain classifier, the features will first pass through a gradient reversal layer. The purpose of the gradient reversal layer and the domain classifier is to improve the generalization of the model.
[0060] To facilitate understanding of the embodiments of the present invention, several specific embodiments will be further explained below with reference to the accompanying drawings, and each embodiment does not constitute a limitation on the technical solution of the present invention.
[0061] First embodiment
[0062] This embodiment provides a method for automatically detecting sleep apnea. Figure 1 The figure shows a flow chart of the automatic sleep apnea detection method. Figure 1 As shown, the sleep apnea automatic detection method includes the following steps:
[0063] Step S1, collecting the ECG signal of the human body during sleep, and extracting the time interval between adjacent R waves as RR interval data based on the R wave in the five waves of the electrocardiogram cycle PQRST, to generate a heartbeat interval time series.
[0064] In this step, the sleep ECG signal can be collected using various mobile devices. Generally, the acquisition frequency is 100 Hz. To generate the required time series, the RR sequence extracted from the ECG is resampled to 2 Hz to generate the heartbeat interval time series.
[0065] Step S2, using a dual residual neural network model containing two residual networks with different structures to extract features of the heartbeat interval time series, where one residual network is used to capture time domain information and the other is used to capture frequency domain information, and the heartbeat interval time series is converted into two heart rate interval features of the same dimension.
[0066] In this step, the two residual networks with different structures can be distinguished by their size: one is a large RN structure, such as a convolutional neural network (CNN); the other is a small RN structure, such as a residual neural network trained using the backpropagation (BP) algorithm. Typically, the small RN structure is used to capture time domain information, while the large RN structure is used to capture frequency domain information.
[0067] In this step, the dual residual neural network model includes two residual networks with different residual block lengths. Here, the large RN structure has 8 residual blocks and the small RN structure has 4 residual blocks as an example. However, in actual operation, other structural parameters can also be selected as needed. After the heartbeat interval time series is input, it is first divided into 2 groups of data of the same length and enters 2 different residual networks respectively. Each group of data first undergoes 5 one-dimensional convolution layers of size 1*20, followed by a batch normalization layer for normalization and a ReLU function layer for activation, and then average pooling is performed through an average pooling layer of size 1*2; followed by 4 (8) identical residual blocks connected in sequence, each residual block is to pass the incoming feature map through 2 one-dimensional convolution layers of size 1*3, 2 BN layers, and 2 ReLU function layers and then add it to itself. The short-circuit connection is used to add the input and output of the residual block; finally, it passes through a convolution layer of size 1*3 and an average pooling layer to obtain a set of feature maps. Finally, the two sets of feature maps extracted by the two residual networks are fused to obtain the heartbeat interval features automatically extracted by the dual residual neural network model.
[0068] The one-dimensional convolutional layer is the core of CNN. In the convolutional layer, a weight vector W with a fixed size is multiplied by the input data one by one, which is the convolution operation. The convolution result plus the bias term B constitutes the input vector of the activation function h. The output of the activation function h will be the input of the next layer. If the input vector is X, then the output of the convolutional layer l is for:
[0069]
[0070] In formula (1), It is a convolution calculation, B is the bias matrix, and W is a weight vector with a fixed size.
[0071] In this embodiment, all activation functions h in the convolutional layer are ReLU functions to speed up training and reduce the final error rate in the neural network. The ReLU function is:
[0072] h RelU (x) = max(0, x) (2)
[0073] The batch normalization layer (BN layer) is used to reduce the internal covariate shift in the residual neural network and normalize the input vector X to obtain
[0074]
[0075] In formula (3), E(x) and Var(x) are the expectation and deviation of x, x is the input sample, and ∈ is a smoothing term used to avoid division by zero. It is usually set to a very small positive number that can be ignored. The batch normalization layer (BN layer) in the neural network can achieve the function of data whitening.
[0076] In the 4 (8) residual blocks of the residual neural network, each residual block consists of two one-dimensional convolutional layers, two BN layers and two ReLU function layers, and uses the input vector X to define its output Y:
[0077] Y=F(X,{W}) (4)
[0078] In formula (4), F represents the mapping of the block, and the set {W} represents all the weighted vectors in the block, and the output Y of the residual block is obtained r for:
[0079] Y r =Y+X=F(X,{W})+X (5)
[0080] In the 4 (8) residual blocks, a short-circuit connection is established to add the input of the residual block to its output, and projection is performed in the short-circuit connection so that the input size matches the output size.
[0081] Step S3: Fusing the two heart rate interval features to obtain a fused heart rate feature.
[0082] Step S4: After removing the unlabeled generalized domain data from the fused heart rate features, the features are input into a label classifier, and the parameters of the dual residual neural network model and the label classifier are updated according to the output results of the label classifier.
[0083] In this step, for each sample, the label classifier outputs the probability p of apnea, and the manually labeled label is y. The cross-entropy loss function L = -y log(p) - (1-y) log(1-p) is calculated. This loss is then used to update the weights of the residual network and the label classifier using the gradient backpropagation algorithm.
[0084] In step S5, the fused heart rate features are input into the domain classifier after passing through the gradient reversal layer. The parameters of the dual residual neural network model and the domain classifier are updated according to the output results of the domain classifier to obtain a mature dual residual neural network model.
[0085] In this step, the heart rate interval features are input into the domain classifier after passing through the gradient reversal layer to determine whether the features of the training domain and the generalization domain cannot be distinguished, thereby optimizing the generalization ability of the double residual neural network model. The gradient reversal layer reduces the training distribution DS by optimizing X With the test distribution DT X H divergence d between H (DS X , DT X ), optimize the generalization ability of the double residual neural network model.
[0086] The calculation method of H divergence is:
[0087]
[0088] Where η(x) is the optimized classification prediction label of sample x, Pr[η(x)=1] is the probability that the predicted label of x is 1, and sup is the supremum. For example, sup E refers to the supremum of the set E, that is, the smallest element greater than or equal to all other elements of E. This number is not necessarily in the set E. In the derivation of domain adversarial learning, the above optimization problem is proved to be equivalent to optimizing the following objective loss function L d :.
[0089]
[0090] Among them, G d (·) is a domain classifier used to distinguish data x i From the training domain or the test domain, G f (·) is the representation function, which can be realized by using the hidden layer output before the neural network classification output, d i is the true label of the sample source domain. If the data comes from the training distribution, it is 0, and if it comes from the test distribution, it is 1.
[0091] Implementing domain classifier G using neural network d(·) and represents the function G f (·), the stochastic gradient descent method is used to update the parameters. During the propagation process, the error calculated by formula (7) is used to update the domain classifier G d The parameter θ of (·) d , represents the function G f The parameter θ of (·) f and the final label output classifier G f The parameter θ of (·) y , the update formula is
[0092]
[0093]
[0094]
[0095] Where μ is the learning rate, is the updated representation function G f The parameters of (·), is the representation function G before update f The parameter θ of (·) f , Represents the loss function value of the i-th mini-batch, and so on; λ is the weight factor, adjusting the importance of.
[0096] Among the three parameter update formulas mentioned above, formula (9) and formula (10) can be implemented by the normal back propagation algorithm, but the gradient subtraction part in formula (8) cannot be implemented.
[0097] In this step, the gradient reversal layer is used to reverse the sign of the gradient during backpropagation. The output of the gradient reversal layer during forward propagation is equal to the input, i.e., affine propagation. During backpropagation, the gradient is multiplied by a negative factor of -1 to reverse the gradient, thus achieving gradient subtraction.
[0098] Step S6: input the heartbeat interval time series into a trained mature double residual neural network model, then input the output features into a label classifier, and then determine whether apnea occurs based on the results and the set threshold.
[0099] In this step, the output result of the label classifier is p, and a threshold is set. For example, the threshold is set to 0.5. If p<0.5, it is determined that apnea has not occurred; if p≥0.5, it is considered that apnea has occurred.
[0100] As can be seen from the above technical solutions, the automatic sleep apnea detection method provided in this embodiment is based on a heartbeat time series dataset, uses a dual residual neural network for feature extraction, and then performs two types of classification. The model parameters are optimized through a label classifier and a domain classifier. The classifier optimizes the model so that the model cannot distinguish between training domain and generalization domain data, thereby improving the model's generalization ability. After obtaining a mature dual residual neural network model, the generated time series is input into the model, and the output result is then input into the label classifier. The sleep state is judged based on the result of the label classifier, thereby improving the accuracy of sleep prediction.
[0101] Second embodiment
[0102] This embodiment provides a sleep apnea automatic detection device. Figure 2 The figure shows the structure of the automatic detection device. Figure 2 As shown, the automatic sleep apnea detection device includes: an ECG signal acquisition module, a heartbeat interval information generation module, a double residual neural network module, a feature fusion module, a label classifier module, a domain classifier module and a sleep apnea judgment module.
[0103] The ECG signal acquisition module is used to acquire the electrocardiogram (ECG) signal of the human body during sleep;
[0104] The heartbeat interval information generation module acquires the heartbeat interval information according to the R wave in the electrocardiogram cycle, further generates a heartbeat interval time series, and sends it to the double residual neural network module;
[0105] The dual residual neural network module is used to extract features from the heartbeat interval time series using a dual residual neural network model comprising two residual networks with different structures, and convert the heartbeat interval time series into two heart rate interval features of the same dimension;
[0106] The feature fusion module is used to fuse the two heart rate interval features to obtain a fused heart rate feature;
[0107] The label classifier module is used to remove the unlabeled generalized domain data from the fused heart rate features and input them into the label classifier, and update the parameters of the double residual neural network model and the label classifier according to the output results of the label classifier;
[0108] The domain classifier module is used to input the fused heart rate features into the domain classifier after passing through the gradient reversal layer, and update the parameters of the double residual neural network model and the domain classifier according to the output of the domain classifier to obtain a mature double residual neural network model, and save it to the sleep apnea judgment module;
[0109] The sleep apnea judgment module is used to read the heartbeat interval time series after receiving the mature double residual neural network model, and input it into the mature double residual neural network model, and then input the features output by the model into the label classifier, and judge whether apnea occurs based on the output result of the label classifier and the set threshold.
[0110] In this embodiment, each module is implemented by a processor, and a memory is appropriately added when storage is required. The processor may be, but is not limited to, a microprocessor MPU, a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), other programmable logic devices, discrete gates, transistor logic devices, discrete hardware components, etc. The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0111] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode.
[0112] It should be noted that the gradient inversion layer-based sleep apnea detection device described in this example is a technical solution corresponding to the gradient inversion layer-based automatic sleep apnea detection method described in the first embodiment. Reference is made to the same or similar parts between the embodiments, and each embodiment focuses on the differences from the other embodiments. In particular, the device or system embodiments are generally similar to the method embodiments, so their description is relatively brief. For relevant details, please refer to the description of the method embodiments and will not be repeated here.
[0113] The foregoing description is a preferred embodiment of the present invention. It should be noted that the present invention is not limited to the exemplary embodiments disclosed above. The essence of this description is merely to help those skilled in the relevant art comprehensively understand the specific details of the present invention. For those skilled in the art, various improvements and modifications, as well as readily conceivable changes or substitutions made within the technical scope of the present invention without departing from the principles of the present invention, should be included within the scope of protection of the present invention.
Claims
1. A method for automatically detecting sleep apnea, characterized in that: The method comprises the following steps: Step S1, collecting the ECG signal of the human body during sleep, and extracting the time interval between adjacent R waves as RR interval data based on the R wave in the five waves of the electrocardiogram cycle PQRST, to generate a heartbeat interval time series; Step S2, using a dual residual neural network model including two residual networks RN with different structures to extract features from the heartbeat interval time series, where one residual network is used to capture time domain information and the other is used to capture frequency domain information, thereby converting the heartbeat interval time series into two heart rate interval features of the same dimension; Step S3, fusing the two heart rate interval features to obtain a fused heart rate feature; Step S4: After removing the unlabeled generalized domain data from the fused heart rate features, the features are input into a label classifier, and the parameters of the double residual neural network model and the label classifier are updated according to the output of the label classifier; Step S5: The fused heart rate features are passed through a gradient reversal layer and then input into a domain classifier. The parameters of the dual residual neural network model and the domain classifier are updated according to the output of the domain classifier to obtain a mature dual residual neural network model. Step S6, inputting the heartbeat interval time series into a trained mature double residual neural network model, then inputting the output features into a label classifier, and then judging whether apnea occurs based on the results and a set threshold; In the above step S5, the fused heart rate features are input into the domain classifier after passing through the gradient reversal layer to determine whether the features of the training domain and the generalization domain cannot be distinguished, thereby optimizing the generalization ability of the double residual neural network model; the gradient reversal layer reduces the training distribution DS by optimizing X With the test distribution DT X H divergence d between H (DS X , DT X ), optimize the generalization ability of the double residual neural network model; The calculation method of H divergence is: Where η(x) is the optimized classification prediction label of sample x, Pr[η(x)=1] is the probability that the prediction label of x is 1, and sup is the upper limit; Optimizing the generalization ability of the dual residual neural network model is equivalent to optimizing the following objective loss function: Among them, G d (·) is a domain classifier used to distinguish data x i From the training domain or the test domain, G f (·) is the representation function, which is realized by using the hidden layer output before the neural network classification output, d i is the true label of the sample source domain. If the data comes from the training distribution, it is 0, and if it comes from the test distribution, it is 1; Implementing domain classifier G using neural network d (·) and represents the function G f (·), the stochastic gradient descent method is used to update the parameters; during the propagation process, the error calculated by formula (7) is used to update the domain classifier G d The parameter θ of (·) d , represents the function G f The parameter θ of (·) f and the final label output classifier G f The parameter θ of (·) y , the update formula is Where μ is the learning rate, is the updated representation function G f The parameters of (·), is the representation function G before update f The parameter θ of (·) f , Represents the loss function value of the i-th mini-batch, and so on; is the weight factor.
2. The sleep apnea automatic detection method according to claim 1, characterized in that: In step S5, the positive and negative reversal of the gradient during back propagation is achieved through the gradient reversal layer; the output of the gradient reversal layer in forward propagation is equal to the input, and affine propagation is performed; during back propagation, a negative factor of -1 is multiplied on the gradient to reverse the gradient.
3. The automatic sleep apnea detection method according to claim 1 or 2, characterized in that: The two residual networks RN with different structures are distinguished by the size of the structure, one of which is a large RN structure for capturing frequency domain information; and the other is a small RN structure for capturing time domain information.
4. The automatic sleep apnea detection method according to claim 3, characterized in that: The dual residual neural network model includes two residual networks with different residual block lengths; wherein the large RN structure has 8 residual blocks and the small RN structure has 4 residual blocks; After the heart rate interval time series is input, it is first divided into two groups of data of the same length and enters two different residual networks respectively; each group of data first undergoes 5 one-dimensional convolution layers of size 1*20, followed by a batch normalization layer for normalization and a ReLU function layer for activation, and then average pooling is performed through an average pooling layer of size 1*2; followed by 4 or 8 identical residual blocks connected in sequence, and each residual block makes the incoming feature map pass through 2 one-dimensional convolution layers of size 1*3, 2 BN layers, and 2 ReLU function layers, and then adds it to itself. The short-circuit connection is used to add the input and output of the residual block; finally, it passes through a convolution layer of size 1*3 and an average pooling layer, and finally the two residual networks extract two groups of heart rate interval features.
5. The automatic sleep apnea detection method according to claim 4, characterized in that: The one-dimensional convolutional layer is the core of CNN. In the convolutional layer, a weight vector W with a fixed size is multiplied by the input data one by one, which is the convolution operation. The convolution result plus the bias term B constitutes the input vector of the activation function h; the output of the activation function h will be the input of the next layer. Let the input vector be X, then the output Y of the l-th convolutional layer is: In formula (1), It is a convolution calculation, B is the bias matrix, and W is a weight vector with a fixed size.
6. The automatic sleep apnea detection method according to claim 5, characterized in that: The ReLU function in the convolutional layer is: h RelU (x)=max (0,x) (2) Normalize the input vector X to obtain In formula (3), E(x) and Var(x) are the expectation and deviation of x, x is the input sample, and ∈ is a smoothing term used to avoid division by zero; In the 4 or 8 residual blocks of the residual neural network, each residual block consists of two one-dimensional convolutional layers, two BN layers and two ReLU function layers, using the input vector X to define the output Y: Y=F(X,{W}) (4) In formula (4), F represents the mapping of the block, and the set {W} represents all the weighted vectors in the block, and the output Y of the residual block is obtained r for: Y r =Y+X=F(X,{W})+X (5) In the 4 or 8 residual blocks, a short circuit connection is established, the input of the residual block is added to its output, and projection is performed in the short circuit connection so that the input size matches the output size.
7. The automatic sleep apnea detection method according to claim 1 or 2, characterized in that: In step S4, the parameters of the dual residual neural network model and the label classifier are updated according to the output result of the label classifier, specifically including: The output of the label classifier is the probability p of apnea, and the manually labeled label is y; the cross-entropy loss function L = -ylog(p) - (1-y)log(1-p) is calculated, and then the calculated loss value is used to update the weights of the residual network and the label classifier through the gradient backpropagation algorithm.
8. The automatic sleep apnea detection method according to claim 1 or 2, characterized in that: In step S6, the threshold is set to 0.
5. If p<0.5, it is determined that apnea has not occurred; if p≥0.5, it is determined that apnea has occurred.
9. An automatic sleep apnea detection device, characterized in that: The automatic sleep apnea detection device includes: an ECG signal acquisition module, a heartbeat interval information generation module, a double residual neural network module, a feature fusion module, a label classifier module, a domain classifier module and a sleep apnea judgment module; wherein, The ECG signal acquisition module is used to collect ECG signals of the human body during sleep; The heartbeat interval information generation module acquires the heartbeat interval information according to the R wave in the electrocardiogram cycle, further generates a heartbeat interval time series, and sends it to the double residual neural network module; The dual residual neural network module is used to extract features from the heartbeat interval time series using a dual residual neural network model comprising two residual networks with different structures, and convert the heartbeat interval time series into two heart rate interval features of the same dimension; The feature fusion module is used to fuse the two heart rate interval features to obtain a fused heart rate feature; The label classifier module is used to remove the unlabeled generalized domain data from the fused heart rate features and input them into the label classifier, and update the parameters of the double residual neural network model and the label classifier according to the output results of the label classifier; The domain classifier module is used to input the fused heart rate features into the domain classifier after passing through the gradient reversal layer, and update the parameters of the double residual neural network model and the domain classifier according to the output of the domain classifier to obtain a mature double residual neural network model, and save it to the sleep apnea judgment module; The fused heart rate features are input into the domain classifier after passing through the gradient reversal layer to determine whether the features of the training domain and the generalization domain cannot be distinguished, thereby optimizing the generalization ability of the dual residual neural network model; the gradient reversal layer reduces the training distribution DS by optimizing X With the test distribution DT X H divergence d between H (DS X , DT X ), optimize the generalization ability of the double residual neural network model; The calculation method of H divergence is: Where η(x) is the optimized classification prediction label of sample x, Pr[η(x)=1] is the probability that the prediction label of x is 1, and sup is the upper limit; Optimizing the generalization ability of the dual residual neural network model is equivalent to optimizing the following objective loss function: Among them, G d (·) is a domain classifier used to distinguish data x i From the training domain or the test domain, G f (·) is the representation function, which is realized by using the hidden layer output before the neural network classification output, d i is the true label of the sample source domain. If the data comes from the training distribution, it is 0, and if it comes from the test distribution, it is 1; Implementing domain classifier G using neural network d (·) and represents the function G f (·), the stochastic gradient descent method is used to update the parameters; during the propagation process, the error calculated by formula (7) is used to update the domain classifier G d The parameter θ of (·) d , represents the function G f The parameter θ of (·) f and the final label output classifier G f The parameter θ of (·) y , the update formula is Where μ is the learning rate, is the updated representation function G f The parameters of (·), is the representation function G before update f The parameter θ of (·) f , Represents the loss function value of the i-th mini-batch, and so on; is the weight factor; The sleep apnea judgment module is used to read the heartbeat interval time series after receiving the mature double residual neural network model, and input it into the mature double residual neural network model, and then input the features output by the model into the label classifier, and judge whether apnea occurs based on the output result of the label classifier and the set threshold.
Citation Information
Patent Citations
Sleep apnea risk assessment method, device and equipment and storage medium
CN114550932A
Method for predicting sleep apnea from neural networks
US20200365271A1