Sleep apnea detection method based on wavelet transform
The electrocardiogram signal is processed through wavelet transformation and deep learning models, and the problems of complex feature extraction and analysis in the existing technology are solved, efficient and accurate sleep apnea detection is achieved, simplifying the detection process and improving accuracy.
Patent Information
- Application Number
- CN202411392319.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-10-08
AI Technical Summary
Existing sleep apnea detection methods rely on complex feature extraction and analysis, resulting in cumbersome detection processes and insufficient accuracy. In particular, ECG-based methods require complex front-end processing and feature extraction, and may lose the time domain characteristics of the original signal.
Wavelet transform is used to denoising and discrete decomposition of the ECG signal, generating multi-scale signal components as input, and combining convolutional neural network (CNN), bidirectional long and short-term memory network (BiLSTM) and supervised comparison learning to build an end-to-end depth Learn the model to detect sleep apnea events.
Reduces dependence on specific ECG features, improves detection accuracy and efficiency, simplifies signal processing flow, directly uses timing signals as input, avoids complex secondary feature extraction processes, and achieves efficient and accurate sleep breathing. Pause classification and surpass existing models in performance validation.
Smart Images

Figure CN119257556A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of sleep apnea detection, and in particular relates to a sleep apnea detection method based on wavelet transform. Background Art
[0002] Sleep apnea (SA) is a common sleep disorder characterized by brief, periodic episodes of respiratory arrest during sleep. This disorder often increases the risk of cardiovascular disease, diabetes and other metabolic diseases. SA is divided into two types: obstructive sleep apnea (OSA) and central sleep apnea. Most adults and children with sleep apnea belong to the former.
[0003] Polysomnography (PSG) is considered to be the diagnostic standard for sleep disorders such as sleep-related breathing disorders (SRBD), snoring or OSA. PSG can collect various physiological signals of patients during a whole night's sleep, including electroencephalogram, electrooculogram, electromyogram, electrocardiogram, thermosensitivity and oral and nasal pressure airflow, but its high cost and complicated operation process limit its wide application. Therefore, finding a more convenient method with higher detection accuracy has become a research hotspot. Given that the correlation between electrocardiogram and respiratory status has been confirmed by clinical experiments, electrocardiogram has gradually become a new way to detect SA. With the rapid development of artificial intelligence technology, especially the introduction of machine learning and deep learning technology, automatic SA detection methods based on electrocardiogram have emerged.
[0004] Automatic SA detection methods based on ECG are mainly divided into traditional machine learning methods and deep learning methods. Among them, the deep learning-based methods include a variety of front-end data processing and feature extraction methods to adapt to the back-end neural network. At present, there are two mainstream feature engineering methods in this field. One is to manually extract statistical features of ECG, such as heart rate, etc.; the other is to extract R peak peak value, R peak interval, etc. from the ECG as features. The latter is widely used in various deep learning methods as model input. However, these methods require complex analysis and calculation of the original ECG signal, and the extracted features lose their time domain characteristics and may lose some important information in the original ECG. In recent years, some methods have also emerged to convert one-dimensional ECG signals into two-dimensional frequency domain images and use methods in the field of image processing for SA detection. Although this method can sometimes increase the prediction accuracy of the model, the front-end work is too complicated and the cost is high, and the actual application value is not great. For this reason, a sleep apnea detection method based on wavelet transform is proposed. Summary of the invention
[0005] The purpose of the present invention is to provide a sleep apnea detection method based on wavelet transform, aiming to solve the problems raised in the above background technology.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] A sleep apnea detection method based on wavelet transform comprises the following steps:
[0008] Step 1: De-noise the original ECG signal, use the Symlet4 wavelet function to perform a 5-layer discrete wavelet decomposition on the denoised ECG signal, generate 5 high-frequency sub-bands and 1 low-frequency sub-band, and splice the 6 signal components obtained by decomposition as input data for subsequent processing;
[0009] Step 2: Input the spliced signal components into a CNN consisting of 9 one-dimensional convolutional layers for feature transformation and extraction; input the multi-channel time series output by CNN into a BiLSTM to extract the time domain features of each channel; flatten the output features of BiLSTM and input them into a classifier network consisting of two fully connected layers and an activation function layer, and finally calculate the probability of sleep apnea events through the Softmax function, and then determine the specific type of event based on this probability;
[0010] Step 3: Construct two contrast losses based on the sample labels, namely noise contrast estimation loss and normalized temperature scale cross entropy loss. The overall loss obtained by combining the cross entropy loss with the two contrast losses is used as the final network loss function for model training.
[0011] Furthermore, the decomposition process of the Symlet4 wavelet function on the denoised ECG signal by 5-layer discrete wavelet decomposition includes:
[0012] Filtering: filtering the ECG signal through a set of low-pass filters and high-pass filters to obtain approximate coefficients and detail coefficients, i.e., low-frequency signal components and high-frequency signal components;
[0013] Downsampling, sampling the filtered signal at intervals;
[0014] The calculation formula of the filtering process is as follows:
[0015]
[0016] Where A[n] is the low-frequency approximation coefficient of the nth layer, d[n] is the high-frequency approximation coefficient of the nth layer, and A[n+1] and D[n+1] of the n+1th layer are decomposed from A[n] of the nth layer; x is the original signal sequence, f and g are the high-frequency and low-frequency filters respectively, and k is the serial number corresponding to each layer of decomposition;
[0017] After 5 layers of decomposition, 6 signal components are obtained: D[1], D[2], D[3], D[4], D[5] and A[5].
[0018] Furthermore, the number of channels of the CNN is c = {16, 16, 32, 32, 64, 64, 128, 128, 256}, and the formula for each convolution layer is as follows:
[0019] x c =ReLU(Conv1d(x c-1 ))
[0020] Among them, x c-1 is the output feature of the previous layer, ReLU is the activation function used, Conv1d is a one-dimensional convolution, and the output of the last layer is defined as x c .
[0021] Furthermore, the formula of the BiLSTM is as follows:
[0022] h,(h n ,c n )=BiLSTM(x c )
[0023] Among them, x c is the input feature, h is the output of all time steps, and h n and c n are the hidden state and cell state of the last time step respectively; finally, h is used as the input of the classifier network.
[0024] Furthermore, the probability distribution formula of the classification result obtained by the classifier network is as follows:
[0025] x out =Softmax(Linear(ReLU(Linear(Flatten(Dropout(h))))))
[0026] Among them, h is the input feature, x out is the output prediction result, ReLU is the activation function used, Linear is the linear neural network, Flatten is the flattening function, and Dropout is the random neuron discarding function.
[0027] Furthermore, the noise contrast estimation loss formula is as follows:
[0028] For a target sample x i And its positive sample Construct K noise samples where k∈{1,2,…,K}:
[0029]
[0030]
[0031] Among them, sim is the similarity of the sample pair, calculated by cosine similarity; x is the sample, is the corresponding positive sample, is the contrast loss of the positive sample pair, is the contrast loss of the noise sample pair, L i is the overall loss, L NCE is the overall loss of this batch, N is the total number of samples, and i is the corresponding serial number.
[0032] Furthermore, the normalized temperature scaled cross entropy loss formula is as follows:
[0033] For the sample x i And its positive sample
[0034]
[0035] Among them, sim is the similarity of the sample pair, calculated by cosine similarity; τ is the temperature coefficient, j is the corresponding sequence number, L NTXENT_i is the normalized temperature-scaled cross entropy loss of the positive sample pair, L NTXENT is the overall loss of this batch, N is the total number of samples, and i is the corresponding sequence.
[0036] Furthermore, the cross entropy loss formula is as follows:
[0037]
[0038] Among them, L CE is the average cross entropy loss of samples in this batch, M is the number of samples in this batch; y i is the true label of the jth sample, which takes a value of 0 or 1; The probability that the jth sample predicted by the model belongs to the positive category is between 0 and 1.
[0039] Furthermore, the overall loss formula is as follows:
[0040] L=αL CE +(λ1L NCE +λ2L NTXENT )
[0041] Among them, L is the total loss, L CE is the cross entropy loss, L NCE is the noise contrast estimation loss, L NTXENTis the normalized temperature scaled cross entropy loss. α, λ1 and λ2 are parameters for adjusting the proportion of the three losses. α regulates the cross entropy loss, accounting for 90%. λ1 and λ2 regulate the noise contrast estimation loss and the normalized temperature scaled cross entropy loss, respectively, accounting for 10% in total. The sum of α, λ1 and λ2 is 1.
[0042] Compared with the prior art, the present invention has the following beneficial effects:
[0043] The present invention not only reduces the dependence on specific electrocardiogram features, but also improves the accuracy of detection. The core is to use discrete wavelet decomposition technology to decompose the electrocardiogram signal into multi-scale information as model input, and integrate the concept of supervised contrast learning to build an end-to-end deep learning network model to achieve efficient and accurate classification of sleep apnea. Compared with traditional detection methods that rely on expert manual analysis methods or require complex preprocessing steps, the present invention improves detection efficiency, simplifies the complexity of signal processing, and makes the entire detection process smoother and more automated. More importantly, the present invention directly uses time series signals as input, avoiding the complex secondary feature extraction process, which makes the present invention easier to convert into actual hardware devices for implementation. In addition, in terms of performance verification, the prediction accuracy of the present invention surpasses the current electrocardiogram-based automatic sleep apnea detection model using the public ApneaECG data set for testing, proving its excellent performance and great potential in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is a flow chart of the algorithm implementation proposed in the present invention.
[0045] Figure 2 The following is a comparison chart of the predicted results and true labels of the same sample; (a) is the true label and (b) is the predicted result. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0047] like Figure 1 As shown, a sleep apnea detection method based on wavelet transform is provided in one embodiment of the present invention, comprising the following steps:
[0048] 1. Wavelet decomposition; Discrete wavelet decomposition (DWT) is a tool for analyzing signals at multiple resolutions. DWT decomposes the signal into sub-signals of different frequency bands, so that it has good localization characteristics in time and frequency. This decomposition method is very suitable for processing non-stationary signals, such as images, time series signals, etc. Among them, common time series signals include audio signals and physiological time series signals such as electrocardiograms. The electrocardiogram (ECG) signal obtained by original sampling has certain noise, and there are phenomena such as baseline drift and power frequency interference, which are not convenient for direct learning and training of neural networks. DWT can effectively realize the denoising of time series data, and extract low-frequency trend information and high-frequency detail information respectively, while retaining effective information to a large extent. The wavelet function used in the present invention is the Symlet4 wavelet, which is a member of the Symlet wavelet family and a wavelet with good symmetry. Symlet series wavelets have symmetry and orthogonality. In addition, Symlet4 wavelet can better fit signals with peak waveforms such as electrocardiograms. Therefore, the present invention first performs denoising on the ECG signal. The specific operation is to use a bandpass filter with the high frequency set to 45HZ and the low frequency set to 0.05HZ. Then, the denoised ECG signal is decomposed into 5 high-frequency parts and 1 low-frequency part using a 5-layer Symlet4 wavelet function, and then these 6 signal components are spliced together as the input data of the model.
[0049] The decomposition process includes two steps: filtering and downsampling. Filtering is to filter the denoised ECG signal through a set of low-pass filters and high-pass filters to obtain approximate coefficients and detail coefficients, that is, low-frequency signal and high-frequency signal components; downsampling is to perform interval sampling on the filtered signal. The calculation formula of the filtering process is as follows:
[0050]
[0051] Where A[n] is the low-frequency approximation coefficient of the nth layer, D[n] is the high-frequency approximation coefficient of the nth layer, and A[n+1] and D[n+1] of the n+1th layer are decomposed from A[n] of the nth layer. x is the original signal sequence, f and g are the high-frequency and low-frequency filters respectively, and k is the serial number corresponding to each layer of decomposition. After 5 layers of decomposition, we finally get 6 signal components: D[1], D[2], D[3], D[4], D[5] and A[5].
[0052] 2. Hierarchical feature extraction: In order to extract the high-dimensional features of the sequence data, the six signal components are first concatenated and then input into a convolutional neural network (CNN) consisting of 9 one-dimensional convolutional layers for feature transformation and extraction, and finally a multi-channel time series feature is obtained.
[0053] Among them, the number of channels is c = {16, 16, 32, 32, 64, 64, 128, 128, 256}, and the formula for each layer of convolution is as follows:
[0054] x c =ReLU(Conv1d(x c-1 ))
[0055] Among them, x c-1 is the output feature of the previous layer, ReLU is the activation function used, Conv1d is a one-dimensional convolution, and the output of the last layer is defined as x c .
[0056] 3. Time domain feature extraction; BiLSTM is a recurrent neural network that can capture the dependencies between sequence data. It processes the input sequence through LSTM layers in both the forward and backward directions, so it can better understand the contextual information of the sequence. The input of the BiLSTM layer is the multi-channel time series features extracted by CNN, and its main function is to further learn the time series related features in the data. The formula of BiLSTM is as follows:
[0057] h,(h n ,c n )=BiLSTM(x c )
[0058] Among them, x c is the input feature, h is the output of all time steps, and h n and c n are the hidden state and cell state of the last time step respectively. Finally, h is used as the input of the classifier network.
[0059] 4. Classification: Flatten the output features of BiLSTM and input them into the classifier network consisting of two fully connected layers and one activation function layer. Finally, the output is normalized by the second fully connected layer of the Softmax function to obtain the probability distribution of the two categories. The probability distribution is then converted into the final prediction result, that is, whether there is sleep apnea. The probability distribution formula for the classification result is as follows:
[0060] x out =Softmax9Linear9ReLU9Linear(Flatten(Dropout(h))))))
[0061] Among them, h is the input feature, x outis the output prediction result, ReLU is the activation function used, Linear is the linear neural network, Flatten is the flattening function, and Dropout is the random neuron discarding function.
[0062] 5. Contrast loss;
[0063] (1) Noise Contrastive Estimation (NCE) Loss: NCE loss was originally designed for training unsupervised models. It converts the target distribution into a binary classification problem by comparing the target distribution with the noise distribution. By constructing a binary classification problem, the target sample is compared with the noise sample to optimize the embedding representation of the model. Its loss function is based on cosine similarity, adjusts the distribution of similarity through the temperature parameter, and uses the logarithmic loss function to calculate the final loss.
[0064] The NCE loss formula used in this invention is as follows: i And its positive sample And construct K noise samples where k∈{1,2,…,K}:
[0065]
[0066] Among them, sim represents the similarity of sample pairs, which is calculated by cosine similarity; x is the sample, is the corresponding positive sample, is the contrast loss of the positive sample pair, is the contrast loss of the noise sample pair, L i is the overall loss, L NCE is the overall loss of this batch, N is the total number of samples, and i is the corresponding serial number.
[0067] (2) Normalized Temperature Scaled Cross Entropy (NTXent) Loss: NTXent loss is a commonly used loss function for contrastive learning and is used to learn effective feature representations. The main idea is to train the model by maximizing the similarity of similar sample pairs (positive sample pairs) and minimizing the similarity of dissimilar sample pairs (negative sample pairs). The embedding representation of the model is optimized by making positive sample pairs closer in the embedding space and negative sample pairs farther away. Its loss function is also based on cosine similarity, and the distribution of similarity is adjusted by the temperature parameter.
[0068] The NTXent loss formula used in the present invention is as follows: i And its positive sample
[0069]
[0070] Among them, sim is the similarity of the sample pair, calculated by cosine similarity; τ is the temperature coefficient, j is the corresponding sequence number, L NTXENT_i is the normalized temperature-scaled cross entropy loss of the positive sample pair, L NTXENT is the overall loss of this batch, N is the total number of samples, and i is the corresponding sequence.
[0071] 6. Loss function: Cross entropy (CE) loss is a commonly used loss function in classification tasks, and its goal is to measure the difference between the predicted probability distribution and the true distribution. The cross entropy loss formula used in the present invention is as follows:
[0072]
[0073] Among them, L CE is the average cross entropy loss of samples in this batch, M is the number of samples in this batch; y i is the true label of the jth sample, which takes a value of 0 or 1; The probability that the jth sample predicted by the model belongs to the positive category is between 0 and 1.
[0074] During model training, cross entropy loss and two contrast losses are used simultaneously, and the overall loss formula is as follows:
[0075] L=αL CE +(λ1L NCE +λ2L NTXENT )
[0076] Among them, L is the total loss, L CE is the cross entropy loss, L NCE is the noise contrast estimation loss, L NTXENT is the normalized temperature scaled cross entropy loss. α, λ1 and λ2 are parameters for adjusting the proportion of the three losses. α regulates the cross entropy loss, accounting for 90%. λ1 and λ2 regulate the noise contrast estimation loss and the normalized temperature scaled cross entropy loss, respectively, accounting for 10% in total. The sum of α, λ1 and λ2 is 1.
[0077] Example 1. ApneaECG is a public data set in the PhysioNet database. It contains 70 full-night sleep electrocardiogram records of subjects, each record is 7 to 10 hours long. PhysioNet divides the first 35 records of the data set into a training set, and the last 35 records into a test set. Based on this division, the present invention divides 20% of the fragments in the training set into a validation set, trains the model, and stops training at 30 epochs. The prediction index results of the final model on the test set are shown in Table 1:
[0078] Table 1 Prediction index results
[0079]
[0080] As can be seen from Table 1, the accuracy, recall, specificity and F1 score of this method reached 92.2%, 90.8%, 93.1% and 0.899 respectively. Except for specificity, other indicators are better than other methods, which reflects the accuracy and efficiency of this method in the task of sleep apnea detection.
[0081] The comparison of the prediction results and the true labels of the same sample is shown in the figure Figure 2 As shown, (a) is the true label and (b) is the predicted result. Figure 2 It shows that this method can predict most sleep apnea events during sleep. The overall trend is the same, but there are certain differences in details.
[0082] The above are only preferred embodiments of the present invention. It should be pointed out that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention. These should also be regarded as the protection scope of the present invention. These will not affect the effect of the implementation of the present invention and the practicality of the patent.
Claims
1. A sleep apnea detection method based on wavelet transform, characterized in that: The following steps are involved: Step 1: De-noise the original ECG signal, use the Symlet4 wavelet function to perform a 5-layer discrete wavelet decomposition on the denoised ECG signal, generate 5 high-frequency sub-bands and 1 low-frequency sub-band, and splice the 6 signal components obtained by decomposition as input data for subsequent processing; Step 2: Input the spliced signal components into a CNN consisting of 9 one-dimensional convolutional layers for feature transformation and extraction; input the multi-channel time series output by CNN into a BiLSTM to extract the time domain features of each channel; flatten the output features of BiLSTM and input them into a classifier network consisting of two fully connected layers and an activation function layer, and finally calculate the probability of sleep apnea events through the Softmax function, and then determine the specific type of event based on the probability; Step 3: Construct two contrast losses, namely noise contrast estimation loss and normalized temperature scale cross entropy loss. The overall loss obtained by combining the cross entropy loss with the two contrast losses is used as the final network loss function for model training.
2. The sleep apnea detection method based on wavelet transform according to claim 1, characterized in that: The decomposition process of performing 5-layer discrete wavelet decomposition on the denoised ECG signal using the Symlet4 wavelet function includes: Filtering: filtering the ECG signal through a set of low-pass filters and high-pass filters to obtain approximate coefficients and detail coefficients, i.e., low-frequency signal components and high-frequency signal components; Downsampling, sampling the filtered signal at intervals; The calculation formula of the filtering process is as follows: Where A[n] is the low-frequency approximation coefficient of the nth layer, D[n] is the high-frequency approximation coefficient of the nth layer, and A[n+1] and D[n+1] of the n+1th layer are decomposed from A[n] of the nth layer; x is the original signal sequence, f and g are the high-frequency and low-frequency filters respectively, and k is the serial number corresponding to each layer of decomposition; After 5 layers of decomposition, 6 signal components are obtained: D[1], D[2], D[3], D[4], D[5] and A[5].
3. The sleep apnea detection method based on wavelet transform according to claim 1, characterized in that: The number of channels of the CNN is c = {16, 16, 32, 32, 64, 64, 128, 128, 256}, and the formula for each convolution layer is as follows: x c =ReLU(Conv1d(x c-1 )) Among them, x c-1 is the output feature of the previous layer, ReLU is the activation function used, Conv1d is a one-dimensional convolution, and the output of the last layer is defined as x c .
4. The sleep apnea detection method based on wavelet transform according to claim 1, characterized in that: The formula of the BiLSTM is as follows: h,(h n ,c n )=BiLSTM(x c ) Among them, x c is the input feature, h is the output of all time steps, and h n and c n are the hidden state and cell state of the last time step respectively; finally, h is used as the input of the classifier network.
5. The sleep apnea detection method based on wavelet transform according to claim 1, characterized in that: The probability distribution formula of the classification result obtained by the classifier network is as follows: x out =Softmax(Linear(ReLU(Linear(Flatten(Dropout(h)))))) Among them, h is the input feature, x out is the output prediction result, ReLU is the activation function used, Linear is the linear neural network, Flatten is the flattening function, and Dropout is the random neuron discarding function.
6. The sleep apnea detection method based on wavelet transform according to claim 1, characterized in that: The noise contrast estimation loss formula is as follows: For a target sample x i And its positive sample Construct K noise samples where k∈{1,2,…,K}: Among them, sim is the similarity of the sample pair, calculated by cosine similarity; x is the sample, is the corresponding positive sample, is the contrast loss of the positive sample pair, is the contrast loss of the noise sample pair, L i is the overall loss, L NCE is the overall loss of this batch, N is the total number of samples, and i is the corresponding serial number.
7. The sleep apnea detection method based on wavelet transform according to claim 1, characterized in that: The normalized temperature scaled cross entropy loss formula is as follows: For the sample x i And its positive sample Among them, sim is the similarity of the sample pair, calculated by cosine similarity; τ is the temperature coefficient, j is the corresponding sequence number, L NTXENT_i is the normalized temperature-scaled cross entropy loss of the positive sample pair, L NTXENT is the overall loss of this batch, N is the total number of samples, and i is the corresponding sequence.
8. The sleep apnea detection method based on wavelet transform according to claim 1, characterized in that: The cross entropy loss formula is as follows: Among them, L CE is the average cross entropy loss of samples in this batch, M is the number of samples in this batch; y i is the true label of the jth sample, which takes a value of 0 or 1; The probability that the jth sample predicted by the model belongs to the positive category is between 0 and 1.
9. The sleep apnea detection method based on wavelet transform according to claim 1, characterized in that: The overall loss formula is as follows: L=αL CE +(λ1L NCE +λ2L NTXENT ) Among them, L is the total loss, L CE is the cross entropy loss, L NCE is the noise contrast estimation loss, L NTXENT is the normalized temperature scaled cross entropy loss. α, λ1 and λ2 are parameters for adjusting the proportion of the three losses. α regulates the cross entropy loss, accounting for 90%. λ1 and λ2 regulate the noise contrast estimation loss and the normalized temperature scaled cross entropy loss, respectively, accounting for 10% in total. The sum of α, λ1 and λ2 is 1.
Citation Information
Patent Citations
CNN (convolutional neural network) based automatic sleep apnea detection method
CN111248859A
Lightweight ECG classification method based on combination of BiLSTM and serial-parallel multi-scale CNN
CN112733774A
ECG self-supervision interpretable method and system for customizing fine granularity
CN118051824A
Electroencephalogram emotion recognition method based on comparative learning in combination with double-layer high-speed noise and meiosis
CN118114136A
Physiological signal segment classification method based on multi-scale time-through feature fusion
CN118152925A
Cited By
IM signal detection method based on machine learning and wavelet decomposition coefficient characteristics
CN119961660A