Electrocardiosignal characteristic wave segmentation method and FS-Net model
Through the FS-Net model and adaptive waveform correction filter, the ECG signal is processed, and the problem of identification of ECG signal characteristic waves in disease situations is solved, the detection accuracy and interpretability are improved, and the P and T waves are realized. effective segmentation and enhancement.
Patent Information
- Application Number
- CN202411379821.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-09-30
AI Technical Summary
The characteristic waves of the ECG signal are difficult to effectively identify in disease situations, especially because the ST segment changes and T wave inversion caused by myocardial ischemia increase the difficulty of identification.
The FS-Net model is used to combine adaptive waveform correction filter and Pan-Tommpkins algorithm to process ECG signals through denoising, normalization, correction and feature enhancement, and construct a model for segmenting the characteristic waves of the ECG signal, and then propose it. Process algorithms to correct error detection.
Improve the detection accuracy of the characteristic waves of the ECG signal, enhance the performance of P and T waves, realize the bidirectional matching of data and algorithms, improve the performance of neural networks, and provide an interpretable deep learning process and feature distribution. visualization.
Smart Images

Figure CN119074008A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an electrocardiogram signal analysis method, in particular to an electrocardiogram signal characteristic wave segmentation method and an FS-Net model. Background Art
[0002] Electrocardiogram testing is non-invasive and convenient, and the 12-lead electrocardiogram has become an important method for detecting heart disease. The detection of electrocardiogram characteristic waves has important clinical application value in the diagnosis, treatment decision-making, disease monitoring and prognosis evaluation of heart disease. The morphology, interval and frequency of characteristic waves are a direct reflection of the electrical activity of the heart and are crucial for the diagnosis of heart disease. Different heart diseases can cause a variety of changes in characteristic waves such as P waves, QRS segments and T waves, such as ST segment changes caused by myocardial ischemia and T wave inversion caused by myocardial infarction. These changes and the characteristic differences between leads in the 12-lead electrocardiogram and the differences between patients increase the difficulty of accurately identifying characteristic waves, making characteristic waves a challenge. Summary of the invention
[0003] One of the purposes of the present invention is to provide a method for segmenting characteristic waves of electrocardiogram signals to solve the problem that characteristic waves are difficult to effectively identify in the case of disease.
[0004] The second purpose of the present invention is to provide a FS-Net model for segmenting characteristic waves of ECG signals, so as to establish a model for effectively segmenting characteristic waves of ECG signals.
[0005] One of the purposes of the present invention is achieved in that:
[0006] A method for segmenting characteristic waves of an electrocardiogram signal comprises the following steps:
[0007] S1. ECG signal denoising: Use the median filter algorithm to correct the baseline drift of the ECG signal, and use the third-order Butterworth low-pass filter to eliminate the high-frequency noise in the ECG signal;
[0008] S2. Normalization of ECG signal peak value: Use the Pan-Tompkins algorithm to calibrate the R peak information of the denoised ECG signal, calculate the RR interval information, then use the sliding window to select data and normalize the data in the sliding window;
[0009] S3. ECG signal waveform correction and feature enhancement: firstly, the normalized ECG signal is smoothed, then the QRS wave, P wave and T wave of the ECG signal are corrected, and finally the P wave and T wave in the corrected ECG signal are feature enhanced;
[0010] S4. Model construction: Construct the FS-Net model for segmenting the characteristic waves of ECG signals;
[0011] S5. Model training: input the ECG signal processed by steps S1-S3 into the FS-Net model for training to segment the P wave, QRS wave, and T wave in the ECG signal;
[0012] S6. Post-processing algorithm: correct the features of segmentation errors;
[0013] S7. ECG signal segmentation: Use the trained FS-Net model to segment the characteristic waves of the measured ECG signal.
[0014] Furthermore, the low-pass cutoff frequency of the third-order Butterworth low-pass filter in step S1 is 0.5 Hz.
[0015] Furthermore, the size of the sliding window in step S2 is 1.1 times the RR interval of the 5 s ECG data near the current sampling point.
[0016] Furthermore, the normalization formula is:
[0017]
[0018] Among them, ECG nomalized Represents the ECG signal of a period of time, time1 is the start time of each sampling of the sliding window, time2 is the end time of each sampling of the sliding window, max is the maximum amplitude of the ECG signal in the sliding window, and abs is the absolute value of the corresponding amplitude of the ECG signal from time1 to time2.
[0019] Furthermore, the specific method of smoothing the ECG signal in step S3 is:
[0020] A sliding window with a length of 60ms slides on the ECG signal at a speed of 1 sampling point, and the standard deviation of the data in each window is calculated. The points greater than the set threshold are taken as characteristic waves, and the amplitude of the ECG signal less than the threshold is taken as 0 to obtain the corrected ECG signal. The value of the set threshold is 1.2% of the maximum value of the standard deviation;
[0021] The calculation formula for smoothing is:
[0022]
[0023]
[0024] Among them, ECG std Indicates the standard deviation of the ECG signal. amend (t) represents the corrected ECG signal, std (t) is the standard deviation of the sliding window at time t, max(ECG std ) is the maximum standard deviation of the sliding window at all times.
[0025] Furthermore, the specific method of correcting the QRS wave of the electrocardiogram signal in step S3 is:
[0026] S3a-1. Take the absolute value of the amplitude of the ECG signal, and use the Pan-Tompkins algorithm to determine the QRS wave peak point of the ECG signal after taking the absolute value;
[0027] S3a-2. If the original amplitude corresponding to the QRS wave peak point is a positive value, it remains unchanged; if the original amplitude corresponding to the peak point is a negative value, the original amplitude of the peak point is saved as its opposite.
[0028] Furthermore, the specific method of correcting the P wave and the T wave in step S3 is:
[0029] S3b-1. Locate the T wave position and the P wave position respectively, and calculate the mean of the T wave amplitude and the P wave amplitude respectively;
[0030] S3b-2. When the mean value of the T wave amplitude is a negative number, the T wave is an inverted T wave; when the mean value of the P wave amplitude is a negative number, the P wave is an inverted P wave;
[0031] S3b-3. Count the two zero-crossing positions of the T wave, and determine the inverted T wave according to the amplitude and vibration direction of the T wave; count the two zero-crossing positions of the P wave, and determine the inverted P wave according to the amplitude and vibration direction of the P wave; if there is no zero-crossing position, use the statistical information to determine the inverted T wave and the inverted P wave respectively;
[0032] S3b-4. Take the absolute values of the amplitudes of the inverted T wave and the inverted P wave respectively.
[0033] Furthermore, the specific method of enhancing the features of the P wave and the T wave in step S3 is:
[0034] S3c-1. Shift the corrected ECG signal upward by 1mV, so that the baseline of the ECG signal is 1mV;
[0035] S3c-2. Perform the initial transformation on the up-shifted ECG signal according to the logarithmic function. The transformation formula is:
[0036]
[0037] Among them, ECG log (t) is the amplitude of the corresponding ECG signal after the initial transformation at time t;
[0038] S3c-3. Enhance the transformed ECG signal. The enhancement formula is:
[0039]
[0040] Among them, ECG enhance (t) is the amplitude of the enhanced ECG signal at time t;
[0041] S3c-4. The enhanced ECG signal is shifted down by 1mV, so that the baseline of the ECG signal is 0mV, and the ECG signal after the shift is processed by Gaussian smoothing algorithm;
[0042] S3c-5. Use the Pan-Tompkins algorithm to calibrate the R peak information of the enhanced ECG signal after Gaussian smoothing, calculate the RR interval information, then use the sliding window to select data, and normalize the data in the sliding window;
[0043] S3c-6. Slide a sliding window of 60ms on the ECG signal at a speed of 1 sampling point, calculate the standard deviation of the data in each window, take the points greater than the set threshold as the characteristic wave, and take the amplitude of the ECG signal less than the threshold as 0 to obtain the corrected ECG signal, the set threshold value is 3.5% of the maximum value of the standard deviation;
[0044] S3c-7. Loop through steps S3c-1-S3c-6 for a total of 6 times, and the final ECG signal obtained is an ECG signal with enhanced features.
[0045] Furthermore, the FS-Net model includes:
[0046] An encoder, connected to a decoder, for learning dependencies between feature waves; and
[0047] A decoder, connected to the encoder, for performing characteristic wave segmentation on the ECG signal;
[0048] The input of the encoder passes through 3 modules consisting of convolutional layers and normalization layers in sequence, then enters 8 modules consisting of a multi-head attention layer, an Add layer, a normalization layer, a feedforward layer, an Add layer, and a normalization layer in sequence, and is output to the decoder;
[0049] The input of the decoder passes through 4 modules consisting of a bidirectional long short-term memory network and Dropout, and then passes through 2 time-distributed fully connected mapping networks, and finally enters the Softmax layer and outputs. The time-distributed fully connected mapping network includes a time distribution network and a feedforward layer.
[0050] The second object of the present invention is achieved in this way:
[0051] A FS-Net model for segmenting characteristic waves of electrocardiogram signals, comprising:
[0052] An encoder, connected to a decoder, for learning dependencies between feature waves; and
[0053] A decoder, connected to the encoder, for performing characteristic wave segmentation on the ECG signal;
[0054] The input of the encoder passes through 3 modules consisting of convolutional layers and normalization layers in sequence, then enters 8 modules consisting of a multi-head attention layer, an Add layer, a normalization layer, a feedforward layer, an Add layer, and a normalization layer in sequence, and is output to the decoder;
[0055] The input of the decoder passes through 4 modules consisting of a bidirectional long short-term memory network and Dropout, and then passes through 2 time-distributed fully connected mapping networks, and finally enters the Softmax layer and outputs. The time-distributed fully connected mapping network includes a time distribution network and a feedforward layer.
[0056] Furthermore, the fully connected network based on time distribution maps a signal with a time length of m and a feature length of n at each time point to a signal with a time length of m and a feature length of n′ at each time point, where n′ is less than n.
[0057] ECG characteristic wave recognition is a challenging task in ECG signal analysis. In order to solve the problem of characteristic wave changes caused by myocardial ischemia, the present invention introduces an adaptive waveform correction filter, which effectively enhances the performance of P wave and T wave in the ECG and improves the accuracy of characteristic wave detection. The algorithm adaptively corrects the T wave morphological changes caused by myocardial ischemia, and enhances the amplitude of P wave and T wave, realizes two-way matching of data and algorithm, and improves the performance of neural network. The present invention also proposes an interpretable end-to-end neural network model FS-Net, which can detect the characteristic waves of the corrected and enhanced 12-lead ECG, and provides visualization of feature distribution and backtracking to show the deep learning process. In addition, a post-processing algorithm is proposed to correct false detection and accurately classify characteristic waves. The proposed algorithm has made significant progress in ECG characteristic wave detection. These methods not only improve the accuracy of ECG detection, but also have interpretability and practicality. Future research can apply these methods in a wider range of heart disease detection and further optimize them to enhance the effect of ECG detection and the feasibility of clinical application. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a flow chart of the method of the present invention.
[0059] Figure 2 It is a comparison chart of the effects before and after noise reduction in diseased individuals and healthy individuals.
[0060] Figure 3 It is a comparison chart of the effects before and after normalization treatment in diseased individuals and healthy individuals.
[0061] Figure 4 It is a comparison chart of the effects before and after smoothing of non-characteristic bands in diseased individuals and healthy individuals.
[0062] Figure 5 It is a comparison chart of the effects before and after QRS direction correction in disease states and healthy individuals.
[0063] Figure 6 This is a comparison chart of the effects of the original signals of T wave inversion and T wave depression before and after characteristic wave enhancement.
[0064] Figure 7 This is the overall structure diagram of the FS-Net model.
[0065] Figure 8 It is a fully connected mapping network structure diagram based on time distribution.
[0066] Fig. 9 is a visual comparison of the gradients under different disease conditions. DETAILED DESCRIPTION
[0067] The present invention is further described below.
[0068] like Figure 1 As shown, the present invention provides a method for segmenting characteristic waves of an electrocardiogram signal, which specifically comprises the following steps:
[0069] First, the signal is preprocessed, which mainly involves noise removal and signal normalization to make the signal a pure and stable ECG signal. Then the data is corrected to correct the characteristic waveform changes caused by the disease, and the features are enhanced so that the FS-Net model can detect ECG signals more effectively. The signal with corrected and enhanced features is sent to the FS-Net model, and the FS-Net model is used to analyze the data. The results of the analysis are corrected by the post-processing algorithm, and the segmentation of the characteristic wave is completed.
[0070] S1. ECG signal denoising: Use the median filter algorithm to correct the baseline drift of the ECG signal, and use the third-order Butterworth low-pass filter to eliminate the high-frequency noise in the ECG signal.
[0071] like Figure 2 As shown in the figure, ECG signals are easily affected by noise during the acquisition process, and these noises mainly include power supply noise interference and myoelectric noise interference. The median filter algorithm is used to correct the baseline drift of the ECG signal, and the third-order Butterworth low-pass filter is used to eliminate the high-frequency noise in the signal. The low-pass cutoff frequency of the filter is 0.5 Hz, and the denoised ECG signal is obtained.
[0072] Figure 2 The red line in the middle is the ECG signal with noise, and the blue line is the ECG signal after noise removal. Figure 2The middle left picture shows the ECG signal of a sick individual before and after denoising, and the right picture shows the ECG signal of a healthy individual before and after denoising. Whether in sick or healthy individuals, the ECG signal is smoother after removing noise.
[0073] S2. Normalization of ECG signal peak value: Use the Pan-Tompkins algorithm to calibrate the R peak information of the denoised ECG signal, calculate the RR interval information, then use the sliding window to select the data and normalize the data within the sliding window.
[0074] The acquisition of ECG signals is affected by the differences in the subjects' breathing rhythm, heartbeat, and acquisition equipment, resulting in differences in the R peak height in the same lead of the same person in a single test. In the next step of P wave and T wave enhancement, statistical parameters such as the mean and variance of the ECG signal are required, so the stability of the data is crucial to the enhancement effect. The present invention proposes an adaptive cyclic filtering scheme to solve the problem of different R peak heights when acquiring ECG signals and stabilize the ECG signals.
[0075] like Figure 3 As shown, the Pan-Tompkins algorithm is used to calibrate the R peak information of the ECG signal and calculate the RR interval information, that is, the length of adjacent R peaks; then the sliding window is used to select data and the data in the sliding window is normalized. The size of the sliding window is 1.1 times the RR interval of the closest 5-second ECG data, and the sliding speed is 10 sampling points each time. During each sliding process of the sliding window, the data in the sliding window is cyclically normalized until the normalization operation in the window is completed for all sampling points. Figure 3 The R peak height has been corrected, the R peak height is relatively uniform, and the height difference between the R peaks is small.
[0076] Among them, the normalization formula is:
[0077]
[0078] Among them, ECG nomalized Represents the ECG signal of a period of time, time1 represents the start time, time2 represents the end time, ECG[time1:time2] is the amplitude of the ECG signal corresponding to each time point, max is the maximum amplitude of the ECG signal in the sliding window, and abs is the absolute value of the amplitude of the ECG signal from time1 to time2.
[0079] S3. ECG signal waveform correction and feature enhancement: firstly, the normalized ECG signal is smoothed, then the QRS wave, P wave and T wave of the ECG signal are corrected, and finally the P wave and T wave in the corrected ECG signal are feature enhanced;
[0080] In order to stabilize and enhance the characteristic wave band of the ECG, it is first necessary to determine the existence of the characteristic wave. Since the characteristic wave morphology varies greatly, but the ECG signal is stable near the baseline when there is no characteristic wave, and the amplitude changes slowly, the area without characteristic waves is first calibrated, and then the area with characteristic waves is reversely determined. This calibration only requires a rough distinction, and the detailed division is completed by the ECG characteristic wave segmentation model. When the area without characteristic waves is determined, the ECG signal without characteristic waves will not change when the characteristic waves are enhanced later.
[0081] like Figure 4 As shown, the present invention proposes a non-characteristic band smoothing method based on a window function to calibrate areas without characteristic waves and areas with characteristic waves. By calculating the standard deviation of the amplitude of the electrocardiogram signal in a sliding window with a length of 60ms, and sliding a sampling point each time, it is determined whether a characteristic wave appears. The rapid change in amplitude caused by the characteristic wave will produce a larger standard deviation, while the point without a band is relatively stable, resulting in a smaller standard deviation. The point with an amplitude greater than the set threshold is considered to be a characteristic wave, and the point with an amplitude less than or equal to the set threshold is considered to have no characteristic wave. Among the characteristic waves, the amplitude of the P wave is the smallest. The selection of the set threshold is based on distinguishing the P band from the non-band. The P wave is distinguished, and other characteristic waves and the non-band are also distinguished, but it is impossible to determine which type of characteristic wave it is. The value of the set threshold is 1.2% of the maximum standard deviation. The formula for calculating the standard deviation and the threshold is expressed as:
[0082]
[0083]
[0084] Among them, ECG std Represents the variance of the signal, ECG amend Represents the corrected signal, ECG std (t) is the standard deviation of the sliding window at time t, max(ECG std ) is the maximum standard deviation of the sliding window at all times, max(ECG std )×0.012 is the setting threshold.
[0085] For example, when the time corresponding to the sampling point is 1 second, time1 is 970 seconds and time2 is 1030 seconds.
[0086] Figure 4 The middle left picture shows the ECG signal of a diseased individual before and after non-feature band smoothing, and the right picture shows the ECG signal of a healthy individual before and after non-feature band smoothing. The T wave and P wave have been smoothed by non-feature bands, and the clutter has been filtered out.
[0087] Correction of the direction of the QRS wave of the ECG signal. In the standard 12-lead system, the QRS band morphology may change due to different sampling positions and different possible disease types of the subjects. Even in the absence of disease, the ECG morphology is different. For example, under normal conditions, the QRS band peaks in leads I, II, and III are usually upward, but the axis offset may change the direction of the peak. In order to meet the training requirements of the characteristic wave segmentation model for the same distribution data, the present invention proposes an adaptive algorithm to correct the QRS band peak direction.
[0088] like Figure 5 As shown in the figure, since only the peak direction of the QRS wave band needs to be corrected, there is no need to accurately locate the R peak position. First, the absolute value of the amplitude corresponding to each point in the ECG signal is taken, and then the peak point is determined using the Pan-Tompkins algorithm. Next, the peak direction is determined based on the original data corresponding to the point: when the corresponding point information is a positive value, the signal is retained unchanged; if it is a negative value, the ECG signal is saved as its opposite. In this way, the peak direction of the QRS wave band is uniformly upward, and the same distribution of data helps to optimize the training effect of the characteristic wave segmentation model.
[0089] Figure 5 The left picture in the middle shows the ECG signal of a diseased individual before and after the QRS wave direction is corrected, and the right picture shows the ECG signal of a healthy individual before and after the QRS wave direction is corrected. Figure 5 After the QRS wave direction is corrected, the peak direction of the QRS wave band is uniformly upward.
[0090] The P wave and T wave direction correction algorithm of the ECG signal is affected by lead differences and cardiogenic diseases, and the P wave and T wave may be deformed. In order to better enhance the ECG characteristic wave, all P waves and T waves need to be corrected. The first screening: inverted P wave and inverted T wave: calculate the mean of the T wave amplitude respectively. If the T wave mean information is a negative number, the T wave is determined to be an inverted T wave; if the P wave mean information is a negative number, the P wave is determined to be an inverted P wave. The second screening: count the first two zero-crossing positions of the T wave, take the absolute value to correct the inverted T wave; count the two zero-crossing positions of the P wave, and determine the inverted P wave according to the amplitude and vibration direction of the P wave; when the amplitude is negative and the vibration direction is downward, it is an inverted characteristic wave; when there is no zero-crossing information, directly use the statistical information to correct the T wave direction. Among them, the statistical information is: the left side of the QRS wave is the P wave, and the right side of the QRS wave is the T wave.
[0091] The P and T waves of the ECG signal are enhanced. In a standard 12-lead ECG, the energy of the QRS band is usually higher than that of the P and T waves, and the amplitude of the P wave is only 1 / 5 to 1 / 3 of that of the QRS band, making the P wave easily masked in the ECG signal. However, feature wave segmentation is more sensitive to rapid gradient changes, so energy enhancement of the P and T waves is helpful for feature wave detection. The P and T wave values in the original signal are small, and the values increase after logarithmic transformation, but the QRS segment value is higher than that of the P and T waves, and the relative increment after logarithmic transformation is small. The ECG signal is processed by taking advantage of the characteristic that the growth rate of the logarithmic function decreases as the input value increases.
[0092] The specific method of enhancing the characteristics of P wave and T wave is:
[0093] S3c-1. Shift the corrected ECG signal upward by 1 mV, and the baseline of the ECG signal will be 1 mV.
[0094] S3c-2. Perform the initial transformation on the up-shifted ECG signal according to the logarithmic function. The transformation formula is:
[0095]
[0096] Among them, ECG log (t) is the amplitude of the corresponding ECG signal after the initial transformation at time t.
[0097] S3c-3. Enhance the transformed ECG signal. The enhancement formula is:
[0098]
[0099] Among them, ECG enhance (t) is the amplitude of the enhanced ECG signal at time t.
[0100] S3c-4. The enhanced ECG signal is shifted down by 1 mV, so that the baseline of the ECG signal is 0 mV, and the shifted ECG signal is processed by a Gaussian smoothing algorithm.
[0101] S3c-5. Use the Pan-Tompkins algorithm to calibrate the R peak information of the enhanced ECG signal after the downward shift, calculate the RR interval information, then use the sliding window to select the data, and normalize the data in the window. The normalization formula is formula (1);
[0102] S3c-6. Slide a sliding window of 60ms on the ECG signal at a speed of 1 sampling point, calculate the standard deviation of the data in the window each time, take the points greater than the set threshold as the characteristic wave, and take the amplitude of the ECG signal less than the threshold as 0 to obtain the corrected ECG signal. The threshold value is set to 3.5% of the maximum standard deviation; the formula for calculating the standard deviation is formula (2).
[0103]
[0104] Among them, ECG amend1 (t) is the corrected ECG signal.
[0105] S3c-7. Loop through steps S3c-1-S3c-6 for a total of 6 times, and the final ECG signal obtained is an ECG signal with enhanced features.
[0106] In order to obtain a significant effect, a total of 6 cycles of enhancement were performed to finally obtain an enhanced ECG signal.
[0107] like Figure 6 As shown, no matter the original ECG signal has T wave inversion or T wave depression, after the characteristic wave enhancement, the P wave and T wave of the ECG signal are significantly enhanced.
[0108] After the ECG signal is enhanced, the raw data is segmented into individual heartbeat intervals to fit the FS-Net model. Each heartbeat is mainly composed of P wave, QRS complex and T wave, and the rest is non-band. The division of the heartbeat is based on the midpoint between the end of the T wave of the current heartbeat and the beginning of the P wave of the next heartbeat (about 58% of the RR interval) as a statistical reference. After segmentation, the data is uniformly adjusted to a length of 500 sampling points, and the original length is recorded for final calculation.
[0109] S4. Model construction: Construct a FS-Net model for segmenting ECG signal feature waves.
[0110] like Figure 7 As shown, the FS-Net model for segmenting the characteristic waves of the ECG signal in the present invention includes an encoder and a decoder to achieve the segmentation of the characteristic waves of the ECG signal.
[0111] FS-Net encoder, taking into account the temporal correlation of ECG signals, the reciprocating contraction of the atria and ventricles forms the periodicity of P waves, QRS waves and T waves. Therefore, the encoder of the present invention mainly adopts the self-attention module to learn the dependencies between the characteristic waves. Before sending to the encoder, in order to make the self-attention module more effectively learn the potential information in the ECG signal, the present invention expands the feature dimension of the characteristic wave through the convolution module.
[0112] As shown in Table 1, the model input first passes through a three-layer convolutional neural network to expand the dimension to 64. The 64-dimensional feature channel has enough semantic information of the ECG signal. The self-attention mechanism is used to enable the network to learn the correlation between the previous and next information on the ECG, so that the network has the ability to observe the whole situation and fully learn the information of the time points before and after the P wave, QRS wave, and T wave of the ECG signal.
[0113] The input signal first passes through three modules consisting of a convolutional layer and a first normalization layer in sequence, and then enters eight standard self-attention modules in sequence. The input of the self-attention module is divided into two paths, one path passes through the multi-head attention network to the first superposition layer, and the other path goes directly to the first superposition layer. After addition in the superposition layer, it passes through the second normalization layer. The output of the second normalization layer is divided into two paths, one path passes through the feedforward layer to the second superposition layer, and the other path goes directly to the second superposition layer. After addition in the second superposition layer, it enters the third normalization layer. The outputs of the third normalization layer in the first, second, third, fourth, fifth, sixth and seventh self-attention modules all go to the next layer of self-attention modules, and the output of the third normalization layer in the eighth self-attention module goes to the encoder.
[0114] The expanded data is fed into an eight-layer standard self-attention module, and position encoding information is added to the first layer in order for the network to better learn the sequence of the data. The number of heads used in the self-attention module is 4, and then the nonlinear mapping of features is performed through the feedforward network to enhance the modeling ability of the model. To prevent overfitting, the connection is randomly disconnected, and the coefficient is 0.1.
[0115] The input of the encoder passes through 3 modules consisting of convolutional layers and normalization layers in sequence, and then enters 8 modules consisting of multi-head attention layers, Add layers, normalization layers, feedforward layers, Add layers and normalization layers in sequence, and is output to the decoder.
[0116] The signal encoded by the encoder still contains timing information in the FS-Net decoder, and is decoded using a timing decoder. The first four layers use a bidirectional long short-term memory module for dimensionality reduction, and the last two layers use a time-distributed fully connected mapping network to complete the decoding and realize the calibration of the start and end points of the characteristic wave.
[0117] The input of the decoder passes through four modules consisting of a bidirectional long short-term memory network and Dropout in sequence, and then passes through two time-distributed fully connected mapping networks, and finally enters the Softmax layer and outputs. The time-distributed fully connected mapping network includes a time distribution network and a feedforward layer.
[0118] The decoder is responsible for the characteristic wave segmentation of the ECG signal. It first reduces the dimension of the result encoded by the self-attention module in the characteristic channel. The encoding result contains time series information, so a bidirectional long short-term memory network (Bi-LSTM) is used for feature decoding, and the four-layer Bi-LSTM is used to reduce the dimension to 16.
[0119] After Bi-LSTM decoding, the dimension is reduced to 16, and further reduced to 2 to mark the presence or absence of characteristic waves.
[0120] like Figure 8As shown in the figure, the fully connected mapping network based on time distribution performs the final decoding. The specific decoding method is as follows: Use the fully connected network to process the features at each moment, that is, apply the fully connected network to each time step of the sequence. The time length of the signal is m, and the feature length of each time point is n. After the fully connected mapping of the time step, the time length is still m, but the feature length of each time point becomes n′. Among them, n′ is less than n. Parameters are shared between each time step, and the decoding process uses a two-layer network with dimensions of 64 and 2 respectively. Finally, the output layer applies the softmax function to complete the decoding.
[0121] Table 1: Network model parameter description
[0122] Layers Type Number of neurons output Quantity 1 Conv1DPack (batch,500,64) 3 2 Encoder (batch,500,64) 8 3 BiLSTM (batch,500,32) 4 4 TimeDistrubute (batch,500,2) 2
[0123] Considering that ECG signals are time series signals and their characteristic waves have periodic changes, a neural network structure that is sensitive to time series is selected. The encoder mainly uses a time-based self-attention network, while the decoder combines a long short-term memory network (LSTM) with a time series description module, so that the model can effectively capture the temporal dependencies between characteristic waves.
[0124] S5. Model training: The ECG signal processed by steps S1-S3 is input into the FS-Net model for training to achieve segmentation of the P wave, QRS wave, and T wave in the ECG signal.
[0125] The ECG signal processed by steps S1-S4 is input into the constructed FS-Net model for training. The present invention uses focal loss as a loss function to make the edge information that is difficult to segment have a better accuracy. The formula is expressed as follows.
[0126]
[0127] When training a neural network, we hope to achieve rapid convergence of the network in the early stage. The learning rate is 0.001 at the beginning of training. When the accuracy rate exceeds 90%, the learning rate is reduced to 0.00005 until the accuracy rate of the training set no longer increases.
[0128] S6. Post-processing algorithm: correct the features with segmentation errors.
[0129] The characteristic wave segmentation model performs characteristic wave segmentation. Under normal circumstances, a heart beat contains three characteristic waves, but diseases may cause misdetection of clutter.
[0130] Use neural network to segment characteristic bands. Under normal circumstances, a heartbeat contains three characteristic bands. However, diseases may cause noise to be mistakenly detected as characteristic waves. In the case of multiple detections, edge error segments and short periods will be removed. In the case of missing characteristic waves, the missing P wave or T wave needs to be supplemented according to the position of the R wave.
[0131] In the case of multiple detections, the edges and short-term error bands are removed. In the case of missed detections, the missed P waves or T waves are supplemented according to the R peak position.
[0132] Because each heartbeat has been adjusted to 500 sampling points before the ECG signal is recognized by the FS-Net model, the length of the minimum band is determined to be 4% of the heartbeat length, and all bands calibrated by the FS-Net model are traversed; the Pan-Tompkins algorithm is used to determine the R peak, and the band where the R peak is located is the QRS band, and the index of the QRS band, that is, the time corresponding to the QRS band, is recorded.
[0133] 4% of the heartbeat length is used as the minimum band length, and bands with lengths less than the minimum band length are filtered out.
[0134] Traverse the band containing the R wave again, that is, the QRS band, and record its index.
[0135] When the number of heartbeat bands is 3 and the R wave is in the middle band, retain the three bands; when the number of bands is 3 and the R wave is in the first band, merge the T band, that is, the start time of the second wave is used as the start time of the T band, and the end time of the third band is used as the end time of the T wave; when the number of bands is 3 and the R wave is in the third band, merge the P band, that is, the start time of the first wave is used as the start time of the P band, and the end time of the second band is used as the end time of the P band.
[0136] When the number of heartbeat bands is greater than 3, the bands on the left of the R wave are merged into the P band, and the rightmost band of the R wave is merged into the T band.
[0137] When the number of heartbeat bands is less than 2, the missed bands are supplemented, and the missed bands are determined based on the position of the R wave. Based on all the detected heartbeat bands, the distance between the P wave and the R wave is calculated, and the average value of the distance between the P wave and the R wave in all heartbeats is used as the reference value of the distance between the P wave and the R wave, and the distance between the T wave and the R wave is calculated, and the average value of the distance between the T wave and the R wave in all heartbeats is used as the reference value of the distance between the T wave and the R wave.
[0138] When there is no band on the left side of the R wave, the P wave band is supplemented according to the reference value of the distance between the P wave and the R wave; when there is no band on the right side of the R wave, the T wave band is supplemented according to the reference value of the distance between the T wave and the R wave.
[0139] Since the individual conditions of the measured ECG signals are different, the reference value of the distance between the P wave and the R wave is determined based on the distance between the P wave and the R wave in all the heartbeats of the individual, and the reference value of the distance between the T wave and the R wave is determined based on the distance between the T wave and the R wave in all the heartbeats of the individual. The supplemented P wave and T wave are more accurate.
[0140] S7. ECG signal segmentation: Use the trained FS-Net model to segment the characteristic waves of the measured ECG signal.
[0141] For the measured ECG signal, it also needs to be processed through steps S1-S3 before segmentation using the FS-Net model, and then processed through step S6 after segmentation.
[0142] S8. Model evaluation: The LUDB feature bands are segmented using the modified FS-Net model under different tolerances, and the modified FS-Net model is evaluated based on the segmentation results.
[0143] The characteristic wave segmentation evaluation indicators are the segmentation accuracy of the characteristic band, and the mean and variance of the comparison error between the predicted characteristic wave start and end points and the label. The mean reflects the average deviation of the model's prediction, and the variance reflects the stability of the model.
[0144] Table 2: LUDB feature band segmentation performance
[0145]
[0146] LUDB contains standard 12-lead ECG signals of 200 subjects, each signal lasting 10 seconds and with a sampling frequency of 500Hz. These signals were manually annotated by cardiologists, and the present invention used all the data of 183 of them, containing a total of 14,480 heartbeats. The other 17 people suffered from atrial fibrillation or unannotated P waves. The P waves disappeared in the ECG of patients with atrial fibrillation and can be diagnosed by heart rate. The present invention focuses on the detection of the full waveform of the characteristic wave, so the data of these 17 people are not used.
[0147] As shown in Table 2, the characteristic wave segmentation results under tolerances of 40ms, 70ms and 150ms are shown. When the model is trained jointly using the original ECG signal and the ECG signal processed by steps S1-S3, the model effect is better. Under the standard tolerance of 150 milliseconds of the algorithm proposed in the present invention, the detection results of the start and end points of each band in LUDB obtained a sensitivity close to 100%, and when the model training simultaneously inputs the original signal and the enhanced signal, the electrical signal characteristic wave segmentation model of the present invention can capture more effective information, and the mean and variance of the characteristic wave detection error are better controlled. The electrical signal characteristic wave segmentation model of the present invention shows excellent stability.
[0148] By comparing the present invention with other solutions, the ECG signal segmentation effect of the present invention is evaluated.
[0149] Table 3: Comparison of the results of the present invention and other solutions
[0150]
[0151] As shown in Table 3, the present invention is compared with other schemes on the LUDB dataset and the QTDB dataset. Based on the results of LUDB, the deep learning-based methods tend to produce better performance under the tolerance of 150ms. Wang et al. used a residual network to synchronously analyze the structure and position of the wave, and achieved a sensitivity of 100% for the prominent QRS complex, but noticed that the detection performance of the smaller amplitude P wave decreased. Wang et al., Sereda and Chen et al. used a method based on the U-Net network to capture finer details and increased the P wave detection rate by 2% to 99.5%. However, since the ECG signal is a time series signal, it is crucial to understand the time relationship. These methods use LSTM networks. The IT-Net of the present invention also uses time series modeling, enhances the feature representation of PT waves through filtering, improves the understanding of time series logic by using an attention mechanism, and prevents time series overlap by using a time distribution layer, thereby showing excellent performance in terms of the mean and variance of the start and end point errors. Compared with the scheme of Chen et al., the present invention reduces the average error by 2 milliseconds and the variance by 5 milliseconds, further improving the stability.
[0152] As can be seen from Table 3, the detection sensitivity of the two data sets for P waves and QRS waves is similar, both exceeding 99%, but the segmentation error of LUDB is smaller than that of QTDB. The test results of the QTDB data set show that the line drawing errors of the deep learning methods of Jimenez, Peimankar and Chen are generally higher than the digital processing methods of Martinez, Bote and Kalyakulina. Compared with the digital processing method, the variance of the present invention in P waves and QRS complexes is about 5 milliseconds, and the variance in T waves is about 20 milliseconds. The LUDB data set annotated by experts contains 14480 heartbeats, which is about five times the 2845 heartbeats of the QTDB data set. The digital processing method for feature extraction can more effectively capture the threshold information of the onset and offset of the feature wave, so the digital processing method performs better on the QTDB data set. On this data set, the present invention, like other deep learning methods, has a sensitivity of more than 99% for P waves and QRS complexes. Due to the small amount of QTDB data, the generalization ability is poor. Therefore, the present invention uses LUDB for pre-training and achieves better results.
[0153] The main reason why deep learning models do not perform as well on QTDB as LUDB is the quality and quantity of annotation information. Deep learning models rely on data-driven training. The presence of abnormal annotations, inaccurate or inconsistent labels in the QTDB database will seriously affect the performance of deep learning models. For example, the lack of starting point markers in some T wave signals is an abnormal annotation that affects the convergence direction of the IT-Net model and becomes a key factor in the model's inability to effectively identify T waves. In addition, the QTDB dataset only provides information on two random leads, resulting in data imbalance. This imbalance may cause the model to favor common characteristic wave types during learning and prediction. Although most deep learning methods do not perform as well as digital processing methods on QTDB, they usually obtain more accurate results when trained with LUDB because LUDB has more accurate annotations and a larger amount of data, especially when the lead information is fixed. Later, the model trained with the LUDB dataset was trained on the QTDB dataset, which also achieved good results.
[0154] S9. Visualization of model characteristic wave feature extraction.
[0155] like Fig. 9 As shown, the CAM method is used to show the gradient visualization information of the characteristic wave changes of four different attributes of the model proposed in the present invention, corresponding to inverted P wave, inverted T wave, towering T wave, and overall abnormal waveform. These visualizations show that the focus of the model is still on the characteristic band. Thanks to the correction and enhancement of the data by the filter proposed in the present invention, the model shows the same degree of attention to different types of heart diseases. Through the visualized colors, it can be observed that the peaks of the P wave, QRS wave, and T wave are all red, indicating that these areas have similar degrees of activation. This shows that the model maintains the same segmentation accuracy when dealing with different diseases.
Claims
1. A method for segmenting characteristic waves of an electrocardiogram signal, characterized in that: The steps include: S1. ECG signal denoising: Use the median filter algorithm to correct the baseline drift of the ECG signal, and use the third-order Butterworth low-pass filter to eliminate the high-frequency noise in the ECG signal; S2. Normalization of ECG signal peak value: Use the Pan-Tompkins algorithm to calibrate the R peak information of the denoised ECG signal, calculate the RR interval information, then use the sliding window to select data and normalize the data in the sliding window; S3. ECG signal waveform correction and feature enhancement: firstly, the normalized ECG signal is smoothed, then the QRS wave, P wave and T wave of the ECG signal are corrected, and finally the P wave and T wave in the corrected ECG signal are feature enhanced; S4. Model construction: Construct the FS-Net model for segmenting the characteristic waves of ECG signals; S5. Model training: input the ECG signal processed by steps S1-S3 into the FS-Net model for training to segment the P wave, QRS wave, and T wave in the ECG signal; S6 post-processing algorithm: correct the features of segmentation errors; S7. ECG signal segmentation: Use the trained FS-Net model to segment the characteristic waves of the measured ECG signal.
2. The method for segmenting characteristic waves of an electrocardiogram signal according to claim 1, characterized in that: The low-pass cutoff frequency of the third-order Butterworth low-pass filter in step S1 is 0.5 Hz.
3. The method for segmenting characteristic waves of an electrocardiogram signal according to claim 1, characterized in that: The size of the sliding window in step S2 is 1.1 times the RR interval of the 5 s ECG data near the current sampling point.
4. The method for segmenting characteristic waves of an electrocardiogram signal according to claim 1, characterized in that: The normalization formula is: Among them, ECG nomalized Represents the ECG signal of a period of time, time1 is the start time of each sampling of the sliding window, time2 is the end time of each sampling of the sliding window, max is the maximum amplitude of the ECG signal in the sliding window, and abs is the absolute value of the corresponding amplitude of the ECG signal from time1 to time2.
5. The method for segmenting characteristic waves of an electrocardiogram signal according to claim 1, characterized in that: The specific method of smoothing the ECG signal in step S3 is: A sliding window with a length of 60ms slides on the ECG signal at a speed of 1 sampling point, and the standard deviation of the data in each window is calculated. The points greater than the set threshold are taken as characteristic waves, and the amplitude of the ECG signal less than the threshold is taken as 0 to obtain the corrected ECG signal. The value of the set threshold is 1.2% of the maximum value of the standard deviation; The calculation formula for smoothing is: Among them, ECG std Indicates the standard deviation of the ECG signal. amend (t) represents the corrected ECG signal, std (t) is the standard deviation of the sliding window at time t, max(ECG std ) is the maximum standard deviation of the sliding window at all times.
6. The method for segmenting characteristic waves of an electrocardiogram signal according to claim 1, characterized in that: The specific method of correcting the QRS wave of the ECG signal in step S3 is: S3a-1. Take the absolute value of the amplitude of the ECG signal, and use the Pan-Tompkins algorithm to determine the QRS wave peak point of the ECG signal after taking the absolute value; S3a-2. If the original amplitude corresponding to the QRS wave peak point is a positive value, it remains unchanged; if the original amplitude corresponding to the peak point is a negative value, the original amplitude of the peak point is saved as its opposite.
7. The method for segmenting characteristic waves of an electrocardiogram signal according to claim 1, characterized in that: The specific method of correcting the P wave and T wave in step S3 is: S3b-1. Locate the T wave position and the P wave position respectively, and calculate the mean of the T wave amplitude and the P wave amplitude respectively; S3b-2. When the mean value of the T wave amplitude is a negative number, the T wave is an inverted T wave; when the mean value of the P wave amplitude is a negative number, the P wave is an inverted P wave; S3b-3. Count the two zero-crossing positions of the T wave, and determine the inverted T wave according to the amplitude and vibration direction of the T wave; count the two zero-crossing positions of the P wave, and determine the inverted P wave according to the amplitude and vibration direction of the P wave; if there is no zero-crossing position, use the statistical information to determine the inverted T wave and the inverted P wave respectively; S3b-4. Take the absolute values of the amplitudes of the inverted T wave and the inverted P wave respectively.
8. The method for segmenting characteristic waves of an electrocardiogram signal according to claim 1, characterized in that: The specific method of enhancing the features of the P wave and the T wave in step S3 is: S3c-1. Shift the corrected ECG signal upward by 1mV, so that the baseline of the ECG signal is 1mV; S3c-2. Perform the initial transformation on the up-shifted ECG signal according to the logarithmic function. The transformation formula is: Among them, ECG log (t) is the amplitude of the corresponding ECG signal after the initial transformation at time t; S3c-3. Enhance the transformed ECG signal. The enhancement formula is: Among them, ECG enhance (t) is the amplitude of the enhanced ECG signal at time t; S3c-4. The enhanced ECG signal is shifted down by 1mV, so that the baseline of the ECG signal is 0mV, and the ECG signal after the shift is processed by Gaussian smoothing algorithm; S3c-5. Use the Pan-Tompkins algorithm to calibrate the R peak information of the enhanced ECG signal after Gaussian smoothing, calculate the RR interval information, then use the sliding window to select data, and normalize the data within the sliding window; S3c-6. Slide a sliding window of 60ms on the ECG signal at a speed of 1 sampling point, calculate the standard deviation of the data in each window, take the points greater than the set threshold as the characteristic wave, and take the amplitude of the ECG signal less than the threshold as 0 to obtain the corrected ECG signal, the set threshold value is 3.5% of the maximum value of the standard deviation; S3c-7. Loop through steps S3c-1-S3c-6 for a total of 6 times, and the final ECG signal obtained is a feature-enhanced ECG signal.
9. The method for segmenting characteristic waves of an electrocardiogram signal according to claim 1, characterized in that: The FS-Net model includes: An encoder, connected to a decoder, for learning dependencies between feature waves; and A decoder, connected to the encoder, for performing characteristic wave segmentation on the ECG signal; The input of the encoder passes through 3 modules consisting of convolutional layers and normalization layers in sequence, then enters 8 modules consisting of a multi-head attention layer, an Add layer, a normalization layer, a feedforward layer, an Add layer, and a normalization layer in sequence, and is output to the decoder; The input of the decoder passes through 4 modules consisting of a bidirectional long short-term memory network and Dropout, and then passes through 2 time-distributed fully connected mapping networks, and finally enters the Softmax layer and outputs. The time-distributed fully connected mapping network includes a time distribution network and a feedforward layer.
10. A FS-Net model for segmenting characteristic waves of electrocardiogram signals, characterized in that: include: The encoder, connected to the decoder, is used to learn the dependencies between feature waves; as well as A decoder, connected to the encoder, for performing characteristic wave segmentation on the ECG signal; The input of the encoder passes through 3 modules consisting of convolutional layers and normalization layers in sequence, then enters 8 modules consisting of a multi-head attention layer, an Add layer, a normalization layer, a feedforward layer, an Add layer, and a normalization layer in sequence, and is output to the decoder; The input of the decoder passes through 4 modules consisting of a bidirectional long short-term memory network and Dropout, and then passes through 2 time-distributed fully connected mapping networks, and finally enters the Softmax layer and outputs. The time-distributed fully connected mapping network includes a time distribution network and a feedforward layer.
Citation Information
Patent Citations
Cardioelectric characteristic extracting process based on evolutive wavelet wiener deconvolution
CN101088456A
Retrieval method of electrocardiogram signal
CN110169767A
Electrocardiosignal R wave detection method based on improved U-Net
CN111481192A
Atrial fibrillation event detection method based on deep learning
CN111803062A
Heart attack classification
CN117396980A
Cited By
R peak detection method and system suitable for electrocardiogram monitoring
CN120694657A
A method and system for R-peak detection suitable for electrocardiogram monitoring
CN120694657B
Electrocardio gating scanning control method and system based on multi-model fusion algorithm
CN121667735A
