An ECG signal denoising method, device, equipment and storage medium

By processing ECG signals with a frequency-guided multi-head self-attention model and a global channel and spatial enhancement convolution model, the problem of poor robustness of ECG signal denoising in the existing technology is solved, better noise removal effect is achieved, and the accuracy of heart disease diagnosis is improved.

CN119366932BActive Publication Date: 2025-10-24SUN YAT SEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411644060.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-10-24
Estimated Expiration
2044-11-18

AI Technical Summary

Technical Problem

Existing ECG signal denoising methods have poor robustness and are difficult to effectively remove various noises, which affects the accuracy of heart disease diagnosis.

Method used

A frequency-guided multi-head self-attention model and a global channel and spatial enhanced convolutional model are adopted to segment the ECG signal through discrete wavelet transform, extract low-frequency and high-frequency components, perform encoding calculation and attention processing, and combine time-frequency analysis and attention mechanism to remove noise.

Benefits of technology

The performance and robustness of ECG signal denoising are improved, effectively removing different types of noise and improving the accuracy of heart disease diagnosis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119366932B_ABST
    Figure CN119366932B_ABST
Patent Text Reader

Abstract

The application provides an ECG signal denoising method, device, equipment and storage medium. The ECG signal denoising method comprises the following steps: segmenting an ECG signal to be denoised into a plurality of segmented ECG signals; extracting low-frequency components and high-frequency components of each segmented ECG signal based on a discrete wavelet transform; performing encoding calculation on the segmented ECG signals to obtain corresponding encoding matrices; processing the low-frequency components, the high-frequency components and the encoding matrices of the segmented ECG signals by using a frequency-guided multi-head self-attention model to obtain attention results corresponding to each segmented ECG signal; performing denoising processing on the attention results corresponding to the segmented ECG signals by using a global channel and spatial enhancement convolution model to obtain denoising results corresponding to each segmented ECG signal; and splicing the denoising results corresponding to each segmented ECG signal to obtain a denoised ECG signal. The application solves the technical problem that the prior art is not sensitive to noise intensity and has poor robustness.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of ECG signal processing, and in particular to an ECG signal denoising method, device, equipment and storage medium. BACKGROUND

[0002] An electrocardiogram (ECG) is a comprehensive reflection of the electrical physiological activity of myocardial cell groups, and an ECG signal can reflect the physiological conditions of various parts of the heart to some extent and has been widely used in the clinical diagnosis of arrhythmia, myocardial infarction and various cardiovascular diseases. An ECG record reflects the electrical signals of the heart, and it is clinically used to further diagnose arrhythmia and other related diseases. A traditional ECG detection method is to collect short-time ECG signals of a patient by using a hospital electrocardiograph, and a cardiologist diagnoses the ECG signals by visual manual diagnosis.

[0003] However, an ECG signal is easily affected by various interferences or additional activities of other parts of the heart, which may cause distortion of the ECG signal in the detection process, greatly reducing the accuracy of the judgment of heart diseases, and thus denoising becomes a primary problem of ECG signal detection.

[0004] An ECG signal is essentially a non-stationary, nonlinear quasi-periodic continuous signal, and existing technologies mainly use time domain / frequency domain-based denoising methods to denoise the ECG signal. However, these methods are not sensitive to noise intensity and have poor robustness, and it is difficult to achieve accurate ECG signal denoising. SUMMARY

[0005] In view of the deficiencies of the prior art, the present application provides an ECG signal denoising method, device, equipment and storage medium, which has better denoising performance and more stable robustness.

[0006] The technical scheme of the present application is as follows: an ECG signal denoising method, comprising the following steps:

[0007] S1), segmenting an ECG signal to be denoised into a plurality of segmented ECG signals;

[0008] S2), extracting low-frequency components and high-frequency components of each segmented ECG signal based on a discrete wavelet transform;

[0009] S3), performing encoding calculation on each segmented ECG signal to obtain an encoding matrix corresponding to each segmented ECG signal;

[0010] S4), processing the low-frequency components, high-frequency components and encoding matrix of each segmented ECG signal by using a preset frequency-guided multi-head self-attention model to obtain an attention result corresponding to each segmented ECG signal;

[0011] S5), denoising the attention results corresponding to each segmented ECG signal by using a global channel and a spatial enhancement convolution model to obtain denoised results corresponding to each segmented ECG signal;

[0012] S6), splicing the denoised results corresponding to each segmented ECG signal to obtain a denoised ECG signal.

[0013] As preferred, in step S2), the extraction of the low-frequency component and the high-frequency component of each segmented ECG signal based on the discrete wavelet transform comprises the following steps:

[0014] S21), extracting the low-frequency component of each segmented ECG signal through a low-pass filter and convolution operation;

[0015] S22), extracting the high-frequency component of each segmented ECG signal through a high-pass filter and convolution operation.

[0016] As preferred, in step S2), before extracting the low-frequency component and the high-frequency component of each segmented ECG signal, it is also necessary to perform normalization processing on each segmented ECG signal.

[0017] As preferred, in step S3), the encoding matrix comprises a query matrix, a key matrix and a value matrix.

[0018] As preferred, in step S3), the encoding calculation of the encoding matrix corresponding to each segmented ECG signal comprises the following steps:

[0019] S31), based on a preset query matrix calculation formula, performing encoding calculation on each segmented ECG signal to obtain a query matrix corresponding to each segmented ECG signal, and the query matrix calculation formula is:

[0020] [Q1, Q2,..., Q h ] = s·W q ;

[0021] In the formula, [Q1, Q2,..., Q h ] is the query matrix; h is the number of heads in the frequency-guided multi-head self-attention model; s is the segmented ECG signal; W q is the projection mapping of the query matrix;

[0022] S32), based on a preset key matrix calculation formula, performing encoding calculation on each segmented ECG signal to obtain a key matrix corresponding to each segmented ECG signal, and the key matrix calculation formula is:

[0023] [K1, K2,..., K h ] = Concat(s L ,sH )·W k

[0024] wherein [K1, K2, …, K h ] is a key matrix; Concat(s L , s H ) is a connection operation of the low-frequency component and the high-frequency component of the segmented ECG signal; s L is the low-frequency component; s H is the high-frequency component; W k is a projection mapping of the key matrix;

[0025] S33), based on a preset value matrix calculation formula, encoding calculation is performed on each of the segmented ECG signals to obtain a value matrix corresponding to each of the segmented ECG signals, wherein the value matrix calculation formula is:

[0026] [V1, V2, …, V h ] = s·W v

[0027] wherein [V1, V2, …, V h ] is a value matrix; W v is a projection mapping of the value matrix.

[0028] As preferred, in step S4), the low-frequency component, the high-frequency component and the encoding matrix of each of the segmented ECG signals are taken as input signals of a frequency-guided multi-head self-attention model, and the frequency-guided multi-head self-attention model calculates attention scores and signal features corresponding to each of the segmented ECG signals by using a softmax function, and calculates an attention result according to the attention scores and the signal features.

[0029] As preferred, in step S5), the global channel and spatial enhancement convolution model processes the attention result of the segmented ECG signal by using channel attention and spatial attention to obtain a comprehensive feature;

[0030] Then, an inter-band relationship of the comprehensive feature is calculated by a one-dimensional convolution layer, and the comprehensive feature and the inter-band relationship are processed by a spatial enhancement convolution network to obtain a denoising result corresponding to each of the segmented ECG signals.

[0031] As preferred, the present application further provides an ECG signal denoising device, comprising:

[0032] a segmentation module, configured to segment an ECG signal to be denoised into a plurality of segmented ECG signals;

[0033] a high-low frequency conversion module, configured to extract a low-frequency component and a high-frequency component of each of the segmented ECG signals by using discrete wavelet transform;

[0034] The encoding module is configured to perform encoding calculation on each segmented ECG signal to obtain an encoding matrix corresponding to each segmented ECG signal.

[0035] The multi-head self-attention module is configured to calculate an attention result of the segmented ECG signal according to the low-frequency component, the high-frequency component and the encoding matrix of the segmented ECG signal.

[0036] The denoising module is configured to input the attention result of each segmented ECG signal into a global channel and spatial enhancement convolution model to perform denoising processing on the segmented ECG signal.

[0037] The splicing module is configured to splice each denoised segmented ECG signal to obtain a denoised ECG signal.

[0038] As a preferred embodiment, the application further provides an ECG signal denoising device, which comprises a processor and a memory.

[0039] The processor is configured to execute the ECG signal denoising method according to the instructions in the program code.

[0040] As a preferred embodiment, the application further provides a computer readable storage medium for storing program code, wherein the program code is used to execute the ECG signal denoising method.

[0041] The application has the following advantages:

[0042] 1. The frequency-guided multi-head self-attention model and the global channel and spatial enhancement convolution model are used to denoise the ECG signal to be denoised, which has better denoising performance and more stable robustness, and solves the technical problem of poor robustness of the existing denoising method based on time domain / frequency domain.

[0043] 2. The ECG signal is divided into multiple segments, so that each segment covers all important features of the ECG signal.

[0044] 3. The frequency-guided multi-head self-attention model FG-MSA effectively captures the intra-band dependency relationship by combining time-frequency analysis and MSA to introduce frequency domain information to guide the time domain attention process, effectively combines the advantages of time-frequency analysis and attention mechanism, and improves the denoising ability.

[0045] 4、The application reduces spectral overlapping noise by global channel and spatial enhanced convolution GCSC, and the GCS can also adaptively adjust the weight ratio of different frequency bands and signal parts to better capture the correlation between frequency bands. BRIEF DESCRIPTION OF DRAWINGS

[0046] Figure 1 A flowchart of the denoising method in embodiment 1 of the application is shown.

[0047] Figure 2 A structural diagram of the frequency-guided multi-head self-attention model in embodiment 1 of the application is shown.

[0048] Figure 3 A structural diagram of the global channel and spatial enhanced convolution model in embodiment 1 of the application is shown.

[0049] Figure 4 A diagram showing the effect of denoising by various methods in embodiment 2 of the application is shown.

[0050] Figure 5 A framework structure diagram of the denoising device in embodiment 3 of the application is shown. DETAILED DESCRIPTION

[0051] The specific embodiments of the application will be further described below in conjunction with the accompanying drawings:

[0052] Embodiment 1

[0053] As shown in the figure, the embodiment provides a denoising method for ECG signals, including the following steps: Figure 1

[0054] S1), segmenting the ECG signal to be denoised into several segmented ECG signals;

[0055] As shown in the figure, the ECG signal is mainly affected by four kinds of noise, such as baseline wander (BW), electrode motion (EM), muscle artifact (MA) and their mixture (Mix). Figure 2 Different types of noise have different characteristics. For example, BW noise is mainly caused by involuntary autonomic movement of the human body, which is a low-frequency noise of about 0.05 to 1 Hz, and its characteristic is the deviation of the baseline, which fluctuates up and down. EM noise is caused by changes in skin impedance and potential of the human body, showing large amplitude and strong randomness. MA noise is a high-frequency noise with a frequency range of 5 to 2000 Hz, caused by tremors caused by muscle contraction of the human body, showing irregular and rapidly changing waveforms. Compared with BW noise and MA noise, EM noise is more difficult to remove. Its frequency spectrum is mainly in the range of 1 to 10 Hz, which has a large overlap with the frequency spectrum of the ECG signal.

[0056]

[0057] ​​Due to the potential long duration of the original ECG, long-time denoising brings huge time and resource costs. The embodiment divides the ECG signal to be denoised, avoiding the iterative error caused by the detection algorithm. It can be understood that, in order to further ensure the accuracy of the calculation, the embodiment divides the ECG signal to be denoised into fixed-length segments (for example, each segment can be 1024 sampling points). Since the sampling rate is 360Hz, a typical ECG cardiac cycle is about 0.5 to 1 second, and such segmentation can make each segment have at least 2 complete ECG cardiac cycles. Each segment covers all important features of the ECG signal, such as P wave, QRS wave complex, T wave and U wave.

[0058] S2), extracting low-frequency components and high-frequency components of each segmented ECG signal based on discrete wavelet transform;

[0059] The discrete wavelet transform of the embodiment is embedded in the multi-head self-attention operation, which increases the perception field by combining frequency features and time features and provides fine-grained prediction changes, including the following steps:

[0060] S21), normalizing the segmented ECG signal to obtain a normalized segmented ECG signal, and the data amplitude range is 0 to 1; wherein the calculation formula of the normalization processing is:

[0061]

[0062] In the formula, s min , s max are the minimum and maximum values of the segmented ECG signal, s i is the i-th segmented ECG signal; Norm(s i ) is the i-th segmented ECG signal after normalization processing;

[0063] S22), extracting low-frequency components of each segmented ECG signal based on discrete wavelet transform and a preset low-frequency component calculation formula, and the low-frequency component calculation formula is:

[0064] s L = (s*g) downarrow 2;

[0065] In the formula, s L is the low-frequency component of the segmented ECG signal, s is the segmented ECG signal, g is a low-pass filter, * is a convolution operation, and downarrow 2 is a down-sampling operation with a step of 2;

[0066] S23), extracting high-frequency components of each segmented ECG signal based on discrete wavelet transform and a preset high-frequency component calculation formula, and the high-frequency component calculation formula is:

[0067] s H = (s*h) downarrow 2;

[0068] wherein s H is a high frequency component of the segmented ECG signal, and h is a high-pass filter.

[0069] S3), encoding and calculating each segmented ECG signal to obtain an encoding matrix corresponding to each segmented ECG signal;

[0070] In the embodiment, the encoding matrix includes a query matrix, a key matrix, and a value matrix, and the calculation of each matrix is as follows:

[0071] S31), based on a preset query matrix calculation formula, encoding and calculating each segmented ECG signal to obtain a query matrix corresponding to each segmented ECG signal, and the query matrix calculation formula is:

[0072] [Q1, Q2,..., Q h ]=s·W q ;

[0073] wherein [Q1, Q2,..., Q h ] is a query matrix; h is the number of heads in a frequency-guided multi-head self-attention model; s is a segmented ECG signal; W q is a projection mapping of the query matrix;

[0074] S32), based on a preset key matrix calculation formula, encoding and calculating each segmented ECG signal to obtain a key matrix corresponding to each segmented ECG signal, and the key matrix calculation formula is:

[0075] [K1, K2,..., K h ]=Concat(s L ,s H )·W k

[0076] wherein [K1, K2,..., K h ] is a key matrix; Concat(s L ,s H ) is a connection operation of a low frequency component and a high frequency component of a segmented ECG signal; s L is a low frequency component; s H is a high frequency component; W k is a projection mapping of the key matrix;

[0077] S33), based on a preset value matrix calculation formula, encoding and calculating each segmented ECG signal to obtain a value matrix corresponding to each segmented ECG signal, and the value matrix calculation formula is:

[0078] [V1, V2,..., Vh ] = s · W v

[0079] where [V1, V2,..., V h ] is a value matrix; W v is a projection mapping of the value matrix.

[0080] S4), processing the low-frequency component, the high-frequency component and the encoding matrix of each segmented ECG signal by using the preset frequency-guided multi-head self-attention model to obtain the attention result corresponding to each segmented ECG signal;

[0081] As shown in the formula (1), the embodiment proposes a frequency-guided multi-head self-attention model FG-MSA. Figure 2 The frequency-guided multi-head self-attention model FG-MSA introduces frequency domain information by combining time-frequency analysis and MSA to guide the time domain attention process, and further captures the in-band dependency relationship.

[0082] In the embodiment, the frequency-guided multi-head self-attention model FG-MSA can automatically distinguish and filter out the noise in the ECG signal, effectively combines the advantages of time-frequency analysis and attention mechanism, and improves the denoising ability of the method of the embodiment.

[0083] In the embodiment, the low-frequency component, the high-frequency component and the encoding matrix of each segmented ECG signal are used as the input signal of the frequency-guided multi-head self-attention model. The frequency-guided multi-head self-attention model calculates the attention score and signal feature corresponding to each segmented ECG signal by using the softmax function. The calculation expression of the attention score of the frequency-guided multi-head self-attention model FG-MSA is as follows:

[0084]

[0085] where AttentionScore i is the attention score of the i-th head; Q i is the query matrix of the i-th head, is the transpose matrix of the key matrix of the i-th head, T represents the transpose operation; d k is the dimension of the key matrix; softmax represents the softmax function.

[0086] The attention result is calculated according to the attention score and the signal feature, and specifically:

[0087]

[0088]

[0089] where, is the attention calculation result of the i-th head, Vi is the value matrix of the i-th head, is the attention calculation result of the segmented ECG signal, is the concatenation of the calculation results of h different attention heads, W L×L is the projection mapping of the segmented ECG signal with input length and output length both being L.

[0090] S5), using a global channel and spatial enhancement convolution model to denoise the attention result corresponding to each segmented ECG signal to obtain the denoising result corresponding to each segmented ECG signal;

[0091] In this embodiment, the global channel and spatial enhancement convolution model processes the attention result of the segmented ECG signal using channel attention and spatial attention to obtain comprehensive features;

[0092] Then the inter-band relationship of the comprehensive features is calculated through a one-dimensional convolution layer, and the comprehensive features and the inter-band relationship are processed through a spatial enhancement convolution network to obtain the denoising result corresponding to each segmented ECG signal.

[0093] In this embodiment, as shown in Figure 3 , the global channel and spatial enhancement convolution model fuses a lightweight attention module LA and a 1-D convolution layer to adjust the weight ratio of different frequency bands and signal parts; two lightweight attention modules LA are executed in different dimensions while sharing the same structure, and the lightweight attention module LA is respectively arranged for channel attention LA c and spatial attention LA s of key frequency bands and key parts of signals; specifically, for channel attention, this embodiment first applies average pooling and maximum pooling operations in the spatial dimension to obtain feature maps, then connects the two pooling results in the channel dimension, and applies a 1-D convolution to extract the inter-band relationship. Finally, a sigmoid function is used to generate the weight of the channel attention. The expression of the channel attention LA c in this embodiment is as follows:

[0094]

[0095]

[0096] In the formula, AP c AP c (·) and MP c respectively represent the average pooling and maximum pooling operations of the channel attention in the spatial dimension, is the result of the channel attention average pooling, is the result of the channel attention maximum pooling, and Z cis the input of the channel attention module, is the weight of the channel attention, and k=1 is a 1-D convolution, and k represents the kernel size, is the concatenation operation of the channel attention average pooling and maximum pooling results.

[0097] Similar to the channel attention, the spatial attention LA c shares the same structure. s The expression is as follows:

[0098]

[0099]

[0100] In the formula, AP s and MP s respectively represent the average pooling and maximum pooling operations of the spatial attention in the spatial dimension, is the result of the spatial attention average pooling, is the result of the spatial attention maximum pooling, and Z s is the input of the spatial attention module, is the weight of the spatial attention, and k=7 is a 1-D convolution, is the concatenation operation of the spatial attention average pooling and maximum pooling results.

[0101] After the above two attention processes, the fine features of the frequency band are obtained, and the representation of the signal time sequence is further elaborated. Finally, the inter-band correlation is obtained by applying a 1-D convolution layer, so as to combine the important parts of the frequency and time features.

[0102] Z c = Z g + LA c (Z g )·Z g

[0103] Z s = Z c + LA s (Z c )·Z c

[0104]

[0105] In the formula, LA c and LA s respectively represent the channel attention module and the spatial attention module, and Z cZ is the output of the channel attention module g Z is the input of the global channel and spatial enhancement convolutional model g Z is the output of the spatial attention module Z is the comprehensive feature output by the global channel and spatial enhancement convolutional model

[0106] S6), splicing the denoising results corresponding to each segmented ECG signal to obtain a denoised ECG signal.

[0107] Embodiment 2

[0108] In this embodiment, the MIT-BIH arrhythmia and QT database are used as clean ECG ground truth (Origin), and the MIT-BIH noise stress test database is used as noisy data (Noisy).

[0109] The MIT-BIH arrhythmia database is a widely used ECG arrhythmia classification database, which can also be used as a pure signal for ECG denoising. It includes 48 ECG signal records from different patients with 11-bit resolution in the 10mV range. The sampling objects include 25 males aged 32 to 89 and 22 females aged 23 to 89. All records contain two channels, of which the MLII lead appears most frequently in the record. Each ECG record is 30 minutes long and is sampled at a frequency of 360Hz.

[0110] The QT database contains 105 records with two channels, created from seven different databases. Each record contains the onset, peak, and offset markets of P waves, QRS complexes, T waves, and U waves, containing 30 to 50 selected beats. Each ECG record is 15 minutes long and is sampled at a frequency of 250Hz. Since its data source is samples from other databases, the QT database lacks statistical analysis of lead types, gender, and age distribution.

[0111] The MIT-BIH noise stress test database is an ECG noise database based on the MIT-BIH arrhythmia database, including 12 half-hour ECG records and 3 half-hour typical noise, all sampled at 360Hz. The noise records include baseline wander (BW), electrode motion (EM), and muscle artifact (MA), respectively. Based on these baseline noises, they are mixed in proportion, called mixed noise.

[0112] In this embodiment, the method of embodiment 1 is compared with WT, improved DAE, FCN-DAE, SCED-Net+LNC, SRD, and ADnCNN methods, which are specifically designed for ECG denoising.

[0113] In this embodiment, the number of embedded feature dimensions C is set to 32, and the depth N of the model is set to 3. In order to evaluate the robustness of the model of the method of embodiment 1 under different noise intensities, three different signal-to-noise ratio levels (-1 dB, 3 dB, 7 dB) are selected for training, and another three levels (0 dB, 1.25 dB, 5 dB) are selected for testing. According to the same setting as the baseline method, the training pair is generated by adding randomly sampled additive noise to the clean ECG signal to obtain the training pair. During the training process, the Adam optimizer is adopted, and the learning rate is initially set to 1 10-3 . The adaptive training strategy is used to automatically reduce the learning rate according to the loss metric. Specifically, if the loss does not decrease for 10 consecutive cycles, the learning rate is reduced to half of the previous value. The total training period is set to 300.

[0114] Three indicators are used to evaluate the denoising performance, namely, the signal-to-noise ratio (SNR), the root mean square error (RMSE), and the percentage of root mean square difference (PRD). The signal-to-noise ratio is used to quantify the power ratio of the signal, and the higher the signal-to-noise ratio value, the better the signal quality. The RMSE describes the error between the pure signal and the denoised signal of the electrocardiogram, and a smaller value indicates excellent denoising performance. The PRD measures the similarity between the pure signal and the denoised signal of the electrocardiogram, and a smaller value reflects a closer signal.

[0115] In order to evaluate the performance of the method of embodiment 1, four different noise types (BW, EM, MA, and Mix) are used in this embodiment, with six noise intensities ranging from (-1db to 7db). The denoising results are shown in Tables 1 and 2. As can be seen from Tables 1 and 2, the method of embodiment 1 achieves excellent denoising performance under different input signal-to-noise ratios and noise types. This is because embodiment 1 combines traditional wavelet transform with attention networks, effectively learning the time and frequency domain features of ECG signals. Specifically, for the MIT-BIH arrhythmia database, the output signal-to-noise ratio of the method of this application is as high as 38.01 dB, the minimum RMSE is 0.0036, and the minimum PRD is 1.342%. For the QT database, the signal-to-noise ratio is as high as 38.14 dB, and the RMSE and PRD are as low as 0.0049 and 1.341%. In addition, the denoising performance of MA noise is slightly worse compared to other noises, due to its high-frequency characteristics with strong randomness. Nevertheless, the method of embodiment 1 still achieves satisfactory denoising performance. Overall, the denoising changes under various indicators are not significant as the input signal-to-noise ratio increases, further demonstrating the robustness of the model of this application.

[0116] Table 1 - Comparison of denoising performance of different methods under different noise types and intensities in the MIT-BIH arrhythmia database

[0117]

[0118]

[0119] Table 2 Denoising comparison of different methods under different noise types and intensities on QT database

[0120]

[0121] As can be seen from the table, as expected, the method of embodiment 1 is superior to all other baseline methods on four different intensities of noise. ADnCNN, due to the combination of adversarial training strategy and convolutional neural network, achieves suboptimal denoising effect - this work introduces frequency domain loss in model training. However, the combination of frequency and loss function is not an effective approach, because the frequency domain contains key information that is beneficial to the electrocardiogram denoising process itself. In the method of embodiment 1, the time-frequency analysis is fused into the attention process to capture long-range dependencies and multi-modal information in the denoising process. In addition, channel and spatial enhancement convolutions are introduced to further improve the ability to capture inter-band correlations to eliminate spectral overlapping noise. Compared with ADnCNN, the average output signal-to-noise ratio of the method of embodiment 1 on MIT-BIH arrhythmia and QT database is increased by 2.21 dB and 5.977 dB, respectively, and the average RMSE is reduced by 0.0022 and 0.00698, respectively. The results of the comparative experiments prove the effectiveness of our method.

[0122] In addition, Figure 4 For the denoising effect diagram of the method of embodiment 1 and WT, improved DAE, FCN-DAE, SCED-Net+LNC, SRD and ADnCNN method, the visualization results under different noise types (from left to right, the first column to the fourth column represent BW, EM, MA and Mix noise) and intensities (from top to bottom, the first row to the third row represent 0 dB, 1.25 dB and 5 dB) of different databases, where “Origin” represents the ground truth, “Noisy” represents the noisy electrocardiogram signal, and “Ours” represents the denoising result of our method. As can be seen from the figure, red represents the electrocardiogram signal denoised by the method of embodiment 1, sky blue and blue represent the clean electrocardiogram signal and the electrocardiogram signal contaminated by noise, respectively. It can be observed intuitively that there is almost no sky blue in the figure because it is almost completely covered by red. This means that the method of embodiment 1 achieves excellent denoising performance, very close to the ground truth. In summary, the experimental results show that the method of embodiment 1 has good performance in terms of denoising ability on four different noise types and multiple levels of noise intensity on different databases.

[0123] Embodiment 3

[0124] AsFigure 5 The embodiment shown provides a denoising device for ECG signals, comprising:

[0125] a segmentation module, configured to segment an ECG signal to be denoised into a plurality of segmented ECG signals;

[0126] a high and low frequency conversion module, configured to extract low frequency components and high frequency components of each segmented ECG signal by using discrete wavelet transform;

[0127] an encoding module, configured to perform encoding calculation on each segmented ECG signal to obtain an encoding matrix corresponding to each segmented ECG signal;

[0128] a multi-head self-attention module, configured to calculate an attention result of a segmented ECG signal according to the low frequency components, the high frequency components and the encoding matrix of the segmented ECG signal;

[0129] a denoising module, configured to input the attention result of each segmented ECG signal into a global channel and spatial enhancement convolution model to perform denoising processing on the segmented ECG signal;

[0130] a splicing module, configured to splice each denoised segmented ECG signal to obtain a denoised ECG signal.

[0131] In the embodiment, the high and low frequency conversion module further performs normalization processing on each segmented ECG signal before extracting the low frequency components and the high frequency components.

[0132] Embodiment 4

[0133] The embodiment provides a denoising device for ECG signals, which comprises a processor and a memory; the memory is used to store program codes and transmit the program codes to the processor;

[0134] The processor is used to execute the denoising method for ECG signals according to the instructions in the program codes.

[0135] In the embodiment, the memory can be realized by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The processor is coupled with the memory and is used to execute the computer program in the memory.

[0136] Embodiment 5

[0137] The embodiment provides a computer readable storage medium for storing program codes, the program codes being used for executing the ECG signal denoising method.

[0138] The above embodiment and description are only to illustrate the principles and the best mode of the present application, and various changes and improvements can be made to the present application without departing from the spirit and scope of the present application, and all the changes and improvements fall within the scope of the present application.

Claims

1. A method of denoising an ECG signal, characterized in that, The method comprises the following steps: S1), segmenting the ECG signal to be denoised into a plurality of segmented ECG signals; S2), extracting the low-frequency component and the high-frequency component of each segmented ECG signal based on discrete wavelet transform; specifically comprising the following steps: S21), extracting the low-frequency component of each segmented ECG signal through a low-pass filter and a convolution operation; the low-frequency component calculation formula is: s L = (s * g) ↓ 2; where s L is a low frequency component of the segmented ECG signal, s is the segmented ECG signal, g is a low pass filter, * is a convolution operation, and is a down-sampling operation with a step of 2. S22), extracting the high-frequency component of each segmented ECG signal through a high-pass filter and a convolution operation, and the high-frequency component calculation formula is: s H = (s * h) ↓ 2; where s H is the high frequency component of the segmented ECG signal, h is a high pass filter; S3), encoding calculation is performed on each segmented ECG signal to obtain the encoding matrix corresponding to each segmented ECG signal; specifically comprising the following steps: S31), based on the preset query matrix calculation formula, the encoding calculation is performed on each segmented ECG signal to obtain the query matrix corresponding to each segmented ECG signal, and the query matrix calculation formula is: [Q1, Q2,..., Q h ] = s · W q ; In the formula, [Q1, Q2, …, Q h ] is a query matrix; h is the number of heads in the frequency-guided multi-head self-attention model; s is a segmented ECG signal; W q is a projection mapping of the query matrix; S32), based on the preset key matrix calculation formula, the encoding calculation is performed on each segmented ECG signal to obtain the key matrix corresponding to each segmented ECG signal, wherein the key matrix calculation formula is: [K1, K2,..., K h ] = Concat(s L , s H ) · W k where [K1, K2,..., K h ] is a key matrix; Concat(s L , s H ) is a concatenation operation of the low frequency component and the high frequency component of the segmented ECG signal; s L is the low frequency component; s H is the high frequency component; W k is a projection mapping of the key matrix; S33), based on the preset value matrix calculation formula, the encoding calculation is performed on each segmented ECG signal to obtain the value matrix corresponding to each segmented ECG signal, wherein the value matrix calculation formula is: [VI, V2,..., V h ] = s - W v where [V1, V2,..., V h ] is a matrix of values; W v is a projection mapping of a matrix of values; S4), processing the low-frequency component, the high-frequency component and the encoding matrix of each segmented ECG signal by using a preset frequency-guided multi-head self-attention model to obtain the attention result corresponding to each segmented ECG signal; The low-frequency component, the high-frequency component and the encoding matrix of each segmented ECG signal are used as the input signal of the frequency-guided multi-head self-attention model, the frequency-guided multi-head self-attention model uses a softmax function to calculate the attention score and the signal feature corresponding to each segmented ECG signal, and the attention result is calculated according to the attention score and the signal feature, and the calculation of the attention result is specifically: where AttentionScore i is the attention score for the i-th head; is the attention computation result for the i-th head, V i is the value matrix for the i-th head, is the attention computation result for the segmented ECG signal, is the concatenation of the computation results for h different attention heads, W L×L is the projection mapping for the segmented ECG signal with input length and output length both L; S5), using a global channel and spatial enhancement convolution model to denoise the attention result corresponding to each segmented ECG signal to obtain the denoising result corresponding to each segmented ECG signal; The global channel and spatial enhancement convolution model fuses a lightweight attention module LA and a 1-D convolution layer to adjust the weight ratio of different frequency bands and signal parts; two lightweight attention modules LA are executed in different dimensions while sharing the same structure, and the lightweight attention modules LA are respectively arranged for channel attention LA of key frequency bands c and spatial attention LA of signal key parts s ; S6), splicing the denoising result corresponding to each segmented ECG signal to obtain the denoised ECG signal.

2. The ECG signal denoising method of claim 1, wherein: In step S5), the global channel and spatial enhancement convolution model processes the attention result of the segmented ECG signal by using channel attention and spatial attention to obtain a comprehensive feature; Then the inter-band relationship of the comprehensive feature is calculated through a one-dimensional convolution layer, and the comprehensive feature and the inter-band relationship are processed through a spatial enhancement convolution network to obtain the denoising result corresponding to each segmented ECG signal.

3. The method of claim 1, wherein: In step S5), for channel attention, firstly, average pooling and max pooling operations are applied on the spatial dimension to obtain feature maps, then the two pooling results are connected on the channel dimension, and a 1-D convolution is applied to extract the inter-band relationship; finally, a sigmoid function is used to generate the weight of the channel attention; the channel attention LA c The expression is as follows: where AP c and MP c denote average pooling and max pooling operation of channel attention in spatial dimension, respectively, is the result of channel attention average pooling, is the result of channel attention max pooling, Z c is the input of channel attention module, is the weight of channel attention, and σ is sigmoid function, W k=1 is 1-D convolution, and k denotes the kernel size, is the concatenation operation of channel attention average pooling and max pooling results; Channel attention LA when operating in different dimensions c Spatial attention LA sharing the same structure s The expression is as follows: where AP s and MP s are average pooling and max pooling operations for spatial attention, respectively, is the result of spatial attention average pooling, is the result of spatial attention max pooling, Z s is the input of the spatial attention module, is the weight of the spatial attention, W kx7 is a 1-D convolution, is a concatenation operation for spatial attention average pooling and max pooling results; Then the inter-band relationship is obtained through a 1-D convolution layer, so as to combine the important parts of the frequency and time features; Z c = Z g + LA c (Z g ) · Z g Z s = Z c + LA s (Z c ) · Z c wherein LA c and LA s denote the channel attention module and the spatial attention module, respectively, Z c is the output of the channel attention module, Z g is the input of the global channel and spatial enhanced convolutional model, Z s is the output of the spatial attention module, is the comprehensive feature output by the global channel and spatial enhanced convolutional model.

4. An apparatus for denoising an ECG signal, characterized by, The denoising device is used for the denoising method in any one of claims 1-3, and the denoising device comprises: A segmentation module for segmenting the ECG signal to be denoised into a plurality of segmented ECG signals; A high-frequency transform module is configured to extract low-frequency components and high-frequency components of each segmented ECG signal by using a discrete wavelet transform; An encoding module is configured to perform encoding calculation on each segmented ECG signal to obtain an encoding matrix corresponding to each segmented ECG signal; A multi-head self-attention module is configured to calculate an attention result of each segmented ECG signal according to the low-frequency components, the high-frequency components and the encoding matrix of the segmented ECG signal; A denoising module is configured to input the attention result of each segmented ECG signal into a global channel and spatial enhancement convolution model to perform denoising processing on the segmented ECG signal; A splicing module is configured to splice each denoised segmented ECG signal to obtain a denoised ECG signal.

5. A device for de-noising an ECG signal, characterized in that, The denoising device is configured to execute the denoising method in any one of claims 1-3, and the device comprises a processor and a memory; the memory is configured to store program code and transmit the program code to the processor; The processor is configured to execute the denoising method in any one of claims 1-3 according to instructions in the program code.

6. A computer-readable storage medium, characterized in that, The computer readable storage medium is configured to store program code, and the program code is configured to execute the denoising method in any one of claims 1-3.

Citation Information

Patent Citations

  • Unsupervised multi-mode electrocardiogram anomaly detection method based on attention mechanism

    CN115944302A

  • Arrhythmia classification method based on SincNet and multi-head attention mechanism

    CN117653135A