A deep learning-based electrocardiogram denoising method
By constructing a training sample generator and an improved convolutional neural network model, the problem of modifying the original waveform during ECG denoising was solved, achieving the preservation of useful information while denoising and improving the accuracy of ECG recognition.
Patent Information
- Application Number
- CN202310666918.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-07
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-06-07
AI Technical Summary
Existing ECG denoising methods modify useful information in the original waveform during the denoising process, leading to deviations in subsequent ECG recognition results.
A training sample generator is constructed to generate noise simulation data. A noise filtering model is built through a convolutional neural network. An improved Euclidean distance loss function and a multi-channel summation mechanism are adopted to ensure that the original waveform information is preserved while filtering out noise.
This method achieves the goal of not modifying the original waveform information during the denoising process, thereby improving the accuracy and reliability of ECG recognition.
Smart Images

Figure CN116738146B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to a method for denoising electrocardiograms based on deep learning. Background Technology
[0002] An electrocardiogram (ECG) is a non-invasive diagnostic tool that records the electrical activity of the heart. It can be used to detect heart health, arrhythmias, and other conditions. However, due to physiological and environmental interference, ECG signals are often contaminated by various noises, such as electromyographic interference, electric field interference, and baseline drift, which greatly complicates the identification and analysis of ECG signals. Figure 1 The image shows an example of a raw electrocardiogram (ECG). Due to interference from other devices, the ECG contains pulse interference noise, indicated by the arrows in the image. A typical ECG signal is a millivolt-level signal, meaning it has a low frequency and small amplitude. Therefore, compared to surrounding noise signals, the ECG signal is usually very weak. This significant characteristic makes extracting the raw ECG signal more difficult than processing general engineering signals.
[0003] Traditional methods for denoising ECG signals are mostly based on filtering, employing wavelet transform filtering or bandpass filtering. While these methods effectively address issues like baseline drift, they are less effective at filtering irregular noise, such as impulse noise generated by interference from other devices. Furthermore, traditional filtering-based denoising methods modify useful information in the original waveform during the denoising process, leading to errors in subsequent ECG recognition and other operations. Figure 2 As shown, this is the... Figure 1 The waveform shown is the result of filtering and denoising using traditional methods. Pulse interference noise was not completely filtered out, and other information in the original electrocardiogram was also modified, affecting the subsequent electrocardiogram recognition results.
[0004] Among existing methods, there are also methods for processing EGG signal noise based on neural networks. For example, the technical solution disclosed in the patent application number 201911279110.5 is to reduce the noise of ECG signals based on adversarial neural networks. Its core idea is to generate a clean ECG from the noisy ECG. Although the noise is removed from the generated ECG curve, because it is a regenerated ECG, it will also modify the useful information in the original waveform while reducing noise. Summary of the Invention
[0005] To address the problem that existing electrocardiogram (ECG) denoising methods modify useful information in the original waveform, this invention provides a deep learning-based ECG denoising method that does not modify the original waveform during the denoising process, thus preserving all useful information in the original waveform.
[0006] The technical solution of this invention is as follows: a deep learning-based electrocardiogram noise reduction method, characterized by comprising the following steps:
[0007] S1: Construct a training sample generator;
[0008] Noise simulation data is generated based on the training sample generator;
[0009] The noise simulation data includes: impulse interference noise and Gaussian noise;
[0010] The pulse interference noise is shaped as spikes of varying amplitudes oriented in one direction, with a width not exceeding 0.03 seconds; the amplitude of the pulse interference noise is random.
[0011] The Gaussian noise includes Gaussian noise of different amplitudes and sizes;
[0012] S2: Collect clean, noise-free electrocardiogram curves as the basic data for training samples;
[0013] Based on the training sample generator, the noise simulation data is randomly added to the curve of the basic training sample data to obtain the training sample data.
[0014] S3: Construct a training sample set based on the training sample data;
[0015] S4: Construct a noise filtering model based on a convolutional neural network;
[0016] The input size of each convolutional layer in the noise filtering model is [x, y, inputchannel], where x and y are the data size, and inputchannel is the number of input channels, with x taking the value of 1.
[0017] The output size of each convolutional layer is [x, y, outputchannel], where outputchannel is the number of output channels;
[0018] The size of each convolutional kernel is set to [sx, sy, inputchannel, outputchannel], where sx takes the value of 1;
[0019] Then there is,
[0020] Wherein, the output data of convolutional layer o, where m represents the m-th channel, n represents the n-th value, and c i,n σ represents the nth value of the i-th input channel. i,n The weight is the nth value of the i-th input channel of the convolutional layer; the outlier represents noisy data in the input data;
[0021] S5: Train the noise filtering model based on the training sample set to obtain the trained noise filtering model;
[0022] The training process adopts an end-to-end training method;
[0023] S6: Input the ECG curve to be processed into the noise filtering model based on the trained noise filtering model to perform noise filtering.
[0024] Its further features are:
[0025] In step S5, the loss function uses Euclidean distance during training;
[0026] In step S5, during training, the original clean training sample base data is added as input data to the training sample data; and weights are added to the output data of the training sample data and the training sample base data respectively, and then the weights are added together to form the loss function for one iteration of training.
[0027] In step S5, during training, weights are added to the noise simulation data and the basic training data in the training sample data, respectively.
[0028] The loss function used during the training of the noise filtering model is:
[0029]
[0030] Where α, β, and δ are hyperparameters, y is the length of the one-dimensional electrocardiogram, input1 is the input electrocardiogram curve using the training sample data as input data, output1 is the output corresponding to input1; input2 is the input curve using the training sample data as input data, output2 is the output corresponding to input2; j represents the j-th point on the curve of the input data.
[0031] The method for screening outliers specifically includes the following steps:
[0032] a1: Sort all input data by size to obtain a data sequence;
[0033] a2: Calculate the quartiles of all data and arrange the quartiles in ascending order: Q1, Q2, Q3;
[0034] a3: Calculate the quarter-satellite distance (IQR) of the data sequence:
[0035] IQR = Q3 - Q1;
[0036] a4: All data points that are less than Q1–0.25*IQR or greater than Q3+0.25*IQR are denoted as outliers.
[0037] This application provides a deep learning-based electrocardiogram (ECG) denoising method. It generates simulated noise data using a training sample generator and randomly adds this data to noise-free ECG curves to generate training sample data. This ensures the training sample data covers any noise type under different conditions, thereby ensuring the noise filtering model learns noise information and improves the model's accuracy in noise identification. The noise filtering model is constructed based on a convolutional neural network (CNN). The multi-channel addition mechanism of the CNN is improved by deleting outlier noise data before adding channels, reducing the probability of noise data in the calculation result and improving accuracy. The training method is improved based on Euclidean distance. When training the noise filtering model, basic training sample data is added as input, balancing the impact of noise filtering on the original waveform and increasing the probability of preserving the original waveform information. Hyperparameter settings control the training effect, ensuring that useful information in the original waveform is not modified while filtering noise. Based on this denoising method, the original waveform is not modified during the denoising process, preserving all useful information and providing a good foundation for subsequent ECG signal recognition. Attached Figure Description
[0038] Figure 1 Here is an example of a raw electrocardiogram (ECG) image.
[0039] Figure 2 To Figure 1 The waveform shown is the result of filtering and denoising using traditional methods.
[0040] Figure 3 A schematic diagram of the convolutional layer channel relationships in a noise filtering model;
[0041] Figure 4 This refers to the basic data for the training samples in Example 1;
[0042] Figure 5 for Figure 4 ECG curves after adding noise simulation data
[0043] Figure 6 This refers to the noise-free baseline data in Example 2;
[0044] Figure 7 for Figure 6 Electrocardiogram curves after adding noise to simulated data;
[0045] Figure 8 for Figure 7 After the data is fed into the noise filtering model, the resulting denoised electrocardiogram curve is obtained.
[0046] Figure 9 for Figure 6 The data was directly fed into the noise filtering model, and the resulting denoised electrocardiogram curve was obtained. Detailed Implementation
[0047] This invention includes a deep learning-based electrocardiogram noise reduction method, which includes the following steps.
[0048] S1: Construct a training sample generator;
[0049] Noise simulation data is generated based on the training sample generator;
[0050] The noise simulation data includes: impulse noise and Gaussian noise;
[0051] The shape of pulse interference noise is a spike of varying amplitude oriented in one direction, with a width typically not exceeding 0.03 seconds; the amplitude of pulse interference noise is random.
[0052] Gaussian noise includes Gaussian noise of different amplitudes and sizes.
[0053] The technical solution of this application mainly includes two modules: a training sample generator and a noise filtering model. The training sample generator simulates pulse interference noise, covering the noise generated by the ECG acquisition equipment in actual operation. Gaussian noise covers the noise generated in ECG signals by electromyography interference, electrostatic interference, and electric field interference in actual operation. The training sample generator ensures coverage of all noise types and can simulate different types of noise interference, thereby ensuring that the noise filtering model can learn various noise information and effectively process all different noises.
[0054] S2: Collect clean, noise-free electrocardiogram curves as the basic data for training samples;
[0055] Based on the training sample generator, noise simulation data is randomly added to the curve of the basic training sample data to obtain the training sample data.
[0056] S3: Construct a training sample set based on the training sample data.
[0057] like Figure 4As shown, this is the original, clean, noise-free training sample base data in Example 1. Figure 5 For training sample generator to Figure 4 Examples of training sample data obtained by adding similar waveforms with random height and random width to random positions of the training sample base data, as well as Gaussian noise.
[0058] S4: Construct a noise filtering model based on a convolutional neural network;
[0059] The noise filtering model in this application takes a noisy curve as input and outputs a noisy curve as output, with the input and output dimensions being the same.
[0060] In traditional convolutional neural networks, each layer has an input channel and an output channel during convolution. That is, the output of each layer with a size of [x, y, input channel] serves as the input of the next layer, where x and y are the data dimensions.
[0061] In this patent application, the electrocardiogram curve is a one-dimensional curve, therefore x is 1, and inputchannel represents the number of input channels. After the next convolutional layer, the size becomes [x, y, outputchannel], meaning the number of input channels is transformed into the number of output channels through convolution. This is achieved by setting the size of the convolutional kernel of this layer to [sx, sy, inputchannel, outputchannel], where sx and sy are the sizes of a single convolutional kernel. Since the electrocardiogram curve in this patent is a one-dimensional curve, sx is set to 1, inputchannel represents the number of input channels, and outputchannel represents the number of output channels. See details... Figure 3 As shown.
[0062] That is, each data point in the output channel is formed by convolving the data points from the input channel and then directly summing them together.
[0063] The formula is as follows:
[0064]
[0065] Where m represents the m-th channel and n represents the n-th value, in traditional convolutional layers, the data of all channels are directly added together, that is, the weights of all channels are the same.
[0066] Because different channels of a convolutional network use different convolutional kernels, the extracted information is not entirely consistent. This application filters out noise. If the data from different channels are directly added together, some channel data that has not been effectively filtered out will also be added, resulting in the result still containing noise.
[0067] Therefore, this application improves upon traditional convolutional networks by statistically analyzing the data at corresponding positions of all input channels, calculating the quartiles and inner limits of the data, and classifying the data into normal values and outliers.
[0068] Specifically, outliers need to be removed first. The removal method includes the following steps:
[0069] a1: Sort all input data by size to obtain a data sequence;
[0070] a2: Calculate the quartiles of all data and arrange the quartiles in ascending order: Q1, Q2, Q3;
[0071] a3: Calculate the quarter-way distance (IQR) of the data sequence.
[0072] IQR = Q3 - Q1;
[0073] a4: All data points that are less than Q1–0.25*IQR or greater than Q3+0.25*IQR are denoted as outliers.
[0074] Set the weight of outliers to 0 and the weight of normal points to 1.
[0075] Therefore, the relationship formula between the input channel and the output channel in this application becomes:
[0076] Then there is,
[0077] Wherein, the output data of convolutional layer o, where m represents the m-th channel, n represents the n-th value, and c i,n σ represents the nth value of the i-th input channel. i,n is the weight of the nth value of the i-th input channel of the convolutional layer; outliers represent noisy data in the input data.
[0078] In this application, the Euclidean distance formula is used for the training loss function of the noise filtering model.
[0079] The traditional Euclidean distance formula is:
[0080]
[0081] Where y is the length of the one-dimensional electrocardiogram, input is the input electrocardiogram curve, and output is the output electrocardiogram curve.
[0082] However, while traditional loss functions can filter out noise, they cannot preserve the original information well while filtering out noise, and there is still a problem of modifying the useful information in the original waveform.
[0083] Therefore, in this application, the loss function is improved by adding the original clean training sample basic data as input during training to balance the impact of noise filtering.
[0084] In practical applications, for the same network model, the original clean training sample data input1 is input first, generating output1. Then, training sample data input2 with added noise simulation data is input, generating output2. The losses of output1 and output2 are weighted and summed as the loss function for one iteration of training; that is, the influence of noise filtering is controlled by the weights.
[0085] Because noise is randomly added when the training sample data input2 is generated, a portion of the input2 curve is noise, while the remainder is the noise-free basic training sample data. Therefore, during training, the noise-simulated data in input2 and the basic training sample data are also weighted to achieve the algorithm's goal of balancing noise filtering and preserving the original waveform. The details are shown below.
[0086] S5: Train the noise filtering model based on the training sample set to obtain the trained noise filtering model; the training process adopts an end-to-end training method.
[0087] The loss function used during the training of the noise filtering model is:
[0088]
[0089] Where α, β, and δ are hyperparameters, y is the length of the one-dimensional electrocardiogram, input1 is the input electrocardiogram curve using the training sample data as input data, output1 is the output corresponding to input1; input2 is the input curve using the training sample data as input data, output2 is the output corresponding to input2; j represents the j-th point on the curve of the input data.
[0090] Here, α, β, and δ are hyperparameters. By adjusting different proportions, the model can exhibit different filtering effects. For example, increasing the values of α and β makes the model retain the original data information but reduces the filtering effect; increasing the value of δ makes the model's filtering effect more obvious but reduces the retention of the original data information.
[0091] In this embodiment, α = 0.5, β = 0.5, and δ = 1 are used. By balancing the noise data and the original data, the goal of balancing noise filtering and preserving the original waveform can be achieved, filtering out noise without modifying the original waveform information.
[0092] S6: Input the ECG curve to be processed into the trained noise filtering model to perform noise filtering.
[0093] like Figure 6 In Example 2 shown, a segment of noise-free baseline data is used to generate noise-simulated data based on the training sample generator. The noise-simulated data is then randomly added to the noise-free baseline data to obtain... Figure 7 The electrocardiogram curve shown is... Figure 7 The noisy electrocardiogram (ECG) curve was fed into a noise filtering model for denoising. The resulting denoised ECG curve is shown below. Figure 8 As shown. Comparison Figure 6 and Figure 8 It can be known that Figure 6 The information is stored in Figure 8 In the curve. And directly... Figure 6 The curve is fed into the noise filtering model for noise reduction processing, and the resulting noise-reduced curve is as follows. Figure 9 As shown. Comparison Figure 6 and Figure 9 It can be known that Figure 6 The curve was not modified.
[0094] Using the technical solution of this invention, various noise data can be automatically generated based on the training sample generator, covering any noise type under different conditions, thus solving the problem of insufficient training data. Based on the improved multi-channel addition mechanism of the convolutional neural network, outlier data is removed, ensuring that the noise filtering model is more suitable for noise filtering. Based on the improved training method and training data, the setting of hyperparameters ensures that the noise filtering model in this application can filter noise without modifying the original waveform information.
Claims
1. A deep learning based electrocardiogram denoising method, characterized in that, It comprises the following steps: S1: Constructing a training sample generator; Generating noise simulation data based on the training sample generator; The noise simulation data includes impulse interference noise and Gaussian noise; The shape of the impulse interference noise is a sharp wave with different amplitudes in one direction, and the width is not more than 0.03 seconds; the amplitude of the impulse interference noise is a random size; The Gaussian noise includes Gaussian noise with different amplitudes and different sizes; S2: Collecting clean electrocardiogram curves without noise as training sample basic data; Based on the training sample generator, the noise simulation data is randomly added to the curve of the training sample basic data to obtain training sample data; S3: Constructing a training sample set based on the training sample data; S4: Constructing a noise filtering model based on a convolutional neural network; The input size of each convolutional layer of the noise filtering model is [x, y, inputchannel], wherein x and y are data sizes, and inputchannel is the number of input channels, wherein x is 1; The output size of each convolutional layer is [x, y, outputchannel], and outputchannel is the number of output channels; The size of each convolutional kernel is set to [sx, sy, inputchannel, outputchannel], wherein sx is 1; Then, (σ i,n = 0, if c i,n ∈ outlier, else σ i,n = 1) wherein o represents the output data of the convolution layer, m represents the mth channel, n represents the nth value, c i,n represents the nth value of the i th input channel, σ i,n is the weight of the nth value of the i th input channel of the convolution layer; outliers represent noise data in the input data; S5: Training the noise filtering model based on the training sample set to obtain the trained noise filtering model; The training process adopts an end-to-end training method; S6: Inputting the electrocardiogram curve to be processed into the trained noise filtering model for noise filtering; The outlier screening method specifically comprises the following steps: a1: Sort all input data by size to obtain a data sequence; a2: Calculate the quartiles of all data, and arrange the quartiles from small to large: Q1, Q2, Q3; a3: Calculate the interquartile range IQR of the data sequence: IQR = Q3 - Q1; a4: Mark all data points less than Q1-0.25*IQR or greater than Q3+0.25*IQR as outliers.
2. The deep learning-based electrocardiogram noise reduction method of claim 1, wherein: In step S5, the loss function uses the Euclidean distance during training.
3. The deep learning-based electrocardiogram denoising method of claim 2, wherein: In step S5, during training, the original clean training sample basic data is added as input data based on the training sample data as input data; And add weights to the output data of the training sample data and the training sample basic data respectively and then add them, as the loss function of one iteration training.
4. The deep learning-based electrocardiogram noise reduction method of claim 3, wherein: In step S5, during training, the noise simulation data in the training sample data and the training sample basic data are added with weights respectively.
5. The deep learning-based electrocardiogram noise reduction method of claim 1, wherein: The loss function used in the training process of the noise filtering model is: Wherein, alpha, beta and delta are hyperparameters, y is the length of the one-dimensional electrocardiogram, input1 is the input electrocardiogram curve of the training sample basic data as input data, output1 is the output corresponding to input1; input2 is the input curve of the training sample data as input data, output2 is the output corresponding to input2; j represents the jth point on the curve of the input data.
Citation Information
Patent Citations
Automatic noise reduction method of dynamic electrocardiograms
CN110840445A
Electrocardiogram P wave identification method based on machine learning
CN116807492A
Systems and methods for electrocardiogram deep learning interpretability
US20250022596A1