An adaptive electrocardiogram rhythm recognition method based on variational autoencoder
By using an adaptive electrocardiogram rhythm recognition method based on variational autoencoders, the problem of large errors in electrocardiogram data analysis is solved, and accurate identification of arrhythmias and screening of abnormal data are achieved.
Patent Information
- Application Number
- CN202311156493.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-08
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2043-09-08
AI Technical Summary
Existing ECG data analysis algorithms struggle to accurately identify arrhythmias after considering a variety of complex factors, resulting in significant errors.
An adaptive electrocardiogram (ECG) rhythm recognition method based on variational autoencoder is adopted. By collecting diverse ECG data, preprocessing and 2D processing are performed to train a neural network model. K-means clustering is used to cluster and classify the ECG data, and the model is adaptively updated to adapt to different individuals and environmental changes.
It improves the accuracy and adaptability of ECG data recognition, reduces errors, effectively distinguishes normal ECGs from different types of arrhythmias, and can identify abnormal data.
Smart Images

Figure CN117195023B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of electrocardiogram recognition, in particular to an adaptive electrocardiogram rhythm recognition method based on a variational autoencoder BACKGROUND
[0002] Arrhythmia refers to abnormal or abnormal heart activity caused by various reasons, and is usually clinically identified by collecting and analyzing electrocardiogram data, however, the abnormality of electrocardiogram data may come from individual differences, or environment, collection method and other complex factors, which are difficult to be fully considered in algorithm design, therefore, if only a static and general detection model is used to analyze a large number of people, some unexpected errors are inevitable. SUMMARY
[0003] Based on the above problems, the present application proposes a new adaptive electrocardiogram rhythm recognition method, which is realized by the following steps: an adaptive electrocardiogram rhythm recognition method based on a variational autoencoder, the method comprises:
[0004] S1: creating and training a model;
[0005] S2: importing data according to the trained model to recognize the result and classification;
[0006] S3: adaptive update.
[0007] The step of creating and training a model in S1 is:
[0008] 1) collecting a large amount of electrocardiogram data; and preprocessing the collected data;
[0009] 2) two-dimensionizing the collected and preprocessed electrocardiogram data;
[0010] 3) creating a neural network model;
[0011] 4) clustering classifier;
[0012] As a preferred, the specific steps of collecting and preprocessing in step 1) are:
[0013] (1) collecting electrocardiogram data with different interference degrees. The data needs to cover as many different populations as possible, such as different genders, different ages, different occupations, etc., to ensure the diversity of the data. At the same time, the absolute value of the voltage value is limited within a certain range, so as to prevent the influence of individual large values from being too large;
[0014] (2) filtering the obtained electrocardiogram data, and then manually labeling the electrocardiogram data according to the content of the electrocardiogram data to form a data set;
[0015] (3) Using PAA algorithm to reduce the dimension of the training set data, and make the length uniform to M.
[0016] As preferred: the specific method of the step 2) centering the two-dimensionalization of the electrocardiogram data is:
[0017] (1) Quantizing the electrocardiogram data to make it an integer distributed in [m, n];
[0018] (2) Drawing the M points of the quantized electrocardiogram data in a matrix with a size of M*M in turn;
[0019] (3) Calculating three features related to the electrocardiogram, and after quantization, drawing the positions of the electrocardiogram data points in the same size matrix in turn, and finally forming a three-dimensional matrix with quantized electrocardiogram data and corresponding features on the upper and lower sides.
[0020] The three features are:
[0021] The variance of the data within a certain range to the right or left of the data point;
[0022] The relative change difference to the right or left of the data point;
[0023] The slope of the fitting straight line of the data within a certain range to the right or left of the data point;
[0024] (4) Dividing the obtained data set into a training set for training the variational autoencoder model and an optimization set for model optimization.
[0025] As preferred: the specific method of training the neural network model in the step 3) is:
[0026] (1) The variational autoencoder uses a convolutional network as the encoding end and a deconvolutional network as the decoding end, and the training set optimization model parameters are imported in a loop to make the results at the output end as close as possible to the input end. The model can encode the input electrocardiogram data into a vector with a length of N, and can decode the vector to restore the original electrocardiogram data;
[0027] (2) Input the data of the training set into the model to train the model;
[0028] (3) Input the data of the optimization set into the model and compare the difference between the restored electrocardiogram data and the original electrocardiogram data to judge the performance of the model. If the performance is not good, return to the previous step for adjustment until the model effect reaches the expectation.
[0029] As preferred: the specific method of the clustering classifier in the step 4) is:
[0030] (1) Using K-means clustering method, the encoded electrocardio data is clustered to obtain the encoding X corresponding to the cluster center point, the length of which should be consistent with the encoding length, also N;
[0031] (2) According to the previous annotation, the encoding Y corresponding to the cluster center point of each electrocardio type is calculated, and the length is also N.
[0032] (3) Comparing the difference between X and Y, if the difference is greater than the threshold, the adjustment algorithm is adjusted to make X close to Y.
[0033] As preferred: the specific method of identifying results and classification in step 5) is:
[0034] (1) When new data W is input, it is also encoded to obtain Z, and the length should also be N;
[0035] (2) Calculate the distance from Z to each cluster center point Y, where the shortest distance is less than the preset threshold L, then judge W belongs to the corresponding type, and the distance is Euclidean distance or Manhattan distance or Chebyshev distance.
[0036] As preferred: the specific method of adaptive updating in step S3 is:
[0037] (1) If the shortest distance is greater than L, then judge W as abnormal data and exclude it;
[0038] (2) If the shortest distance is less than L, then make a weighted average of Z and Y, and the algorithm is as follows:
[0039]
[0040] Where n is the amount of original data used to calculate Y. X and Y are both vectors with length N.
[0041] In the pre-training process, after the electrocardio is encoded by the unsupervised variational autoencoder, the normal electrocardio and different types of arrhythmia are distinguished by clustering, a good general model is obtained, and the newly collected electrocardio data is classified, then the new data can also be added to the clustering to form a new clustering model, so as to better adapt to different physical conditions and environmental changes, at the same time, some data with drastic changes can also be removed after judgment, avoiding data pollution. BRIEF DESCRIPTION OF DRAWINGS
[0042] Figure 1 is a network model structure diagram;
[0043] Figure 2 is a two-dimensional feature extraction schematic diagram;
[0044] Figure 3This is a schematic diagram of sinusoidal simulated electrocardiogram data;
[0045] Figure 4 This is a schematic diagram of a quantized sine wave;
[0046] Figure 5 This is a schematic diagram of two-dimensional feature extraction of a sine wave;
[0047] Figure 6 This is a schematic diagram of a two-dimensional feature example of a sine wave. Detailed Implementation
[0048] The invention will now be described in detail with reference to the accompanying drawings: Figures 1-2 As shown, an adaptive electrocardiogram rhythm recognition method based on a variational autoencoder is described, the method comprising:
[0049] S1: Creating and training the model;
[0050] S2: Import the data based on the trained model to identify and classify the results;
[0051] S3: Adaptive update.
[0052] The steps for creating and training the model in S1 are as follows:
[0053] 1) Collect a large amount of electrocardiogram data; and preprocess the collected data;
[0054] 2) The collected and preprocessed electrocardiogram data are converted into two dimensions;
[0055] 3) Create and train a neural network model;
[0056] 4) Cluster classifier;
[0057] The specific steps for collection and preprocessing in step 1) are as follows:
[0058] (1) Collect electrocardiogram (ECG) data with varying degrees of interference. The data should cover a wide range of people, including different genders, ages, and occupations, to ensure data diversity. At the same time, limit the absolute values of voltage to a certain range to prevent excessive influence from a few large values.
[0059] (2) Filter the obtained electrocardiogram data, and then manually annotate the electrocardiogram data according to its content to form a dataset;
[0060] (3) The training data is approximated by the PAA algorithm to reduce its length to M.
[0061] The specific method for two-dimensionalizing the central electrical data in step 2) is as follows:
[0062] (1) Quantize the above electrocardiogram data to make them integers distributed in [m, n];
[0063] (2) Plot the M points of the quantified electrocardiogram data in a matrix of size M*M;
[0064] (3) Calculate the three features related to the ECG, quantize them, and then plot them sequentially in a matrix of equal size along the position of the ECG data points. The final result is a three-dimensional matrix with quantized ECG data and corresponding feature representations above and below it.
[0065] The three characteristics are as follows:
[0066] The variance of data within a certain range to the right or left of the data point;
[0067] The relative change difference to the right or left of this data point;
[0068] The slope of the fitted line for data within a certain range to the right or left of the data point;
[0069] (4) Divide the obtained dataset into a training set for training the variational autoencoder model and an optimization set for model tuning.
[0070] The specific method for training the neural network model in step 3) is as follows:
[0071] (1) This variational autoencoder uses a convolutional network as the encoder and a deconvolutional network as the decoder, and iteratively imports the training set to optimize the model parameters so that the output is as close as possible to the input. This model can encode the input ECG data into a vector of length N, and can decode this vector in reverse to restore the original ECG data;
[0072] (2) Input the training set data into the model and train the model;
[0073] (3) Input the data from the tuning set into the model and compare the difference between the restored ECG data and the original data to judge the model performance. If the performance is not good, return to the previous step for adjustment until the model effect reaches the expected level.
[0074] The specific method for the clustering classifier in step 4) is as follows:
[0075] (1) Use K-means clustering to cluster the encoded ECG data to obtain the code X corresponding to the cluster center point. Its length should be the same as the code length, which is also N.
[0076] (2) Based on the previous annotations, calculate the code Y corresponding to the cluster center point of each ECG type, which is also N in length.
[0077] (3) Compare the differences between X and Y. If the difference is greater than the threshold, the algorithm will be adjusted to make X closer to Y.
[0078] The specific method for identifying and classifying the results in step 5) is as follows:
[0079] (1) When new data W is input, it is also encoded to obtain Z, and the length should also be N;
[0080] (2) Calculate the distance from Z to each cluster center point Y. If the distance is the shortest and the shortest distance is lower than the preset threshold L, then W belongs to the corresponding type. The distance is Euclidean distance, Manhattan distance or Chebyshev distance.
[0081] As a preferred embodiment, the specific method for adaptive updating in step S3 is as follows:
[0082] (1) If the shortest distance is greater than L, then W is considered abnormal data and is excluded;
[0083] (2) If the shortest distance is less than L, then Z and Y are weighted averaged, and the algorithm is as follows:
[0084]
[0085] Where n is the amount of original data used to calculate Y. Both X and Y are vectors of length N.
[0086] like Figure 3 The figure shows a schematic diagram of sinusoidal simulated electrocardiogram data, where the horizontal axis represents time in 4ms units and the vertical axis represents the standardized voltage.
[0087] like Figure 4 As shown, this is a schematic diagram of the quantized sine wave. The horizontal axis represents the relative position after PAA approximate dimensionality reduction, and the vertical axis represents the voltage value after integerization to [3,60], which has no unit.
[0088] like Figure 5 The figure shows a schematic diagram of two-dimensional feature extraction of a sine wave. The horizontal axis represents the relative position after PAA approximate dimensionality reduction, and the vertical axis represents the voltage value after integerization to [3,60], which has no unit.
[0089] like Figure 6 The figure shows a schematic diagram of a two-dimensional feature of a sine wave. The horizontal axis represents the relative position after the PAA approximate dimensionality reduction, and the vertical axis represents the voltage value after being integerized to [3,60], which has no unit. Specific implementation examples:
[0091] 1. Modeling and training the electrocardiogram (ECG) model:
[0092] Collect electrocardiogram data:
[0093] (1) Collect ECG data with varying degrees of interference. The data should cover a wide range of people, including different genders, ages, and occupations, to ensure data diversity. At the same time, limit the absolute value of the voltage to a certain range to prevent excessive influence from a few large values.
[0094] (2) Filter the obtained electrocardiogram data, and then manually annotate the electrocardiogram data according to its content to form a dataset.
[0095] (3) The training data is approximated by the PAA algorithm to reduce its length to 64.
[0096] Two-dimensional conversion of ECG data:
[0097] (1) Quantize the above electrocardiogram data to make them integers distributed in [3,60].
[0098] (2) Plot the M points of the quantified ECG data sequentially in a 64*64 matrix.
[0099] (3) Calculate the three features related to the ECG, quantize them, and then plot them sequentially in a matrix of equal size along the positions of the ECG data points. The final result is a three-dimensional matrix with the quantized ECG data and corresponding feature representations above and below it.
[0100] The three characteristics mentioned here are:
[0101] The variance of data within a certain range to the right or left of this data point
[0102] The relative change difference to the right or left of the data point
[0103] The slope of the fitted line for data within a certain range to the right or left of this data point.
[0104] (4) Divide the obtained dataset into a training set for training the variational autoencoder model and an optimization set for model tuning.
[0105] Training neural network models
[0106] (1) This variational autoencoder uses a convolutional network as the encoding end and a deconvolutional network as the decoding end, and iteratively imports the training set to optimize the model parameters so that the output result is as close as possible to the input. This model can encode the input ECG data into a vector of length 8, and can decode this vector in reverse to restore the original ECG data.
[0107] (2) Input the training set data into the model and train the model to make it...
[0108] (3) Input the data from the tuning set into the model and compare the difference between the restored ECG data and the original data to judge the model performance. If the performance is not good, return to the previous step for adjustment until the model effect reaches the expected level.
[0109] Cluster classifier:
[0110] (1) Use K-means clustering to cluster the encoded ECG data and obtain the code X corresponding to the cluster center point. Its length should be consistent with the code length, which is also 8.
[0111] (2) Based on the previous annotations, calculate the code Y corresponding to the cluster center point of each ECG type, which is also 8 in length.
[0112] (3) Compare the differences between X and Y. If the difference is greater than the threshold, the algorithm will be adjusted to make X closer to Y.
[0113] Specifically, a specific neural network is used for recognition and classification:
[0114] Recognition results and classification:
[0115] (1) When new data W is input, it is also encoded to obtain Z, and the length should also be 8.
[0116] (2) Calculate the distance from Z to each cluster center Y. If the distance is the shortest and the shortest distance is less than the preset threshold of 0.2, then W belongs to the corresponding type. Here, the distance refers to the Euclidean distance, but Manhattan distance or Chebyshev distance can also be used instead.
[0117] Updating the trained model:
[0118] Adaptive update:
[0119] (1) If the shortest distance is greater than L, then W is considered abnormal data and is excluded.
[0120] (2) If the shortest distance is less than L, then Z and Y are weighted averaged, and the algorithm is as follows:
[0121]
[0122] Where n is the amount of original data used to calculate Y. Both X and Y are vectors of length 8.
Claims
1. An adaptive electrocardiogram rhythm recognition method based on a variational autoencoder, characterized in that: The method includes: S1: Creating and training the model; S2: Import the data based on the trained model to identify and classify the results; S3: Adaptive update; The steps for creating and training the model in S1 are as follows: 1) Collect a large amount of electrocardiogram data; and preprocess the collected data; 2) Convert the acquired and preprocessed ECG data into two dimensions: (1) Quantize the above electrocardiogram data to make them integers distributed in [m, n]; (2) Plot the M points of the quantified electrocardiogram data sequentially in a matrix of size M*M; (3) Calculate the three features related to the ECG, quantize them, and then plot them in a matrix of equal size along the position of the ECG data points. The final result is a three-dimensional matrix with quantized ECG data and corresponding feature representations on its upper and lower sides. The three characteristics are as follows: The variance of data within a certain range to the right or left of the data point; The relative change difference to the right or left of this data point; The slope of the fitted line for data within a certain range to the right or left of the data point; (4) Divide the obtained dataset into a training set for training the generative variational autoencoder model and an optimization set for model tuning; 3) Create and train a neural network model; 4) Cluster classifier.
2. The adaptive electrocardiogram rhythm recognition method based on variational autoencoder according to claim 1, characterized in that: The specific steps for collection and preprocessing in step 1) are as follows: (1) Collect ECG data with different levels of interference. The data should cover a variety of people such as gender, age and occupation as much as possible to ensure the diversity of data. At the same time, limit the absolute value of voltage to a certain range to prevent the influence of individual large values from being too great. (2) Filter the obtained electrocardiogram data, and then manually annotate the electrocardiogram data according to its content to form a dataset; (3) Use the PAA algorithm to approximate the dimensionality reduction of the training data so that its length is uniformly M.
3. The adaptive electrocardiogram rhythm recognition method based on variational autoencoder according to claim 1, characterized in that: The specific method for training the neural network model in step 3) is as follows: (1) The variational autoencoder uses a convolutional network as the encoding end and a deconvolutional network as the decoding end. It cyclically imports the training set to optimize the model parameters so that the output result is as close as possible to the input end. The model can encode the input ECG data into a vector of length N and can decode this vector in reverse to restore the original ECG data. (2) Input the training set data into the model and train the model; (3) Input the data of the tuning set into the model and compare the difference between the restored ECG data and the original data to judge the model performance. If the performance is not good, return to the previous step of adjustment until the model effect reaches the expected level.
4. The adaptive electrocardiogram rhythm recognition method based on variational autoencoder according to claim 1, characterized in that: The specific method for the cluster classifier in step 4) is as follows: (1) Using the K-means clustering method, cluster the encoded ECG data to obtain the code X corresponding to the cluster center point. Its length should be consistent with the code length, which is also N. (2) Based on the previous annotations, calculate the code Y corresponding to the cluster center point of each ECG type, with a length of N; (3) Compare the differences between X and Y. If the difference is greater than the threshold, the algorithm will be adjusted to make X closer to Y.
5. The adaptive electrocardiogram rhythm recognition method based on variational autoencoder according to claim 1, characterized in that: The specific method for identifying and classifying the results in step 5) is as follows: (1) When new data W is input, it is also encoded to obtain Z, and its length should also be N; (2) Calculate the distance from Z to each cluster center point Y. If the distance is the shortest and the shortest distance is lower than the preset threshold L, then W belongs to the corresponding type. The distance is Euclidean distance, Manhattan distance or Chebyshev distance.
6. The adaptive electrocardiogram rhythm recognition method based on variational autoencoder according to claim 1, characterized in that: The specific method for adaptive updating in step S3 is as follows: (1) If the shortest distance is greater than L, then W is considered abnormal data and should be excluded; (2) If the shortest distance is less than L, then Z and Y are weighted averaged, and the algorithm is as follows: Where n is the amount of original data used to calculate Y, and X and Y are both vectors of length N.
Citation Information
Patent Citations
Electrocardiogram data quality evaluation method and device
CN108573227A
Sentiment classification method of 3D matrix and multi-dimensional convolutional network, medium and equipment
CN113558644A
Electrocardiogram-based arrhythmia identification and detection method and system
CN116503673A