Obstructive sleep breathing state detection method based on joint denoising
By employing an improved variational mode decomposition and adaptive wavelet thresholding joint denoising technique and a DenseNet-Transformer hybrid architecture, the problems of noise removal and feature preservation in existing OSA detection methods are solved, achieving high-precision OSA detection and improving the accuracy and robustness of detection.
Patent Information
- Application Number
- CN202511494449.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2026-01-06
AI Technical Summary
Existing methods for detecting obstructive sleep apnea (OSA) based on single-lead ECG lack adaptability in the signal preprocessing stage, making it difficult to effectively remove noise of different types and intensities and to distinguish between noise and physiological signals, resulting in the loss of key feature information. At the same time, they have limited ability to capture multi-scale temporal patterns and long-range dependencies, affecting detection accuracy and generalization ability.
An improved variational mode decomposition and adaptive wavelet thresholding joint denoising technique is adopted, combined with an enhanced DenseNet-Transformer hybrid architecture. Through adaptive parameter adjustment and spatiotemporal protection mechanisms, noise is effectively removed and physiological characteristics are protected, capturing OSA-related features in ECG signals.
It improves the accuracy and robustness of OSA detection, and can generate high-quality denoised signals in baseline drift and electromyography interference environments, thereby enhancing the model's detection accuracy and generalization ability.
Smart Images

Figure CN121265076A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of biomedical signal processing and artificial intelligence, specifically to an automatic detection method for obstructive sleep apnea based on an improved variational mode decomposition and adaptive wavelet thresholding joint denoising technique, combined with an enhanced DenseNet-Transformer hybrid architecture. Background Technology
[0002] Obstructive sleep apnea (OSA) is a common sleep disorder characterized by recurrent upper airway collapse during sleep, leading to intermittent apnea and hypoventilation. This type of breathing abnormality not only severely affects patients' sleep quality but also significantly increases the risk of cardiovascular and cerebrovascular diseases such as hypertension, arrhythmia, and stroke. Currently, the clinical diagnosis of OSA mainly relies on polysomnography (PSG). Although its accuracy is high, its expensive equipment, complex operation, and reliance on professional personnel make it difficult to promote its application in primary healthcare and large-scale screening. Studies have shown that the intermittent hypoxia and intrathoracic pressure fluctuations induced by OSA can interfere with the autonomic nervous system, leading to abnormal cardiac electrical activity, manifested in ECG signals as characteristic changes such as heart rate variability, providing a theoretical basis for non-invasive detection based on single-lead ECG. In recent years, deep learning technology has made significant progress in ECG signal analysis, but existing methods still have the following technical shortcomings: First, traditional filtering methods with fixed parameters are mostly used in the signal preprocessing stage, which lacks adaptability and is difficult to effectively remove noise of different types and intensities; second, existing denoising algorithms are difficult to effectively distinguish between various noise components and valid physiological signals, and are prone to losing key physiological feature information during the denoising process; third, there is a lack of feature protection mechanisms for ECG signal characteristics, which leads to distortion of important waveform features such as QRS complex waves during the denoising process; finally, existing deep learning models have limited ability to capture OSA-related multi-scale temporal patterns and long-range dependencies in ECG signals, affecting the accuracy and generalization ability of the detection model. Summary of the Invention
[0003] To address the shortcomings of existing technologies, this invention provides a method for detecting obstructive sleep apnea based on joint denoising. This invention improves the joint denoising technology of variational mode decomposition and adaptive wavelet thresholding, combined with an enhanced DenseNet-Transformer hybrid architecture, to achieve high-precision OSA detection with better denoising performance, higher detection accuracy, and more stable robustness.
[0004] This invention includes a complete three-step process: Step 1 is to construct a dataset (including five sub-steps: signal segmentation, improved VMD-DWT denoising, feature extraction, interpolation resampling, and dataset partitioning); Step 2 is feature learning and classification based on the enhanced DenseNet-Transformer hybrid architecture; Step 3 is to automatically detect OSA events and output normal or OSA detection results.
[0005] The technical solution of this invention is: a method for detecting obstructive sleep apnea based on joint denoising, comprising the following steps:
[0006] S1. Constructing the dataset: Input the original ECG signal, perform signal segmentation, improve VMD-DWT denoising, extract the R peak and interpolate resampling, obtain the standardized feature matrix and complete the dataset partitioning;
[0007] S2. Feature Learning and Classification: The extracted feature matrix is processed for deep feature learning and classification using a hybrid model based on the enhanced DenseNet-Transformer.
[0008] S3. Detection result output: The trained model performs forward inference on the ECG signal under test and outputs the detection result of normal or OSA.
[0009] In step S1, signal segmentation is based on the starting point of each labeled respiratory event, extending forward and backward by n seconds, and extracting an ECG signal segment of length 3n seconds as a single sample.
[0010] Preferably, in step S1, the improved VMD-DWT denoising process includes the following steps:
[0011] S11. Adaptive decomposition of individual samples of segmented ECG signals is performed using the improved VMD module to obtain IMF components, and the optimal number of modes K and penalty factor α are automatically determined.
[0012] S12. Denoise each IMF component by using an adaptive wavelet threshold processing module and integrate a spatiotemporal protection mechanism.
[0013] S13. After denoising, residual artifacts are eliminated by the inverse modal artifact suppression module to generate the final denoised ECG signal.
[0014] Preferably, in step S11, the determination of the mode number K adopts a multi-feature fusion decision mechanism, which comprehensively analyzes multi-dimensional information such as spectral characteristics, time-domain complexity, and peak distribution for estimation. The calculation formula is as follows:
[0015]
[0016] in, w is the floor function. snr w entropy w peaks These are the signal-to-noise ratio weighting factor, complexity weighting factor, and peak value weighting factor, respectively; K snr K represents the candidate values for the number of modes determined based on the signal-to-noise ratio characteristics. entropy Candidate values for the number of modes determined based on signal entropy characteristics; K min and K max These are the lower and upper bounds of the modality number, respectively; K final The final determined number of modes; N peaks The number of significant peaks detected in the power spectrum.
[0017] Preferably, in step S11, the penalty factor α is determined using an adaptive adjustment strategy based on spectral flatness, and the calculation formula is as follows:
[0018] α=α min +(α max -α min )·(1-SFM) γ (2)
[0019] Where γ is the adaptive adjustment factor; SFM is the spectral flatness; α min and α max These are the lower and upper bounds of the penalty factor, respectively.
[0020] Preferably, in step S12, the adaptive wavelet thresholding process includes fusing R-peak location information to construct a spatiotemporal protection mechanism, generating a Gaussian weighted protection mask centered on each R-peak:
[0021]
[0022] Where m(t) is the protection mask value at time t, with a value range of [0,1]; M is the total number of detected peak values. i σ represents the time position of the i-th R peak; m =0.02f s It is the standard deviation of the Gaussian function, where f s It is the sampling frequency of the signal.
[0023] Differential thresholding based on masks:
[0024]
[0025] in c represents the wavelet coefficients after thresholding. l,k (t) represents the original wavelet coefficients; sign() is the sign function; σ is the threshold for the detail coefficient of the k-th IMF layer l.k w represents the noise standard deviation. k The weighting factor of the k-th IMF component, l corresponds to the decomposition level, and N is the signal length.
[0026] In step S1, the R-peak extraction uses the Hamilton peak detection algorithm to accurately locate the R-peak in the denoised ECG signal, and calculates the RR interval sequence and R-wave amplitude sequence based on the R-peak position.
[0027] In step S1, the interpolation resampling process resamples the cleaned RR interval sequence and R wave amplitude sequence to a fixed length using cubic spline interpolation and then performs standardization to form a feature matrix.
[0028] In step S1, the dataset is divided into training set, validation set and test set according to a predetermined ratio, with each independent subject as the unit, to ensure that the data of the same subject is strictly isolated.
[0029] Preferably, in step S2, the hybrid model based on the enhanced DenseNet-Transformer includes an HSTE-enhanced feature extraction module, an SCSPA collaborative attention module, a Transformer encoder, and a classification decision module.
[0030] Preferably, the HSTE-enhanced feature extraction module is built upon an improved DenseNet backbone network. It integrates the HSTE attention mechanism onto the traditional DenseNet dense connection architecture, fully leveraging DenseNet's feature reuse advantages and gradient flow characteristics. Specifically, the HSTE attention mechanism converts the time-domain signal into a frequency-domain representation using discrete cosine transform, extracting the signal's spectral features. Simultaneously, it employs a multi-scale dilated convolution strategy, setting different dilation rates to construct multiple parallel branches to capture feature patterns across different temporal ranges from local to global. An adaptive weight fusion mechanism achieves deep fusion of frequency-domain features and multi-scale time-domain features. Building upon feature fusion, the HSTE attention mechanism further integrates channel attention and temporal attention mechanisms. Through dual-path parallel processing and an adaptive gating fusion strategy, it significantly enhances the model's ability to extract and express OSA-related features in ECG signals.
[0031] Preferably, the SCSPA collaborative attention module adopts a multi-dimensional feature refinement strategy, which collaboratively optimizes semantic information from three dimensions: channel, time, and point level. It captures temporal dependencies through multi-scale temporal convolution and combines point-level attention mechanism to achieve refined feature weight allocation, significantly enhancing the model's feature expression and discrimination capabilities.
[0032] The Transformer encoder captures long-range dependencies through a multi-head self-attention mechanism, injects temporal position information using sinusoidal position encoding, and adds learnable CLS tokens as global feature aggregation points.
[0033] The classification decision module adopts a structure design of LayerNorm normalization, high-intensity Dropout and linear classifier, and uses Focal Loss loss function to solve the class imbalance problem, and finally outputs the detection results.
[0034] The hybrid model based on the enhanced DenseNet-Transformer is implemented as follows:
[0035] S21. The input feature matrix is processed through a convolutional layer, and then batch normalization and ReLU activation function are applied to obtain the initial feature representation.
[0036] S22. Based on the initial feature representation, feature extraction is performed through three progressively connected Dense Blocks. Each Dense Block consists of several DenseLayers, enabling the layer-by-layer transfer and reuse of features.
[0037] The HSTE module is introduced as a preprocessor before the convolution of each DenseLayer. The specific processing steps of this module are as follows:
[0038] First, the input feature map X in Perform a Discrete Cosine Transform (DCT) to obtain the initial frequency domain representation F. f Subsequently, the F f The signal is fed into a two-layer 1×1 convolutional network to obtain the enhanced frequency domain feature F′. f .
[0039] Simultaneously, d dilated convolution branches with different dilation rates are used to process the input X. in Temporal patterns under different receptive fields are extracted to construct a multi-scale feature set {C1, C2, ..., C}. d}
[0040] In obtaining frequency domain enhancement features F′ f After combining the multi-scale temporal feature set, an importance weight of each feature is calculated through a weight generation network and adaptively fused. This weight generation network first processes the original input signal X... in Adaptive average pooling is performed, followed by a convolutional layer and a softmax function to generate a normalized weight distribution vector W = [w freq ,w ms1 ,w ms2 ,…,w msd ].
[0041] Based on this weight distribution, channel-level weighted fusion is performed on the features of each branch, and the weighted features are concatenated and passed through a fusion convolutional layer to obtain a unified feature representation F. fused :
[0042] F fused =Fusion(Concat(w freq ·F′ f ,w ms1 ·C1,w ms2 ·C2,…,w msd ·C d (5)
[0043] Fusion is a fused convolutional layer composed of 1×1 convolutions.
[0044] Subsequently, the fusion feature F fused It is refined sequentially through channel and spatial attention mechanisms.
[0045] Finally, the refined result of the channel and spatial attention mechanism is balanced by an adaptive gating mechanism to optimize the refined feature F. t With X in Perform residual connections and output feature F. out .
[0046] S23. After processing by the enhanced DenseNet backbone network, the resulting feature F dense The features are fed into the SCSPA module, which employs a serial-parallel hybrid architecture: features are first reweighted by channel attention, and then fed in parallel into temporal and point-level attention branches. Specifically, feature F dense First, the features F focused on key channels are reweighted using the channel attention module. c Feature F c The data is fed in parallel into the temporal and point-level attention branches. The temporal attention branch uses multi-scale temporal convolution to capture temporal patterns across different time ranges through grouped convolutions, and then concatenates the features output from each group to obtain feature F. t .
[0047] The point-level attention branch then performs dimensionality reduction and dimensionality increase operations on the number of channels through convolution to obtain the feature F. p .
[0048] Finally, the output features F of the two branches are... t With F p The final output F of the collaborative attention module is obtained by fusing elements-wise through multiplication. refined .
[0049] S24, Regarding feature Frefined Perform serialization and enhancement processing. Serialization and enhancement processing: Feature F refined First, through the projection and serialization module, the tokens are sequentially converted into sequence format F by channel dropout, 1×1 convolutional projection, token average pooling, and transpose operations. T Subsequently, sequence F is encoded by adding a [CLS] token before the sequence and then using sine position encoding. T Enhancement is then performed. Finally, the enhanced sequence is processed by a two-layer LayerDrop Transformer encoder, and the feature vector corresponding to the [CLS] token in the output sequence is extracted as the global feature representation F. global .
[0050] Finally, the classification decision module processes the global feature representation F from the Transformer encoder. global The obstructive sleep apnea state is obtained by performing multi-classification output through a classifier.
[0051] The beneficial effects of this invention are as follows:
[0052] This invention improves upon existing OSA detection methods by combining variational mode decomposition (VMD) and adaptive wavelet thresholding with an enhanced DenseNet-Transformer hybrid architecture. This effectively addresses the technical challenges of relying on fixed-parameter filters and the difficulty in distinguishing noise from valid physiological signals in traditional methods, enabling accurate and efficient detection of obstructive sleep apnea. In environments with baseline drift and electromyography (EMG) interference, this method exhibits excellent denoising performance, effectively reducing signal distortion. A spatiotemporal protection mechanism effectively preserves QRS complex wave characteristics, generating high-quality denoised signals that conform to physiological patterns. The improved VMD module achieves intelligent parameter adaptive adjustment through a multi-feature fusion decision mechanism, reducing the limitations of manual parameter settings. Combined with inverse mode artifact suppression technology, it effectively reduces the impact of residual noise. The HSTE frequency domain enhancement and SCSPA collaborative attention mechanism effectively capture OSA-related local features and long-range dependencies in ECG signals, thereby significantly improving the model's detection accuracy, robustness, and generalization ability. Attached Figure Description
[0053] Figure 1 This is a flowchart of the OSA detection method provided in an embodiment of the present invention;
[0054] Figure 2 A comparison chart of the processing effects of the adaptive noise reduction system on different noise types;
[0055] Figure 3 An overall structure diagram of the enhanced DenseNet-Transformer hybrid model;
[0056] Figure 4 Diagram of the HSTE frequency domain enhanced multi-scale attention mechanism structure;
[0057] Figure 5 Here is a structural diagram of the SCSPA collaborative attention module;
[0058] Figure 6 This is a comparison chart of ROC curves. Detailed Implementation
[0059] Figure 1 The flowchart of the OSA detection method provided in this embodiment of the invention illustrates a complete three-step process: Step 1 is to construct the dataset; Step 2 is to perform feature learning and classification using the enhanced DenseNet-Transformer hybrid architecture; and Step 3 is to automatically detect and output OSA events. The invention will be further described below:
[0060] The technical solution of the present invention includes the following steps:
[0061] Step 1: Obtain raw ECG data with respiratory event annotations from a public dataset. The data processing workflow includes signal segmentation, adaptive denoising, feature extraction, interpolation resampling, and dataset partitioning. Specific implementation details are as follows:
[0062] (1) Signal segmentation: Based on the starting point of each labeled respiratory event, extend forward and backward by 60 seconds each, and extract an ECG signal segment with a length of 180 seconds as a single sample.
[0063] (2) Adaptive denoising: A multi-level denoising system based on improved variational mode decomposition-discrete wavelet transform (VMD-DWT) is constructed. The system includes four core modules: improved VMD module, R-wave detection module, adaptive wavelet thresholding module and adaptive inverse mode artifact suppression module.
[0064] The improved VMD module: determines the mode number K and penalty factor α through an adaptive strategy, decomposes the ECG signal, and outputs a set of multi-order intrinsic mode functions (IMFs). Where u k Let K be the k-th order IMF component, and K be the adaptively determined number of modes.
[0065] The determination of the mode number K adopts a multi-feature fusion decision mechanism, which comprehensively analyzes multi-dimensional information such as spectral characteristics, time-domain complexity, and peak distribution for estimation.
[0066] First, the frequency domain characteristics of the signal are obtained using the Welch power spectral density estimation method. The calculation formula is as follows:
[0067]
[0068] Among them, Pxx (f) represents the estimated power spectral density at frequency f. M is the total number of segments; U is the normalized energy factor of the window function; L is the length of each segment; x i w(n) is the signal value of the i-th segment at time n; w(n) is the window function; f s The sampling frequency.
[0069] Based on the obtained power spectrum information, the time-domain complexity characteristics are quantized using signal entropy, and the calculation formula is as follows:
[0070]
[0071] Where H is the signal entropy; p i N represents the probability density of the i-th interval of the signal amplitude histogram; bins This represents the number of intervals in the histogram.
[0072] Simultaneously, utilizing the statistical distribution information of significant peaks in the power spectrum, the calculation formula is as follows:
[0073] N peaks =count({f k |P xx (f k )>P xx (f k-1 ) and P xx (f k )>P xx (f k+1 ) and P xx (f k )>θ peak})(3)
[0074] Where, N peaks f is the number of significant peaks detected in the power spectrum. k P represents the k-th frequency point; xx (f k () represents the frequency f k Power spectral density at θ; peak This is the peak detection threshold.
[0075] Based on the above multidimensional feature information, an adaptive determination mechanism for the modality number K is established, and the calculation formula is as follows:
[0076]
[0077] in, w is the floor function. snr w entropy w peaks These are the signal-to-noise ratio weighting factor, complexity weighting factor, and peak value weighting factor, respectively; K snrK represents the candidate values for the number of modes determined based on the signal-to-noise ratio characteristics. entropy Candidate values for the number of modes determined based on signal entropy characteristics; K min and K max These are the lower and upper bounds of the modality number, respectively; K final This represents the final determined number of modes.
[0078] The penalty factor α is determined using an adaptive adjustment strategy based on spectral flatness (SFM), which is used to quantize the noise level of the signal.
[0079] The formula for calculating spectral flatness is:
[0080]
[0081] Where SFM is the spectral flatness, with a value range of [0,1]; N is the number of power spectrum sampling points; and ∈ is the numerical stability parameter, set to 1×10. -12 .
[0082] Using the spectral flatness index, the penalty factor α is adaptively adjusted according to the following rules:
[0083] α=α min +(α max -α min )·(1-SFM) γ (6)
[0084] Where γ is the adaptive adjustment factor; α min and α max These are the lower and upper bounds of the penalty factor, respectively.
[0085] The objective function for VMD decomposition is:
[0086]
[0087] Constraints:
[0088] Among them, u k (t) represents the k-th IMF; ω k Let be the center frequency of the k-th IMF; K be the mode number; δ(t) be the Dirac function; is the time partial derivative operator; f(t) is the original ECG signal; ||·||2 is the L2 norm.
[0089] The R-wave detection module, based on the multi-order IMF set output by the improved VMD module, obtains a preprocessed ECG signal by initially reconstructing the low-order IMF components (k≤K / / 2). Subsequently, the module uses the preprocessed ECG signal as input and employs the Hamiltonian peak detection algorithm to achieve precise location of the R-peak through bandpass filtering, signal differentiation, sliding integral, and adaptive threshold filtering steps, ultimately obtaining the R-peak location set R. peaks ={r1,r2,...,r N}, where r i Let represent the time position of the i-th R-peak, and N be the total number of detected R-peaks;
[0090] The adaptive wavelet thresholding module: uses the IMF set output by VMD. The set of R-peak positions output by the R-wave detection module. peaks ={r1,r2,...,r N Using} as input, denoising is performed on each IMF component. The specific implementation process is as follows:
[0091] Step 1: Perform a 4-level decomposition on each IMF component using the sym6 wavelet basis to obtain the approximation coefficients c. A4,k With detail coefficient {c D1,k ,c D2,k ,c D3,k ,c D4,k};
[0092] Step 2: Based on the differences in noise characteristics of each IMF component, a hierarchical threshold calculation model is constructed. First, the highest frequency detail coefficient c is used... D4,k The median absolute deviation (MAD) is used to estimate the noise standard deviation:
[0093]
[0094] Where, σ k This represents the noise standard deviation.
[0095] Based on the energy distribution patterns of the IMF, a weighting factor that dynamically varies with the component order is designed:
[0096]
[0097] Among them, w k The weighting factor of the k-th IMF component; K is the total number of IMF components.
[0098] Step 3: To avoid distortion of QRS composite wave characteristics during denoising, a spatiotemporal protection mechanism is constructed by fusing R-peak position information, using each R-peak p i Generate a Gaussian weighted protection mask for the center:
[0099]
[0100] Where m(t) is the protection mask value at time t, with a value range of [0,1]; M is the total number of detected peak values. i σ represents the time position of the i-th R peak; m =0.02f s It is the standard deviation of the Gaussian function, where f s It is the sampling frequency of the signal.
[0101] Differential thresholding based on masks:
[0102]
[0103] in c represents the wavelet coefficients after thresholding. l,k (t) represents the original wavelet coefficients; sign() is the sign function; is the threshold for the detail coefficients of the k-th IMF at the l-th level (l = 1, 2, 3, 4 correspond to the decomposition levels), and N is the signal length.
[0104] Step 4: For the threshold-processed coefficient set Perform inverse wavelet transform to reconstruct the denoised IMF components:
[0105]
[0106] in This is the time-domain signal of the k-th IMF component reconstructed after wavelet threshold denoising.
[0107] Considering that higher-order IMFs mainly contain noise components, selective superposition is used to... A low-order IMF generates an initial denoised signal:
[0108]
[0109] Where x prelim (t) represents the initial denoised signal.
[0110] The inverse modal artifact suppression module takes the initial denoised signal output from the adaptive wavelet threshold processing module, the original IMF set output from the improved VMD module, and the denoised IMF set as inputs, and eliminates residual artifacts by constructing an inverse compensation mechanism. The specific implementation process is as follows:
[0111] First, threshold residual aggregation is performed. Considering that wavelet thresholding may cause distortion in the QRS composite region, the threshold processing residuals of each IMF component are extracted as artifact carriers.
[0112]
[0113] Where u k(t) represents the k-th original IMF component; Let be the k-th denoised IMF component.
[0114] Based on the differences in the contribution of IMFs of different orders to the ECG signal, a decreasing weighting strategy is used for weighted aggregation:
[0115]
[0116] Where 1 / k is the decreasing weight coefficient;
[0117] After obtaining the total artifact signal A(t), in order to extract the effective modal components that can be used for compensation, a second VMD decomposition is performed on it to extract the inverse modal components that can be used for cancellation:
[0118] {a1(t),a2(t),a3(t),a4(t)}=VMD(A(t)) (16)
[0119] Where {a1(t),a2(t),a3(t),a4(t)} is the set of inverse IMF components output by VMD decomposition.
[0120] Based on the obtained set of inverse IMF components, and considering that the artifact energy is mainly concentrated in a few modes, the inverse IMFs are sorted according to their energy magnitude:
[0121] E i =var(a i (t)) (i=1,2,3,4) (17)
[0122] Where E i Let be the energy of the i-th inverted IMF (quantized by variance), reflecting the contribution of this component to the total artifacts.
[0123] Then, the two components with the highest energy are selected to construct the compensation signal:
[0124] A anti (t)=a rank(0) (t)+0.3·a rank(1) (t) (18)
[0125] Where rank(0) and rank(1) are the first and second inverse IMF indices after energy sorting, respectively, and γ is the weight coefficient of the secondary inverse IMF.
[0126] After constructing the compensation signal, in order to determine the optimal artifact cancellation intensity, a candidate coefficient set β∈[0.1,0.9] (with 20 candidate values taken at equal intervals) is constructed and optimized based on the L-curve method.
[0127] Define a dual-index system for signal quality evaluation:
[0128] Smoothness index:
[0129]
[0130] Where S(β) is the smoothness index function; For signal x β (t) is the second time derivative of (t) at time t.
[0131] Residual norm index:
[0132]
[0133] Where x β (t)=x prelim (t)-β·A anti (t) represents the candidate cancellation signal; R(β) is the residual norm index; For Fourier transform operators, This is an indicator function; its value is 1 when the frequency ff is higher than the set cutoff frequency fcfc; otherwise, it is 0. c This is the cutoff frequency.
[0134] By calculating the curvature function of the L-curve, the optimal balance point between smoothness and residuals is determined:
[0135] β opt =argmax β C(β) (21)
[0136] Where β opt β is the optimal offset coefficient; C(β) is the curvature of the L curve.
[0137] Finally, the optimal cancellation coefficient is applied to achieve adaptive artifact suppression, generating the final denoised ECG signal:
[0138] x final (t)=x prelim (t)-β opt ·A anti (t) (22)
[0139] Figure 2 The proposed adaptive denoising system demonstrates its effectiveness against different noise types. The figure includes two sets of comparative experiments: a comparison of denoising performance for baseline drift (BW) noise, showing the difference between the processed ECG signal containing BW noise and the ideal clean signal; and a comparison of denoising performance for electromyographic interference (MA) noise, showing the difference in denoising performance before and after processing the ECG signal containing MA noise. By comparing the ECG signals before and after processing, it can be seen that this method has good suppression capabilities for different types of noise, while effectively maintaining the morphological integrity of the ECG signal.
[0140] (3) Feature Extraction: Based on the R-peak positions and corresponding amplitudes located in step (2), the RR interval (RRI) signal sequence is obtained by calculating the time interval between adjacent R-peaks; the R-wave amplitude (RA) signal sequence is constructed from the amplitudes of the R-wave peaks. Simultaneously, abnormal signal segments that may cause interference are filtered out using a heart rate threshold. If the average heart rate is below 40 beats / min or above 200 beats / min, or the instantaneous heart rate is below 20 beats / min or above 300 beats / min, its window is removed. To further eliminate abrupt changes in the RRI sequence caused by artifacts or arrhythmias, a medium-range filter is applied to smooth the generated RRI signal.
[0141] (4) Interpolation and resampling: The cleaned RRI and RA sequences are resampled to a fixed length using cubic spline interpolation. The standardized RRI and RA sequences are then combined to form a 2×N sequence. sample The feature matrix of , where N sample This indicates the number of fixed sampling points after resampling.
[0142] (5) Data set partitioning: Using independent subjects as units, all samples are divided into training set, validation set and test set according to a predetermined ratio to ensure that the data of the same subject is strictly isolated, avoid data leakage and ensure the reliability of model evaluation.
[0143] Step two involves the following steps: The training and validation sets, pre-defined in Step one, are input into the enhanced DenseNet-Transformer hybrid architecture for model training and OSA event recognition. This architecture first extracts temporal and frequency domain co-features from the original signal using the enhanced DenseNet backbone network. Then, the extracted features are input into the SCSPA co-attention module. Next, the features are converted into a sequence format suitable for Transformer via a feature projection and serialization module, and input into the Transformer encoder to capture global long-range dependencies. Finally, the classification decision module outputs the final OSA event recognition result based on the global feature representation from the Transformer. The overall model structure is as follows: Figure 3 As shown.
[0144] The enhanced DenseNet backbone network is an improvement upon the traditional structure. The specific processing procedure is as follows:
[0145] (1) The input feature matrix is processed by an initial convolutional layer with a 7×1 convolutional kernel and a stride of 2, and then batch normalization BatchNorm1d and ReLU activation function are applied to map it to a 16-channel feature space to obtain the initial feature representation.
[0146] (2) Based on this initial feature, the network extracts features through three progressively connected Dense Blocks. Each Dense Block consists of four DenseLayers, enabling the layer-by-layer transfer and reuse of features.
[0147] (3) To deeply fuse frequency and time domain features, an HSTE module is introduced as a preprocessor before the bottleneck layer (1×1 convolution) of each DenseLayer. For example... Figure 4 As shown, the specific processing steps of this module are as follows:
[0148] First, for the input feature map X in Perform a Discrete Cosine Transform (DCT) to map it to the frequency domain, obtaining the initial frequency domain representation F. f Subsequently, this frequency domain feature F f The data is fed into a two-layer 1×1 convolutional network for depth extraction to obtain the enhanced frequency domain features F′. f :
[0149] F f =DCT(X) in ) (twenty three)
[0150] F′ f =ReLU(BN(Conv) 1×1 (ReLU(BN(Conv 1×1 (F f )))))) (twenty four)
[0151] Meanwhile, in order to capture the temporal patterns of the input signal under different receptive fields, this path employs four dilated convolution branches with dilation rates d∈{1,2,4,8}, starting from the same input X. in Temporal patterns under different receptive fields are extracted to form a multi-scale feature set {C1, C2, C4, C8}:
[0152] C d =DConv k=3,r=d (X in ),d∈{1,2,4,8} (25)
[0153] Where F′ f DConv represents the output feature of the d-th dilated convolution branch. k=3,r=d This indicates the use of dilated convolution with a kernel size of 3 and an inflation rate of d.
[0154] In obtaining frequency domain enhancement features F′ f After combining the multi-scale temporal feature set, the module adaptively fuses them by calculating the importance weights of each feature through a weight generation network. This weight generation network first processes the original input signal X...in Adaptive average pooling is performed, followed by a convolutional layer and a softmax function to generate a normalized weight distribution vector W:
[0155] W=Softmax(Conv(AdaptiveAvgPool(X in (26)
[0156] Where W = [w freq ,w ms1 ,w ms2 ,w ms3 ,w ms4 [ ] represents the weight distribution of the 5 branches.
[0157] Based on this weight distribution, channel-level weighted fusion is performed on the features of each branch, and the weighted features are concatenated and passed through a fusion convolutional layer to obtain a unified feature representation F. fused :
[0158] F weighted =(w freq ·F′ f ,w ms1 ·C1,w ms2 ·C2,…,w msd ·C d (27)
[0159] F fused =Fusion(Concat(F weighted (28)
[0160] Where Fusion is a fused convolutional layer (1×1 convolution); F weighted This is the weighted set of multi-branch features.
[0161] Subsequently, the fusion feature F fused The process is refined sequentially through channel and spatial attention mechanisms. Channel attention employs a dual-path parallel processing of average pooling and max pooling to focus on important channels:
[0162] 29 F c =σ(Conv 1×1 (AvgPool(F fused ))+Conv 1×1 (MaxPool(F fused (29)
[0163] Where σ represents the Sigmoid activation function; F c This represents the output feature of the channel attention module.
[0164] Spatial attention, on the other hand, emphasizes key time steps in the time dimension by operating on the mean and maximum values along the channel dimension:
[0165] F t =σ(Conv 1×1 (Concat(AvgPool(F c ),MaxPool(F c )))) (30)
[0166] Where F t This represents the output features of the temporal attention module.
[0167] Finally, the refined result of the channel and spatial attention mechanism is balanced by an adaptive gating mechanism to optimize the refined feature F. t Compared with the original residual input X in Perform residual connections and output feature F. out :
[0168] F out =γ·F t +(1-γ)·X in (32)
[0169] Among them, F out γ represents the output characteristics of the gating mechanism; γ is the dynamic weighting coefficient generated by the gating function.
[0170] Furthermore, after processing with the enhanced DenseNet backbone network, the resulting feature F dense It is sent to the SCSPA module, such as Figure 5 As shown. This module adopts a serial-parallel hybrid architecture: features are first reweighted by channel attention, and then fed in parallel into temporal and point-level attention branches. Specifically, feature F dense First, the features F focused on key channels are reweighted using the channel attention module. c After this, feature F c The data is fed in parallel into the temporal and point-level attention branches. The temporal attention branch employs multi-scale temporal convolutions with kernel sizes of 5, 7, 11, and 21. It captures temporal patterns across different time ranges through grouped convolutions and concatenates the outputs of each group to obtain feature F. t :
[0171] F t =∑ i∈{5,7,11,21} DepthConv k=i (F c (31)
[0172] Among them, DepthConv k=i Let i denote a depthwise convolution with kernel size i.
[0173] The point-level attention branch learns point-by-point weights by performing dimensionality reduction and expansion operations on the number of channels through convolution, thus obtaining the feature F. p :
[0174] F p =F c ⊙σ(Conv 1×1 (ReLU(Conv 1×1 (F c (32)
[0175] Finally, the output features F of the two branches are... t With F p The final output F of the collaborative attention module is obtained by fusing elements-wise through multiplication. refined :
[0176]
[0177] Furthermore, to adapt the features to the Transformer encoder to capture global long-range dependencies, they need to be serialized and enhanced. Serialization and enhancement: Feature F refined First, through the projection and serialization module, the tokens are sequentially converted into sequence format F by channel dropout, 1×1 convolutional projection, token average pooling, and transpose operations. T Subsequently, sequence F is encoded by adding a [CLS] token before the sequence and then using sine position encoding. T Enhancement is performed to aggregate global information and preserve temporal context. Finally, the enhanced sequence is processed by a two-layer LayerDrop Transformer encoder, and the feature vector corresponding to the [CLS] token in the output sequence is extracted as the global feature representation F. global .
[0178] Finally, the classification decision module processes the global feature representation F from the Transformer encoder. global The process involves processing the data and using a classifier to perform multi-classification output, resulting in the obstructive sleep apnea state. The specific process is as follows:
[0179] (1) Apply LayerNorm normalization to the input global features to stabilize the feature distribution:
[0180] F norm =LayerNorm(F global (34)
[0181] Among them, F norm This represents the normalized features.
[0182] (2) Apply Dropout operation to randomly discard some neuron outputs to prevent model overfitting:
[0183] F drop =Dropout(F norm (35)
[0184] Among them, F drop This indicates a feature that has undergone regularization.
[0185] (3) The processed features are mapped to classification logits through a linear transformation layer:
[0186] y logits =W·F drop +b (36)
[0187] Where W and b are the weight matrix and bias term of the classification layer, respectively. logits This is the final classification of logits.
[0188] Step 3 is as follows: The enhanced DenseNet-Transformer hybrid model trained in Step 2 is loaded into the inference environment, and forward propagation calculation is performed on the independent test set data to output the automatic detection results of OSA events. To systematically verify the effectiveness and contribution of each key module in the proposed method, this embodiment designs an ablation experiment based on the Apnea-ECG dataset. The ablation experiment includes the following model configurations: DenseNet uses the original DenseNet backbone network as the performance comparison baseline; DenseNet-Transformer: integrates the Transformer encoder module on the DenseNet model; DenseNet-Transformer_HSTE: further introduces the HSTE module on the DenseNet-Transformer architecture; DenseNet-Transformer_SCSTA: further introduces the SCSTA module on the DenseNet-Transformer architecture; Complete model: an enhanced DenseNet-Transformer hybrid architecture integrating all improved modules. The experiment uses four metrics for evaluation: accuracy (Acc), recall (Rec), F1 score, and specificity (Spe), and the calculation formulas are shown below:
[0189]
[0190] In the formula, TP represents the number of correctly identified positive samples, TN represents the number of correctly identified negative samples, FP represents the number of falsely reported positive samples, and FN represents the number of falsely diagnosed negative samples.
[0191] To visually visualize and comprehensively evaluate the classification performance of the model, this embodiment plots the Receiver Operating Characteristic (ROC) curve, as shown below. Figure 6 As shown in Table 1, a comparison of the numerical results of the ablation experiments is provided.
[0192] Table 1 Comparison of ablation test results
[0193]
[0194] Combined Table 1 and Figure 6 The analysis results show that the proposed enhanced DenseNet-Transformer architecture, by introducing key modules such as Transformer, HSTE, and SCSTA, significantly improves the model's performance in multiple metrics such as accuracy, recall, specificity, and F1 score in the OSA event detection task, demonstrating stronger discriminative ability, robustness, and excellent clinical application potential.
Claims
1. A method for detecting obstructive sleep apnea based on joint denoising, characterized in that, Includes the following steps: S1. Input the raw ECG signal and preprocess it to obtain a standardized feature matrix; S2. The extracted feature matrix is subjected to deep feature learning and classification using a hybrid model based on enhanced DenseNet-Transformer. S3. The trained hybrid model performs forward inference on the ECG signal under test and outputs the detection results.
2. The obstructive sleep apnea detection method based on joint denoising according to claim 1, characterized in that, The preprocessing includes signal segmentation, improved VMD-DWT denoising, R-peak extraction, and interpolation resampling.
3. The obstructive sleep apnea detection method based on joint denoising according to claim 2, characterized in that, The signal segmentation is based on the starting point of each labeled respiratory event, extending n seconds forward and backward, and extracting an ECG signal segment of length 3n seconds as a single sample. The R-peak extraction uses the Hamiltonian peak detection algorithm to locate the R-peak in the denoised ECG signal, and calculates the RR interval sequence and R-wave amplitude sequence based on the R-peak position. The interpolation resampling process uses cubic spline interpolation to resample the RR interval sequence and R wave amplitude sequence to a fixed length, and then performs standardization to form a feature matrix.
4. The obstructive sleep apnea detection method based on joint denoising according to claim 3, characterized in that, The improved VMD-DWT denoising process includes the following steps: S11. Adaptive decomposition of a single sample of the ECG signal is performed using the improved VMD module to obtain the IMF component, and the optimal number of modes K and penalty factor α are automatically determined. S12. Denoise each IMF component by using an adaptive wavelet threshold processing module and integrate a spatiotemporal protection mechanism. S13. After denoising, residual artifacts are eliminated by the inverse modal artifact suppression module to generate the final denoised ECG signal.
5. The obstructive sleep apnea detection method based on joint denoising according to claim 4, characterized in that, In step S11, the determination of the mode number K adopts a multi-feature fusion decision mechanism, which comprehensively analyzes the spectral characteristics, time-domain complexity, and peak distribution for estimation. The calculation formula is as follows: in, w is the floor function. snr w entropy w peaks These are the signal-to-noise ratio weighting factor, complexity weighting factor, and peak value weighting factor, respectively; K snr K represents the candidate values for the number of modes determined based on the signal-to-noise ratio characteristics. entropy Candidate values for the number of modes determined based on signal entropy characteristics; K min and K max These are the lower and upper bounds of the modality number, respectively; K final The final determined number of modes; N peaks The number of significant peaks detected in the power spectrum; The penalty factor α is determined using an adaptive adjustment strategy based on spectral flatness, and the calculation formula is as follows: a = a min +(a max -a min )·(1-SFM) γ Where γ is the adaptive adjustment factor, and SFM is the spectral flatness; α min and α max These are the lower and upper bounds of the penalty factor, respectively.
6. The obstructive sleep apnea detection method based on joint denoising according to claim 4, characterized in that, In step S12, the adaptive wavelet thresholding process includes fusing R-peak position information to construct a spatiotemporal protection mechanism, generating a Gaussian weighted protection mask centered on each R-peak: Where m(t) is the protection mask value at time t, with a value range of [0,1]; M is the total number of detected peak values; p i σ represents the time position of the i-th R peak; m =0.02f s It is the standard deviation of the Gaussian function, where f s It is the sampling frequency of the signal; differential thresholding is implemented based on a mask: in c represents the wavelet coefficients after thresholding. l,k (t) represents the original wavelet coefficients; sign() is the sign function; σ is the threshold for the detail coefficient of the k-th IMF layer l. k w represents the noise standard deviation. k The weighting factor of the k-th IMF component, l corresponds to the decomposition level, and N is the signal length.
7. The obstructive sleep apnea detection method based on joint denoising according to claim 4, characterized in that, The hybrid model based on the enhanced DenseNet-Transformer is implemented as follows: S21. The input feature matrix is processed through a convolutional layer, and then batch normalization and ReLU activation function are applied to obtain the initial feature representation. S22. Feature enhancement is performed based on the initial feature representation through the enhanced DenseNet backbone network: feature extraction is performed through three progressively connected Dense Blocks; each Dense Block consists of several dense layers DenseLayer, realizing the layer-by-layer transfer and reuse of features; and an HSTE module is introduced as a preprocessor before the convolution of each DenseLayer. S23. After processing by the enhanced DenseNet backbone network, the resulting feature F dense The features are fed into the SCSPA module, which employs a serial-parallel hybrid architecture: the features are first reweighted by channel attention, and then fed in parallel into temporal and point-level attention branches to obtain the final output F. refined ; S24, Regarding feature F refined The sequence undergoes serialization and enhancement. The enhanced sequence is then processed by a LayerDrop Transformer encoder to output the global feature representation F. global ; S25. The classification decision module processes the global feature representation F from the Transformer encoder. global The obstructive sleep apnea state is obtained by performing multi-classification output through a classifier.
8. The obstructive sleep apnea detection method based on joint denoising according to claim 7, characterized in that, The specific implementation of the HSTE module is as follows: First, the input feature map X in Perform a Discrete Cosine Transform (DCT) to obtain the initial frequency domain representation F. f Subsequently, the F f The signal is fed into a two-layer 1×1 convolutional network to obtain the enhanced frequency domain feature F′. f ; Simultaneously, d dilated convolution branches with different dilation rates are used to process the input X. in Temporal patterns under different receptive fields are extracted to construct a multi-scale feature set {C1, C2, ..., C}. d }; In obtaining frequency domain enhancement features F′ f After combining with a multi-scale temporal feature set, an importance weight of each feature is calculated and adaptively fused using a weight generation network; this weight generation network first processes the original input signal X... in Adaptive average pooling is performed, followed by a convolutional layer and a softmax function to generate a normalized weight distribution vector W = [w freq ,w ms1 ,w ms2 ,…,w msd ]; Based on this weight distribution, channel-level weighted fusion is performed on the features of each branch, and the weighted features are concatenated and passed through a fusion convolutional layer to obtain a unified feature representation F. fused : F fused =Fusion(Concat(w freq ·F′ f ,w ms1 ·C1,w ms2 ·C2,…,w msd ·C d )) Fusion is a fused convolutional layer composed of 1×1 convolutions; Subsequently, the fusion feature F fused It is refined sequentially through the channels and spatial attention mechanisms. Finally, the refined result of the channel and spatial attention mechanism is balanced by an adaptive gating mechanism to optimize the refined feature F. t With X in Perform residual connections and output feature F. out .
9. The obstructive sleep apnea detection method based on joint denoising according to claim 7, characterized in that, The SCSPA module is specifically implemented as follows: Feature F dense First, the features F focused on key channels are reweighted using the channel attention module. c Feature F c The data is fed in parallel into the temporal and point-level attention branches. The temporal attention branch uses multi-scale temporal convolution to capture temporal patterns across different time ranges through grouped convolutions, and then concatenates the features output from each group to obtain feature F. t ; The point-level attention branch then performs dimensionality reduction and dimensionality increase operations on the number of channels through convolution to obtain the feature F. p ; Finally, output feature F t With F p The final output F of the SCSPA module is obtained by fusing elements-by-element multiplication. refined .
10. The obstructive sleep apnea detection method based on joint denoising according to claim 7, characterized in that, The specific implementation of step S24 is as follows: Feature F refined First, through the projection and serialization module, the tokens are sequentially converted into sequence format F by channel dropout, 1×1 convolutional projection, token average pooling, and transpose operations. T Subsequently, sequence F is encoded by adding a [CLS] token before the sequence and then using sine position encoding. T The sequence is then enhanced, processed by a LayerDropTransformer encoder, and the feature vector corresponding to the [CLS] token in the output sequence is extracted as the global feature representation F. global .
Citation Information
Cited By
Method for detecting interpretable respiratory event based on priori guidance graph structure learning
CN121867708A