Electrocardiogram cardiac beat multi-label classification method based on double-layer conditional random field

By adopting the double-layer conditional random field method in the multi-label classification of electrocardiogram, the problems of low classification accuracy and long-tail data in the prior art are solved, and higher classification accuracy and better system generalization are achieved.

CN119888328APending Publication Date: 2025-04-25AFFILIATED HOSPITAL OF JINING MEDICAL UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411949709.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The prior art has low accuracy in multi-label heart-photo classification, and the conditional random field method cannot perform multi-label classification. After multi-label merger processing, the data is severely long-tailed, and the threshold setting is not uniform, resulting in poor generalization of the system.

Method used

The multi-label classification method of electrocardiogram based on double-layer conditional random field is adopted. Through the loss calculation method and decoding method of double-layer conditional random field, the serialization characteristics of the heart beat sequence and label are fully considered, and the accuracy of multi-label heart beat classification is improved.

Benefits of technology

The accuracy of multi-label heart-photo classification is improved, and the problem of inability to perform multi-label classification and data long-tail in traditional methods is solved, and the problem of poor generalization caused by inconsistent threshold settings is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888328A_ABST
    Figure CN119888328A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of electrocardiosignals, and discloses an electrocardiogram cardiac beat multi-label classification method based on a double-layer conditional random field, and the method comprises model training and model reasoning. The model training comprises the following steps: step 1, to-be-classified cardiac beat labels altogether have P classes, and P is a positive integer; 2, an electrocardiogram data set marked with heart beat results is obtained and expressed as a set {(W1, L1), (W2, L2), (W3, L3),..., (WN, LN)}, set elements (Wi, Li) represent the ith data, the accuracy of multi-label heart beat classification is improved, the problem that a traditional conditional random field method cannot carry out multi-label classification or data is seriously long-tailed after multi-label merging processing is adopted is solved, and the accuracy of multi-label heart beat classification is improved. And the problems of non-uniform threshold setting in different data and poor system generalization are avoided to a great extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electrocardiogram signals, and in particular to an electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field. Background Art

[0002] Electrocardiogram technology is currently the most widely used heart disease examination technology and plays an irreplaceable role in the diagnosis of heart disease.

[0003] Heartbeat classification is a technical method that uses various methods to classify the type of each heartbeat in the electrocardiogram signal. With the rapid development of machine learning technology in recent years, heartbeat classification based on machine learning technology has been increasingly used in current electrocardiogram automatic diagnosis systems.

[0004] There are often multiple labels for each heartbeat in an electrocardiogram. For example, in patients with atrial fibrillation and right bundle branch block, the two labels of atrial fibrillation and right bundle branch block may appear on the same heartbeat at the same time; there may be both junctional premature beats and WPWa type preexcitation on the same heartbeat. There are countless such multiple label phenomena.

[0005] Currently, there are two main technical paths for multi-label heartbeat classification based on machine learning technology: the traditional multi-label method and the conditional random field method based on multi-label merging processing.

[0006] At present, there are two main technical paths for multi-label heart beat classification based on machine learning technology: traditional multi-label method and conditional random field method based on multi-label merging processing. However, both methods have certain problems.

[0007] Traditional multi-label classification methods can directly output multiple categories of a single heartbeat, but their essence is to stack multiple binary logistic regressions independently, and the cross entropy loss is calculated independently for each label of each heartbeat, which makes it impossible to link the serialization characteristics of the ECG signal itself at the label level, and to link all the heartbeats of a single ECG for overall analysis. Moreover, since the multiple labels of a single heartbeat are independent, the logical association between multiple labels is not taken into account. For example, in the same heartbeat, ventricular premature beats cannot appear at the same time as left bundle branch or right bundle branch block; in the same heartbeat, atrial synchronous pacing cannot appear at the same time as atrial premature beats or atrial escape beats. To compensate for the above problems, it is often necessary to add rule methods in the process of decoding the heartbeat categories, and rule methods will produce various trade-off problems. Since the multiple categories of the heartbeat are independent logistic regressions, the proportions of each category are different, resulting in different optimal thresholds. If unified trade-offs are made through rule methods, there will be a serious problem of reduced accuracy.

[0008] The conditional random field method based on multi-label merging processing is to add multi-label merging processing before the traditional conditional random field method. Multi-label merging processing is to regard the labels that can appear simultaneously in a heartbeat as a new category. This processing will transform all multi-label classification problems into single-label multi-classification problems, but it will generate a large number of new categories. In electrocardiograms, abnormal heartbeats are not common. Due to the small amount of abnormal heartbeat data, the distribution of heartbeat categories is uneven, which leads to poor classification of abnormal heartbeats. The large number of new categories generated by multi-label merging processing seriously aggravates the problem of uneven distribution of heartbeat categories, which is what is called the long-tail problem in statistics. Although the conditional random field partially alleviates the problem of uneven distribution of label categories in sequence classification problems from the perspective of global probability normalization, it is not completely solved. The large number of categories generated do not have training examples, which will cause the heartbeat classification method based on this method to be unable to give classification results for these combinations that have not appeared, which leads to poor generalization of the method. Moreover, the new labels generated by merging have certain logical connections with the single category labels that make up the new labels, while the multi-label merging process ignores these connections and assumes that each category exists independently. This assumption itself is not valid. This method has this contradiction from a theoretical level and cannot be solved.

[0009] To solve the above problems, this application proposes an electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field. Summary of the invention

[0010] The purpose of the present invention is to provide an electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field, so as to solve the problems of low accuracy of multi-label heart beat classification in the prior art proposed in the above background technology, the inability of the conditional random field method to perform classification, or the serious long-tailing of data after multi-label merging processing, the inconsistent threshold setting in different data, and poor system generalization.

[0011] To achieve the above object, the present invention provides the following technical solutions: a method for multi-label classification of electrocardiogram heart beats based on a double-layer conditional random field, the method comprising model training and model inference;

[0012] The model training steps are:

[0013] Step 1: There are P types of heartbeat labels to be classified, where P is a positive integer;

[0014] Step 2: Obtain an ECG dataset with annotated heartbeat results and represent it as a set {(W1, L1), (W2, L2), (W3, L3), …, (W N , L N )}, where the set element (Wi , L i ) represents the i-th data, where the central electrostatic data is W i , and its corresponding annotation result is L i , there are N data in the data set, W i The dimension is (len i , D), each data in the matrix is ​​a floating point number, representing the voltage value of the ECG signal of the corresponding lead and frame position, where len i is a positive integer representing the number of data frames of the ECG data, D represents the number of leads in the ECG data; L i Represented as a set

[0015]

[0016] , where the collection element (Start i,j , End i,j , Label i,j ) represents the starting position of the jth QRS complex of the i-th data in the data set. i,j And the end position End i,j , Start i,j and End i,j They are all positive integers representing the frame numbers of the start and end points, and their maximum value is len i , Label i,j is the heartbeat label set, with a total of K i heartbeats, heartbeat label set Label i,j Represented as a set Label i,j,x It represents the sequence number of the xth label of the jth heartbeat of the ith data in the ECG data set. The minimum value of this sequence number is 1 and the maximum value is P. There are V i,j Tags;

[0017] Step 3: For the i-th data in the ECG data set, use the formula Calculate the label length value Olen i , Indicates greater than or equal to len i ×The minimum integer of α, the recommended value of α is 0.25;

[0018] Step 4: For the i-th data in the ECG data set, the dimension is (Olen i , 1) the activation label matrix Act i ;

[0019] Step 5: For the i-th data in the ECG data set, the dimension is (P, K i ) heartbeat label matrix Labi , K i Indicates L i The number of heart beats in

[0020] Step 6: For the i-th data in the ECG data set, the dimension is (Olen i , K i ) output merge transformation matrix Trans i ;

[0021] Step 7, adjust the i value in steps 3, 4, 5, and 6 from 1 to N, and execute steps 3, 4, 5, and 6 in a loop to obtain the activation label matrix, heart beat label matrix, and output merge conversion matrix of each ECG data in the ECG data set;

[0022] Step 8: Initialize the neural network model M. For the i-th data in the ECG data set, the model input dimension is (len i , D) matrix, the output dimension is (Olen i , P+1), the internal trainable parameters of model M are denoted as θ M ;

[0023] Step 9: Initialize the multi-path linear chain conditional random field model MCRF. For the i-th data in the ECG data set, the model can be initialized by inputting two dimensions (Olen i , P) matrix, calculate the floating-point multipath conditional random field loss value, and the internal trainable transfer matrix parameter of the model MCRF is expressed as θ MCRF , is a matrix with dimension (P, P);

[0024] Step 10, initialize a non-transfer linear chain conditional random field model NTCRF with a dimension of 2, the model can input two matrices with dimensions (P, 2), and calculate a floating-point non-transfer conditional random field loss value;

[0025] Step 11: Collect the ECG data into the i-th data W i Input model M and get the output matrix of the model, represented as Out i ,Out i is a dimension (Olen i , P+1), the data type is floating point data;

[0026] Step 12: Out i The first column of the matrix is ​​decomposed into dimensions (Olen i , 1) is expressed as OUT i The matrix is ​​decomposed except the first column of data to get the dimension (Olen i, P) is expressed as

[0027] Step 13: Use the formula

[0028] The activation loss LossAct is obtained by calculation i , LossAct i is a floating point number. In the formula, ⊙ represents the Hadamard product operation, sigmoid represents the sigmoid function calculation, log is the logarithm calculation with base 10, and ε is the minimum bias;

[0029] Step 14: Use the formula The calculated dimension is (P, K i ) Representation Matrix The transpose of , × represents matrix multiplication;

[0030] Step 15: With Lab i Input to the model MCRF and calculate the multipath conditional random field loss, expressed as LossMCRF i ;

[0031] Step 16: With Lab i Input to the model NTCRF and calculate the conditional random field loss without transfer, expressed as LossNTCRF i ;

[0032] Step 17: Use the formula Loss i =LossMCRF i +LossNTCRF i Calculate the final loss value, expressed as Loss;

[0033] Step 18: Through the gradient back propagation algorithm, according to Loss i The value is propagated back through the optimizer to adjust θ M and θ MCRF The optimizer is the Adam optimizer;

[0034] Step 19: Constantly change i from step 11 to step 18, constantly change the samples of the input model, and adjust θ M and θ MCRF The value of

[0035] Step 20, repeatedly perform steps 11 to 19 until the average value of Loss is less than the set value, or other preset conditions are met, and then stop training. The neural network model M and the multi-path conditional random field model MCRF finally obtained are the final models to be used;

[0036] The model reasoning steps are:

[0037] S1. Obtaining ECG data W to be classified q , W q The dimension is (len q , D), each data in the matrix is ​​a floating point number, representing the voltage value of the ECG signal of the corresponding lead and frame position, where len q is a positive integer representing the number of data frames of the ECG data, and D represents the number of leads in the ECG data;

[0038] S2, obtaining the neural network model M and the multi-path conditional random field model MCRF obtained in the model training part;

[0039] S3, W q Input the neural network model M and get the matrix (Olen q , P+1), which is represented as Out q ;

[0040] S4. Out q The first column of data is split from its column data. After the first column of data is split, the dimension is (Olen q , 1) is expressed as The dimensions of other column data after splitting are (Olen q , P) matrix, expressed as

[0041] S5. Through the formula Change The value of

[0042] S6. The matrix The value greater than γ is set to 1, and the value of other parts is set to 0. The γ value is a value greater than 0 and less than 1, and it is recommended to be set to 0.5;

[0043] S7, The indexes corresponding to the starting and ending points of all the parts with consecutive values ​​of 1 in the , are recorded separately to obtain the set Denote the collection as B, where Start q,1 for The index of the first dimension corresponding to the starting point of the first continuous part of 1 in End q,1 for The index of the first dimension corresponding to the end point of the first continuous part of 1;

[0044] S8. Use 0 to initialize the dimension (Olen q , K q ) is merged into the transformation matrix, which is represented as Trans q ;

[0045] S9. For the lth element in set B, transform the matrix Trans q All first dimension indices in the table are greater than or equal to Start q,l , and less than or equal to End q,l The part assigned to

[0046] S10, from l to K q Adjust the l value in step S9, and execute step S9 repeatedly to continuously adjust Trans q , the final adjusted Trans q That is the output merge transformation matrix of the ECG data;

[0047] S11, through the formula The calculated dimension is (P, K q )

[0048] S12, extract the matrix The rth column of

[0049] S13, through the formula Get a matrix of dimension (2, P) The matrix Considered as a fence network with dimension 2 and length P, the Viterbi algorithm is used to decode the path corresponding matrix The set of indexes of values ​​{(H1, 1), (H2, 2), ..., (H p , P)}, represents the set as Path q,r , the elements in the set (H S , S) means that when the path passes through the Sth fence, it passes through the Hth fence of the fence S dimension, S is an integer greater than or equal to 1 and less than or equal to P, H S The value is 1 or 2. It represents the operation of concatenating two matrices along the second dimension of the two matrices.

[0050] S14. Set Path q,rExtract the fence index values ​​of all elements whose first number is equal to 1, convert them into corresponding labels, and form a set Represented as Label q,r ;

[0051] S15, from 1 to K q Adjust the r value in steps S12, S13, and S14, loop through steps S12, S13, and S14, and collect Label q,r , which is represented as a set Combine this set with set B according to the following formula:

[0052] , the elements in the set Indicates ECG data W q The first heartbeat starts at End point The corresponding heartbeat label set is Label q,1 .

[0053] Furthermore, the step 5 is specifically as follows:

[0054] 4.1. For the i-th data in the ECG data set, use 0 to initialize the dimension (Olen i , 1) is the activation label matrix, denoted as Act i ;

[0055] 4.2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Act i The first dimension index of the data is greater than or equal to and less than The value of part is 1, Indicates less than or equal to Start i,j ×The maximum integer of α;

[0056] 4.3 From 1 to K i Adjust the j value in step 4.2, and repeat step 4.2 to continuously adjust Act i , the final adjusted Act i It is the activation label matrix of the i-th data in the ECG dataset.

[0057] Furthermore, the step 5 is specifically as follows:

[0058] 5.1. For the i-th data in the ECG data set, use 0 to initialize the dimension to (P, K i )’s heartbeat label matrix, denoted as Lab i ;

[0059] 5.2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Lab i In the index (Label i,j,x , j) assigns a value of 1, and keeps adjusting the value of x until all labels of the heart beat are traversed;

[0060] 5.3 From 1 to K i Adjust the j value in step 5.2, and repeat step 5.2 to continuously adjust Lab i , the final adjusted Lab i It is the heartbeat label matrix of the i-th data in the ECG dataset.

[0061] Furthermore, the step 6 is specifically as follows:

[0062] 6.1. For the i-th data in the ECG data set, use 0 to initialize the dimension (Olen i , K i ) is merged into the transformation matrix, which is represented as Trans i ;

[0063] 6.2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Trans i All first dimension indices in the and less than The part assigned to

[0064] 6.3 From 1 to K i Adjust the j value in step 6.2, and repeat step 6.2 to continuously adjust Trans i , the final adjusted Trans i That is the output merge transformation matrix of the i-th data in the ECG data set.

[0065] Furthermore, the step 15 is specifically as follows:

[0066] 15.1. Take out The first column of is a matrix of dimension (P, 1);

[0067] 15.2. Remove Lab i The first column is Lab i,1 ,Lab i,1 is a matrix of dimension (P, 1);

[0068] 15.3. By formula Calculate the matrix Score with dimension (P, 1) Num ;

[0069] 15.4. Take out The ath column of is a matrix of dimension (P, 1);

[0070] 15.5. Remove Lab i The ath column represents it as Lab i,a ,Lab i,a is a matrix of dimension (P, 1);

[0071] 15.6. By formula

[0072] Adjust Score Num The value of , where LogSumExp1 means to perform LogSumExp operation on the first dimension of the matrix, +2 means to copy and expand along the second dimension of the previous matrix to the same as the second dimension of the following matrix and then perform bitwise addition operation with the following matrix;

[0073] 15.7. From 2 to K i , adjust the value of a, and repeat steps 15.4, 15.5, and 15.6 to continuously adjust the matrix Score Num The final Score Num Matrix, add all elements in the matrix and get the final floating point value represented as Numer;

[0074] 15.8. By formula Calculate the matrix Score with dimension (P, 1) Den ;

[0075] 15.9. Take out The bth column of is a matrix of dimension (P, 1);

[0076] 15.10. By formula Adjust Score Den The value of

[0077] 15.11 From 2 to K i , adjust the value of b, and repeat steps 15.9 and 15.10 to continuously adjust the matrix Score Den The final Score Den Matrix, add all elements in the matrix and get the final floating point value represented as Denom;

[0078] 15.12. LossMCRF i= LossMCRF calculated by Denom-Numer i .

[0079] Furthermore, the step 16 is specifically as follows:

[0080] 16.1. Take out The cth column of is a matrix of dimension (P, 1);

[0081] 16.2. Remove Lab i The cth column is Lab i,c ,Lab i,c is a matrix of dimension (P, 1);

[0082] 16.3. By formula Get a matrix of dimension (2, P) It represents the operation of concatenating two matrices along the second dimension of the two matrices.

[0083] 16.4. By formula Get the matrix DLab of dimension (2, P) i,c ;

[0084] 16.5. By formula Calculate the floating point value Numer;

[0085] 16.6. Take out The first column of is a matrix of dimension (2, 1);

[0086] 16.7. By formula Calculate the matrix Score with dimension (2, 1) Den ;

[0087] 16.8. Take out The sth column represents it as is a matrix of dimension (2, 1);

[0088] 16.9. By formula Adjust Score Den The value of It means that the second dimension of the previous matrix is ​​copied and expanded to be the same as the second dimension of the next matrix, and the first dimension of the next matrix is ​​copied and expanded to be the same as the first dimension of the previous matrix, and then the two expanded matrices are added bit by bit;

[0089] 16.10. Adjust the value of d from 2 to P, and repeat steps 16.8 and 16.9 to continuously adjust the matrix Score. Den The final Score Den Matrix, add all the elements in the matrix, and get the final floating point value represented as Denom c ;

[0090] 16.11. Through the formula LossNTCRF i,c =Denom c -Numer c Calculate the non-transfer conditional random field loss LossNTCRF of column c i,c ;

[0091] 16.12 From 1 to K i , adjust the value of c, loop through steps 16.1 to 16.11, and for all obtained LossNTCRF i,1 arrive The results are averaged to get the final LossNTCRF i .

[0092] Compared with the prior art, the present invention has the following beneficial effects:

[0093] The present invention sets up model training and model reasoning, and steps 15 and 16 of the model training part are loss calculation methods of double-layer conditional random fields, and steps S13 and S14 of the model reasoning part are decoding methods of double-layer conditional random fields. Compared with the traditional method, this method does not solve the problem of multi-label classification of electrocardiogram heartbeats simply by independently superimposing multiple binary classification logistic regressions, but in the model training stage, the heartbeat sequence is correlated from the label level to calculate the loss, fully considering the serialization characteristics of the label, and improving the accuracy of multi-label heartbeat classification. It also solves the problem that the traditional conditional random field method cannot perform multi-label classification, or the data is seriously long-tailed after multi-label merging processing, and except for the activation part, no threshold is used globally, which largely avoids the problem that the threshold setting is not uniform in different data and the system generalization is not good. BRIEF DESCRIPTION OF THE DRAWINGS

[0094] Figure 1 is the final loss value Loss of the electrocardiogram heart beat multi-label classification method based on double-layer conditional random fields in the present invention. i Calculation flow chart. DETAILED DESCRIPTION

[0095] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0096] See also Figure 1 ,The present invention provides a technical solution: a multi-label classification method for electrocardiogram heart beats based on a double-layer conditional random field, the method comprising model training and model reasoning;

[0097] The model training steps are:

[0098] Step 1: There are P types of heartbeat labels to be classified, where P is a positive integer;

[0099] Step 2: Obtain an ECG dataset with annotated heartbeat results and represent it as a set {(W1, L1), (W2, L2), (W3, L3), …, (W N , L N )}, where the set element (W i , L i ) represents the i-th data, where the central electrostatic data is W i , and its corresponding annotation result is L i , there are N data in the data set, W i The dimension is (len i , D), each data in the matrix is ​​a floating point number, representing the voltage value of the ECG signal of the corresponding lead and frame position, where len i is a positive integer representing the number of data frames of the ECG data, D represents the number of leads in the ECG data; L i Represented as a set

[0100]

[0101] , where the collection element (Start i,j , End i,j , Label i,j ) represents the starting position of the jth QRS complex of the i-th data in the data set. i,j And the end position End i,j , Start i,j and End i,j They are all positive integers representing the frame numbers of the start and end points, and their maximum value is len i , Label i,j is the heartbeat label set, with a total of K i heartbeats, heartbeat label set Label i,j Represented as a set Label i,j,xIt represents the sequence number of the xth label of the jth heartbeat of the ith data in the ECG data set. The minimum value of this sequence number is 1 and the maximum value is P. There are V i,j Tags;

[0102] Step 3: For the i-th data in the ECG data set, use the formula Calculate the label length value Olen i , Indicates greater than or equal to len i ×The minimum integer of α, the recommended value of α is 0.25;

[0103] Step 4: For the i-th data in the ECG data set, the dimension is (Olen i , 1) the activation label matrix Act i ;

[0104] 4.1. For the i-th data in the ECG data set, use 0 to initialize the dimension (Olen i , 1) is the activation label matrix, denoted as Act i ;

[0105] 4.2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Act i The first dimension index of the data is greater than or equal to and less than The value of part is 1, Indicates less than or equal to Start i,j ×The maximum integer of α;

[0106] 4.3 From 1 to K i Adjust the j value in step 4.2, and repeat step 4.2 to continuously adjust Act i , the final adjusted Act i That is, the activation label matrix of the i-th data in the ECG data set;

[0107] Step 5: For the i-th data in the ECG data set, the dimension is (P, K i ) heartbeat label matrix Lab i , K i Indicates L i The number of heart beats in

[0108] 5.1. For the i-th data in the ECG data set, use 0 to initialize the dimension to (P, K i )’s heartbeat label matrix, denoted as Lab i ;

[0109] 5.2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Lab i In the index (Label i,j,x , j) assign a value of 1, and keep adjusting the value of x until all the labels of the heart beat are traversed;

[0110] 5.3 From 1 to K i Adjust the j value in step 5.2, and repeat step 5.2 to continuously adjust Lab i , the final adjusted Lab i That is, the heartbeat label matrix of the i-th data in the ECG dataset;

[0111] Step 6: For the i-th data in the ECG data set, the dimension is (Olen i , K i ) output merge transformation matrix Trans i ;

[0112] 6.1. For the i-th data in the ECG data set, use 0 to initialize the dimension (Olen i , K i ) is merged into the transformation matrix, which is represented as Trans i ;

[0113] 6.2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Trans i All first dimension indices in the and less than The part assigned to

[0114]

[0115] 6.3 From 1 to K i Adjust the j value in step 6.2, and repeat step 6.2 to continuously adjust Trans i , the final adjusted Trans i That is, the output merge transformation matrix of the i-th data in the ECG data set;

[0116] Step 7, adjust the i value in steps 3, 4, 5, and 6 from 1 to N, and execute steps 3, 4, 5, and 6 in a loop to obtain the activation label matrix, heart beat label matrix, and output merge conversion matrix of each ECG data in the ECG data set;

[0117] Step 8: Initialize the neural network model M. For the i-th data in the ECG data set, the model input dimension is (len i , D) matrix, the output dimension is (Olen i, P+1), the internal trainable parameters of model M are denoted as θ M ;

[0118] Step 9: Initialize the multi-path linear chain conditional random field model MCRF. For the i-th data in the ECG data set, the model can be initialized by inputting two dimensions (Olen i , P) matrix, calculate the floating-point multipath conditional random field loss value, and the internal trainable transfer matrix parameter of the model MCRF is expressed as θ MCRF , is a matrix with dimension (P, P);

[0119] Step 10, initialize a non-transfer linear chain conditional random field model NTCRF with a dimension of 2, the model can input two matrices with dimensions (P, 2), and calculate a floating-point non-transfer conditional random field loss value;

[0120] Step 11: Collect the ECG data into the i-th data W i Input model M and get the output matrix of the model, represented as Out i ,Out i For step 1, the dimension is (Olen i , P+1), the data type is floating point data;

[0121] Step 12: Out i The first column of the matrix is ​​decomposed into dimensions (Olen i , 1) is expressed as Out i The matrix is ​​decomposed except the first column of data to get the dimension (Olen i , P) is expressed as

[0122] Step 13: Use the formula

[0123] The activation loss LossAct is obtained by calculation i , LossAct i is a floating-point number. In the formula, ⊙ represents the Hadamard product operation, sigmoid represents the sigmoid function calculation, log represents the logarithm calculation with base 10, and ε represents the minimum bias. The recommended value of ε is 1×10 -20 ;

[0124] Step 14: Use the formula The calculated dimension is (P, K i ) Representation Matrix The transpose of , × represents matrix multiplication;

[0125] Step 15: With Lab i Input to the model MCRF and calculate the multipath conditional random field loss, expressed as LossMCRF i ;

[0126] 15.1. Take out The first column of is a matrix of dimension (P, 1);

[0127] 15.2. Remove Lab i The first column is Lab i,1 ,Lab i,1 is a matrix of dimension (P, 1);

[0128] 15.3. By formula Calculate the matrix Score with dimension (P, 1) Num ;

[0129] 15.4. Take out The ath column of is a matrix of dimension (P, 1);

[0130] 15.5. Remove Lab i The ath column represents it as Lab i,a ,Lab i,a is a matrix of dimension (P, 1);

[0131] 15.6. By formula

[0132] Adjust Score Num The value of , where LogSumExp1 means to perform LogSumExp operation on the first dimension of the matrix, +2 means to copy and expand along the second dimension of the previous matrix to the same as the second dimension of the following matrix and then perform bitwise addition operation with the following matrix;

[0133] 15.7 From 2 to K i , adjust the value of a, and repeat steps 15.4, 15.5, and 15.6 to continuously adjust the matrix Score Num The final Score Num Matrix, add all elements in the matrix and get the final floating point value represented as Numer;

[0134] 15.8. By formula Calculate the matrix Score with dimension (P, 1)Den ;

[0135] 15.9. Take out The bth column of is a matrix of dimension (P, 1);

[0136] 15.10. By formula

[0137] Adjust Score Den The value of

[0138] 15.11 From 2 to K i , adjust the value of b, repeat steps 15.9 and 15.10, and continuously adjust the matrix Score Den The final Score Den Matrix, add all elements in the matrix and get the final floating point value represented as Denom;

[0139] 15.12. LossMCRF i = LossMCRF calculated by Denom-Numer i ;

[0140] Step 16: With Lab i Input to the model NTCRF and calculate the conditional random field loss without transfer, expressed as LossNTCRF i ;

[0141] 16.1. Take out The cth column of is a matrix of dimension (P, 1);

[0142] 16.2. Remove Lab i The cth column is Lab i,c ,Lab i,c is a matrix of dimension (P, 1);

[0143] 16.3. By formula Get a matrix of dimension (2, P) It represents the operation of concatenating two matrices along the second dimension of the two matrices.

[0144] 16.4. By formula Get the matrix DLab of dimension (2, P) i,c ;

[0145] 16.5. By formula Calculate the floating point value Numer;

[0146] 16.6. Take out The first column of is a matrix of dimension (2, 1);

[0147] 16.7. By formula Calculate the matrix Score with dimension (2, 1) Den ;

[0148] 16.8. Take out The dth column of is a matrix of dimension (2, 1);

[0149] 16.9. By formula Adjust Score Den The value of It means that the second dimension of the previous matrix is ​​copied and expanded to be the same as the second dimension of the next matrix, and the first dimension of the next matrix is ​​copied and expanded to be the same as the first dimension of the previous matrix, and then the two expanded matrices are added bit by bit;

[0150] 16.10. Adjust the value of d from 2 to P, and repeat steps 16.8 and 16.9 to continuously adjust the matrix Score. Den The final Score Den Matrix, add all the elements in the matrix, and get the final floating point value represented as Denom c ;

[0151] 16.11. Through the formula LossNTCRF i,c =Denom c -Numer c Calculate the non-transfer conditional random field loss LossNTCRF of column c i,c ;

[0152] 16.12 From 1 to K i , adjust the value of c, loop through steps 16.1 to 16.11, and for all obtained LossNTCRF i,1 arrive The results are averaged to get the final LossNTCRF i .

[0153] Step 17: Use the formula Loss i =LossMCRF i +LossNTCRFi Calculate the final loss value, expressed as Loss;

[0154] Step 18: Through the gradient back propagation algorithm, according to Loss i The value is propagated back through the optimizer to adjust θ M and θ MCRF The optimizer is the Adam optimizer;

[0155] Step 19: Constantly change i from step 11 to step 18, constantly change the samples of the input model, and adjust θ M and θ MCRF The value of

[0156] Step 20, repeatedly perform steps 11 to 19 until the average value of Loss is less than the set value, or other preset conditions are met, stop training, and the neural network model M and multi-path conditional random field model MCRF finally obtained are the final models to be used;

[0157] The model reasoning steps are:

[0158] S1. Obtaining ECG data W to be classified q , W q The dimension is (len q , D), each data in the matrix is ​​a floating point number, representing the voltage value of the ECG signal of the corresponding lead and frame position, where len q is a positive integer representing the number of data frames of the ECG data, and D represents the number of leads in the ECG data;

[0159] S2, obtaining the neural network model M and the multi-path conditional random field model MCRF obtained in the model training part;

[0160] S3, W q Input the neural network model M and get the matrix (Olen q , P+1), which is represented as Out q ;

[0161] S4. Out q The first column of data is split from its column data. After the first column of data is split, the dimension is (Olen q , 1) is expressed as The dimensions of other column data after splitting are (Olen q , P) matrix, expressed as

[0162] S5. Through the formula Change The value of

[0163] S6. The matrix The value greater than γ is set to 1, and the value of other parts is set to 0. The γ value is a value greater than 0 and less than 1, and it is recommended to be set to 0.5;

[0164] S7, The indexes corresponding to the starting and ending points of all the parts with consecutive values ​​of 1 in the , are recorded separately to obtain the set Denote the collection as B, where Start q,1 for The index of the first dimension corresponding to the starting point of the first continuous part of 1 in End q,1 for The index of the first dimension corresponding to the end point of the first continuous part of 1;

[0165] S8. Use 0 to initialize the dimension (Olen q , K q ) is merged into the transformation matrix, which is represented as Trans q ;

[0166] S9. For the lth element in set B, transform the matrix Trans q All first dimension indices in the table are greater than or equal to Start q,l , and less than or equal to End q,l The part assigned to

[0167] S10, from 1 to K q Adjust the l value in step S9, and execute step S9 repeatedly to continuously adjust Trans q , the final adjusted Trans q That is the output merge transformation matrix of the ECG data;

[0168] S11, through the formula The calculated dimension is (P, K q )

[0169] S12, extract the matrix The rth column of

[0170] S13, through the formula Get a matrix of dimension (2, P) The matrix Considered as a fence network with dimension 2 and length P, the Viterbi algorithm is used to decode the path corresponding matrix The set of indexes of values ​​{(H1, 1), (H2, 2), ..., (H p, P)}, represents the set as Path q,r , the elements in the set (H S , S) means that when the path passes through the Sth fence, it passes through the Hth fence of the fence S dimension, S is an integer greater than or equal to 1 and less than or equal to P, H S The value is 1 or 2. It represents the operation of concatenating two matrices along the second dimension of the two matrices.

[0171] S14, will gather Rath q,r Extract the fence index values ​​of all elements whose first number is equal to 1, convert them into corresponding labels, and form a set Represented as Label q,r ;

[0172] S15, from 1 to K q Adjust the r value in steps S12, S13, and S14, loop through steps S12, S13, and S14, and collect Label q,r , which is represented as a set Combine this set with set B according to the following formula:

[0173]

[0174] , the elements in the set Indicates ECG data W q The first heartbeat starts at End point The corresponding heartbeat label set is Label q,1 .

[0175] Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making any creative work shall fall within the scope of protection of the present invention.

Claims

1. A multi-label classification method for electrocardiogram heart beats based on a double-layer conditional random field, including model training and model reasoning, characterized in that: The model training steps are: Step 1: There are P types of heartbeat labels to be classified, where P is a positive integer; Step 2: Obtain an ECG dataset with annotated heartbeat results and represent it as a set {(W1, L1), (W2, L2), (W3, L3), …, (W N , L N )}, where the set element (W i , L i ) represents the i-th data, where the central electrostatic data is W i , and its corresponding annotation result is L i , there are N data in the data set, W i The dimension is (len i , D), each data in the matrix is ​​a floating point number, representing the voltage value of the ECG signal of the corresponding lead and frame position, where len i is a positive integer representing the number of data frames of the ECG data, and D represents the number of leads in the ECG data; Step 3: For the i-th data in the ECG data set, use the formula Calculate the label length value Olen i ; Step 4: For the i-th data in the ECG data set, the dimension is (Olen i , 1) the activation label matrix Act i ; Step 5: For the i-th data in the ECG data set, the dimension is (P, K i ) heartbeat label matrix Lab i , K i Indicates L i The number of heart beats in Step 6: For the i-th data in the ECG data set, the dimension is (Olen i , K i ) output merge transformation matrix Trans i ; Step 7, adjust the i value in steps 3, 4, 5, and 6 from 1 to N, and execute steps 3, 4, 5, and 6 in a loop to obtain the activation label matrix, the heart beat label matrix, and the output merge conversion matrix of each ECG data in the ECG data set; Step 8: Initialize the neural network model M. For the i-th data in the ECG data set, the model input dimension is (len i , D) matrix, the output dimension is (Olen i , P+1), the internal trainable parameters of model M are denoted as θ M ; Step 9: Initialize the multi-path linear chain conditional random field model MCRF. For the i-th data in the ECG data set, the model can be initialized by inputting two dimensions (Olen i , P) matrix, calculate the floating-point multipath conditional random field loss value, and the internal trainable transfer matrix parameter of the model MCRF is expressed as θ MCRF , is a matrix with dimension (P, P); Step 10, initialize a non-transfer linear chain conditional random field model NTCRF with a dimension of 2, the model can input two matrices with dimensions (P, 2), and calculate a floating-point non-transfer conditional random field loss value; Step 11: Collect the ECG data into the i-th data W i Input model M and get the output matrix of the model, represented as Out i ,Out i is a dimension (Olen i , P+1), the data type is floating point data; Step 12: Out i The first column of the matrix is ​​decomposed into dimensions (Olen i , 1) is expressed as Out i The matrix is ​​decomposed except the first column of data to get the dimension (Olen i , P) is expressed as Step 13: Use the formula The activation loss LossAct is obtained by operation i , LossAct i is a floating point number. In the formula, ⊙ represents the Hadamard product operation, sigmoid represents the sigmoid function calculation, log is the logarithm calculation with base 10, and ε is the minimum bias; Step 14: Use the formula The calculated dimension is (P, K i ) Representation Matrix The transpose of , × represents matrix multiplication; Step 15: With Lab i Input to the model MCRF and calculate the multipath conditional random field loss, expressed as LossMCRF i ; Step 16: With Lab i Input to the model NTCRF and calculate the conditional random field loss without transfer, expressed as LossNTCRF i ; Step 17: Use the formula Loss i =LossMCRF i +LossNTCRF i Calculate the final loss value, expressed as Loss; Step 18: Through the gradient back propagation algorithm, according to Loss i The value is propagated back through the optimizer to adjust θ M and θ MCRF The value of Step 19: Constantly change i from step 11 to step 18, constantly change the samples of the input model, and adjust θ M and θ MCRF The value of Step 20, repeatedly perform steps 11 to 19 until the average value of Loss is less than the set value, stop training, and the obtained neural network model M and multi-path conditional random field model MCRF are the final models to be used; The model reasoning steps are: S1. Obtaining ECG data W to be classified q , W q The dimension is (len q , D), each data in the matrix is ​​a floating point number, representing the voltage value of the ECG signal of the corresponding lead and frame position, where len q is a positive integer representing the number of data frames of the ECG data, and D represents the number of leads in the ECG data; S2, obtaining the neural network model M and the multi-path conditional random field model MCRF obtained in the model training part; S3, W q Input the neural network model M and get the matrix (Olen q , P+1), which is represented as Out q ; S4. Out q The first column of data is split from its column data. After the first column of data is split, the dimension is (Olen q , 1) is expressed as The dimensions of other column data after splitting are (Olen q , P) matrix, expressed as S5. Through the formula Change The value of S6. The matrix The values ​​greater than γ are set to 1, and the values ​​of other parts are set to 0. The γ value is a value greater than 0 and less than 1; S7. The indexes corresponding to the starting and ending points of all the parts with consecutive values ​​of 1 in the , are recorded separately to obtain the set Denote the collection as B, where Start q,1 for The index of the first dimension corresponding to the starting point of the first continuous part of 1 in End q,1 for The index of the first dimension corresponding to the end point of the first continuous part of 1; S8. Use 0 to initialize the dimension (Olen q , K q ) is merged into the transformation matrix, which is represented as Trans q ; S9. For the lth element in set B, transform the matrix Trans q All first dimension indices in the table are greater than or equal to Start q,l , and less than or equal to End q,l The part assigned to S10, from 1 to K q Adjust the l value in step S9, and execute step S9 repeatedly to continuously adjust Trans q , the final adjusted Trans q That is the output merge transformation matrix of the ECG data; S11, through the formula The calculated dimension is (P, K q ) S12, extract the matrix The rth column of S13, through the formula Get a matrix of dimension (2, P) The matrix Considered as a fence network with dimension 2 and length P, the Viterbi algorithm is used to decode the path corresponding matrix The set of indexes of values ​​{(H1, 1), (H2, 2), ..., (H P , P)}, represents the set as Path q,r , the elements in the set (H S , S) means that when the path passes through the Sth fence, it passes through the Hth fence of the fence S dimension, S is an integer greater than or equal to 1 and less than or equal to P, H S The value is 1 or 2. It represents the operation of concatenating two matrices along the second dimension of the two matrices. S14. Set Path q,r Extract the fence index values ​​of all elements whose first number is equal to 1, and convert them into corresponding labels to form a set {label q,r,1 , label q,r,2 ,…,label q,r , V q,r }, represented as Label q,r ; S15, from 1 to K q Adjust the r value in steps S12, S13, and S14, loop through steps S12, S13, and S14, and collect Label q,r , which is represented as a set Combine this set with set B according to the following formula: , the elements in the set Indicates ECG data W q The first heartbeat starts at End point The corresponding heartbeat label set is Label q,1 .

2. According to claim 1, a method for multi-label classification of electrocardiogram heart beats based on double-layer conditional random fields is characterized by: In step 2, L i Represented as a set , where the collection element (Start i,j , End i,j , Label i,j ) represents the starting position of the jth QRS complex of the i-th data in the data set. i,j And the end position End i,j , Start i,j and End i,j They are all positive integers representing the frame numbers of the start and end points, and their maximum value is len i , Label i,j is the heartbeat label set, with a total of K i heartbeats, heartbeat label set Label i,j Represented as a set Label i,j,x It represents the sequence number of the xth label of the jth heartbeat of the ith data in the ECG data set. The minimum value of this sequence number is 1 and the maximum value is P. There are V i,j tags.

3. The electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field according to claim 1, characterized in that: The step 4 is specifically as follows: 4.

1. For the i-th data in the ECG data set, use 0 to initialize the dimension (Olen i , 1) is the activation label matrix, denoted as Act i ; 4.

2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Act i The first dimension index of the data is greater than or equal to and less than The value of part is 1, Indicates less than or equal to Start i,j ×The maximum integer of α; 4.3 From 1 to K i Adjust the j value in step 4.2, and repeat step 4.2 to continuously adjust Act i , the final adjusted Act i It is the activation label matrix of the i-th data in the ECG dataset.

4. The electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field according to claim 1, characterized in that: The step 5 is specifically as follows: 5.

1. For the i-th data in the ECG data set, use 0 to initialize the dimension to (P, K i )’s heartbeat label matrix, denoted as Lab i ; 5.

2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Lab i In the index (Label i,j,x , j) assigns a value of 1, and keeps adjusting the value of x until all labels of the heart beat are traversed; 5.3 From 1 to K i Adjust the value of i in step 5.2, and repeat step 5.2 to continuously adjust Lab i , the final adjusted Lab i It is the heartbeat label matrix of the i-th data in the ECG dataset.

5. The electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field according to claim 1, characterized in that: The step 6 is specifically as follows: 6.

1. For the i-th data in the ECG data set, use 0 to initialize the dimension (Olen i , K i ) is merged into the transformation matrix, which is represented as Trans i ; 6.

2. For the i-th data in the ECG data set, for the j-th heart beat, transform the matrix Trans i All first dimension indices in the and less than The part assigned to 6.3 From 1 to K i Adjust the j value in step 6.2, and repeat step 6.2 to continuously adjust Trans i , the final adjusted Trans i That is the output merge transformation matrix of the i-th data in the ECG data set.

6. The electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field according to claim 1, characterized in that: The step 15 is specifically as follows: 15.

1. Take out The first column of is a matrix of dimension (P, 1); 15.

2. Remove Lab i The first column is Lab i,1 ,Lab i,1 is a matrix of dimension (P, 1); 15.

3. By formula Calculate the matrix Score with dimension (P, 1) Num ; 15.

4. Take out The ath column of is a matrix of dimension (P, 1); 15.

5. Remove Lab i The ath column represents it as Lab i,a ,Lab i,a is a matrix of dimension (P, 1); 15.

6. By formula Adjust Score Num The value of , where LogSumExp1 means to perform LogSumExp operation on the first dimension of the matrix, +2 means to copy and expand along the second dimension of the previous matrix to the same as the second dimension of the following matrix and then perform bitwise addition operation with the following matrix; 15.

7. From 2 to K i , adjust the value of a, and repeat steps 15.4, 15.5, and 15.6 to continuously adjust the matrix Score Num The value of Num Matrix, add all elements in the matrix and get the final floating point value represented as Numer; 15.

8. By formula Calculate the matrix Score with dimension (P, 1) Den ; 15.

9. Take out The bth column of is a matrix of dimension (P, 1); 15.

10. By formula Adjust Score Den The value of 15.11 From 2 to K i , adjust the value of b, and repeat steps 15.9 and 15.10 to continuously adjust the matrix Score Den The final Score Den Matrix, add all elements in the matrix and get the final floating point value represented as Denom; 15.

12. LossMCRF i = LossMCRF calculated by Denom-Numer i .

7. The electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field according to claim 1, characterized in that: The step 16 is specifically as follows: 16.

1. Take out The cth column of is a matrix of dimension (P, 1); 16.

2. Remove Lab i The cth column is Lab i,c ,Lab i,c is a matrix of dimension (P, 1); 16.

3. By formula Get a matrix of dimension (2, P) It represents the operation of concatenating two matrices along the second dimension of the two matrices. 16.

4. By formula Get the matrix DLab of dimension (2, P) i,c ; 16.

5. By formula Calculate the floating point value Numer; 16.

6. Take out The first column of is a matrix of dimension (2, 1); 16.

7. By formula Calculate the matrix Score with dimension (2, 1) Den ; 16.

8. Take out The dth column of is a matrix of dimension (2, 1); 16.

9. By formula Adjust Score Den The value of It means that the second dimension of the previous matrix is ​​copied and expanded to be the same as the second dimension of the next matrix, and the first dimension of the next matrix is ​​copied and expanded to be the same as the first dimension of the previous matrix, and then the two expanded matrices are added bit by bit; 16.

10. Adjust the value of d from 2 to P, and repeat steps 16.8 and 16.9 to continuously adjust the matrix Socre Den The final Score Den Matrix, add all the elements in the matrix, and get the final floating point value represented as Denom c ; 16.

11. Through the formula LossNTCRF i,c =Denom c -Numer c Calculate the non-transfer conditional random field loss LossNTCRF of column c i,c ; 16.12 From 1 to K i , adjust the value of c, loop through steps 16.1 to 16.11, and for all obtained LossNTCRF i,1 arrive The results are averaged to get the final LossNTCRF i .

8. The electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field according to claim 1, characterized in that: In step 3, Indicates greater than or equal to len i ×The minimum integer of α, the value of α is 0.

25.

9. The electrocardiogram heart beat multi-label classification method based on a double-layer conditional random field according to claim 1, characterized in that: In step 18, the optimizer is the Adam optimizer.