Electrocardiosignal correction method and device, computer equipment and storage medium
Through vector synthesis and machine learning models, the electrode offset classification and correction of the ECG signals in the palm electrocardiogram acquisition device is solved, and the acquisition efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202510535022.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-04-27
AI Technical Summary
During the electrocardiogram signal acquisition process, the accuracy of the electrode position is difficult to ensure, resulting in distortion of the electrocardiogram signal and affecting the diagnostic results.
By extracting the R-peak amplitude of each lead of the ECG signal, a vector representing each lead is generated, and the average electrical axial vector and angle are obtained using vector synthesis. The electrode offset situation is classified in combination with machine learning models (such as random forest, decision tree and XGBoost), and the correction model is used to correct the ECG signal.
The direct correction of the ECG signal is achieved, the efficiency of the ECG signal is improved, and the use needs of non-medical professionals are met without the need for additional equipment or manual correction of the electrode position.
Smart Images

Figure CN120052912A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electrocardiogram detection, and in particular, to a method and device for correcting electrocardiogram signals, a computer device, and a storage medium. Background Art
[0002] A palm-type electrocardiogram acquisition device is a small and portable electrocardiogram monitoring tool suitable for non-medical professionals. Compared with traditional electrocardiogram acquisition devices that require large equipment and professional operations, the palm-type electrocardiogram acquisition device has the advantages of small size, easy portability, and strong real-time performance. It can collect and analyze electrocardiograms at any time in various scenarios such as at home, in the office, and outdoors, and is widely used in fields such as daily health monitoring, telemedicine, and cardiovascular disease prevention.
[0003] However, the convenience of the palm-type electrocardiogram acquisition device also brings problems with the accuracy of electrode placement. During the electrocardiogram (ECG) signal acquisition process, the accuracy of electrode placement has an important impact on the quality of electrocardiogram signals and the diagnostic results. Especially in portable electrocardiogram acquisition devices, due to the small size of the device and the non-professional medical staff as users, it is easy to cause deviation in the placement position. A small deviation in the electrode position often leads to distortion of the collected electrocardiogram signals, thereby affecting the quality of electrocardiogram signals and further affecting the accuracy of clinical diagnosis. By calculating the deviation between lead signals, the deviation of the electrode position can be judged, but it is still necessary to manually judge the deviation situation according to the deviation calculation result and correct the electrode position, and re-collect the electrocardiogram signal with the correct electrode position. The electrocardiogram waveform cannot be directly corrected according to the deviation situation, resulting in low acquisition efficiency. Summary of the Invention
[0004] Embodiments of the present invention provide a method and device for correcting electrocardiogram signals, a computer device, and a storage medium to solve the technical problem that the corrected waveform cannot be directly output for electrocardiogram signals.
[0005] In a first aspect, embodiments of the present invention provide a method for correcting electrocardiogram signals, including: Preprocessing the acquired electrocardiogram signal to obtain a preprocessed electrocardiogram signal; Performing QRS wave positioning on the preprocessed electrocardiogram signal to obtain the R peak amplitude of lead I, the R peak amplitude of lead II, and the R peak amplitude of lead III, and calculating the ratio of the R peak amplitudes of lead I and lead III; According to the R peak amplitude of lead I, the R peak amplitude of lead II, and the R peak amplitude of lead III, obtaining an average electrical axis vector by vector synthesis and calculating the average electrical axis angle; Using the trained random forest model, decision tree model, and XGBoost model, based on the mean electrical axis angle, R peak amplitude in lead I, R peak amplitude in lead II, R peak amplitude in lead III, and the ratio of R peak amplitudes in lead I to lead III, the electrode offset conditions of the preprocessed electrocardiogram (ECG) signals are discriminated respectively to obtain the first electrode offset type, the second electrode offset type, and the third electrode offset type. Voting method ensemble learning is performed based on all electrode offset types to obtain the electrode offset label; According to the electrode offset label, the preprocessed ECG signal is corrected using the trained correction model based on multi-head attention and gated recurrent units. The correction model first performs weight allocation on the ECG signal in matrix form using the multi-head attention mechanism, and then uses the gated recurrent unit for temporal modeling to generate the corrected ECG signal.
[0006] Furthermore, the step of correcting the preprocessed ECG signal using the trained correction model based on multi-head attention and gated recurrent units according to the electrode offset label includes: According to the electrode offset label, the electrode offset correction parameters corresponding to the electrode offset label are called and loaded into the correction model; The preprocessed ECG signal is input into the correction model, and the correction model outputs the corrected ECG signal.
[0007] Furthermore, the step of inputting the preprocessed ECG signal into the correction model and the correction model outputting the corrected ECG signal includes: The preprocessed ECG signal is converted into matrix form to generate an ECG waveform matrix; Using the multi-head attention mechanism, weight allocation is performed on the ECG waveform matrix to generate an attention ECG waveform matrix; Using the gated recurrent unit, temporal modeling is performed according to the attention ECG waveform matrix to generate a corrected ECG waveform matrix; The corrected ECG waveform matrix is converted into an ECG waveform to generate the corrected ECG signal.
[0008] Furthermore, the step of obtaining the mean electrical axis vector by vector synthesis based on the R peak amplitudes in lead I, lead II, and lead III and calculating the mean electrical axis angle includes: Using Einthoven's triangle rule and Bailey's hexaxial system, the lead I vector, lead II vector, and lead III vector are determined according to the R peak amplitudes in lead I, lead II, and lead III; Vector synthesis is performed using the lead I vector, lead II vector, and lead III vector to generate the mean electrical axis vector; According to the coordinates of the mean electrical axis vector, the mean electrical axis angle is calculated.
[0009] Further, the determining of the vector of Lead I, the vector of Lead II, and the vector of Lead III according to the R peak amplitude of Lead I, the R peak amplitude of Lead II, and the R peak amplitude of Lead III by using Einthoven's triangle law and Bell's six-axis system includes: Determining the angle of Lead I, the angle of Lead II, and the angle of Lead III by using Einthoven's triangle law and Bell's six-axis system; Determining the vector of Lead I according to the angle of Lead I and the R peak amplitude of Lead I, determining the vector of Lead II according to the angle of Lead II and the R peak amplitude of Lead II, and determining the vector of Lead III according to the angle of Lead III and the R peak amplitude of Lead III.
[0010] Further, the preprocessing of the acquired electrocardiogram (ECG) signal to obtain a preprocessed ECG signal includes: Performing denoising processing on the acquired ECG signal by using a band-pass filter and wavelet transform; Performing baseline drift elimination on the acquired ECG signal by using a high-pass filter.
[0011] Further, the wavelet transform uses Daubechies4 as the wavelet basis function and performs four-layer wavelet decomposition.
[0012] In a second aspect, an embodiment of the present invention provides an ECG signal correction device, including: An ECG signal processing module, configured to preprocess the acquired ECG signal; A QRS wave positioning module, configured to perform QRS wave positioning on the preprocessed ECG signal; A vector synthesis module, configured to perform vector synthesis and calculate the mean electrical axis angle; An electrode offset classification module, configured to discriminate the type of electrode offset and generate an electrode offset label; An ECG signal correction module, configured to correct the ECG signal by using the trained correction model according to the electrode offset label.
[0013] In a third aspect, an embodiment of the present invention provides a computer device, including: One or more processors; A storage device, configured to store one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned ECG signal correction method.
[0014] In a fourth aspect, an embodiment of the present invention provides a storage medium containing computer-executable instructions, and the computer-executable instructions are used to execute the above-mentioned ECG signal correction method when executed by a computer processor.
[0015] An electrocardiogram (ECG) signal correction method, device, computer device, and storage medium provided by an embodiment of the present invention. The method extracts the R-peak amplitudes of each lead of the ECG signal to generate vectors representing each lead, uses vector synthesis to obtain the mean electrical axis vector and mean electrical axis angle indicating the intensity and directionality of cardiac electrical activity, uses the mean electrical axis angle, the R-peak amplitude of each lead, and the amplitude ratio of lead I to lead III, and performs integrated voting using decision tree models, random forest models, and XGBoost models to classify the electrode offset situation and output an electrode offset label. According to the electrode offset label, the corresponding correction parameters are called to load the trained correction model to correct the ECG signal and obtain the corrected ECG waveform. It is possible to directly identify the electrode offset situation based on the collected ECG waveform, then correct the ECG waveform according to the offset situation, and directly output the corrected ECG signal without using additional equipment to analyze the electrode offset situation, nor manually correcting the electrode placement position and re-collecting it twice. The corrected ECG signal can be directly generated, greatly improving the acquisition efficiency of the ECG signal and meeting the usage requirements of non-medical professionals. Description of the Drawings
[0016] The drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 It is a flowchart of an electrocardiogram (ECG) signal correction method according to Embodiment 1 of the present invention; Figure 2 It is a flowchart of an electrocardiogram (ECG) signal correction method according to Embodiment 2 of the present invention; Figure 3 It is a flowchart of an electrocardiogram (ECG) signal correction method according to Embodiment 3 of the present invention; Figure 4 It is a schematic diagram of the mean electrical axis angle and each type of electrode offset type according to Embodiment 3 of the present invention; Figure 5 It is a schematic diagram of mean electrical axis vector synthesis according to Einthoven's triangle rule and Bailey's hexaxial system according to Embodiment 3 of the present invention; Figure 6 It is a structural schematic diagram of an electrocardiogram (ECG) signal correction device according to Embodiment 4 of the present invention; Figure 7 It is a structural diagram of a computer device according to Embodiment 5 of the present invention. Detailed Embodiments
[0017] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. In addition, it should be noted that for the convenience of description, only the parts related to the present invention rather than all the structures are shown in the drawings.
[0018] When collecting electrocardiogram (ECG) signals using a portable ECG acquisition device, for example, using a palm-type ECG monitor to detect the ECG, the electrodes need to be attached to the corresponding positions on the human body, including the left upper limb, right lower limb, left lower limb and other parts. Due to the portability of the palm-type ECG device, many household users, chronic patients, etc., due to their own needs, often choose to attach the electrodes by themselves to collect ECG signals for detecting their own ECG conditions. However, such operations by non-medical professionals often result in the electrodes not being placed in the correct positions, resulting in deviations in the collected ECG signals and affecting the judgment of the ECG results. And correcting the ECG signals often requires professional personnel, professional equipment, etc. By judging the deviation of the electrodes, the placement positions of the electrodes are corrected, and correct ECG signals are collected again. This not only has a low collection efficiency, but also the means are relatively complex, and it is often impossible to complete the correction of the ECG signals under the operating conditions of non-medical professionals such as household users and chronic patients for daily health monitoring.
[0019] Embodiment 1
[0020] Figure 1 It is a flowchart of a method for correcting ECG signals according to Embodiment 1 of the present invention. In this embodiment, the deviation of the electrodes is judged and the corresponding calculation model is called to correct the ECG waveform. The specific steps are as follows:
[0021] S101, preprocess the acquired ECG signal to obtain a preprocessed ECG signal.
[0022] During the ECG acquisition process, there are often interference situations such as noise. It is necessary to preprocess the acquired ECG signal by means of denoising, baseline drift elimination, etc. to reduce the irrelevant and interfering content in the ECG signal and eliminate the deviation effects caused by breathing or poor electrode contact, etc. In this embodiment, taking a palm-type ECG acquisition device using a twelve-lead acquisition method as an example, the ECG signals of Lead I, Lead II and Lead III are respectively collected for subsequent processing.
[0023] S102, locate the QRS wave of the preprocessed ECG signal to obtain the R peak amplitude of Lead I, the R peak amplitude of Lead II and the R peak amplitude of Lead III, and calculate the R peak amplitude ratio of Lead I to Lead III.
[0024] By QRS wave localization, the R peak amplitude of each lead is determined respectively. The R peak amplitude is an important feature reflecting the intensity of cardiac electrical activity and can be used to evaluate the electrophysiological state of the heart and the accuracy of electrode positions. The R wave and QRS complex of the electrocardiogram signal can be detected by using the alternate difference and double-threshold methods to determine the R peak amplitude of each lead. Exemplarily, Findpeaks is used for R peak localization, and the localization position of the R peak is corrected by searching 10 points forward and backward; according to the R peak position, the lowest point is searched forward to determine the Q wave position, and the lowest point is searched backward to determine the S wave position. The R peak amplitude of lead I and the R peak amplitude of lead III are compared and calculated to obtain the R peak amplitude ratio of lead I to lead III. The directional distribution of cardiac electrical activity and electrode positions is evaluated by the ratio of the R peak amplitudes of the two leads.
[0025] S103. According to the R peak amplitude of lead I, the R peak amplitude of lead II, and the R peak amplitude of lead III, the mean electrical axis vector is obtained by vector synthesis, and the mean electrical axis angle is calculated.
[0026] Since each lead can reflect the cardiac electrical activity of the human heart in a certain direction, the R peak amplitudes of the three leads can be used to generate vectors corresponding to the directions of the leads respectively, and the vectors of the three leads are vectorially superimposed and synthesized. Finally, a mean electrical axis vector that can indicate the directionality of the cardiac electrical activity of the human body under the current acquisition conditions and is used to analyze the offset of the electrode position is determined. Exemplarily, the Einthoven triangle rule and the Bailey hexaxial system can be used to determine the directions of the three leads respectively, and then the R peak amplitudes of each lead are used to determine the vectors representing the three leads respectively, and vector synthesis is performed to generate a mean electrical axis vector. According to the coordinates of the mean electrical axis vector, the mean electrical axis angle is calculated, which can reflect the overall electrical activity direction of the heart and can be used to evaluate whether the electrode has shifted.
[0027] S104. Using the trained random forest model, decision tree model, and XGBoost model, according to the mean electrical axis angle, the R peak amplitude of lead I, the R peak amplitude of lead II, the R peak amplitude of lead III, and the R peak amplitude ratio of lead I to lead III, the electrode offset conditions of the preprocessed electrocardiogram signal are discriminated respectively to obtain the first electrode offset type, the second electrode offset type, and the third electrode offset type. Voting method ensemble learning is performed according to all electrode offset types to obtain the electrode offset label.
[0028] Select the mean electrical axis angle, the R peak amplitude of lead I, the R peak amplitude of lead II, the R peak amplitude of lead III, and the ratio of the R peak amplitudes of lead I to lead III as five input features, and use a classification model to classify the electrode offset situation. The mean electrical axis angle can reflect the overall electrical activity direction of the heart. The R peak amplitudes of lead I, lead II, and lead III can respectively reflect the electrical activity intensity of the heart in the corresponding directions of each lead. The ratio of the R peak amplitudes of lead I to lead III can reflect the directional distribution of the heart's electrical activity and the electrode position. Using the trained random forest model, decision tree model, and XGBoost model, input the above five features into each model respectively, and use the model to classify the electrode offset situation. The classification results include seven electrode position situations, including normal, upward deviation, downward deviation, left deviation, right deviation, counterclockwise rotation, and clockwise rotation. Among them, the random forest model outputs the first electrode offset type, the decision tree model outputs the second electrode offset type, and the XGBoost model outputs the third electrode offset type. Then, use the first electrode offset type, the second electrode offset type, and the third electrode offset type for voting-based ensemble learning. According to the classification results of the three models, finally obtain the electrode offset situation and form a label, that is, the electrode offset label. Exemplarily, the correspondence between the electrode offset type and the label is: normal - 0, upward deviation - 1, downward deviation - 2, left deviation - 3, right deviation - 4, counterclockwise rotation - 5, clockwise rotation - 6, where the label 0 indicates that the electrode has no offset, and the labels 1 - 6 respectively represent different offset types. Utilize the characteristics of the decision tree suitable for classification and discrimination tasks, the characteristics of the random forest model that can integrate multiple decision trees to handle complex data, and the characteristics of the XGBoost model with the advantages of the boosting tree model. Integrate and vote on the classification results of the three models. Introduce randomness and diversity through the random forest model and the XGBoost model to make up for the defect that the decision tree model is easily affected by data changes, improve the classification accuracy, robustness, and generalization ability of the model, reduce the overfitting risk, and reduce the instability that may be brought by a single model.
[0029] S105, according to the electrode offset label, use the trained correction model based on multi-head attention and gated recurrent unit to correct the preprocessed electrocardiogram signal. The correction model first assigns weights to the electrocardiogram signal in matrix form using the multi-head attention mechanism, and then uses the gated recurrent unit for temporal modeling to generate the corrected electrocardiogram signal.
[0030] The electrode offset label can indicate the type of electrode offset of the currently preprocessed electrocardiogram (ECG) signal. According to the electrode offset label, the corresponding correction parameters can be called and loaded into the trained correction model to form a correction model corresponding to the electrode offset type. The correction model first converts the ECG waveform into a matrix form, uses the multi-head attention mechanism for weight allocation, identifies important partial waveforms and weights them, and then uses the gated recurrent unit to model according to the time sequence to generate a corrected matrix. Converting the corrected matrix into an ECG waveform can obtain the corrected ECG signal. It should be noted that during the training process of the correction model based on multi-head attention and gated recurrent units, ECG waveforms with different deviation types and normal non-deviated ECG waveforms are used to train the correction model. The model parameters for correction of different deviation types are obtained through training respectively. Then, during correction, according to the electrode offset label, the model parameters corresponding to the electrode offset type can be selected to correct the ECG waveform, rather than using the same model parameters to correct all offset type ECG waveforms. Exemplarily, the trained model parameters mainly include the weight matrix of the multi-head attention mechanism and the weight matrix of the gated recurrent unit. Through different weight parameters, ECG signal correction can be performed for different electrode offset types.
[0031] In this embodiment, the R peak amplitude of each lead of the ECG signal is extracted to generate a vector representing each lead. The average electrical axis vector and the average electrical axis angle indicating the intensity and directionality of cardiac electrical activity are obtained by vector synthesis. Using the average electrical axis angle, the R peak amplitude of each lead, and the amplitude ratio of the first lead to the third lead, the decision tree model, the random forest model, and the XGBoost model are used for integrated voting to classify the electrode offset situation and output the electrode offset label. According to the electrode offset label, the corresponding correction parameters are called to load the trained correction model to correct the ECG signal and obtain the corrected ECG waveform. The electrode offset situation of the ECG can be directly identified based on the collected ECG waveform, and then the ECG waveform can be corrected according to the offset situation, and the corrected ECG signal can be directly output. There is no need to use additional equipment to analyze the electrode offset situation, nor to manually correct the electrode placement position and re-collect it twice. The corrected ECG signal can be directly generated, greatly improving the acquisition efficiency of the ECG signal and meeting the usage requirements of non-medical professionals.
[0032] Embodiment 2
[0033] Figure 2 It is a flowchart of a method for correcting an electrocardiogram (ECG) signal according to Embodiment 2 of the present invention. This embodiment is optimized based on the above embodiment. In this embodiment, according to the electrode offset label, the preprocessed ECG signal is corrected by using the trained correction model based on multi-head attention and gated recurrent units. The specific optimization is as follows: According to the electrode offset label, call the electrode offset correction parameters corresponding to the electrode offset label and load them into the correction model; Input the preprocessed electrocardiogram (ECG) signal into the correction model, and the correction model outputs the corrected ECG signal.
[0034] Correspondingly, the ECG signal correction method provided in this embodiment specifically includes:
[0035] S201. Preprocess the obtained ECG signal to obtain the preprocessed ECG signal.
[0036] S202. Locate the QRS wave of the preprocessed ECG signal to obtain the R peak amplitude of lead I, the R peak amplitude of lead II, and the R peak amplitude of lead III, and calculate the ratio of the R peak amplitude of lead I to the R peak amplitude of lead III.
[0037] S203. According to the R peak amplitude of lead I, the R peak amplitude of lead II, and the R peak amplitude of lead III, obtain the mean electrical axis vector through vector synthesis and calculate the mean electrical axis angle.
[0038] S204. Use the trained random forest model, decision tree model, and XGBoost model to respectively discriminate the electrode offset situation of the preprocessed ECG signal according to the mean electrical axis angle, the R peak amplitude of lead I, the R peak amplitude of lead II, the R peak amplitude of lead III, and the ratio of the R peak amplitude of lead I to the R peak amplitude of lead III, to obtain the first electrode offset type, the second electrode offset type, and the third electrode offset type, and perform voting method ensemble learning according to all electrode offset types to obtain the electrode offset label.
[0039] S205. According to the electrode offset label, call the electrode offset correction parameters corresponding to the electrode offset label and load them into the correction model.
[0040] In the training stage of the correction model, use ECG signals of different offset types and ECG signals of normal electrode positions to train the correction model respectively. Corresponding correction parameters can be obtained according to different electrode offset types. According to the electrode offset type, the corresponding correction parameters can be loaded into the correction model to perform corresponding correction on the ECG signal. Exemplarily, the corresponding relationship between the electrode offset type and the label is: normal - 0, upward - 1, downward - 2, left - 3, right - 4, counterclockwise rotation - 5, clockwise rotation - 6. Among them, the label 0 indicates that the electrode has no offset, and the labels 1 - 6 respectively represent different offset types. When the electrode offset label input to the correction model is 0, directly output the original ECG signal by skipping the correction model. When the electrode offset label input to the model is 1, load the correction parameters corresponding to the upward electrode offset type to form a correction model for upward electrode offset, and so on.
[0041] S206, input the preprocessed electrocardiogram (ECG) signal into the correction model, and the correction model outputs the corrected ECG signal.
[0042] Based on the loaded correction parameters, the correction model first assigns weights to the ECG signal converted into matrix form based on the multi-head attention mechanism, and then uses the gated recurrent unit to perform fitting based on time series to correct the ECG waveform with electrode offset and generate the corrected ECG signal. The correction parameters mainly include the weight matrix of the multi-head attention and the weight matrix of the gated recurrent unit, which can be obtained through the training process.
[0043] Specifically, inputting the preprocessed ECG signal into the correction model and the correction model outputting the corrected ECG signal includes: Convert the preprocessed ECG signal into matrix form to generate an ECG waveform matrix; Adopt a fixed-length segmentation method based on R-peak positioning: with each R-peak as the center, intercept 150 sampling points forward and 150 sampling points backward to form a one-dimensional heartbeat segment with a length of 300, and each sample is a one-dimensional vector of 1×300. In this way, complete heartbeat samples with clear structure and stable rhythm can be extracted. Finally, all samples are arranged in chronological order to form an ECG waveform matrix, which is used as the model input for the electrode offset correction task. By converting the preprocessed ECG signal into matrix form to generate an ECG waveform matrix, it is convenient for the subsequent processing of the correction model. Exemplarily, the ECG waveform matrix can be expressed as:
[0044] Among them, represents the ECG waveform matrix, represents the electrode offset label, N represents the number of samples, represents the N th electrocardiogram signal vector with the offset type of
[0045] Use the multi-head attention mechanism to assign weights to the ECG waveform matrix to generate an attention ECG waveform matrix.
[0046] The core of the multi-head attention mechanism is to map the input signal into query (Q, Query), key (K, Key), and value (V, Value). Taking the electrode offset type of upward as an example, the electrode offset label is , for the input data , first perform linear transformation to obtain their Q, K, and V values respectively:
[0047] Among them, , , is the weight matrix obtained through training.
[0048] Calculate the dot product of the query Q and the key K to obtain the attention scores, and perform scaling: where is the dimension of the key vector.
[0049] Perform softmax normalization on the score matrix to obtain the attention weights:
[0050] Use the attention weights and the value matrix V to calculate the output:
[0051] For multi-head attention, concatenate the outputs of multiple attention heads and perform a linear transformation to obtain the final multi-head attention output:
[0052] where is the output of each attention head, is the weight matrix.
[0053] Use a gated recurrent unit to perform temporal modeling based on the attention electrocardiogram waveform matrix to generate a corrected electrocardiogram waveform matrix.
[0054] The reset gate of the gated recurrent unit and the update gate are expressed as:
[0055] The candidate hidden state is expressed as:
[0056] The final hidden state is expressed as:
[0057] where represents the output of the reset gate, represents the output of the update gate, and are the weight matrices of the reset gate and the update gate respectively, and are the bias terms, is Sigmoid the activation function, is the candidate hidden state at the current time, is the weight matrix of the candidate hidden state, is the bias term of the candidate hidden state, Denotes the hyperbolic tangent activation function, is the hidden state at the final moment. The hidden state at the final moment, as the output of the gated recurrent unit, is obtained by the weighted average of the hidden state at the previous moment and the current candidate hidden state, and the corrected electrocardiogram waveform matrix is obtained.
[0058] Convert the corrected electrocardiogram waveform matrix into an electrocardiogram waveform to generate the corrected electrocardiogram signal.
[0059] The corrected electrocardiogram waveform matrix needs to be converted into a continuous electrocardiogram waveform to generate the final corrected electrocardiogram signal. The output of the gated recurrent unit is in the form of a matrix representing the corrected electrocardiogram waveform, where each row corresponds to a corrected cardiac beat segment. By extracting the 1×300 vector of each row, the corresponding single cardiac beat signal can be restored, and the correction and reconstruction of the overall electrocardiogram waveform are completed.
[0060] In this embodiment, according to the electrode offset labels classified according to the electrode offset situation, the corresponding correction parameters are called by the label to load the correction model, and the correction model corresponding to the electrode offset situation is adopted to specifically correct the electrocardiogram signals of each electrode offset situation. The multi-head attention mechanism is used for weight distribution to increase the weight ratio of the electrocardiogram waveform features with strong representativeness and reduce the influence of irrelevant factors. Then, the gated recurrent unit is used for temporal modeling. The gated recurrent unit can well capture the long dependencies in time series and better fit the electrocardiogram waveform. Finally, the corrected electrocardiogram signal is obtained without adjusting the electrode position to re-collect the electrocardiogram signal, which improves the acquisition efficiency of the electrocardiogram signal.
[0061] Embodiment III
[0062] Figure 3 is the flowchart of an electrocardiogram signal correction method according to Embodiment III of the present invention. This embodiment is optimized based on the above embodiment. In this embodiment, the average electrical axis vector is obtained by vector synthesis according to the R peak amplitude of Lead I, the R peak amplitude of Lead II, and the R peak amplitude of Lead III, and the average electrical axis angle is calculated. Specifically, the optimization is as follows: Using Einthoven's triangle rule and the Bailey hexaxial system, determine the Lead I vector, the Lead II vector, and the Lead III vector according to the R peak amplitude of Lead I, the R peak amplitude of Lead II, and the R peak amplitude of Lead III; Perform vector synthesis using the Lead I vector, the Lead II vector, and the Lead III vector to generate the average electrical axis vector; Calculate the average electrical axis angle according to the coordinates of the average electrical axis vector.
[0063] Correspondingly, the electrocardiogram signal correction method provided in this embodiment specifically includes:
[0064] S301, preprocess the acquired electrocardiogram (ECG) signal to obtain a preprocessed ECG signal.
[0065] S302, perform QRS complex localization on the preprocessed ECG signal to obtain the R peak amplitudes of Lead I, Lead II, and Lead III, and calculate the ratio of the R peak amplitudes of Lead I to Lead III.
[0066] S303, use Einthoven's triangle law and Bailey's hexaxial system to determine the Lead I vector, Lead II vector, and Lead III vector based on the R peak amplitudes of Lead I, Lead II, and Lead III.
[0067] Einthoven's triangle law is an approximately equilateral triangle formed by three standard limb leads (Lead I, Lead II, and Lead III). The electrodes of these three leads are placed on the right arm, left arm, and left leg respectively, forming a closed triangle, which is mainly used to describe the spatial direction distribution of cardiac electrical activity and can be used to help analyze the direction and deviation of the electrical axis. Bailey's hexaxial system (Bailey's hexaxial system) is to keep the axis leads of the six limb leads in their original directions and move them parallelly so that they intersect at a central point, forming a radial geometric figure, which can be used to evaluate the deviation and direction of the electrical axis. By using Einthoven's triangle law and Bailey's hexaxial system to determine the direction of each lead, and then combining the R peak amplitude of each lead as the length of the vector, the Lead I vector, Lead II vector, and Lead III vector that can represent the cardiac electrical activity on each lead can be formed.
[0068] S304, perform vector synthesis using the Lead I vector, Lead II vector, and Lead III vector to generate an average electrical axis vector.
[0069] Based on the plane coordinate system established by Einthoven's triangle law and Bailey's hexaxial system, the average electrical axis vector is obtained by superimposing the vectors of the three leads : = +
[0070] S305, calculate the average electrical axis angle according to the coordinates of the average electrical axis vector.
[0071] The average electrical axis vector can indicate the cardiac electrical activity. The horizontal and vertical coordinates of the average electrical axis vector can reflect the intensity of cardiac electrical activity in different directions to a certain extent. Calculate the average electrical axis angle 𝜃 using the coordinates of the average electrical axis vector. The average electrical axis angle 𝜃 reflects the overall cardiac electrical activity direction. The displacement of the electrode can be judged through the deviation trend of the electrical axis angle:
[0072] Among them, and respectively represent the abscissa and ordinate of the mean electrical axis vector. is the inverse trigonometric function of the four quadrants, which is used to calculate the angle from the x positive direction of the axis to the point Figure 5 As shown in Figure 4 , translate V1, V2, and V3 in the figure to obtain V1', V2', and V3' respectively. Superimpose and synthesize V1', V2', and V3' to obtain the mean electrical axis vector, and then calculate the mean electrical axis angle using the coordinates of the mean electrical axis vector. As shown in Figure 4 (a) shows the result of the normal electrode placement position; compared with the normal position, Figure 4 in (b), the amplitude of the vector in lead I decreases, the mean electrical axis angle becomes larger, and the electrode placement position is biased upward; Figure 4 in (c), the amplitude of the vector in lead I increases, the amplitude of the vector in lead III decreases, the mean electrical axis angle becomes smaller, and the electrode placement position is biased downward; Figure 4 in (d), the amplitude of the vector in lead III decreases, the mean electrical axis angle becomes smaller, and the electrode placement position is biased to the left; Figure 4 in (e), the amplitude of the vector in lead III increases, the mean electrical axis angle becomes abnormally larger, and the electrode placement position is biased to the right; Figure 4 in (f), the amplitude of the vector in lead I decreases, the amplitude of the vector in lead III increases, the mean electrical axis angle becomes larger, and the electrode placement position rotates clockwise; Figure 4 in (g), the amplitude of the vector in lead I increases, the amplitude of the vector in lead III decreases, the mean electrical axis angle becomes smaller, and the electrode placement position rotates counterclockwise.
[0073] S306. Using the trained random forest model, decision tree model, and XGBoost model, respectively determine the electrode offset situation of the preprocessed electrocardiogram signal according to the mean electrical axis angle, the R peak amplitude of lead I, the R peak amplitude of lead II, the R peak amplitude of lead III, and the ratio of the R peak amplitudes of lead I and lead III, to obtain the first electrode offset type, the second electrode offset type, and the third electrode offset type. Perform voting method ensemble learning based on all electrode offset types to obtain the electrode offset label.
[0074] S307. According to the electrode offset label, use the trained correction model based on multi-head attention and gated recurrent units to correct the preprocessed electrocardiogram signal. The correction model first performs weight allocation on the electrocardiogram signal in matrix form using the multi-head attention mechanism, and then performs temporal modeling using the gated recurrent unit to generate the corrected electrocardiogram signal.
[0075] In this embodiment, the Einthoven's triangle rule and the Bailey hexaxial system are used to determine the vectors of each lead by combining the R peak amplitudes of each lead, and then the mean electrical axis vector is obtained through vector synthesis. The mean electrical axis angle is calculated using the mean electrical axis vector. The mean electrical axis angle can reflect the overall electrical activity direction of the heart. The mean electrical axis vector and the mean electrical axis angle can reflect to a certain extent the intensity of the heart's electrical activity in different directions, and can be used to analyze the offset of the electrode position. Together with the R peak amplitude of each lead, they form the input features of a classification model for classifying electrode offsets. The classification model can classify the types of electrode offsets based on the electrical activity intensity of the heart on each lead and the directional relationship between each lead reflected by the input features.
[0076] Specifically, using the Einthoven's triangle rule and the Bailey hexaxial system, the vectors of Lead I, Lead II, and Lead III are determined according to the R peak amplitude of Lead I, the R peak amplitude of Lead II, and the R peak amplitude of Lead III, including: Using the Einthoven's triangle rule and the Bailey hexaxial system to determine the angles of Lead I, Lead II, and Lead III.
[0077] According to the Einthoven's triangle rule and the Bailey hexaxial system, as Figure 5 shown, the angle of Lead I can be determined to be 0°, and the R peak amplitude is , the angle of Lead II is 60°, and the R peak amplitude is , the angle of Lead III is 120°, and the R peak amplitude is .
[0078] Determine the vector of Lead I according to the angle of Lead I and the R peak amplitude of Lead I, determine the vector of Lead II according to the angle of Lead II and the R peak amplitude of Lead II, and determine the vector of Lead III according to the angle of Lead III and the R peak amplitude of Lead III.
[0079] Taking the R peak amplitude of Lead I as the vector length and the angle of Lead I as the vector direction, the vector of Lead I can be formed; similarly, taking the R peak amplitude of Lead II as the vector length and the angle of Lead II as the vector direction, the vector of Lead II can be formed; the vector of Lead III can be obtained in the same way.
[0080] The vector of Lead I can be expressed as:
[0081] The vector of Lead II can be expressed as:
[0082] The vector of Lead III can be expressed as:
[0083] An optional implementation of this embodiment is to preprocess the acquired electrocardiogram (ECG) signal to obtain a preprocessed ECG signal, including: Denoise the acquired ECG signal by using a band-pass filter and wavelet transform.
[0084] During the acquisition of the ECG signal, noise is generated due to power frequency interference, equipment circuits, etc. A band-pass filter is used for specific frequency filtering, and then wavelet transform is used to perform scaling and translation operations to decompose the signal into wavelet basis functions of different scales and positions, obtaining the denoised ECG signal. The decomposition process of wavelet transform can be expressed as:
[0085] where, is the original signal, is the wavelet basis function, is the wavelet coefficient, and are the scale and translation parameters. During the signal processing, first perform wavelet decomposition on the original ECG signal , that is, project it onto the basis functions of different scales to calculate the corresponding wavelet coefficients . The calculation of wavelet coefficients is achieved by performing scale transformation (decomposing into different frequency components) and time translation transformation (locating features at different time points) on the signal.
[0086] Eliminate baseline drift of the acquired ECG signal by using a high-pass filter.
[0087] During the acquisition of the ECG signal, low-frequency baseline drift is caused due to breathing, poor electrode contact, etc. A high-pass filter is used to filter the low frequency, perform baseline drift elimination processing on the ECG signal, and reduce the influence of irrelevant factors.
[0088] Optionally, Daubechies4 is used as the wavelet basis function for wavelet transform, and four-layer wavelet decomposition is performed.
[0089] Using Daubechies4 (wavelet db4) as the wavelet basis function and performing four-layer wavelet decomposition. Exemplarily, first use the scale factor to control the decomposition level of wavelet transform, so that the signal is analyzed at different resolutions; then, calculate the wavelet coefficients under the action of the translation parameter , different frequency components of the electrocardiogram (ECG) signal are extracted respectively. To optimize the noise reduction effect, signal smoothing is performed with a smoothing coefficient of 0.8 to reduce the influence of random noise. Meanwhile, a nonlinear correction factor of 0.5 is used to perform threshold processing on the wavelet coefficients to further suppress high-frequency noise and power frequency interference.
[0090] Embodiment 4
[0091] Figure 6 As shown in the structural schematic diagram of an ECG signal correction device according to Embodiment 4 of the present invention. In this embodiment, the ECG signal correction device includes: An ECG signal processing module 810, configured to preprocess the acquired ECG signal; A QRS wave positioning module 820, configured to perform QRS wave positioning on the preprocessed ECG signal; A vector synthesis module 830, configured to perform vector synthesis and calculate the mean electrical axis angle; An electrode offset classification module 840, configured to discriminate the type of electrode offset and generate an electrode offset label; An ECG signal correction module 850, configured to correct the ECG signal according to the electrode offset label by using the trained correction model.
[0092] In this embodiment, the ECG signal is preprocessed by the ECG signal processing module, the QRS wave is positioned on the ECG signal by the QRS wave positioning module, vector synthesis is performed by the vector synthesis module, the electrode offset situation is classified by the electrode offset classification module, and the ECG signal is corrected according to the electrode offset type by the ECG signal correction module. Vectors of each lead are generated based on the R peak amplitude of each lead of the ECG signal, then vector synthesis is performed to obtain the mean electrical axis vector and calculate the mean electrical axis angle. After that, the electrode offset situation is classified, and the correction model corrects the ECG signal according to the electrode offset type by loading the trained correction model to obtain the corrected ECG waveform. The electrode offset situation of the acquired ECG waveform can be analyzed, the ECG waveform can be corrected, and the corrected ECG signal can be directly output without manually correcting the placement position of the electrodes and re-collecting them again, which improves the acquisition efficiency of the ECG signal and can meet the usage requirements of non-medical professionals.
[0093] The ECG signal correction device provided by the embodiment of the present invention can execute the ECG signal correction method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the method.
[0094] Embodiment 5
[0095] Figure 7 As shown in the structural diagram of a computer device according to Embodiment 5 of the present invention, Figure 7FIG. 0 is a block diagram showing an exemplary computer device 12 suitable for use in implementing embodiments of the present invention. Figure 7 The illustrated computer device 12 is only an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0096] As Figure 7 shown, computer device 12 appears in the form of a general-purpose computing device. The components of computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples different system components including the system memory 28 and the processing unit 16.
[0097] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus structures. By way of example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0098] Computer device 12 typically includes a variety of computer system readable media. Such media can be any available media that can be accessed by computer device 12, including both volatile and nonvolatile media, removable and non-removable media.
[0099] System memory 28 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer device 12 may further include other removable / non-removable, volatile / nonvolatile computer system storage media. By way of example only, a storage system 34 can be used for reading from and writing to non-removable, nonvolatile magnetic media ( Figure 7 not shown, typically referred to as a "hard disk drive"). Although Figure 7 not shown in FIG., a disk drive for reading from and writing to a removable nonvolatile disk (such as a "floppy disk"), and an optical disk drive for reading from and writing to a removable nonvolatile optical disk (such as a CD-ROM, DVD-ROM, or other optical media) can be provided. In these instances, each drive can be connected to bus 18 by one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of the embodiments of the present invention.
[0100] A program / utilities 40 having a set (at least one) of program modules 42 can be stored, for example, in a memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules 42 generally execute the functions and / or methods in the embodiments described in the present invention.
[0101] The computer device 12 can also communicate with one or more external devices 14 (such as a keyboard, a pointing device, a display 24, etc.), and can also communicate with one or more devices that enable a user to interact with the device / server / computer device 12, and / or communicate with any device that enables the computer device 12 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through an input / output (I / O) interface 22. Moreover, the computer device 12 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As shown in the figure, the network adapter 20 communicates with other modules of the computer device 12 through a bus 18. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in conjunction with the computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0102] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the electrocardiogram signal correction method provided in the embodiments of the present invention.
[0103] Embodiment Six
[0104] Embodiment Six of the present invention also provides a storage medium containing computer-executable instructions, and the computer-executable instructions are used to execute the electrocardiogram signal correction method provided in the above embodiments when executed by a computer processor.
[0105] The computer storage medium of the embodiments of the present invention may adopt any combination of one or more computer-readable media. The computer-readable media may be computer-readable signal media or computer-readable storage media. The computer-readable storage media may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage media may be any tangible medium that contains or stores a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0106] The computer-readable signal media may include data signals propagated in a baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal media may also be any computer-readable media other than the computer-readable storage media, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0107] The program code contained on the computer-readable media may be transmitted by any appropriate medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0108] The computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Python, Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., by connecting through an Internet service provider via the Internet).
[0109] Note that the above is only the preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for correcting an electrocardiogram signal, characterized in that: include: Preprocessing the acquired ECG signal to obtain a preprocessed ECG signal; Perform QRS wave positioning on the preprocessed ECG signal to obtain the R peak amplitude of lead I, lead II and lead III, and calculate the R peak amplitude ratio of lead I to lead III; According to the R peak amplitude of lead I, lead II and lead III, the average electric axis vector is obtained by vector synthesis, and the average electric axis angle is calculated; Using the trained random forest model, decision tree model and XGBoost model, the electrode offset of the preprocessed ECG signal is respectively identified according to the average electrical axis angle, the R peak amplitude of lead I, the R peak amplitude of lead II, the R peak amplitude of lead III and the R peak amplitude ratio of lead I to lead III, and the first electrode offset type, the second electrode offset type and the third electrode offset type are obtained. Voting method ensemble learning is performed based on all electrode offset types to obtain the electrode offset label; According to the electrode offset label, the preprocessed ECG signal is corrected using a trained correction model based on multi-head attention and gated loop. The correction model first assigns weights to the ECG signal in matrix form using a multi-head attention mechanism, and then uses a gated loop unit for timing modeling to generate a corrected ECG signal.
2. The method according to claim 1, characterized in that The method of correcting the preprocessed ECG signal according to the electrode offset label using a trained correction model based on multi-head attention and gated loop includes: According to the electrode offset label, calling the electrode offset correction parameter corresponding to the electrode offset label and loading it into the correction model; The preprocessed ECG signal is input into the correction model, and the correction model outputs the corrected ECG signal.
3. The method according to claim 2, characterized in that The step of inputting the preprocessed ECG signal into the correction model, and the correction model outputting the corrected ECG signal, comprises: Convert the preprocessed ECG signal into a matrix form to generate an ECG waveform matrix; Using the multi-head attention mechanism, the ECG waveform matrix is weighted and the attention ECG waveform matrix is generated; Using the gated recurrent unit, the timing modeling is performed based on the attention ECG waveform matrix to generate the correction ECG waveform matrix; The corrected ECG waveform matrix is converted into an ECG waveform to generate a corrected ECG signal.
4. The method according to claim 1, characterized in that: The method of obtaining the average electric axis vector by vector synthesis according to the R peak amplitude of lead I, the R peak amplitude of lead II and the R peak amplitude of lead III, and calculating the average electric axis angle includes: Using Einthoven's triangle law and the Bayley six-axis system, the lead I vector, the lead II vector and the lead III vector are determined according to the R peak amplitude of lead I, the R peak amplitude of lead II and the R peak amplitude of lead III; Performing vector synthesis using the lead I vector, the lead II vector, and the lead III vector to generate an average electric axis vector; The average electrical axis angle was calculated based on the coordinates of the average electrical axis vector.
5. The method according to claim 4, characterized in that The method of using the Einthoven triangle law and the Bayley six-axis system to determine the first lead vector, the second lead vector and the third lead vector according to the first lead R peak amplitude, the second lead R peak amplitude and the third lead R peak amplitude comprises: The angles of Lead I, Lead II, and Lead III were determined using Einthoven's triangulation rule and the Bayley six-axis system; The lead I vector is determined according to the lead I angle and the lead I R peak amplitude, the lead II vector is determined according to the lead II angle and the lead II R peak amplitude, and the lead III vector is determined according to the lead III angle and the lead III R peak amplitude.
6. The method according to claim 1, characterized in that The step of preprocessing the acquired ECG signal to obtain a preprocessed ECG signal includes: The acquired ECG signal is denoised using bandpass filter and wavelet transform; A high-pass filter is used to eliminate the baseline drift of the acquired ECG signal.
7. The method according to claim 6, characterized in that: The wavelet transform uses Daubechies4 as the wavelet basis function and performs four-layer wavelet decomposition.
8. An electrocardiogram signal correction device, characterized in that: include: An ECG signal processing module, used for preprocessing the acquired ECG signal; QRS wave positioning module, used for QRS wave positioning of pre-processed ECG signals; A vector synthesis module, used for performing vector synthesis and calculating the average electric axis angle; The electrode offset classification module is used to identify the electrode offset type and generate an electrode offset label; The ECG signal correction module is used to correct the ECG signal using the trained correction model according to the electrode offset label.
9. A computer device, characterized in that: The computer device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the ECG signal correction method as described in any one of claims 1-7.
10. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute the electrocardiogram signal correction method according to any one of claims 1 to 7 when executed by a computer processor.
Citation Information
Patent Citations
Vector ECG instrument and carrying out method thereof
CN101011242A
Electrocardiogram monitoring method and electrocardiogram monitoring device
CN107320095A
Electrocardiograph electrode position correction method and system
CN117137493A
Electrocardiosignal processing method and device, electronic equipment and storage medium
CN118319316A
Method and apparatus for developing a vectorcardiograph in an implantable medical devicee
US20030083587A1
Cited By
Impedance cardiogram correction method and device, equipment, storage medium and product
CN120788547A