Electrocardiogram atrial fibrillation data detection method based on machine learning

Through the detection method of ECG AF data based on machine learning, using segmentation, sampling and feature extraction techniques, an ECG classification model is constructed, which solves the problem of inaccurate R-wave and P-wave identification in traditional methods, and achieves higher room Accuracy of ECG data recognition.

CN119454045AActive Publication Date: 2025-02-18WUXI JIANWEI INSTR CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202411480987.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-18
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

The traditional atrial fibrillation recognition method has low accuracy in the identification of ECG data due to inaccurate R wave and P wave.

Method used

Using the electrocardiogram atrial fibrillation data detection method based on machine learning, the original electrocardiogram data is segmented, sampled and feature extracted, and the electrocardiogram feature matrix is ​​constructed, and the electrocardiogram classification model is used to realize the electrocardiogram of atrial fibrillation. Data identification.

Benefits of technology

There is no need to perform R-wave and P-wave recognition in the ECG waveform, which avoids a large number of calculation processes, improves the recognition accuracy of the ECG data of atrial fibrillation, and has a small calculation amount and high recognition efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119454045A_ABST
    Figure CN119454045A_ABST
Patent Text Reader

Abstract

According to the electrocardiogram atrial fibrillation data detection method based on machine learning, the characteristics that the interval between R waves of atrial fibrillation electrocardio data is unstable and no obvious independent P waves exist are utilized, waveform characteristics and waveform characteristic data Distance are emphasized through sampling operation, the characteristics that the atrial fibrillation electrocardio data is irregular and the waveform repetition probability is low are utilized, and therefore the atrial fibrillation electrocardio data can be accurately detected. The method comprises the following steps of: constructing waveform characteristic data Similar; an electrocardiograph classification model is constructed based on a machine learning algorithm, and atrial fibrillation electrocardiograph data and normal electrocardiograph data are classified according to two pieces of waveform feature data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an electrocardiogram atrial fibrillation data detection method based on machine learning. Background Art

[0002] Atrial fibrillation (AF) is a common arrhythmia. The hazards of AF include significantly increasing the risk of stroke, causing heart failure, worsening heart function, reducing the quality of life, and increasing the risk of death, especially when it is not effectively treated and managed. The possibility of AF is usually determined based on electrocardiogram data.

[0003] Atrial fibrillation is characterized by rapid and irregular electrical activity in the atria, which causes the atria to not contract effectively. This abnormal electrical activity spreads through the atrioventricular node to the ventricles, causing them to also beat in an irregular and often rapid pattern. Signs of atrial fibrillation seen on an electrocardiogram (ECG) include:

[0004] 1. P wave disappears: In atrial fibrillation, the traditional P wave disappears because the electrical activity of the atria is irregular and chaotic. Instead, small and irregular waves can be seen, which are called "fibrillation waves" or "f waves."

[0005] 2. Irregular RR interval: The beating of the ventricles (QRS wave) becomes irregular, which is manifested as irregular RR interval (the time interval between two R waves).

[0006] 3. Increased heart rate: Atrial fibrillation is usually accompanied by a rapid heart rate, that is, the ventricular rate is usually between 100-160 beats / minute, but it may be faster or slower.

[0007] like Figure 1 Shown is a comparison chart of normal ECG data and atrial fibrillation ECG data; Figure 1 The horizontal axis of the electrocardiogram in is the sampling point; the vertical axis is the voltage, in millivolts. Figure 1 It can be observed from the data that in a normal electrocardiogram, the intervals between R waves are stable, and there is a clear and stable P wave. In an atrial fibrillation electrocardiogram, the intervals between R waves are unstable, and there is no clear separate P wave. Instead, there is an irregular wave-shaped fibrillation wave.

[0008] In traditional atrial fibrillation recognition algorithms, the R wave is usually recognized first, and the RR intervals between all R waves are calculated to see if they are stable; then the P wave is recognized to see if there are multiple different and irregular waveforms between the R waves. Only through the above two points can it be determined whether it is atrial fibrillation. However, due to technical reasons, the recognition of R waves and P waves is often not very accurate, which can cause the failure of atrial fibrillation recognition. Summary of the invention

[0009] In order to solve the problem that traditional atrial fibrillation recognition methods affect the recognition of atrial fibrillation ECG data due to inaccurate recognition of R waves and P waves, the present invention provides an electrocardiogram atrial fibrillation data detection method based on machine learning, which recognizes atrial fibrillation ECG data without the need to identify R waves and P waves, thereby improving the recognition accuracy of atrial fibrillation ECG data.

[0010] The technical solution of the present invention is as follows: a method for detecting atrial fibrillation data of an electrocardiogram based on machine learning, comprising the following steps:

[0011] S1: collect original ECG data;

[0012] It is characterized in that it also includes the following steps:

[0013] S2: segmenting the ECG waveform of the original ECG data;

[0014] According to the preset segmentation length, the original ECG data is segmented into equal lengths, and the obtained ECG segments are recorded as: ECG segment 1;

[0015] The number of the electrocardiogram segment 1 is recorded as x;

[0016] S3: performing n consecutive sampling operations of different sizes on all the electrocardiogram segments to obtain corresponding sampling operation results;

[0017] The sampling operation includes: a downsampling and an upsampling performed sequentially;

[0018] S4: Counting the distance between the original data of each electrocardiogram segment 1 and the corresponding sampling operation result at each sampling point, recorded as: feature distance Distance;

[0019] S5: randomly selecting x points in the original ECG data as starting points, and cutting according to the segmentation length; cutting out x ECG segments of equal length;

[0020] S6: Obtain each of the second electrocardiogram segments one by one, search in the original electrocardiogram data to obtain similar segments, and count the number of similar segments corresponding to each of the second electrocardiogram segments, recorded as: similar number Similar;

[0021] S7: Construct the ECG feature matrix K based on the feature distance Distance and the similarity number Similar;

[0022] K = [Distance; Similarity], the matrix size of K is [2, x];

[0023] S8: Construct an ECG classification model based on a machine learning algorithm model;

[0024] Constructing a training set based on the electrocardiogram feature matrix K of historical data, training the electrocardiogram classification model, and obtaining the trained electrocardiogram classification model;

[0025] S9: Obtain the electrocardiogram data to be identified, calculate the corresponding electrocardiogram feature matrix K; send the electrocardiogram feature matrix K to the classification model for classification to obtain the identification result of the electrocardiogram data to be identified; complete the detection of the electrocardiogram atrial fibrillation data.

[0026] It is further characterized by:

[0027] The segmentation length is set to be greater than or equal to 2 seconds;

[0028] In step S3, the value of the sampling operation times n is: n≥5;

[0029] The value of the number x of the electrocardiogram segment 1 and the electrocardiogram segment 2 satisfies the condition: x≥2;

[0030] In step S4, the characteristic distance Distance is calculated as follows:

[0031] Distance = [(ECG′1-ECG 1 1) 2 +(ECG′2-ECG 1 2) 2 +…+(ECG′ t -ECG 1 t ) 2 )];

[0032] Where t is the abscissa of the ECG segment including the total number of sampling points involved in the calculation, (ECG 1 1. ECG 1 2……ECG 1 t ) is the value at each sampling point in the first electrocardiogram segment; (ECG′1, ECG′2…ECG′ t ) is the value at each sampling point in the electrocardiogram segment of the sampling operation result;

[0033] In step S6, the method for determining the similar segments is as follows:

[0034] a1: Obtain each of the second electrocardiogram segments one by one, recorded as: the segment to be retrieved;

[0035] Initialize the corresponding similar number Similar to 0;

[0036] a2: read the first sampling point of the original ECG data, recorded as: starting point;

[0037] a3: based on the indicated starting point, obtain the electrocardiogram data of the segmented length backward, recorded as: the segment to be compared;

[0038] a4: Calculate the characteristic distance Distance between the segment to be retrieved and the segment to be compared, denoted as: D;

[0039] a5: Compare D with the preset similarity threshold S;

[0040] If D>S, it means the two are not similar, and execute step a7;

[0041] Otherwise, it means the two are similar, and step a6 is executed;

[0042] a6: increase the number of similarities Similar corresponding to the fragment to be searched by one, and then execute step a7;

[0043] a7: Get the next sampling point, recorded as the starting point, and repeat steps a4 to a5 until all the sampling points in the original ECG data are involved in the calculation;

[0044] The electrocardiogram classification model is constructed based on a support vector machine model.

[0045] The present invention provides an electrocardiogram atrial fibrillation data detection method based on machine learning. The method utilizes the characteristics of unstable intervals between R waves and no obvious separate P waves in atrial fibrillation electrocardiogram data, emphasizes waveform characteristics and waveform characteristic data Distance through sampling operations, and utilizes the characteristics of irregular atrial fibrillation electrocardiogram data and low waveform repetition probability to construct waveform characteristic data Similar; constructs an electrocardiogram wave classification model based on a machine learning algorithm, and classifies atrial fibrillation electrocardiogram data and normal electrocardiogram data according to two waveform characteristic data; in the waveform recognition process of the method, there is no need to perform R wave and P wave recognition in the electrocardiogram waveform, thereby avoiding a large number of calculation processes, and at the same time, there is no need to describe the specific waveform characteristics of the atrial fibrillation electrocardiogram data, and there is no need to perform image recognition on the specific atrial fibrillation electrocardiogram waveform. Instead, based on the waveform difference points between the atrial fibrillation electrocardiogram waveform and the normal electrocardiogram data, the normal electrocardiogram waveform data and the waveform data of the atrial fibrillation electrocardiogram are classified. The overall classification idea is simple and conforms to the characteristics of irregular atrial fibrillation electrocardiogram waveforms. The classification speed is fast and the method is very practical. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 This is a comparison chart of normal ECG data and atrial fibrillation ECG data;

[0047] Figure 2 Example of resampling an ECG for atrial fibrillation;

[0048] Figure 3 This is an example of resampling a normal ECG;

[0049] Figure 4 Example 1 of a similar segment of an electrocardiogram;

[0050] Figure 5 Example 2 of a similar segment of an electrocardiogram;

[0051] Figure 6 Example 3 of a similar segment of an electrocardiogram;

[0052] Figure 7 This application provides a flow chart of a method for detecting atrial fibrillation in electrocardiogram data based on machine learning. DETAILED DESCRIPTION

[0053] like Figure 1 From the comparison chart of normal ECG data and atrial fibrillation ECG data, it can be observed that in a normal ECG, the intervals between R waves are stable, and there is a clear and stable P wave. In the atrial fibrillation ECG, the intervals between R waves are unstable, and there is no obvious separate P wave. Instead, there is an irregular wave-shaped fibrillation wave. In the traditional atrial fibrillation recognition algorithm, it is necessary to identify the P wave, R wave, and the waveform between the P wave and the R wave, and judge whether the ECG to be identified is atrial fibrillation data based on the waveform recognition result. The recognition result is related to the waveform recognition result of the P wave and the R wave. If the recognition of the R wave and the recognition of the P wave are not accurate, the recognition of atrial fibrillation will fail. This method does not require the atrial fibrillation detection method of R wave and P wave recognition, avoids a large amount of calculation process of waveform recognition, and can also improve the recognition accuracy.

[0054] like Figure 7 As shown, the present application includes a method for detecting electrocardiogram atrial fibrillation data based on machine learning, which includes the following steps.

[0055] S1: Collect raw ECG data.

[0056] S2: segmenting the ECG waveform of the original ECG data;

[0057] According to the preset segmentation length, the original ECG data is segmented into equal lengths, and the obtained ECG segments are recorded as: ECG segment 1 (ECG′1, ECG′2...ECG′ x ); let the number of ECG segment 1 be x.

[0058] In specific implementation, the segmentation length is set according to the total length of the original ECG data. In order to ensure that there is enough data in the subsequent feature matrix K, the value of the segmentation length must ensure that the value of the number x of ECG segments one meets the condition: x ≥ 2. At the same time, in order to ensure that the ECG segment includes enough data features, the segmentation length meets the condition: segmentation length ≥ 2 seconds.

[0059] This application is attached Figures 1 to 6 The sampling frequency is 128, and the horizontal axis is the time sampling point. In this embodiment, the segmentation length is set to 2 seconds; it is assumed that the original data is segmented based on 2 seconds to obtain 2 ECG segments, that is, x=2. The original ECG data in this embodiment is atrial fibrillation ECG data, and the cut segments include both segments with atrial fibrillation ECG data characteristics and segments of normal ECG data. It is assumed that after this segmentation, the two ECG segments obtained include one normal ECG data and one atrial fibrillation ECG data.

[0060] S3: performing n consecutive sampling operations of different sizes on all ECG segments to obtain corresponding sampling operation results;

[0061] The sampling operation includes: a downsampling and an upsampling performed sequentially.

[0062] S4: Count the original data of each ECG segment and the corresponding sampling operation result, and the distance at each sampling point is recorded as: feature distance Distanc e .

[0063] In this method, the feature distance Distanc e The calculation method is:

[0064] Distance = [(ECG′1-ECG 1 1) 2 +(ECG′2-ECG 1 2) 2 +…+(ECG′ t -ECG 1 t ) 2 )];

[0065] Among them, t is the sampling point of the horizontal axis of the electrocardiogram, (ECG 1 1. ECG 1 2……ECG 1 t ) is the value at each sampling point in the first electrocardiogram segment; (ECG′1, ECG′2…ECG′ t ) is the value at each sampling point in the electrocardiogram segment of the sampling operation result.

[0066] That is, Figure 2 The atrial fibrillation ECG data shown includes more than 3,000 sampling points. Figure 2 The ECG data is segmented into x =12 ECG segments, each individual ECG segment includes t=256 sampling points.

[0067] Distance 房颤 =[Distance1, Distance2,...,Distance 12 ];

[0068] Then, the characteristic distance Distanc of the individual ECG data is calculated specifically e hour:

[0069] Distance1=[(ECG′1-ECG 1 1) 2 +(ECG′2-ECG 1 2) 2 ......(ECG′ 256 -ECG 1 256 ) 2 )].

[0070] Since there are a large number of irregular and chaotic fibrillation waves in the atrial fibrillation waveform, and the position of the R wave is uncertain; in contrast, the normal ECG wave is more regular and smoother. The upsampling process after downsampling is equivalent to predicting the current data with the surrounding data. In this application, the features in the ECG segment are enhanced by adopting operations to make its features more prominent. Therefore, after multiple downsampling and upsampling of different sizes, the atrial fibrillation wave is more easily distorted, and the normal ECG wave is closer to the original data after restoration. As a result, the Distance of the normal ECG is smaller, and the Distance of the atrial fibrillation wave is larger. In order to ensure that the characteristics of the ECG wave data are enhanced to meet the calculation needs, the specific value of the sampling operation number n satisfies: n≥5. In this embodiment, n is set to 7.

[0071] In this embodiment, the ECG segment is sampled seven times (down-sampling first, then up-sampling), and the sampling frequencies are set to 2, 2, 3, 5, 3, 2, 5 respectively. The resampled waveform of the atrial fibrillation data obtained after the 7-time sampling operation and the comparison diagram of the original atrial fibrillation ECG are shown in FIG. Figure 2 The normal data resampled waveform obtained after 7 sampling operations on the normal electrocardiogram data and the comparison diagram of the original normal electrocardiogram are shown in Figure 3 After enhancing the features, the data difference is calculated at each sampling point for the original data and the data after downsampling and upsampling.

[0072] Assume that the original ECG data is segmented into two ECG segments, and the characteristic distances obtained after calculation are: 房颤1 and Distance 正常; Assume that the characteristic distance Distance of atrial fibrillation ECG is 5.42, and the characteristic distance Distance of normal ECG is 1.16. Then the characteristic distance Distance of the original ECG data is expressed as: Distance = [Distance 房颤1 , Distance 正常 )]=[5.42,1.16].

[0073] S5: In order to ensure the final constructed ECG feature matrix K, the number of ECG segment 2 is kept consistent with the number of ECG segment 1. Randomly select x points in the original ECG data as the starting point and cut according to the segmentation length; cut out x ECG segments of equal length (ECG 2 1. ECG 2 2......ECG 2 x ).

[0074] S6: Obtain each ECG segment 2 one by one, search in the original ECG data to obtain similar segments, and count the number of similar segments corresponding to each ECG segment 2, recorded as: Similar.

[0075] In step S6, the following steps are specifically included:

[0076] a1: Get each ECG segment 2 one by one, recorded as: the segment to be retrieved;

[0077] Initialize the corresponding similarity number Similar to 0;

[0078] a2: read the first sampling point of the original ECG data, recorded as: starting point;

[0079] a3: based on the starting point shown, the ECG data of the segmented length is obtained backward, which is recorded as the segment to be compared;

[0080] a4: Calculate the feature distance Distance between the segment to be retrieved and the segment to be compared, denoted as: D;

[0081] a5: Compare D with the preset similarity threshold S;

[0082] If D>S, it means the two are not similar, and execute step a7;

[0083] Otherwise, it means the two are similar, and execute step a6;

[0084] a6: increase the number of similarities Similar corresponding to the fragment to be searched by one, and then execute step a7;

[0085] a7: Get the next sampling point, recorded as the starting point, and repeat steps a4 to a5 until all the sampling points in the original ECG data are involved in the calculation.

[0086] The similarity threshold S is obtained based on historical data statistics. In this embodiment, the similarity threshold S is set to 2.64. The number of similarities Similar corresponding to the original ECG data is recorded as: Similar = (S1, S2...S x ). For specific examples of similar ECG data, refer to the attached drawings of the specification. Figure 4 , Figure 5 and Figure 6 .

[0087] Usually, since the R wave position of a normal electrocardiogram is stable and the overall electrocardiogram has no irregular waveform, multiple similar segments can be found in a normal electrocardiogram, but no similar segments can be found in an atrial fibrillation electrocardiogram, that is, the corresponding S value is 0 or a small value. In this method, based on this distinguishing characteristic between an atrial fibrillation electrocardiogram and a normal electrocardiogram, another feature parameter is used to distinguish the two types of electrocardiogram data.

[0088] S7: Construct the ECG feature matrix K based on Distance and Similarity.

[0089] K = [Distance; Similarity], where the matrix size of K is [2, x].

[0090] When x is equal to 2, the matrix size of K is [2, 2], that is: K = [Distance1, Distance2; S1, S2].

[0091] In a specific embodiment, when x=2, the two-dimensional matrix of atrial fibrillation ECG data is [5.42, 6.18; 0, 0]; and the two-dimensional matrix of normal ECG data is [1.16, 0.95; 5, 6].

[0092] S8: Construct an ECG wave classification model based on the machine learning algorithm model.

[0093] The electrocardiogram classification model can be implemented based on a classification model in any machine learning algorithm model in the prior art. The electrocardiogram classification model in this embodiment is constructed based on a support vector machine model.

[0094] A training set is constructed based on the ECG feature matrix K of historical data, and labels are constructed for normal ECG and atrial fibrillation ECG data respectively. Then, the ECG classification model is trained based on the training set to obtain a trained ECG classification model.

[0095] S9: Obtain the electrocardiogram data to be identified, calculate the corresponding electrocardiogram feature matrix K; send the electrocardiogram feature matrix K to the classification model for classification, and obtain the identification result of the electrocardiogram data to be identified; complete the detection of the electrocardiogram atrial fibrillation data.

[0096] After using the technical solution of the present invention, the ECG data to be identified is segmented, and the data features of the ECG segments to be identified are strengthened. There is no need to identify the specific waveform of the ECG to be identified, and the atrial fibrillation ECG data can be identified based on the irregular characteristics of the waveform unique to the atrial fibrillation ECG data and its difference from the normal ECG data; the method has low computational complexity and high recognition efficiency.

Claims

1. A method for detecting atrial fibrillation in electrocardiogram data based on machine learning, comprising the following steps: S1: collect original ECG data; It is characterized in that it also includes the following steps: S2: segmenting the ECG waveform of the original ECG data; According to the preset segmentation length, the original ECG data is segmented into equal lengths, and the obtained ECG segments are recorded as: ECG segment 1; The number of the electrocardiogram segment 1 is recorded as x; S3: performing n consecutive sampling operations of different sizes on all the electrocardiogram segments to obtain corresponding sampling operation results; The sampling operation includes: a downsampling and an upsampling performed sequentially; S4: Counting the distance between the original data of each electrocardiogram segment 1 and the corresponding sampling operation result at each sampling point, recorded as: feature distance Distance; S5: randomly selecting x points in the original ECG data as starting points, and cutting according to the segmentation length; cutting out x ECG segments of equal length; S6: Obtain each of the second electrocardiogram segments one by one, search in the original electrocardiogram data to obtain similar segments, and count the number of similar segments corresponding to each of the second electrocardiogram segments, recorded as: similar number Similar; S7: Construct the ECG feature matrix K based on the feature distance Distance and the similarity number Similar; K = [Distance; Similarity], the matrix size of K is [2, x]; S8: Construct an ECG classification model based on a machine learning algorithm model; Constructing a training set based on the electrocardiogram feature matrix K of historical data, training the electrocardiogram classification model, and obtaining the trained electrocardiogram classification model; S9: Obtain the electrocardiogram data to be identified, calculate the corresponding electrocardiogram feature matrix K; send the electrocardiogram feature matrix K to the classification model for classification to obtain the identification result of the electrocardiogram data to be identified; complete the detection of the electrocardiogram atrial fibrillation data.

2. According to claim 1, a method for detecting atrial fibrillation in electrocardiogram data based on machine learning is characterized in that: The segmentation length is set to be greater than or equal to 2 seconds.

3. According to claim 1, a method for detecting atrial fibrillation in electrocardiogram data based on machine learning is characterized in that: In step S3, the value of the sampling operation times n is: n≥5.

4. According to claim 1, a method for detecting atrial fibrillation in electrocardiogram data based on machine learning, characterized in that: The value of the number x of the electrocardiogram segment 1 and the electrocardiogram segment 2 satisfies the condition: x≥2.

5. According to claim 1, a method for detecting atrial fibrillation in electrocardiogram data based on machine learning, characterized in that: In step S4, the characteristic distance Distance is calculated as follows: Distance=[(ECG′1-ECG 1 1) 2 +(ECG′2-ECG 1 2) 2 +…+(ECG′ t -ECG 1 t ) 2 )]; Where t is the abscissa of the ECG segment including the total number of sampling points involved in the calculation, (ECG 1 1.ECG 1 2……ECG 1 t ) is the value at each sampling point in the first segment of the electrocardiogram; (ECG′1,ECG′2…ECG′ t ) is the value at each sampling point in the electrocardiogram segment of the sampling operation result.

6. The method for detecting atrial fibrillation in electrocardiogram data based on machine learning according to claim 1, characterized in that: In step S6, the method for determining the similar segments is as follows: a1: Obtain each of the second electrocardiogram segments one by one, recorded as: the segment to be retrieved; Initialize the corresponding similarity number Similar to 0; a2: the first sampling point of reading the original ECG data, recorded as the starting point; a3: based on the indicated starting point, obtain the electrocardiogram data of the segmented length backward, recorded as: the segment to be compared; a4: Calculate the characteristic distance Distance between the segment to be retrieved and the segment to be compared, denoted as: D; a5: Compare D with the preset similarity threshold S; If D>S, it means the two are not similar, and go to step a7; Otherwise, it means the two are similar, and execute step a6; a6: increase the number of similarities Similar corresponding to the fragment to be searched by one, and then execute step a7; a7: Get the next sampling point, recorded as the starting point, and repeat steps a4 to a5 until all sampling points in the original ECG data are involved in the calculation.

7. The method for detecting atrial fibrillation in electrocardiogram data based on machine learning according to claim 1, characterized in that: The electrocardiogram classification model is constructed based on a support vector machine model.

Citation Information

Patent Citations

  • Sleep stage determining method and sleep stage determining system

    CN104720748A

  • Multi-modal biometric identification

    CN108135502A

  • Electrocardiograph data segmentation method and device, and readable storage medium

    CN109567789A

  • Multi-lead arrhythmia intelligent diagnosis method based on MODWT and LSTM

    CN110236529A

  • System for creating composite map

    CN114269272A