Sleep apnea detection method and system, electronic equipment and storage medium
Through the multi-scale cross attention framework and dynamic weight correction mechanism, the problem of insufficient fusion of multi-scale features in the prior art is solved, and efficient and accurate sleep apnea detection is achieved, which is suitable for portable devices.
Patent Information
- Application Number
- CN202510991899.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-18
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-07-18
AI Technical Summary
The existing ECG-based sleep apnea detection method is insufficient in the fusion of multi-scale features, resulting in limited detection accuracy and generalization capabilities, making it difficult to achieve efficient and accurate sleep apnea screening on portable devices.
Using a multi-scale cross-attention framework, cross-modal features are extracted from ECG and respiratory signals through a parallel feature extraction network, and intelligent fusion is used to use a cross-scale dynamic weight correction attention mechanism, and feature compression and classification are combined with the improved Q-Former module.
It realizes comprehensive capture of features at different time scales, improves the accuracy and robustness of detection, is suitable for real-time monitoring of portable devices, and overcomes the limitations of traditional methods.
Smart Images

Figure CN120477748A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of deep learning and medical signal processing, and in particular to a sleep apnea detection method, system, electronic device and storage medium using multi-scale feature extraction and a cross-attention mechanism. Background Art
[0002] Sleep apnea (SA) is a common and devastating sleep disorder characterized by recurring episodes of apnea or hypopnea during sleep. These episodes can lead to intermittent hypoxemia, hypercapnia, and disrupted sleep architecture. Long-term, untreated SA significantly increases the risk of various chronic diseases, including hypertension, cardiovascular and cerebrovascular disease, and type 2 diabetes. In severe cases, it can even cause sudden nocturnal death.
[0003] Currently, the clinical gold standard for diagnosing sleep apnea is polysomnography (PSG). PSG comprehensively monitors multiple physiological parameters, including EEG, EOG, EMG, ECG, respiratory airflow, and blood oxygen saturation, with high diagnostic accuracy. However, PSG examinations also have significant drawbacks: First, they must be performed in a specialized sleep laboratory, requiring expensive equipment and complex operation, requiring professional technicians to be on duty all night; second, patients must wear multiple sensors throughout the body overnight, which can cause discomfort, disrupt normal sleep, and potentially distort diagnostic results; finally, the high cost and limited medical resources make it difficult to popularize in primary care institutions and home settings, resulting in a large number of potential patients being unable to receive timely screening and diagnosis.
[0004] To overcome the limitations of PSG, researchers are turning to developing alternative diagnostic techniques based on more accessible physiological signals. Among these, the electrocardiogram (ECG) has become a hot topic in sleep apnea screening research due to its non-invasive nature, ease of acquisition, low cost, and widespread availability of relevant equipment. Sleep apnea events affect the cardiovascular system through the autonomic nervous system, and these effects leave specific signatures on the ECG signal, such as cyclical changes in heart rate variability (HRV) and fluctuations in R-wave amplitude.
[0005] Traditional ECG-based detection methods often rely on machine learning algorithms, typically involving three steps: signal preprocessing, manual feature extraction, and classifier design. For example, time-domain, frequency-domain, or nonlinear dynamic features such as the RR interval, R peak amplitude, and QRS complex morphology are extracted and then input into classifiers such as support vector machines (SVMs) and random forests for discrimination. The performance of these methods is highly dependent on the quality of feature engineering. The selected features may not be universally applicable and are susceptible to individual differences and signal noise, making it difficult to capture the complex dynamic characteristics of SA events across different time scales.
[0006] In recent years, with the rise of deep learning techniques, particularly convolutional neural networks (CNNs) and recurrent neural networks (RNNs), automated ECG-based detection methods have shown great potential. Deep learning models can automatically learn discriminative hierarchical features from raw signals, avoiding the tedious and subjective process of manual feature extraction. However, existing deep learning methods still face a key challenge: insufficient multi-scale feature fusion. SA manifests itself in ECG signals with significant temporal variations: short-term (e.g., within 1 minute) may manifest as abrupt changes in heart rate, while medium-term (e.g., 3-5 minutes) may reflect cyclical fluctuations in heart rate caused by respiratory rhythm disturbances. Existing models typically analyze a single fixed-length signal segment or simply concatenate or add features extracted at different scales. This approach ignores the inherent correlations and dynamic interactions between features at different scales, resulting in the loss of critical discriminative information and limiting the model's detection accuracy and generalization capabilities.
[0007] Therefore, there is an urgent need to develop an ECG analysis method that can intelligently fuse multi-scale features to detect sleep apnea events more accurately and robustly, and provide core technical support for the development of portable devices suitable for clinical and home monitoring. Summary of the Invention
[0008] To solve the above technical problems, the present invention proposes a sleep apnea detection method, system, electronic device and storage medium. The core of this method is to achieve collaborative analysis and intelligent fusion of ECG signals and respiratory signals at different time scales through an innovative multi-scale cross-attention framework.
[0009] In a first aspect, the present invention provides a sleep apnea detection method, comprising the following steps: S1: Acquire synchronously collected electrocardiogram signals and respiratory signals, preprocess the electrocardiogram signals and respiratory signals, and segment the preprocessed signals according to at least two different preset time scales to construct a bimodal multi-scale dataset including an electrocardiogram sequence and a respiratory signal sequence; S2: for the signal segments of the at least two different time scales, using a parallel feature extraction network, extracting deep features of corresponding scales from the electrocardiogram sequence and the respiratory signal sequence, respectively, and generating a cross-modal feature for each scale; S3: A cross-scale dynamic weighted attention mechanism is used to interact and fuse the cross-modal features at multiple scales. The cross-scale dynamic weighted attention mechanism dynamically modifies the attention weights according to the vector differences between features at different scales to adaptively aggregate the most discriminative information at each scale. S4: The fused features are input into a feature compression module for dimensionality reduction, and a classifier outputs a probability prediction of a sleep apnea event based on the dimensionality reduced features.
[0010] As an optional implementation of the first aspect of the present application, in step S1, the at least two different preset time scales are 1 minute, 3 minutes and 5 minutes; the preprocessing specifically includes: applying a 3-45 Hz bandpass filter to the electrocardiogram signal, and using the Hamilton algorithm to locate the R peak to extract the RR interval and R peak amplitude characteristics; applying a 0.1-1 Hz bandpass filter to the respiratory signal to extract the respiratory amplitude and the change rate characteristics calculated by numerical differentiation.
[0011] As an optional implementation of the first aspect of the present application, in step S2, the parallel feature extraction network is a parallel bimodal void convolutional neural network; the step S2 specifically includes: for each time scale, setting a void convolutional network branch for the electrocardiogram sequence and the respiratory signal sequence respectively, and the void convolutional network branch extracts multi-level waveform and rhythm features through a void convolution layer and an adaptive pooling layer with an adjustable expansion rate; at each scale, the features extracted by the electrocardiogram network branch and the respiratory signal network branch are respectively projected to a preset dimension and then spliced to form the cross-modal feature.
[0012] As an optional implementation of the first aspect of the present application, in step S3, the implementation method of the cross-scale dynamic weight correction attention mechanism includes: generating a query matrix, a key matrix and a value matrix for the cross-modal features of different scales respectively; when calculating the attention score between the query matrix of any scale and the key matrix of another scale, introducing a correction factor based on the Euclidean distance between the feature vectors of the two scales, and processing the correction factor using the ReLU activation function to enhance the interaction weight of the significantly different features; normalizing the attention score after superimposing the correction factor through the Softmax function to obtain the final attention weight, and using the attention weight to perform weighted summation on the corresponding value matrix to fuse cross-scale information.
[0013] As an optional implementation of the first aspect of the present application, in step S4, the feature compression module is an improved Q-Former module, and the classifier is a multi-layer perceptron; step S4 specifically includes: splicing the fused features from all scales in the sequence dimension to form a high-dimensional splicing feature; inputting the high-dimensional splicing feature into the improved Q-Former module, and the improved Q-Former module uses the query vector to perform multi-head attention interaction with the high-dimensional splicing feature to achieve feature compression and dimensionality reduction; inputting the low-dimensional feature vector output by the improved Q-Former module into the multi-layer perceptron for final classification and judgment.
[0014] As an optional implementation of the first aspect of the present application, the query vector of the improved Q-Former module is a learnable query vector, and an auxiliary query vector calculated from the characteristic entropy values of the electrocardiogram sequence and the respiratory signal sequence is introduced. The auxiliary query vector is used to enhance the model's detection sensitivity to abnormal signal states.
[0015] As an optional implementation of the first aspect of the present application, the method also includes a model training step, which adopts an Adam optimizer and uses a bimodal cross entropy loss function to train the model end-to-end; the bimodal cross entropy loss function is a combination of a classification loss based on electrocardiogram features and a classification loss based on respiratory signal features.
[0016] In a second aspect, an embodiment of the present application provides a sleep apnea detection system, comprising: a data set construction module, configured to obtain synchronously acquired electrocardiogram signals and respiratory signals, preprocess the electrocardiogram signals and respiratory signals, and segment the preprocessed signals according to at least two different preset time scales to construct a bimodal multi-scale data set comprising an electrocardiogram sequence and a respiratory signal sequence; A parallel feature extraction module is configured to extract deep features of corresponding scales from the electrocardiogram sequence and the respiratory signal sequence using a parallel feature extraction network for the signal segments of the at least two different time scales, and generate a cross-modal feature for each scale; A cross-scale feature fusion module, configured to interact and fuse the cross-modal features at multiple scales using a cross-scale dynamic weighted attention mechanism. The cross-scale dynamic weighted attention mechanism dynamically modifies attention weights based on the vector differences between features at different scales to adaptively aggregate the most discriminative information at each scale. The compression classification module is used to input the fused features into a feature compression module for dimensionality reduction, and a classifier outputs a probability prediction of a sleep apnea event based on the features after dimensionality reduction.
[0017] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein when the program or instruction is executed by the processor, the steps of the method described in the first aspect are implemented.
[0018] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0019] Compared with the existing technology, the present invention proposes a sleep apnea detection method using multi-scale feature extraction and cross-attention mechanism, which has the following beneficial effects: (1) The present invention achieves comprehensive feature capture of ECG signals through a multi-time-scale collaborative analysis framework. This method decomposes ECG signals into analysis segments of different time lengths, enabling the system to simultaneously identify transient ECG waveform abnormalities, mid-term respiratory rhythm disturbances, and long-term physiological trend changes. This multi-scale analysis method overcomes the limitations of traditional single-scale detection and can more comprehensively reflect the complex physiological manifestations of sleep apnea, especially with better recognition capabilities for atypical or intermittent cases.
[0020] (2) A unique cross-scale dynamic weight-corrected attention mechanism builds an intelligent interaction channel between features at different scales. This mechanism achieves dynamic fusion of local and global features through adaptive weight allocation, enabling the system to autonomously discover and enhance the most diagnostically valuable information combination. This feature fusion method not only improves the model's sensitivity to key features, but also effectively suppresses noise interference, significantly enhancing the system's robustness while maintaining high accuracy.
[0021] (3) A specially optimized signal processing process was used to accurately extract key features such as the R peak position and RR interval from the raw ECG signal. Through innovative filtering algorithms and peak detection techniques, the accuracy and stability of feature extraction were ensured, providing a reliable data foundation for subsequent analysis. This preprocessing step was specifically optimized for ECG signal interference that is common during sleep, effectively overcoming problems such as baseline drift and electromyographic interference.
[0022] (4) The overall solution has designed a complete lightweight processing architecture, achieving efficient processing from signal acquisition to analysis result output. Through modular design and computational optimization, the algorithm can run stably on portable devices, meeting the application requirements of home monitoring and mobile medical care. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1is a flow chart of a sleep apnea detection method according to an embodiment of the present invention; Figure 2 is a diagram of a parallel dual-modal atrous convolutional neural network architecture according to an embodiment of the present invention; Figure 3 Schematic diagram of a sleep apnea detection system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0025] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the application can be implemented in a sequence other than those illustrated or described here. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally represents that the objects associated before and after are in a kind of "or" relationship. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically limited.
[0026] Example 1 See also Figure 1 , is a flow chart of a sleep apnea detection method provided by an embodiment of the present invention. The method may include the following steps: S1: Acquire synchronously collected electrocardiogram signals and respiratory signals, preprocess the electrocardiogram signals and respiratory signals, and segment the preprocessed signals according to at least two different preset time scales to construct a bimodal multi-scale dataset including an electrocardiogram sequence and a respiratory signal sequence.
[0027] This step aims to construct a bimodal, multi-scale dataset suitable for subsequent model training and validation.
[0028] Specifically, single-lead ECG signals from patients during sleep were collected from the public PhysioNet Apnea-ECG dataset, along with respiratory signals such as chest wall movement or nasal airflow, all at a sampling rate of 100Hz. This dataset contains a number of synchronized ECG and respiratory signal recordings, each lasting between 7 and 10 hours. Each minute of data was annotated by medical experts as either "apnea (A)" or "normal (N)." During raw signal preprocessing, the ECG signal was first subjected to a 3-45Hz bandpass filter to remove baseline drift and high-frequency noise. The Hamiltonian algorithm was used to detect R peaks and extract the RR interval and R peak amplitude. A 0.1-1Hz bandpass filter was applied to the respiratory signal to remove motion artifacts, and respiratory amplitude and rate of change were extracted (calculated using numerical differentiation). Both signals were then smoothed using median filtering, and time synchronization was performed to ensure temporal alignment between the ECG and respiratory signals. Finally, the preprocessed ECG and respiratory signals are divided into three scale segments of 1 minute, 3 minutes, and 5 minutes according to the time dimension. Each segment contains a synchronized ECG sequence and respiratory signal sequence to construct an ECG-respiration bimodal multi-scale dataset.
[0029] S2: For the signal segments of the at least two different time scales, using a parallel feature extraction network, extract deep features of corresponding scales from the electrocardiogram sequence and the respiratory signal sequence respectively, and generate a cross-modal feature for each scale.
[0030] This step uses parallel deep neural networks to extract deep features from bimodal data at different scales. Figure 2 As shown in Figure 3, the core of this module is a parallel bimodal dilated convolutional neural network (Dilated CNN) architecture.
[0031] Specifically, the PyTorch framework is used to build a parallel dual-modal dilated convolutional neural network, corresponding to the synchronized ECG sequence and respiratory signal sequence of 1 minute, 3 minutes and 5 minutes respectively. Synchronous ECG sequence and respiratory signal sequence , the signals of two different modalities are input into the parallel void convolutional neural network with the same structure respectively to form a dual-modal feature extraction architecture.
[0032] In the CNN network, the first step is to pass through the dilated convolution layer. The dilated convolution layer passes through the convolution kernel. Perform a sliding convolution operation on the input signal. The convolution operation formula is: in, is the expansion rate, Indicates that the output signal after convolution is at position The value of is the convolution kernel size, The convolution kernel is at position The weight value of For input signal at position By superimposing multiple convolutional layers, local waveform features at different levels can be extracted.
[0033] By stacking multiple layers of dilated convolutional layers, local waveform features and global rhythm patterns at different levels are extracted. Adaptive pooling is then used to replace fixed maximum pooling, dynamically adjusting the pooling window size according to the input features, reducing the data dimension while retaining key features. After several dilated convolutional layers and adaptive pooling layers, the network output is connected to the fully connected layer. The fully connected layer is connected through the weight matrix and the bias vector Map the features to the target feature space, the formula is: in, is the feature vector output by the fully connected layer, is the activation function, is the weight matrix of the fully connected layer, is the feature vector output by the previous layer, is the bias vector of the fully connected layer.
[0034] The neural network is trained by adjusting the network parameters. Two parallel neural network branches extract features from the ECG sequence and respiratory signal sequence of the corresponding time scale respectively. and , and project the extracted features to dimensions through the fully connected layer The target feature space is used to concatenate the synchronized ECG sequence and respiratory signal sequence to form a 256-dimensional cross-modal feature pair (such as ) Finally, a cross-modal feature pair is formed 、 、 .
[0035] S3: A cross-scale dynamic weighted attention mechanism is used to interact and fuse the cross-modal features of multiple scales. The cross-scale dynamic weighted attention mechanism dynamically modifies the attention weight according to the vector differences between features of different scales to adaptively aggregate the most discriminative information at each scale.
[0036] This is the core step of the present invention, which specifically adopts a cross-scale dynamic weight correction attention mechanism to adaptively fuse information from different scales.
[0037] Specifically, for the cross-modal feature pairs of ECG sequences and respiratory signal sequences at three scales, 、 、 (in , ), generate query (Query), key (Key) and value (Value) matrices for each scale feature. For example, through the weight matrix 、 、 Perform linear transformation and generate the corresponding matrix: in, 、 、 The feature pairs The generated query, key, and value matrix, 、 、 is a learnable weight matrix. The feature pairs are generated in the same way. and feature pairs Corresponding 、 、 and 、 、 matrix.
[0038] When calculating the attention weights between features of different scales, Query As an example, the attention score is calculated by dot product, and a cross-scale dynamic weight correction factor is introduced: in, for right The attention score, is the Euclidean distance of the feature vector, and the ReLU function is used to enhance the interaction weights of features with significant differences. is the bond matrix The attention score is normalized by the Softmax function to obtain the attention weight: in, for right The attention weight matrix of The value matrix of Perform weighted summation and get To Additional information obtained: Same calculation from Supplementary information obtained .Will Fusion of own features with acquired supplementary information: Through the above process, we can achieve By query and The keys and values of are used to obtain supplementary information, and through the soft alignment mechanism, the interaction and fusion of multi-scale features are achieved in the time and morphological dimensions. and Similar operations are also performed to finally obtain the fused multi-scale features .
[0039] S4: The fused features are input into a feature compression module for dimensionality reduction, and a classifier outputs a probability prediction of a sleep apnea event based on the dimensionality reduced features.
[0040] This step efficiently compresses the fused features and performs the final classification judgment.
[0041] Specifically, the bimodal features output by the attention mechanism module are modified with cross-scale dynamic weights (1 minute scale), (3-minute scale), (5-minute scale) Splice in the sequence dimension to obtain splicing features (Total dimension 768), where [;] represents the concatenation operation along the sequence dimension, which aims to preserve complementary information at different time scales.
[0042] It should also be noted that the original Q-Former (Query-based Transformer) module is usually used for feature compression and cross-modal interaction. Its core structure includes: Learnable query vector (Query): used to extract key information from input features; Multi-Head Attention: Calculates the interaction weights between the query, key, and value to achieve feature fusion; Dimensionality reduction output: compress high-dimensional features and reduce the amount of calculation.
[0043] The original Q-Former module has certain limitations: the query vector relies solely on learnable parameters and lacks dynamic adaptation to the characteristics of the input signal itself; it does not consider the entropy information of multi-scale features, which may affect sensitivity to abnormal conditions (such as apnea); and the cross-modal interaction method is relatively fixed, which may not fully explore the dynamic correlation between ECG and respiratory signals.
[0044] Therefore, this embodiment proposes an improved Q-Former module, the core improvements of which include: 1. Introduction of auxiliary query vector: The entropy value of each scale feature of ECG and respiratory signal is used as an additional query vector ( )and ), and the learnable query vector The entropy value is used to quantify the degree of disorder of the signal features, thereby enhancing the model's sensitivity to abnormal conditions (such as apnea events) and improving the detection ability of non-stationary signals.
[0045] 2. Optimizing cross-modal feature interaction: The multi-head attention mechanism of the improved Q-Former module explicitly integrates the entropy information of the ECG and respiratory modalities, and dynamically adjusts the attention weight distribution. This avoids the limitation of the original Q-Former module that relies solely on learnable query vectors and guides cross-modal information fusion through modality-specific features (entropy).
[0046] 3. Lightweight compression design: While preserving the relevance of multi-scale features, the attention mechanism is used to reduce the dimensionality of high-dimensional concatenated features (768 dimensions) to reduce the computational load. This adapts to the deployment requirements of embedded devices and achieves millisecond-level response.
[0047] Therefore, the query vector of the original Q-Former module is usually fixed or learnable, while this scheme additionally introduces the signal entropy value (reflecting the degree of signal chaos) as part of the query, which is an improvement for the non-stationary characteristics of ECG-respiratory signals.
[0048] Specifically, the improved Q-Former module is used to compress long sequence features, and the probability distribution entropy value of each scale feature is used as an auxiliary query vector to enhance the sensitivity to abnormal states. The improved Q-Former module contains a learnable query vector (N is the number of query vectors, is the query vector dimension), through the attention mechanism from the splicing features Extract key information from the . The specific process is: Input the multi-head self-attention layer, interact with the query vector Q, calculate the attention weight and weighted sum to obtain the compressed features The calculation logic is: in, is the learnable query vector, Represent the characteristics of ECG sequences at different scales, Represent the characteristics of respiratory signal sequences at different scales, (•) is the function for calculating the entropy value of the feature probability distribution. are the key matrix and the value matrix respectively, 、 is the weight matrix, is the key matrix dimension. This operation reduces the computational load by reducing the feature dimension while preserving key correlation information across scales.
[0049] Furthermore, the compressed features Enter the Multilayer Perceptron (MLP). The MLP consists of three linear layers, in order: The first linear layer: , used to introduce nonlinear transformations.
[0050] Second linear layer: ,The structure is similar to the first layer, further extracting abstract features.
[0051] The third linear layer (output layer): , The output is mapped to the classification probability of "apnea" or "normal" through the Softmax function to predict the probability distribution.
[0052] above 、 and is the weight matrix, 、 and is the bias vector, is the ReLU activation function, and are the output of the first linear layer and the output of the second linear layer respectively.
[0053] Finally, the PyTorch framework is used to implement the above structure, with the cross entropy loss function Supervised training, the loss function formula is: in, N is the sample size, is the number of categories, For samples The true label (0 or 1), Samples predicted by the model Belong to category probability.
[0054] Classification results of fusion of ECG and respiratory signals: in, and are the cross entropy losses for ECG and respiratory signals, respectively.
[0055] In an optional embodiment, step S5: model training is also included.
[0056] Model training utilizes an end-to-end learning process based on the PyTorch framework, running on an NVIDIA GeForce RTX 4090 GPU for accelerated computation. The Adam optimizer is used to iteratively update network parameters. The initial learning rate is set to a reasonable range to ensure model convergence, and the batch size is set to 128 to balance memory usage and gradient update stability. A dynamic learning rate adjustment strategy is implemented during training: by monitoring the validation set loss curve, a learning rate decay mechanism is automatically triggered when the loss value does not show a downward trend over multiple training epochs, reducing the learning rate by a preset ratio to prevent the model from getting stuck in a local optimum and accelerate convergence. During the training loop, the preprocessed ECG and respiratory signal sequences are first input into the model. After feature extraction, cross-attention fusion, and classification, a predicted probability distribution is generated. The cross-entropy loss function is then used to calculate the difference between the predicted values and the true labels. Gradients are then back-propagated to update the network parameters at each layer. The training process continues until the loss function converges and the validation set performance indicators stabilize, ensuring that the model learns multi-scale feature correlations while maintaining good generalization capabilities.
[0057] In an optional embodiment, step S6 is further included: model evaluation and deployment.
[0058] During the model evaluation phase, a standardized process was established to verify the effectiveness of multi-scale analysis. At the segment level, the test set was divided into sample units at different time scales, each of which was fed into the trained model. By comparing the predicted results with expert annotations, the contribution of feature expression at each scale to classification performance was analyzed. The evaluation process encompassed scenarios with varying noise levels and individual physiological differences, verifying the model's robustness in real-world clinical settings.
[0059] The deployment phase focuses on clinical practical needs, integrating the trained model into a portable medical device. The device acquires ECG and respiratory signals through a real-time acquisition module. After the preprocessing module performs bandpass filtering, R-peak detection, and multi-scale segmentation, the embedded inference engine performs feature extraction, cross-attention fusion, and classification prediction, ultimately generating a real-time warning signal based on preset clinical thresholds. Model compression technology is used during deployment to optimize computational efficiency, ensuring millisecond-level response on a low-power hardware platform. An encrypted transmission protocol ensures the security of medical data during acquisition, processing, and transmission, providing reliable technical support for early screening and real-time monitoring of sleep apnea.
[0060] In summary, in this embodiment, the present invention proposes a sleep apnea detection method using multi-scale feature extraction and cross-attention mechanism. This method focuses on the ECG-respiration bimodal detection task of sleep apnea and constructs an intelligent detection model framework driven by a cross-scale dynamic weight correction attention mechanism. The framework mainly includes six modules: ECG sleep apnea detection dataset construction (S1), multi-scale bimodal feature extraction module design (S2), cross-scale dynamic weight correction attention mechanism module design (S3), feature fusion and classification module design (S4), model training and optimization (S5), and model evaluation and deployment (S6).
[0061] In step S1, ECG signals and respiratory signals are synchronously collected based on the PhysioNet Apnea-ECG dataset. The ECG signals are preprocessed by 3-45 Hz band-pass filtering, and the respiratory signals are processed by 0.1-1 Hz band-pass filtering. The RR interval, R peak amplitude, respiratory amplitude and change rate characteristics are extracted to construct an ECG-respiration bimodal multi-scale dataset with temporal dimension diversity.
[0062] In step S2, a parallel atrous convolutional neural network architecture is designed to process ECG and respiratory signal segments of 1 minute, 3 minutes, and 5 minutes in length, respectively. Local waveform features and global rhythm patterns are extracted through multi-layer atrous convolution and adaptive pooling. The bimodal features are projected into a 128-dimensional target feature space and spliced to form 256-dimensional cross-modal feature pairs.
[0063] In step S3, a dynamic weight correction factor based on Euclidean distance is introduced, and the cross-scale attention weight is calculated through a learnable query-key-value transformation matrix to achieve spatiotemporal dynamic fusion and soft alignment enhancement of 1-minute high-resolution features and 3-minute and 5-minute long-range features.
[0064] In step S4, an improved Q-Former architecture is used to fuse three-scale features, and the entropy value of each modal feature is used as an auxiliary query vector to enhance the sensitivity of anomaly detection. After dimensionality reduction through a multi-head attention mechanism, it is input into a three-layer MLP classifier to realize apnea probability prediction.
[0065] In step S5, a dynamic training strategy with bimodal cross entropy loss supervision is designed based on the Adam optimizer. The convergence process is optimized through adaptive adjustment of the learning rate driven by the validation set, and end-to-end training is implemented under the PyTorch framework.
[0066] In step S6, a clinically oriented evaluation system is constructed to verify the effectiveness of multi-scale features at the segment level and test the robustness in a noisy environment at the system level. Finally, model compression technology is used to achieve embedded device deployment, completing real-time dual-modal signal acquisition, multi-scale analysis, and apnea warning functions.
[0067] Example 2 See also Figure 3 , shown is a schematic structural diagram of a sleep apnea detection system proposed in the second embodiment of the present application, the system includes the following key modules: A data set construction module 100 is configured to obtain synchronously acquired electrocardiogram (ECG) signals and respiratory signals, preprocess the ECG signals and respiratory signals, and segment the preprocessed signals according to at least two different preset time scales to construct a dual-modal multi-scale data set comprising an ECG sequence and a respiratory signal sequence; A parallel feature extraction module 200 is configured to extract deep features of corresponding scales from the electrocardiogram sequence and the respiratory signal sequence using a parallel feature extraction network for the signal segments of the at least two different time scales, and generate a cross-modal feature for each scale; A cross-scale feature fusion module 300 is configured to interact and fuse the cross-modal features at multiple scales using a cross-scale dynamic weighted attention mechanism. The cross-scale dynamic weighted attention mechanism dynamically modifies attention weights based on vector differences between features at different scales to adaptively aggregate the most discriminative information at each scale. The compression classification module 400 is used to input the fused features into a feature compression module for dimensionality reduction, and a classifier outputs a probability prediction of a sleep apnea event based on the dimensionality reduced features.
[0068] A sleep apnea detection system in an embodiment of the present application may be a device, or a component, integrated circuit, or chip in a terminal. The device may be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device may be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), and the non-mobile electronic device may be a server, network attached storage (NAS), personal computer (PC), etc., which are not specifically limited in the embodiments of the present application.
[0069] A sleep apnea detection system in an embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0070] The sleep apnea detection system provided in the embodiment of the present application can achieve Figure 1 To avoid repetition, each process of implementing a sleep apnea detection method in the method embodiment will not be described again here.
[0071] Optionally, an embodiment of the present application further provides an electronic device, including a processor, a memory, and a program or instruction stored in the memory and executable on the processor. When the program or instruction is executed by the processor, the various processes of the above-mentioned sleep apnea detection method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they will not be described here.
[0072] An embodiment of the present application further provides a readable storage medium having a program or instruction stored thereon. When the program or instruction is executed by a processor, the various processes of the embodiment of the above-mentioned sleep apnea detection method are implemented, and the same technical effects can be achieved. To avoid repetition, they are not described here.
[0073] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer-readable storage medium, such as a computer read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk.
[0074] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0075] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a more preferred embodiment. Based on this understanding, the technical solution of this application, or the part that contributes to the existing technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of this application.
[0076] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.
Claims
1. A sleep apnea detection method, characterized in that: The following steps are involved: S1: Acquire synchronously collected electrocardiogram signals and respiratory signals, preprocess the electrocardiogram signals and respiratory signals, and segment the preprocessed signals according to at least two different preset time scales to construct a bimodal multi-scale dataset including an electrocardiogram sequence and a respiratory signal sequence; S2: for the signal segments of the at least two different time scales, using a parallel feature extraction network, extracting deep features of corresponding scales from the electrocardiogram sequence and the respiratory signal sequence, respectively, and generating a cross-modal feature for each scale; S3: A cross-scale dynamic weighted attention mechanism is used to interact and fuse the cross-modal features at multiple scales. The cross-scale dynamic weighted attention mechanism dynamically modifies the attention weights according to the vector differences between features at different scales to adaptively aggregate the most discriminative information at each scale. S4: The fused features are input into a feature compression module for dimensionality reduction, and a classifier outputs a probability prediction of a sleep apnea event based on the dimensionality reduced features.
2. The method according to claim 1, characterized in that In step S1, the at least two different preset time scales are 1 minute, 3 minutes and 5 minutes; the preprocessing specifically includes: Applying a 3-45 Hz bandpass filter to the electrocardiogram signal, and using a Hamilton algorithm to locate the R peak to extract RR interval and R peak amplitude characteristics; A 0.1-1 Hz bandpass filter is applied to the respiratory signal to extract the respiratory amplitude and the change rate characteristics calculated by numerical differentiation.
3. The method according to claim 1, characterized in that In step S2, the parallel feature extraction network is a parallel bimodal dilated convolutional neural network; step S2 specifically includes: For each time scale, a dilated convolutional network branch is set up for the electrocardiogram sequence and the respiratory signal sequence respectively. The dilated convolutional network branch extracts multi-level waveform and rhythm features through a dilated convolution layer with an adjustable expansion rate and an adaptive pooling layer. At each scale, the features extracted by the electrocardiogram network branch and the respiratory signal network branch are projected onto a preset dimension and then concatenated to form the cross-modal features.
4. The method according to claim 1, wherein In step S3, the implementation of the cross-scale dynamic weight correction attention mechanism includes: Generating query matrices, key matrices, and value matrices for the cross-modal features at different scales respectively; When calculating the attention score between the query matrix at any scale and the key matrix at another scale, a correction factor based on the Euclidean distance between the feature vectors of the two scales is introduced and processed using the ReLU activation function to enhance the interaction weight of the significantly different features; The attention score after superimposing the correction factor is normalized by the Softmax function to obtain the final attention weight, and the attention weight is used to perform weighted summation on the corresponding value matrix to fuse cross-scale information.
5. The method according to claim 4, characterized in that In step S4, the feature compression module is an improved Q-Former module, and the classifier is a multi-layer perceptron. Step S4 specifically includes: The fused features from all scales are spliced in the sequence dimension to form a high-dimensional spliced feature; Inputting the high-dimensional splicing features into the improved Q-Former module, the improved Q-Former module uses the query vector to perform multi-head attention interaction with the high-dimensional splicing features to achieve feature compression and dimensionality reduction; The low-dimensional feature vector output by the improved Q-Former module is input into the multi-layer perceptron for final classification and judgment.
6. The method according to claim 5, characterized in that The query vector of the improved Q-Former module is a learnable query vector, and an auxiliary query vector calculated from the characteristic entropy values of the electrocardiogram sequence and the respiratory signal sequence is introduced. The auxiliary query vector is used to enhance the model's detection sensitivity to signal abnormalities.
7. The method according to claim 1, characterized in that The method also includes a model training step, which adopts an Adam optimizer and uses a bimodal cross entropy loss function to train the model end-to-end; the bimodal cross entropy loss function is a combination of a classification loss based on electrocardiogram features and a classification loss based on respiratory signal features.
8. A sleep apnea detection system, characterized in that: include: a data set construction module, configured to obtain synchronously acquired electrocardiogram signals and respiratory signals, preprocess the electrocardiogram signals and respiratory signals, and segment the preprocessed signals according to at least two different preset time scales to construct a bimodal multi-scale data set comprising an electrocardiogram sequence and a respiratory signal sequence; A parallel feature extraction module is configured to extract deep features of corresponding scales from the electrocardiogram sequence and the respiratory signal sequence using a parallel feature extraction network for the signal segments of the at least two different time scales, and generate a cross-modal feature for each scale; A cross-scale feature fusion module, configured to interact and fuse the cross-modal features at multiple scales using a cross-scale dynamic weighted attention mechanism. The cross-scale dynamic weighted attention mechanism dynamically modifies attention weights based on the vector differences between features at different scales to adaptively aggregate the most discriminative information at each scale. The compression classification module is used to input the fused features into a feature compression module for dimensionality reduction, and a classifier outputs a probability prediction of a sleep apnea event based on the features after dimensionality reduction.
9. An electronic device, characterized in that: The invention comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein when the program or instruction is executed by the processor, the steps of the sleep apnea detection method according to any one of claims 1 to 7 are implemented.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the sleep apnea detection method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Wireless invasive arterial blood pressure measuring device
CN112914529A
Target detection method and system using illumination guidance and attention mechanism
CN115131640A
Physiological signal fragment analysis method based on multi-mode and multi-scale common attention
CN116458884A
Feature enhancement multi-modal target tracking method and device based on attention query
CN117333876A
Multi-scale respiratory event automatic positioning method and device based on bimodal feature learning
CN117503056A
Cited By
Non-inductive sleep ambulatory blood pressure rhythm analysis method and system, equipment and medium
CN121080939A
A method and system for analyzing the dynamic blood pressure rhythm of sleep without induction, equipment and medium
CN121080939B
Sleep apnea detection method and system based on electrocardiosignal and storage medium
CN121647600A