An electrocardiogram classification method, classification device, equipment and storage medium

By dividing the signal feature map of the ECG into timing information and channel information, and using the Transformer model to extract features, the problem of low accuracy of electrogram classification in the existing technology is solved, and more efficient and accurate electrogram classification is achieved.

CN116327210BActive Publication Date: 2025-07-08SHENZHEN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310156248.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-14
Publication Date
2025-07-08
Estimated Expiration
2043-02-14

AI Technical Summary

Technical Problem

The classification results of electrocardiograms in the prior art are relatively accurate, and it is impossible to effectively distinguish the timing characteristics and channel characteristics contained in the electrocardiogram.

Method used

The Transformer model is used to process the signal feature map of the electrocardiogram, divided it into timing information and channel information, and the timing characteristics and channel characteristics are extracted respectively, and the classification results of the electrocardiogram are obtained by fusing these characteristics.

Benefits of technology

It improves the accuracy and speed of electrocardiogram classification and can better reflect the user's heart disease.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116327210B_ABST
    Figure CN116327210B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of electrocardiogram processing, and specifically relates to an electrocardiogram classification method, classification device, equipment and storage medium. The present invention first extracts the signal feature map of the electrocardiogram, then distinguishes the timing information and channel information included in the signal feature map, and then extracts the timing features from the timing information and the channel features from the channel information by using the transformer algorithm. Finally, the classification result of the electrocardiogram is given by comprehensively considering the timing features and channel features, and the classification result is used to reflect the user's heart disease. From the above analysis, it can be seen that the present invention processes the timing information and channel information separately, which improves the classification speed on the one hand and the accuracy of the classification result on the other hand.
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 processing, and specifically relates to an electrocardiogram classification method, classification device, equipment and storage medium. Background Technique

[0002] Cardiovascular diseases (CVD) refer to the general term for diseases in which the heart or blood vessels are abnormal. Common cardiovascular diseases include arrhythmia, coronary atherosclerotic heart disease (CAHD), stroke, etc. Cardiovascular diseases are characterized by high incidence and high fatality rate.

[0003] Electrocardiography (ECG) is a non-invasive detection method that captures the abnormal activities of the heart by capturing the electrical conduction signals of the heart, and then makes a diagnosis of cardiovascular diseases. ECG is currently the diagnostic tool with the most application scenarios and the highest application frequency in the clinical diagnosis of cardiovascular diseases. The standard electrocardiogram has 12 leads, including 6 limb leads (I, II, III, aVR, aVL, aVF) and 6 chest leads (V1, V2, V3, V4, V5, V6). These leads (the leads correspond to the electrodes placed on the human body and are used to record the electrical signals of the human body collected by the electrodes) are used to record the body surface electrodes. Accurately interpreting an electrocardiogram requires professionals with rich experience. The method of manual diagnosis is subjective, and there are many types of cardiovascular diseases. Misinterpreting the electrocardiogram will lead to inappropriate clinical diagnoses, resulting in adverse consequences.

[0004] Traditional automatic electrocardiogram diagnosis is based on machine learning algorithms. Researchers first use signal processing techniques to extract useful features from the ECG (manually extracted), and then use these features as the input of the ML classifier. However, the process of manually extracting features is cumbersome and time-consuming, and it is impossible to achieve end-to-end ECG diagnosis. There are many types of cardiovascular diseases, and these methods are often only applicable to the diagnosis of specific types of arrhythmia diseases. It is difficult to mine the deep pathological information contained in the electrocardiogram and unable to characterize the fundamental differences between various categories. Convolutional neural network (CNN) is a neural network with good performance in deep learning, which can extract data features through local receptive fields, weight sharing, downsampling, etc. The global features of the ECG are extracted by the CNN to achieve signal classification, but the CNN has poor learning ability for global features. There are many types of cardiovascular diseases, and the CNN cannot extract the subtle pathological features of different types of ECG signals. The Transformer model has achieved good performance in various tasks relying on its strong global context information learning ability and has good interpretability. In the prior art, neither the CNN nor the Transformer distinguishes the temporal features and channel features contained in the electrocardiogram when classifying the electrocardiogram, resulting in a low accuracy of the classification result.

[0005] In summary, the accuracy of the classification result of the electrocardiogram in the prior art is low.

[0006] Therefore, the prior art still needs to be improved and enhanced. Summary of the Invention

[0007] To solve the above technical problems, the present invention provides an electrocardiogram classification method, classification device, equipment and storage medium, which solves the problem of low accuracy of the classification result of the electrocardiogram in the prior art.

[0008] To achieve the above object, the present invention adopts the following technical solutions:

[0009] In the first aspect, the present invention provides an electrocardiogram classification method, which includes:

[0010] Extract the signal feature map of the electrocardiogram;

[0011] Divide the signal feature map into temporal information and channel information, where the temporal information is used to characterize the electrical signals of the leads, the leads are used to form the electrocardiogram, and the channel information is used to characterize the positions of the leads on the human body;

[0012] Apply the transformer to the temporal information and the channel information respectively to obtain the temporal features corresponding to the temporal information and the channel features corresponding to the channel information;

[0013] Based on the timing characteristics and the channel characteristics, obtain the classification result of the electrocardiogram.

[0014] In one implementation, the extracting the signal feature map of the electrocardiogram includes:

[0015] Apply a convolution algorithm to the electrocardiogram;

[0016] Perform a normalization operation on the convolution result of the electrocardiogram to obtain the electrocardiogram after normalization;

[0017] Apply the activation function ReLu to the electrocardiogram after normalization to obtain the electrocardiogram with signal intensity greater than the threshold, denoted as the standard electrocardiogram;

[0018] Perform a max pooling operation on the standard electrocardiogram;

[0019] Apply a residual algorithm to the standard electrocardiogram after the max pooling operation to obtain the signal feature map of the electrocardiogram.

[0020] In one implementation, the dividing the signal feature map into timing information and channel information, where the timing information is used to characterize the electrical signals of the leads, the leads are used to form the electrocardiogram, and the channel information is used to characterize the positions of the leads on the human body, includes:

[0021] Multiply the signal feature map by a weight matrix set for the channels, and then add a constant matrix to obtain the channel information;

[0022] Multiply the transpose matrix of the matrix corresponding to the signal feature map by a weight matrix set for the timing, and then add a constant matrix to obtain the initial timing information;

[0023] Determine the positions of each data point in the initial timing information in the time series, denoted as the timing positions;

[0024] Based on the timing positions and the initial timing information, obtain the final timing information.

[0025] In one implementation, the applying transformers to the timing information and the channel information respectively to obtain the timing characteristics corresponding to the timing information and the channel characteristics corresponding to the channel information includes:

[0026] Determine a number of self-attention mechanism modules that make up each of the transformers;

[0027] Apply a number of self-attention mechanism modules to the channel information and the final timing information respectively to obtain the channel self-attention values for the channel information and the timing self-attention values for the timing information output by the number of self-attention mechanism modules respectively;

[0028] Concatenate the self-attention values of each channel to obtain the final self-attention value of the channel;

[0029] Concatenate the self-attention values of each time series to obtain the final self-attention value of the time series;

[0030] According to the final time series information and the final self-attention value of the time series, obtain the time series feature;

[0031] According to the channel information and the final self-attention value of the channel, obtain the channel feature.

[0032] In one implementation, the obtaining the time series feature according to the final time series information and the final self-attention value of the time series includes:

[0033] Add the final time series information and the final self-attention value of the time series and then perform normalization processing to obtain the normalized value of the time series information;

[0034] Input the normalized value of the time series information into the feed-forward neural network layer to obtain the output value of the feed-forward neural network layer;

[0035] According to the normalized value of the sum of the normalized value of the time series information and the output value of the feed-forward neural network layer, obtain the time series sub-feature output by each transformer;

[0036] According to the time series sub-feature output by each transformer, obtain the time series feature.

[0037] In one implementation, the obtaining the classification result of the electrocardiogram according to the time series feature and the channel feature includes:

[0038] Concatenate the time series feature and the channel feature to obtain the concatenated feature;

[0039] Calculate the assigned label corresponding to the concatenated feature;

[0040] Concatenate the assigned label, the time series feature and the channel feature to obtain the final concatenated result;

[0041] According to the final concatenated result, obtain the classification result of the electrocardiogram.

[0042] In one implementation, the extraction of the signal feature map of the electrocardiogram and the obtaining of the classification result of the electrocardiogram according to the time series feature and the channel feature are both implemented by a trained neural network, and the transformer is also located in the same trained neural network. The training method of the trained neural network includes:

[0043] Downsample the sample electrocardiogram to obtain the downsampled electrocardiogram;

[0044] Unify the signal time length of the downsampled electrocardiogram to obtain an electrocardiogram with a unified time length;

[0045] Train the neural network based on the electrocardiogram with a unified time length.

[0046] In a second aspect, an embodiment of the present invention further provides an electrocardiogram classification device, where the device includes the following components:

[0047] A feature extraction module for extracting the signal feature map of the electrocardiogram;

[0048] A signal division module for dividing the signal feature map into temporal information and channel information, where the temporal information is used to represent the electrical signals of the leads, the leads are used to form the electrocardiogram, and the channel information is used to represent the positions of the leads on the human body;

[0049] A feature conversion module for applying a transformer to the temporal information and the channel information respectively to obtain the temporal feature corresponding to the temporal information and the channel feature corresponding to the channel information;

[0050] A classification module for obtaining the classification result of the electrocardiogram based on the temporal feature and the channel feature.

[0051] In a third aspect, an embodiment of the present invention further provides a terminal device, where the terminal device includes a memory, a processor, and an electrocardiogram classification program stored in the memory and executable on the processor. When the processor executes the electrocardiogram classification program, the steps of the above-mentioned electrocardiogram classification method are implemented.

[0052] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which an electrocardiogram classification program is stored. When the electrocardiogram classification program is executed by a processor, the steps of the above-mentioned electrocardiogram classification method are implemented.

[0053] Advantageous effects: The present invention first extracts the signal feature map of the electrocardiogram, then distinguishes the temporal information and channel information contained in the signal feature map, then extracts the temporal feature from the temporal information and the channel feature from the channel information by using the transformer algorithm, and finally comprehensively considers the temporal feature and the channel feature to give the classification result of the electrocardiogram, which is used to reflect the user's heart disease. From the above analysis, it can be seen that the present invention processes the temporal information and the channel information separately, which improves the classification speed on the one hand and the accuracy of the classification result on the other hand. Description of the Drawings

[0054] Figure 1 is the overall flowchart of the present invention;

[0055] Figure 2 is the model framework structure diagram in the embodiment of the present invention;

[0056] Figure 3 is the Conv block structure diagram in the embodiment of the present invention;

[0057] Figure 4 is the Residual block structure diagram in the embodiment of the present invention;

[0058] Figure 5 is the Transformer block structure diagram in the embodiment of the present invention;

[0059] Figure 6 is the schematic diagram of feature extraction based on the self-attention mechanism in the embodiment of the present invention;

[0060] Figure 7 is the structure diagram of the gating unit in the embodiment of the present invention;

[0061] Figure 8 is the internal structure principle block diagram of the terminal device provided in the embodiment of the present invention. Specific embodiments

[0062] The following combines the embodiments and the accompanying drawings of the specification to clearly and completely describe the technical solutions in the present invention. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention.

[0063] According to research, cardiovascular disease (DVD) is a general term for diseases with abnormalities in the heart or blood vessels. Common cardiovascular diseases include arrhythmia, coronary heart disease (CAHD), stroke, etc. Cardiovascular diseases are characterized by high morbidity and mortality. Electrocardiography is a non-invasive detection method that captures abnormal heart activity by capturing cardiac conduction signals, and then diagnoses cardiovascular diseases. ECG is currently the most frequently used diagnostic tool in the clinical diagnosis of cardiovascular diseases. The standard electrocardiogram has 12 leads, including 6 limb leads (I, II, III, aVR, aVL, aVF) and 6 chest leads (V1, V2, V3, V4, V5, V6). These leads (leads correspond to electrodes placed on the human body and are used to record human electrical signals collected by electrodes) are used to record surface electrodes. Accurate interpretation of ECG requires experienced professionals. Manual diagnosis methods are subjective and there are many types of cardiovascular diseases. Misinterpretation of ECG can lead to inappropriate clinical diagnosis, resulting in adverse consequences. Traditional automatic ECG diagnosis is based on machine learning algorithms. Researchers first use signal processing technology to extract useful features from ECG (manual extraction), and then use these features as input to the ML classifier. However, the manual feature extraction process is cumbersome and time-consuming, and it is impossible to achieve end-to-end ECG diagnosis. There are many types of cardiovascular diseases. These methods are often only applicable to the diagnosis of a few specific types of arrhythmia diseases. It is difficult to mine the deep pathological information contained in the ECG and cannot characterize the fundamental differences between categories. Convolutional neural network (CNN) is a neural network with better performance in deep learning. It can realize data feature extraction through local receptive field, weight sharing, downsampling, etc. CNN extracts global features of ECG to achieve signal classification, but CNN has poor learning ability for global features. There are many types of cardiovascular diseases, and CNN cannot extract subtle pathological features of different types of ECG signals. The Transformer model has achieved good performance in various tasks and has good interpretability by relying on its powerful global context information learning ability. In the existing technology, neither CNN nor Transformer distinguishes between the timing features and channel features contained in the electrocardiogram when classifying the electrocardiogram, resulting in low accuracy of the classification results.

[0064] To solve the above technical problems, the present invention provides an electrocardiogram classification method, classification device, equipment and storage medium, which solves the problem of low accuracy of the classification results of electrocardiograms in the prior art. Specifically in implementation, first, the signal feature map of the electrocardiogram is extracted, then the signal feature map is divided into temporal information and channel information. After that, the transformer is applied to the temporal information and channel information respectively to obtain the temporal feature corresponding to the temporal information and the channel feature corresponding to the channel information. Finally, based on the temporal feature and the channel feature, the classification result of the electrocardiogram is obtained. The present invention can improve the accuracy of the classification result.

[0065] For example, the temporal information and the channel information are distinguished from the signal feature map of the electrocardiogram. The temporal information is used to represent the electrical signals collected by the electrodes (the electrodes arranged on the body can be called leads) arranged on the body at each moment, and the channel information is used to represent the positions of the leads on the human body (for example, the limb leads are located on the limbs of the human body, and the chest leads are located on the chest of the human body). The transformer is used to extract the temporal feature from the temporal information, and the transformer is used to extract the channel feature from the channel information. Finally, the temporal feature and the channel feature are fused to obtain the classification result for the electrocardiogram. The classification result corresponds to the disease information. For example, the disease corresponding to the classification result of A is A, and the disease corresponding to the classification result of B is B.

[0066] Exemplary method

[0067] The electrocardiogram classification method of this embodiment can be applied to a terminal device. The terminal device can be a terminal product with an image function, such as a cardiac detector, etc. In this embodiment, as Figure 1 shown, the electrocardiogram classification method specifically includes the following steps:

[0068] S100, training a neural network.

[0069] As Figure 2 shown, a low-dimensional embedding extraction module (used to extract the subsequent signal feature map X), a channel module (used to extract the subsequent channel feature C), a temporal module (used to extract the subsequent temporal feature T), and a feature fusion and classification module constitute the neural network. And training the neural network requires the use of training data. In one embodiment, the following preprocessing is performed on the training data:

[0070] The training data includes normal electrocardiograms and electrocardiograms of eight cardiovascular diseases in Table 1, namely atrial fibrillation (AF), first-degree atrioventricular block (I-AVB), left bundle branch block (LBBB), right bundle branch block (RBBB), premature atrial contraction (PAC), premature ventricular contraction (PVC), ST-segment depression (STD), and ST-segment elevation (STE). The sampling rate of the above electrocardiogram signals is 500HZ, and the duration is between 6s and 60s. In this embodiment, abnormal data is deleted, and 6378 pieces of data remain. To unify the length of the input signal, the data set is preprocessed. The signal sampling frequency is reduced to 250HZ, and the signal time length is unified to 30s. For signals with a duration exceeding 30s, they are cropped, and the last 30 seconds of data are retained. For signals with a duration less than 30s, they are padded with zeros to 30 seconds. To reduce model overfitting and enhance generalization performance, random scaling and shifting are applied to the training set to augment the data. The scaling operation multiplies the ECG signal by a random factor sampled from a normal distribution (1, 0.01) to stretch or compress the signal amplitude. The random shift is to shift the time value of the signal.

[0071] Table 1

[0072]

[0073] S200, extract the signal feature map of the electrocardiogram.

[0074] The extraction of the signal feature map is Figure 2 low-dimensional embedding extraction (the low-dimensional embedding extraction is mainly implemented by the convolution module Conv and the residual block in the neural network in step S100). In the process of extracting the signal feature map, the twelve-lead electrocardiogram is first dimensionally reduced to reduce the computational amount, and then the feature map X is extracted.

[0075] In one embodiment, the electrocardiogram is the electrocardiogram after fusing the twelve leads. In this embodiment, step S200 includes the following steps S201 to S205:

[0076] S201, apply the convolution algorithm Conv to the electrocardiogram.

[0077] The electrocardiogram is multi-lead ECG data X′ ∈ R L×S (electrocardiogram), L is the number of leads of the preprocessed signal, S is the total length of the time of the preprocessed signal, and the multi-lead ECG data at the t-th moment is represented by X t denoted as X t =(x 1t , …, x lt ) T , and the electrical signal collected by the k-th lead is :X kt T ={x1, x2, …, x t , …, x s}.

[0078] In S202, perform a batch normalization BN operation on the convolution result of the electrocardiogram to obtain the electrocardiogram after normalization.

[0079] Batch normalization of data can accelerate the convergence speed during model training, make the model training process more stable, avoid gradient explosion or gradient disappearance, and play a certain role in regularization.

[0080] In S203, apply the activation function ReLu to the electrocardiogram after normalization to obtain the electrocardiogram with signal strength greater than the threshold, denoted as the standard electrocardiogram.

[0081] The activation function ReLu has a certain sparsity. After being sparsified by ReLU, the model can better mine relevant features, fit the training data, and improve the expression ability of the model.

[0082] In S204, perform a max pooling operation maxpoling on the standard electrocardiogram.

[0083] After inputting the electrocardiogram X′ into the low-dimensional embedding extraction module in Figure 2 , the convolution module Conv block in the low-dimensional embedding extraction module performs convolution calculations on each electrical signal x of each lead. As Figure 3 shown, Convblock consists of a Conv-BN-Relu structure plus a max pooling layer.

[0084] Steps S201 to S204 process the electrical signal x collected by the lead according to the following formula:

[0085] Output = maxpoling(G(x))

[0086] G(x) = ReLu(BN(Conv(x)))

[0087] S205. Apply the residual algorithm to the standardized electrocardiogram after the max pooling operation to obtain the signal feature map X of the electrocardiogram.

[0088] As Figure 4 shown, the main connection ( Figure 4 in the horizontal direction) of each Residual block consists of two one-dimensional convolutional layers Convld, two normalization layers BN, two activation function (ReLU) layers, and a 1×1 convolution is used in the shortcut residual connection to match the output size of the skip connection with the output size in the main connection. Four Residual blocks are concatenated to obtain the feature representation of the electrocardiogram signal. The operation process of the l-th Residual block is expressed as follows:

[0089]

[0090] y l+1 = f(v l+1 )

[0091] where v l is the input of the l-th residual block (i.e., the output of the l-1-th residual block), and represent the weights of the shortcut connection and the convolutional connection in the l-th residual block respectively, represents the residual function, and y l+1 is the final value (signal feature map X) after v l+1 passes through the ReLU activation function and the max pooling poling ( Figure 4 ReLU and poling after + in l ). When l = 0, v

[0092] In this embodiment, the reason for using a one-dimensional convolutional structure to process the electrocardiogram X′ is based on the following considerations:

[0093] The number of channels of the twelve-lead electrocardiogram data is large, and the signal data volume of each channel is large, containing many non-linear features and redundant signals. Therefore, first using a one-dimensional convolutional structure based on Resnet to process the signal can remove redundant signals, reduce the data complexity, and is beneficial for subsequent modules to extract channel features and temporal features.

[0094] S300. Divide the signal feature map X into temporal information and channel information. The temporal information is used to characterize the electrical signals of the leads, and the leads are used to form the electrocardiogram. The channel information is used to characterize the positions of the leads on the human body.

[0095] Perform a linear transformation on the signal feature map X to separate the channel information (the channel information is the channel embedding in Figure 2 , and the channel embedding is a linear projection of the feature map X in the channel dimension, representing the encoded information of the 12 leads in the 12-lead electrocardiogram) and the temporal information (the temporal information is the temporal embedding in Figure 2 , and the temporal embedding is a linear projection of the feature map X in the time dimension, representing the encoded information of all time points in each lead of the 12-lead electrocardiogram). In one embodiment, step S300 includes the following steps:

[0096] S301, multiply the signal feature map by the weight matrix W set for the channel C , and then add the constant matrix b to obtain the channel information Z c .

[0097] Z c =X·W C +b

[0098] S302, multiply the transposed matrix X of the matrix corresponding to the signal feature map T by the weight matrix W set for the time sequence t , and then add the constant matrix b to obtain the initial temporal information Z t .

[0099] Z t =X T ·W t +b

[0100] l is the hidden layer dimension in the linear transformation.

[0101] S303, determine the positions of the respective data points in the initial temporal information in the time series, denoted as the temporal position Z' t .

[0102] S304, obtain the final temporal information based on the temporal position and the initial temporal information.

[0103] Since there is no positional correlation between the leads of the 12-lead electrocardiogram, simply put, swapping the positions of different leads will not affect the output result of the model. However, there is an order correlation between the data points of the single-channel ECG signal. Therefore, the position embedding PE (pos,2i) , PE (pos,2i+1) is fused in the temporal embedding through the following formula to retain the time information.

[0104] PE (pos,2i) =sin(pos / 10000 2i / h )

[0105] PE(pos,2i+1) = cos(pos / 10000 2i / h )

[0106] Z' t = Z t + PE

[0107] where pos represents the position of the data point in the time series, and the time series feature There are a total of t time vectors, h is the length of the time vector, which is equal to l. 2i represents the even dimension in h, and (2i + 1) represents the odd dimension. Finally, the position embedding and the time series embedding are added point by point to obtain the input embedding Z' of the time series module t .

[0108] S400. For the time series information Z' t and the channel information Z c apply transformers respectively to obtain the time series features corresponding to the time series information and the channel features corresponding to the channel information respectively

[0109] As Figure 2 shown, applying N / 2 consecutive Transformers (for extracting features in the time series information or channel information) to the channel information Z c can obtain the channel feature C. Similarly, applying N consecutive Transformers to the time series information Z' t can obtain the time series feature T

[0110] In one embodiment, step S400 includes the following steps S401 to S406

[0111] S401. Determine a number of self-attention mechanism modules that make up each of the transformers

[0112] As Figure 5 shown, the Transformer includes a multi-head attention mechanism (Multi-Head Attention), and the multi-head attention mechanism includes a number of self-attention mechanisms

[0113] S402. Apply a number of self-attention mechanism modules to the channel information and the final time series information respectively to obtain the channel self-attention values Attention(Q c , K c , V c ) output by each of the self-attention mechanism modules for the channel information and the time series self-attention values Attention(Q t , K t , V t ) for the time series information

[0114] For example, the i-th self-attention mechanism has an effect on the channel information Z c And the final timing information Z' t use Figure 6 The following processing methods are performed respectively:

[0115] Q t =w qt ·Z' t , K t =w kt ·Z' t , V t =w vt ·Z' t

[0116] Q c =w qc ·Z c ,K c =w kc ·Z c ,V c =w vc ·Z c

[0117] Channel self-attention value head output by the i-th self-attention mechanism ti :

[0118]

[0119] In the formula,

[0120] The temporal self-attention value head output by the i-th self-attention mechanism ci :

[0121]

[0122] In the formula,

[0123] S403, concatenate the self-attention values ​​of each channel to obtain the final channel self-attention value MultiHead(Q c ,K c ,V c ):

[0124]

[0125] S404, concatenate the time series self-attention values ​​to obtain the final time series self-attention value MultiHead(Q t ,K t ,V t ):

[0126]

[0127] etc. are all parameter matrices of linear projection transformation.

[0128] S405. Based on the final timing information and the final temporal self-attention value, obtain the temporal feature T:

[0129] The above steps calculate the final temporal self-attention value through the multi-head attention mechanism in a Transformer. Then, a Transformer will continue to calculate the temporal feature T' based on the calculated final temporal self-attention value. The temporal feature T' output by the previous Transformer will be used as the input of the next Transformer until the last Transformer outputs the temporal feature T.

[0130] In one embodiment, step S405 includes steps S4051 to S4054 as follows:

[0131] S4051. Add the final timing information Z' t and the final temporal self-attention value MultiHead(Q t , K t , V t ), and then perform normalization processing to obtain the normalized value y of the timing information t :

[0132] y t = LayerNorm(Z' t + MultiHead(Q t , K t , V t ))

[0133] S4052. Input the normalized value of the timing information into the feed-forward neural network layer FeedForward to obtain the output value FeedForward(y t ) of the feed-forward neural network layer;

[0134] S4053. Based on the normalized value of the sum of the normalized value y of the timing information t and the output value of the feed-forward neural network layer FeedForward(y t ), obtain the temporal sub-feature Transformer(Z' t ) output by each transformer:

[0135] Transformer(Z' t ) = LayerNorm(y t+FeedForward(y t ))

[0136] S4054, Obtain the temporal feature T based on the temporal sub-features Transformer(Z' t ) output by each transformer.

[0137] The temporal sub-feature Transformer(Z′ t ) output by the previous transformer is used as the next transformer, and the output result of the last transformer is the temporal feature T.

[0138] S406, Obtain the channel feature C based on the channel information and the final channel self-attention value.

[0139] The process of obtaining the channel feature C through N / 2 transformers is the same as the process of obtaining the temporal feature T through N transformers. Because in an electrocardiogram, the temporal length of the electrocardiogram is generally greater than the number of channels of the electrocardiogram, the dimension of the temporal feature is higher than that of the channel feature (t>c). Therefore, a larger number of transformer modules are used to extract the temporal feature.

[0140] The specific process of step S406 is as follows:

[0141] yc = LayerNorm(Zc + MultiHead(Q c , K c , V c ))

[0142] Transformer(Z c ) = LayerNorm(y c + FeedForward(y c ))

[0143] The above is the channel sub-feature Transformer(Z c ) obtained by one transformer. The channel sub-feature Transformer(Z C ) obtained by the previous transformer is used as the input of the next transformer, and the output result of the last transformer is the channel feature C.

[0144] S500, Obtain the classification result of the electrocardiogram based on the temporal feature and the channel feature.

[0145] Such as Figure 7As shown, a gating unit is used to perform selective fusion on channel features and temporal features by calculating feature weights. The dimensions of the channel feature C and the temporal feature T are transformed into one dimension, concatenated together, and h is obtained through linear projection. The feature weights w c and w t are calculated through the softmax function. Finally, the feature weights are multiplied by the corresponding feature vectors respectively, and the results are concatenated to obtain the final fused feature y. After obtaining the final feature map, a fully connected layer and a Softmax classifier are used to output the predicted label to obtain the final diagnosis result.

[0146] As described above, according to the temporal features and channel features of the electrocardiogram, the electrocardiogram is classified, and different classification results indicate that the patients with the generated electrocardiogram have different diseases.

[0147] In one embodiment, step S500 includes the following steps:

[0148] S501, concatenate the temporal feature T and the channel feature C to obtain the concatenated feature Concat(C, T).

[0149] S502, calculate the assigned labels w c and w t corresponding to the concatenated feature.

[0150] w c and w t = Softmax(h)

[0151] h = W · Concat(C, T) + b

[0152] After inputting h into Softmax, Softmax outputs w c and w t these two values.

[0153] S503, concatenate the assigned labels, the temporal feature, and the channel feature to obtain the final concatenated result y:

[0154] y = Concat(C · w c , T · w t )

[0155] S504, obtain the classification result of the electrocardiogram according to the final concatenated result.

[0156] In summary, the present invention first extracts the signal feature map of the electrocardiogram, then distinguishes the timing information and channel information contained in the signal feature map, and then extracts the timing features from the timing information and the channel features from the channel information by using the transformer algorithm. Finally, the classification result of the electrocardiogram is given by comprehensively considering the timing features and channel features, and this classification result is used to reflect the user's heart disease. From the above analysis, it can be seen that the present invention processes the timing information and channel information separately, which improves the classification speed on the one hand and the accuracy of the classification result on the other hand.

[0157] In addition, the model framework of the present invention mainly consists of three parts: a low-dimensional embedding extraction module, a channel and timing feature extraction module, and a feature fusion and classification module. Because the number of channels of the twelve-lead electrocardiogram is large, the number of sample points in each channel is large, and the feature dimension is high. The present invention first uses a one-dimensional Resnet network to extract the low-dimensional embedding of the data, reducing the data dimension and complexity, and laying the foundation for the extraction of channel and timing features. Then, the low-dimensional features are respectively linearly transformed to obtain channel embeddings and timing embeddings. By using the self-attention mechanism and global modeling ability of the transformer, the channel and timing feature representations of the signal can be better learned. After extracting the channel and timing features, the present invention designs a gating unit to screen and fuse two types of useful information through the gating unit, and finally realizes classification through a softmax classifier.

[0158] Exemplary device

[0159] This embodiment also provides an electrocardiogram classification device, and the device includes the following components:

[0160] A feature extraction module, configured to extract the signal feature map of the electrocardiogram;

[0161] A signal division module, configured to divide the signal feature map into timing information and channel information, where the timing information is used to characterize the electrical signal of the lead, the lead is used to form the electrocardiogram, and the channel information is used to characterize the position of the lead on the human body;

[0162] A feature conversion module, configured to respectively apply a transformer to the timing information and the channel information to obtain the timing features corresponding to the timing information and the channel features corresponding to the channel information;

[0163] A classification module, configured to obtain the classification result of the electrocardiogram according to the timing features and the channel features.

[0164] Based on the above embodiment, the present invention also provides a terminal device, and its principle block diagram can be as Figure 8As shown. The terminal device includes a processor, a memory, a network interface, a display screen, and a temperature sensor connected via a system bus. Among them, the processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements an electrocardiogram classification method. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen. The temperature sensor of the terminal device is pre-set inside the terminal device and is used to detect the operating temperature of the internal device.

[0165] Those skilled in the art can understand that Figure 8 the block diagram of the principle shown is only a block diagram of some structures related to the solution of the present invention, and does not constitute a limitation on the terminal device to which the solution of the present invention is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.

[0166] In one embodiment, a terminal device is provided. The terminal device includes a memory, a processor, and an electrocardiogram classification program stored in the memory and executable on the processor. When the processor executes the electrocardiogram classification program, the following operation instructions are implemented:

[0167] Extract the signal feature map of the electrocardiogram;

[0168] Divide the signal feature map into timing information and channel information. The timing information is used to characterize the electrical signals of the leads, and the leads are used to form the electrocardiogram. The channel information is used to characterize the positions of the leads on the human body;

[0169] Apply a transformer to the timing information and the channel information respectively to obtain the timing features corresponding to the timing information and the channel features corresponding to the channel information;

[0170] Obtain the classification result of the electrocardiogram based on the timing features and the channel features.

[0171] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided by the present invention can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.

[0172] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or equivalently replace some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An electrocardiogram classification method, characterized in that, including: extracting a signal feature map of an electrocardiogram; dividing the signal feature map into timing information and channel information, where the timing information is used to characterize the electrical signals of leads, the leads are used to form the electrocardiogram, and the channel information is used to characterize the positions of the leads on the human body; applying a transformer to the timing information and the channel information respectively to obtain a timing feature corresponding to the timing information and a channel feature corresponding to the channel information; obtaining a classification result of the electrocardiogram based on the timing feature and the channel feature.

2. The electrocardiogram classification method according to claim 1, wherein The extracting of the signal feature map of the electrocardiogram includes: applying a convolution algorithm to the electrocardiogram; performing a normalization operation on the convolution result of the electrocardiogram to obtain the electrocardiogram after normalization; applying the activation function ReLu to the electrocardiogram after normalization to obtain the electrocardiogram with a signal intensity greater than a threshold, denoted as the standard electrocardiogram; performing a max pooling operation on the standard electrocardiogram; applying a residual algorithm to the standard electrocardiogram after the max pooling operation to obtain the signal feature map of the electrocardiogram.

3. The electrocardiogram classification method according to claim 1, wherein The dividing of the signal feature map into timing information and channel information, where the timing information is used to characterize the electrical signals of leads, the leads are used to form the electrocardiogram, and the channel information is used to characterize the positions of the leads on the human body, includes: multiplying the signal feature map by a weight matrix set for channels and then adding a constant matrix to obtain channel information; multiplying the transposed matrix of the matrix corresponding to the signal feature map by a weight matrix set for timing and then adding a constant matrix to obtain initial timing information; determining the positions of each data point in the initial timing information in the time series, denoted as timing positions; obtaining the final timing information based on the timing positions and the initial timing information.

4. The electrocardiogram classification method according to claim 3, characterized in that The applying of a transformer to the timing information and the channel information respectively to obtain a timing feature corresponding to the timing information and a channel feature corresponding to the channel information includes: determining a plurality of self-attention mechanism modules that make up each transformer; applying the plurality of self-attention mechanism modules to the channel information and the final timing information respectively to obtain channel self-attention values for the channel information and timing self-attention values for the timing information output by the plurality of self-attention mechanism modules respectively; concatenating the respective channel self-attention values to obtain a final channel self-attention value; concatenating the respective timing self-attention values to obtain a final timing self-attention value; obtaining a timing feature based on the final timing information and the final timing self-attention value; obtaining a channel feature based on the channel information and the final channel self-attention value.

5. The electrocardiogram classification method according to claim 4, characterized in that The obtaining of the timing feature based on the final timing information and the final timing self-attention value includes: adding the final timing information and the final timing self-attention value and then performing a normalization process to obtain a normalized value of the timing information; inputting the normalized value of the timing information into a feed-forward neural network layer to obtain an output value of the feed-forward neural network layer; Obtain the temporal sub-features output by each transformer based on the normalized value of the sum of the normalized value of the temporal information and the output value of the feed-forward neural network layer; Obtain the temporal feature based on the temporal sub-features output by each transformer.

6. The electrocardiogram classification method according to claim 1, characterized in that The obtaining the classification result of the electrocardiogram based on the temporal feature and the channel feature includes: Concatenate the temporal feature and the channel feature to obtain a concatenated feature; Calculate the assigned label corresponding to the concatenated feature; Concatenate the assigned label, the temporal feature, and the channel feature to obtain a final concatenated result; Obtain the classification result of the electrocardiogram based on the final concatenated result.

7. The electrocardiogram classification method according to claim 1, characterized in that Extracting the signal feature map of the electrocardiogram and obtaining the classification result of the electrocardiogram based on the temporal feature and the channel feature are both implemented by a trained neural network, and the transformer is also located in the same trained neural network. The training method of the trained neural network includes: Perform downsampling on the sample electrocardiogram to obtain the downsampled electrocardiogram; Unify the signal time length of the downsampled electrocardiogram to obtain an electrocardiogram with a unified time length; Train the neural network based on the electrocardiogram with a unified time length.

8. An electrocardiogram classification device, characterized in that, The device includes the following components: A feature extraction module for extracting the signal feature map of the electrocardiogram; A signal division module for dividing the signal feature map into temporal information and channel information. The temporal information is used to represent the electrical signals of the leads, and the leads are used to form the electrocardiogram. The channel information is used to represent the positions of the leads on the human body; A feature conversion module for applying a transformer to the temporal information and the channel information respectively to obtain the temporal feature corresponding to the temporal information and the channel feature corresponding to the channel information; A classification module for obtaining the classification result of the electrocardiogram based on the temporal feature and the channel feature.

9. A terminal device, characterized in that, The terminal device includes a memory, a processor, and an electrocardiogram classification program stored in the memory and executable on the processor. When the processor executes the electrocardiogram classification program, it implements the steps of the electrocardiogram classification method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, An electrocardiogram classification program is stored on the computer-readable storage medium. When the electrocardiogram classification program is executed by a processor, it implements the steps of the electrocardiogram classification method according to any one of claims 1-7.