A method and system for classifying electrocardiogram signals based on multi-domain feature learning
Through the multi-domain feature learning method, combined with global spatio-temporal features and heart rhythm feature channels, the problem of multi-domain information extraction in ECG signal classification is solved, the accuracy and efficiency of atrial fibrillation diagnosis are improved, and technical support for atrial fibrillation diagnosis is provided.
Patent Information
- Application Number
- CN202210297296.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-24
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2042-03-24
AI Technical Summary
Existing technology is difficult to effectively extract multi-domain information in ECG signal classification, resulting in detection performance that cannot meet clinical needs. Especially in the diagnosis of atrial fibrillation, there are problems such as high misdiagnosis rate and low diagnostic efficiency.
An ECG signal classification method based on multi-domain feature learning is adopted to capture the heart rhythm characteristics and atrial activity characteristics of the ECG signal by deploying a global spatiotemporal feature channel and two feature enhancement channels, and combines local features with global features through a feature fusion layer. , improve the classification accuracy and interpretability of the model.
It achieves a more complete representation of patients' ECG characteristics, improves the effectiveness and accuracy of the model's classification results, provides strong technical support for atrial fibrillation diagnosis, reduces the misdiagnosis rate and improves diagnostic efficiency.
Smart Images

Figure CN114652322B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electrocardiogram signal classification and deep learning, and specifically relates to an electrocardiogram signal classification method and system based on multi-domain feature learning. Background Art
[0002] With the development of my country's social economy, the lifestyle of the people has undergone profound changes. The fast pace of life and heavy work pressure have led to increasingly prominent health problems for residents and are becoming younger. According to the statistical results of the "Report on the Nutrition and Chronic Disease Status of Chinese Residents (2020)", cardiovascular disease has become the biggest threat to the health of residents. Arrhythmia is the most common group of cardiovascular diseases. Although most arrhythmias are not directly life-threatening, they may cause other serious heart diseases and are one of the main causes of sudden cardiac death. For example, atrial fibrillation (AF) is a cardiovascular disease characterized by rapid arrhythmias. About half of cardiovascular deaths and 15% of global deaths in the world are caused by rapid arrhythmias. When atrial fibrillation occurs, the atrium loses its normal and effective contraction function, the heartbeat speeds up, the heart rate increases, and the heartbeat is irregular, which can easily induce thrombosis, cerebral stroke, heart failure and other diseases, and in severe cases can endanger life. Studies in recent years have found that nearly 20% of elderly patients with ischemic stroke are attributed to atrial fibrillation. Many patients suffer from language dysfunction, deterioration of thinking ability, limb movement dysfunction and other problems due to the neurological damage caused by atrial fibrillation, which seriously reduces their quality of life.
[0003] The early stage of atrial fibrillation is usually characterized by paroxysmal and no obvious symptoms, which is easy to be ignored by patients, making it impossible to carry out effective medical intervention at the best treatment time. Electrocardiogram (ECG) is a commonly used non-invasive tool for cardiovascular disease examination in medical diagnosis. It is a curve diagram that records the potential changes of cardiac activity. It is mainly used to reflect human cardiac activity, assist in the diagnosis of cardiovascular disease and inspect the status of artificial heart pacing. Traditional diagnosis is mainly completed by experienced doctors through visual observation of ECG characteristics, which has certain limitations. Some small changes in amplitude and duration cannot be clearly distinguished by the naked eye and are greatly affected by the subjectivity of doctors. At the same time, atrial fibrillation has the characteristics of paroxysmal attacks. Ordinary ECG tests performed during non-attack time show ordinary sinus rhythm. Clinical technicians need to visually diagnose cardiovascular health status in long-term continuous ECG monitoring, which is a very heavy workload. Therefore, an automatic detection algorithm is needed to help clinical personnel objectively detect ECG activity. Give doctors appropriate assistance in diagnosing similar diseases such as atrial fibrillation to reduce the misdiagnosis rate of atrial fibrillation.
[0004] Although many scholars have developed many deep learning-based detection algorithms in the research of atrial fibrillation-related ECG signal classification in recent years, the detection performance still cannot meet the needs of clinical applications. Since the original ECG signal contains a large amount of multi-domain information, how to combine clinical knowledge to guide the model for targeted feature learning, comprehensively extract these implicit features from the original ECG data and effectively represent them, thereby improving the accuracy and interpretability of classification, is still a research problem that needs to be solved. Summary of the invention
[0005] In view of the deficiencies of the prior art, the present invention proposes an ECG signal classification method and system based on multi-domain feature learning. The ECG signal classification method deploys a feature learning channel to learn the global spatiotemporal features of ECG segments, and deploys two feature enhancement channels, focusing on capturing the rhythm features and atrial activity features of ECG signals, thereby realizing the extraction of multi-domain features. Furthermore, by combining local features with global features, a more complete representation of the patient's ECG features is obtained, thereby improving the effectiveness of model classification. The classification results obtained by the present invention can provide technical references for medical personnel in subsequent treatment and diagnosis processes, especially when applied to atrial fibrillation classification based on ECG signals, a higher accuracy rate can be obtained, providing strong support for doctors to diagnose atrial fibrillation.
[0006] On the one hand, the present invention provides an electrocardiogram signal classification method based on multi-domain feature learning, which comprises the following steps:
[0007] Step 1: preprocessing the ECG signal, the preprocessing at least comprising: extracting the RR interval sequence and P wave area data of the ECG signal, and performing time-frequency conversion on the P wave area data to obtain a P wave area time-frequency diagram;
[0008] Step 2: extracting multi-domain features of the ECG signal based on a multi-channel feature extraction network layer, wherein the multi-channel feature extraction network layer includes a temporal feature extraction network of a heart rhythm feature channel, a non-temporal feature extraction network of an atrial feature channel, and a global feature extraction network;
[0009] The method comprises inputting the RR interval sequence into the timing feature extraction network to obtain a cardiac rhythm feature representation of an electrocardiogram, inputting the P wave region time-frequency diagram into the non-timing feature extraction network to obtain atrial activity feature representation; and inputting the electrocardiogram into the global feature extraction network to obtain a global spatiotemporal feature representation;
[0010] Step 3: Use the feature fusion layer to fuse the multi-domain features of the ECG signal to obtain the fusion feature, and input the fusion feature of the ECG signal into the classification layer to obtain the classification result of the ECG signal;
[0011] Among them, the multi-channel feature extraction network layer, the feature fusion layer and the classification layer constitute a classification network; using the ECG signal samples and their classification labels, the ECG signal samples are processed in the manner of steps 1 to 3 and the classification network training is completed based on deep learning; then the trained classification network and the ECG signal to be classified are used, and the classification results corresponding to the ECG signal to be classified are obtained by processing in the manner of steps 1 to 3.
[0012] On the one hand, the present invention proves that the time domain characteristics of the RR sequence are of great significance to the classification of atrial fibrillation based on a large number of experiments and clinical experience; on the other hand, different from the previous unfocused frequency deconstruction of the signal, the present invention confirms the key area for the diagnosis of atrial fibrillation disease based on clinical diagnostic knowledge, locates the P wave position through medical knowledge, and focuses on extracting the frequency characteristics of the P wave area based on easily confused features. Therefore, the method described in the present invention uses the RR interval sequence and the P wave area time-frequency diagram to obtain the rhythm feature representation and atrial activity feature representation of the electrocardiogram signal respectively, and the technical solution corresponding to the classification method is particularly suitable for atrial fibrillation classification, which can guide the model to focus on the key clinical features of atrial fibrillation patients on the electrocardiogram. In addition, the technical solution described in the present invention takes into account that the complete electrocardiogram signal also has periodic characteristics, morphological characteristics and other information. In order to capture this part of the characteristics, the technical solution described in the present invention sets a global channel to supplement the time and morphological characteristics of other parts, thereby achieving the optimal combination of local features and global features.
[0013] Further optionally, the process of extracting the RR interval sequence and P wave area data of the electrocardiogram signal and performing time-frequency conversion on the P wave area data to obtain a P wave area time-frequency diagram is as follows:
[0014] Cut the ECG signal according to the defined window size and retain the ECG signal of the window size;
[0015] Perform R wave detection on the ECG signal and record the R wave position sequence, and then subtract adjacent sequence elements of the R wave position sequence to obtain the RR interval sequence;
[0016] The interval signal of Z seconds before the corresponding point of the R wave position sequence in the electrocardiogram signal is retained, and the remaining signals are all set to zero to obtain the P wave area data, and the P wave area data is regarded as atrial activity data; then the atrial activity data is time-frequency converted to obtain the P wave area time-frequency diagram.
[0017] Further optionally, when the ECG signal is cut according to the defined window size, a dynamic sliding window is selected to cut the ECG signal;
[0018] Among them, the cutting stride b is set to:
[0019]
[0020] Where B is the maximum cutting stride length, C is the category label, and θ is the preset coefficient.
[0021] Further optionally, the atrial activity feature representation is obtained by inputting the P wave region time-frequency diagram into a 2D-CNN network, and the 2D-CNN network is used as a non-temporal feature extraction network for an atrial feature channel;
[0022] The network layers of the 2D-CNN network are composed of a first two-dimensional convolutional layer, a first maximum pooling layer, a second two-dimensional convolutional layer, a second maximum pooling layer, a Flatten layer, a Dropout layer and two fully connected layers connected in sequence.
[0023] In order to extract the non-sequential features in the P wave region time-frequency diagram, the technical solution of the present invention constructs a 2D-CNN network. Considering that the 2D-CNN network performs outstandingly in acquiring image features, the present invention uses 2D-CNN to extract the atrial activity features implicit in the P wave region time-frequency diagram. Experiments have proved that 2D-CNN has good performance and effect in the application of the present invention.
[0024] Further optionally, the global spatiotemporal feature representation is obtained by inputting the ECG signal into a learning network composed of a plurality of TCN (Temporal convolutional network) blocks, each TCN block has the same structure, and the learning network composed of TCN blocks serves as the global feature extraction network;
[0025] The output of the previous TCN block is the input of the next TCN block, and the output of the last TCN block is the global spatiotemporal feature representation of the ECG signal; the output of any TCN block is expressed as:
[0026]
[0027]
[0028] In the formula, x i is the initial ECG signal of the learning network composed of several TCN blocks, the initial ECG signal is the original ECG signal or the original ECG signal after normalization and / or imbalance preprocessing, i is the number of ECG signals, Represents the ECG data input to the I+1th TCN block, is the ECG data after inputting the I-th TCN block and undergoing dilated convolution, weight normalization, linear rectification function RELU, and Dropout layer to prevent overfitting. I is the block number of the TCN block. Dilated CNN represents the dilated convolutional network layer, Activation is the activation function, and Wi represents the weight matrix of layer I.
[0029] The ECG signal is different from other signals in that it contains both temporal and non-temporal features, and the global information channel can capture these two features at the same time. Therefore, the technical solution described in the present invention uses the above network to extract global spatiotemporal features.
[0030] Further optionally, the heart rhythm feature representation of the electrocardiogram signal is obtained by padding the RR interval sequence of the electrocardiogram signal with zeros to a preset length and then inputting it into an LSTM network or a Transformer network, and the LSTM network or the Transformer network serves as a timing feature extraction network for the heart rhythm feature channel.
[0031] For the RR interval sequence, the heart rhythm feature channel mainly contains timing features, so the network with better timing feature extraction performance is selected for feature extraction.
[0032] Further optionally, the fusion feature is expressed as:
[0033]
[0034] In the formula, H i Represents the ECG signal x i The fusion features of, i is the number of ECG signals, V i is the value vector, Q i is the query vector, d k is the scaling factor, K i is the key vector, T is the transposed symbol; the query vector Q i , the key vector K i Sum value vector V i The representation is as follows:
[0035] Q i =W Q r i '
[0036] K i =W K p i '
[0037] V i =W V x i '
[0038] in, is the parameter matrix, m is the feature r i ′、p i ′、x i ′ dimension, the parameter matrix in the present invention is trained, r i ′ is the ECG signal xi The corresponding heart rhythm feature representation, p i ′ is the ECG signal x i The corresponding atrial activity feature representation, x i ′ is the ECG signal x i The corresponding global spatiotemporal feature representation.
[0039] In a second aspect, the present invention provides a system based on the electrocardiogram signal classification method, comprising:
[0040] A preprocessing module is used to preprocess the ECG signal, wherein the preprocessing at least includes: extracting the RR interval sequence and P wave area data of the ECG signal, and performing time-frequency conversion on the P wave area data to obtain a P wave area time-frequency diagram;
[0041] A multi-domain feature extraction module is used to extract multi-domain features of the ECG signal based on a multi-channel feature extraction network, wherein the multi-channel feature extraction network layer includes a temporal feature extraction network for a cardiac rhythm feature channel, a non-temporal feature extraction network for an atrial feature channel, and a global feature extraction network; the multi-domain feature extraction module is used to input the RR interval sequence into the temporal feature extraction network to obtain a cardiac rhythm feature representation of the ECG signal, input the P wave area time-frequency diagram into the non-temporal feature extraction network to obtain an atrial activity feature representation; and input the ECG signal into the global feature extraction network to obtain a global spatiotemporal feature representation;
[0042] A heart rhythm feature representation fusion module, used to fuse multi-domain features of the ECG signal using a feature fusion layer to obtain a fusion feature; a classification module, used to input the fusion feature of the ECG signal into the classification layer to obtain a classification result of the ECG signal;
[0043] A training module is used to utilize ECG signal samples and their classification labels, and complete classification network training based on data processing of the preprocessing module, the multi-domain feature extraction module, the fusion module and the classification module, and based on deep learning. The classification network consists of a multi-channel feature extraction network layer, a feature fusion layer and a classification layer.
[0044] In a third aspect, the present invention provides an electronic terminal, which at least includes: one or more processors; and one or more memories;
[0045] The processor calls the computer program stored in the memory to execute:
[0046] A method for classifying electrocardiogram signals based on multi-domain feature learning.
[0047] In a fourth aspect, the present invention provides a readable storage medium storing a computer program, wherein the computer program is called by a processor to implement:
[0048] A method for classifying electrocardiogram signals based on multi-domain feature learning.
[0049] Beneficial Effects
[0050] The present invention proposes an ECG signal classification method based on multi-domain feature learning. The method essentially constructs a classification network consisting of a multi-channel feature extraction network layer, a feature fusion layer and a classification layer to identify ECG signals. When applied to atrial fibrillation classification, the network can be used to identify ECG signals during atrial fibrillation, providing technical support for subsequent doctors' diagnosis. The classification network deploys a channel to learn the global spatiotemporal features of ECG segments, and the other two feature enhancement channels focus on capturing the rhythm features and atrial activity features of ECG signals. Finally, a multi-channel fusion mechanism is used to obtain a multi-domain feature fusion representation, and signal classification detection is completed. The present invention effectively integrates clinical diagnostic knowledge with a deep learning model, realizes the comprehensive extraction of multi-domain features, and obtains a more complete patient representation through the effective combination of local features and global features, thereby improving the effectiveness and accuracy of the model classification results. The classification results obtained by the present invention can provide technical references for medical staff's diagnosis and treatment decisions, especially when applied to atrial fibrillation classification based on ECG signals, a higher accuracy rate can be obtained, providing beneficial assistance for the diagnosis and decision-making of atrial fibrillation. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A network structure diagram of a multi-channel feature enhancement network proposed in the present invention;
[0052] Figure 2 A schematic diagram of the network structure of the 2D-CNN network proposed in the present invention;
[0053] Figure 3 The present invention is a flowchart of an electrocardiogram signal classification method based on multi-domain feature learning. DETAILED DESCRIPTION
[0054] The present invention provides an ECG signal classification method and system based on multi-domain feature learning, which integrates clinical medical knowledge with deep learning to achieve automatic classification of ECG signals. In particular, the classification method can be applied to atrial fibrillation classification, that is, to identify ECG signals when atrial fibrillation occurs and when it does not occur. In other feasible embodiments, according to classification requirements and classification accuracy, the technical ideas of the present invention can be applied to the classification of ECG signals of other functions. The present invention will be further described below in conjunction with embodiments.
[0055] Embodiment 1:
[0056] This embodiment constructs a classification network composed of a multi-channel feature extraction network layer, a feature fusion layer and a classification layer to identify ECG signals during atrial fibrillation. The classification method of this embodiment mines the features in the ECG data that correspond to clinical diagnostic knowledge, and mines the features of the ECG data from different angles by converting different domains of the one-dimensional ECG data, thereby realizing automatic learning under the guidance of medical knowledge, and finally integrating multiple features to construct a classification layer that can accurately identify patients with atrial fibrillation. The classification results of the present invention are of great significance and application value for assisting doctors in clinical decision-making. The specific implementation process of the classification method of the present invention includes the following steps:
[0057] S1: Preprocess the ECG signal. In this embodiment, the preprocessing includes the steps of normalization, imbalance processing, R wave detection, and local spectrum conversion. In other feasible embodiments, the processing steps are adaptively increased or decreased according to the needs. In this embodiment, the ECG signal that has not been preprocessed is defined as the original ECG signal. In other feasible embodiments, if the normalization and imbalance processing steps are not set, they are collectively referred to as ECG signals.
[0058] 1) The original ECG signal is normalized. In this embodiment, the Z-score method is used to perform data normalization:
[0059]
[0060] Among them, Normalized(X) is the data after the original ECG signal X is processed by data normalization, X is the original ECG signal, is the average value of the entire original ECG signal, and S is the standard deviation of the entire original ECG signal.
[0061] 2) Perform dynamic sliding window cutting on the normalized data to process data imbalance. Define the window size W and the maximum stride length B. The stride size set in the present invention is related to the proportion of the label class to the total label class. Given the maximum stride B, the cutting stride b of the class with label C is set to:
[0062]
[0063] In the formula, B is the maximum cutting step length, and C is the category label. θ is a preset coefficient, which is generally set to 1. When the data category ratio is extremely unbalanced, resulting in b being too small and the data after cutting being too similar, a value greater than 1 is taken. The setting of the coefficient θ makes all types of data balanced, further ensuring the classification accuracy and stability of the classification layer.
[0064] If the length of a record is less than the window size W, the record is removed. The classification label of the data after sliding window cutting is the same as the original classification label of the ECG data. For the ECG signal samples in the training phase, the set of ECG signals after cutting can be expressed as D = {(x i ,y i )|i=1,2,...,N},x i The length of is the same, i represents the condition number of the ECG signal, N is the total number of ECG signals, y i ∈{1,2,...,C}, C represents the number of ECG signal categories.
[0065] 3) For each ECG data x i The R wave detection algorithm in the WFDB (waveform database) software package is used to detect the R wave and record the R wave position sequence r iw , r iw Subtract the adjacent sequence elements to get the RR interval sequence rr i . The R wave position sequence r iw The RR interval sequence rr is obtained by subtracting the adjacent left sequence elements from the adjacent right sequence elements. i .
[0066] 4) For each ECG data x i and its corresponding R wave position sequence r iw Combined with the R wave position sequence r iw The regional signal of 0.4 seconds before the corresponding point is retained, and the rest of the signals are all set to zero to form the P wave area data, which is regarded as the atrial activity data X i Then, the short-time Fourier transform method is used to i Perform time-frequency conversion to obtain the P wave area time-frequency diagram Ps i It should be understood that in this embodiment, 0.4 is set, and in other feasible embodiments, it can be adaptively adjusted according to the accuracy requirements.
[0067] S2: Perform multi-domain feature extraction on ECG signals based on a multi-channel feature extraction network layer. The multi-channel feature extraction network layer includes a temporal feature extraction network for a cardiac rhythm feature channel, a non-temporal feature extraction network for an atrial feature channel, and a global feature extraction network. The multi-channel feature extraction network layer used in the present invention is a parallel three-channel module network used to learn relevant features of data in different domains. The module consists of a cardiac rhythm feature channel, an atrial activity channel, and a global feature channel. The implementation process of each channel is as follows:
[0068] 1) Heart rhythm feature channel
[0069] For ECG signals of the same length x i Will generate rr of different lengths i. By padding all rr with zeros i Length is supplemented to the maximum length rr iwMAX For the time series rr i The time series feature extraction network of this embodiment uses an LSTM network module to learn the time series features of heart rhythm. i Input the two-layer LSTM network. Finally, the ECG signal x is obtained. i The heart rhythm characteristics are expressed as i '.
[0070] r i '=LSTM(LSTM(rr i ))
[0071] It should be understood that this embodiment does not optimize the network structure of LSTM, which is an existing network and an alternative network. For example, the Transformer network, which is more popular in the field of natural language processing, has similar performance in the temporal feature extraction of this channel. However, experimental results have shown that RNN has fewer training parameters, which makes it superior to others in model training and iteration speed.
[0072] 2) Atrial characteristic channel
[0073] P wave area time-frequency diagram Ps i It mainly represents the frequency information of the atrial activity area. For non-sequential features, the non-sequential feature extraction network of this embodiment is to build a 2D-CNN network for learning. The P wave area time-frequency map Ps obtained by the input module i Input the network layer of this module, which consists of the first two-dimensional convolution layer, the first maximum pooling layer, the second two-dimensional convolution layer, the second maximum pooling layer, the Flatten layer, the Dropout layer and two fully connected layers. Finally, the ECG signal x is obtained. i The atrial activity characteristic representation p i '.
[0074] Among them, Figure 2 As shown, the 2D-CNN network of this embodiment is designed based on the features of the converted time-frequency graph, and the horizontal and vertical coordinates of the converted spectrum graph represent time and frequency respectively. Among them, the part of the time-frequency graph that contains information is the atrial activity area of each heartbeat. Therefore, the convolution kernel of the convolutional neural network is designed to be close to the average heartbeat time window in the horizontal size, and the vertical size is kept in the same horizontal and vertical ratio as the image. The first layer of the convolutional neural network obtains the features within a single heartbeat, and the second layer of the convolutional network obtains the features between heartbeats. Experimental comparison has proved that the network can achieve the optimal effect. The fully connected layer makes the final feature dimension of this channel the same as other channels.
[0075] 3) Global feature channel
[0076] For the complete ECG signal x i In this embodiment, the global feature extraction network is a learning network composed of 9 TCN blocks, each of which has the same structure. After the dilated convolution, weight normalization, linear rectification function RELU and Dropout layer to prevent overfitting, the Add the residuals to get the output of the TCN block, which is also the input of the next TCN block. Finally, the output of the 9th TCN block is represented as x i ' is the ECG signal x i The global feature representation of . The specific mathematical representation can be as follows:
[0077]
[0078]
[0079] In the formula, x i is the initial ECG signal of the learning network composed of several TCN blocks. In this embodiment, x i is an ECG signal after the original ECG signal is normalized and unbalanced preprocessed; if in other feasible embodiments, the preprocessing step is adaptively adjusted, then the initial ECG signal x i Also make adaptive adjustments. Represents the ECG data input to the I+1th TCN block, is the ECG data after inputting the I-th TCN block and undergoing dilated convolution, weight normalization, linear rectification function RELU, and Dropout layer to prevent overfitting. I is the block number of the TCN block. Dilated CNN represents the dilated convolutional network layer, Activation is the activation function, and W i represents the weight matrix of layer I.
[0080] At the same time, as the number of TCN blocks I increases, the dilation factor d of the dilated convolution increases exponentially.
[0081] d = 2 I
[0082] S3: Fusion of multi-domain representations. That is, the feature fusion layer is used to fuse the rhythm feature representation, the atrial activity feature representation and the global spatiotemporal feature representation to obtain the fusion features of the ECG signal. In this embodiment, the key-value attention mechanism is used to fuse the features extracted by the three feature learning channels and their relationships. In other embodiments, other fusion mechanisms can also be selected to achieve feature fusion, and the present invention does not specifically limit this.
[0083] For heart rhythm characteristics, r i ′, atrial activity characteristic representation p i ′, and the global feature representation x i ′, and use the parameter matrix to obtain the query vector Q i , the key vector K i Sum value vector V i . Each ECG signal x i These three vectors will be generated.
[0084] Q i =W Q r i '
[0085] K i =W K p i '
[0086] V i =W V x i '
[0087] in, is the parameter matrix,
[0088] 2) Use the softmax function to map the connection and influence between the features of each channel module to the weight coefficient, H i As the final fusion feature representation.
[0089]
[0090] in, is the scaling factor.
[0091] S4: Signal classification.
[0092] The final representation H of the ECG signal obtained by fusing the multi-domain features into the representation module i , input into the classification layer to get the prediction result:
[0093] y i =soft max(W y H i +b y )
[0094] Among them, y i ∈(0,1) represents the final classification result, that is, in this embodiment, 1 represents an ECG signal that has been identified as atrial fibrillation; and 0 represents an ECG signal that has not been identified as atrial fibrillation. is the parameter matrix, b y It should be understood that other classification algorithms or models are also applicable to the present invention.
[0095] It should be understood that the technical means recorded in steps S1-S4 are the data processing process of ECG signals. Before applying the above classification model to ECG signal classification, it is necessary to use ECG signal samples and their classification labels for model learning and training. That is, using the original ECG signal samples and their classification labels, the original ECG signals are processed in the manner of steps S1-S4, and the classification network training is completed based on deep learning. It should be understood that the training process of the classification network is to adaptively adjust the network parameters based on the training error of the samples. This implementation process can be implemented using existing network training means, and the present invention does not specifically limit this.
[0096] For the ECG signal to be classified, the trained classification network and the ECG signal to be classified are used to obtain the classification result in accordance with steps S1-S4.
[0097] In summary, the technical solution of the present invention uses the atrial activity channel and the rhythm feature channel to capture the local time-frequency features of the P wave area and the time domain features of the rhythm. On the one hand, according to a large number of experiments and clinical experience, it is proved that the time domain features of the RR sequence are of great significance to the classification of atrial fibrillation. The technical solution of the present invention adds this feature to further improve the local feature extraction. On the other hand, different from the previous unfocused frequency deconstruction of the signal, the technical solution of the present invention confirms the key diagnosis area of atrial fibrillation diseases based on clinical diagnosis knowledge, locates the P wave position through medical knowledge, and extracts the frequency features of the P wave area based on the easily confused features. Therefore, the method of the present invention can guide the model to focus on the key clinical features of the patient on the electrocardiogram. Furthermore, this embodiment takes into account that the complete electrocardiogram signal also has periodic features, morphological features and other information. In order to capture this part of the features, the technical solution of the present invention sets a global channel to supplement the time and morphological features of other parts. And the weights of different channels are trained through the attention mechanism, so as to obtain the optimal combination of local and global, strengthen the representation of atrial fibrillation features, and guide the deep learning network to focus on key areas. Experiments on multiple databases have proven that the technical solution of the present invention is specifically designed based on domain knowledge, so that the network can obtain more accurate atrial fibrillation classification results while improving the credibility of the results.
[0098] Example 2
[0099] This embodiment provides a system based on the electrocardiogram signal classification method, which includes: a preprocessing module, a multi-domain feature extraction module, a fusion module, a classification module and a training module.
[0100] Among them, the preprocessing module is used to preprocess the ECG signal, and the preprocessing at least includes: extracting the RR interval sequence and P wave area data of the ECG signal, and performing time-frequency conversion on the P wave area data to obtain a P wave area time-frequency diagram.
[0101] The multi-domain feature extraction module is used to extract multi-domain features of the ECG signal based on the multi-channel feature extraction network layer. The multi-channel feature extraction network layer includes a temporal feature extraction network for the rhythm feature channel, a non-temporal feature extraction network for the atrial feature channel, and a global feature extraction network. The multi-domain feature extraction module is used to input the RR interval sequence into the temporal feature extraction network to obtain the rhythm feature representation of the ECG signal, input the P wave area time-frequency diagram into the non-temporal feature extraction network to obtain the atrial activity feature representation; and input the ECG signal into the global feature extraction network to obtain the global spatiotemporal feature representation.
[0102] The fusion module is used to fuse the multi-domain features of the ECG signal using the feature fusion layer to obtain the fusion feature.
[0103] The classification module is used to input the fusion features of the ECG signal into the classification layer to obtain the classification result of the ECG signal.
[0104] A training module is used to utilize ECG signal samples and their classification labels, and complete classification network training based on data processing of the preprocessing module, the multi-domain feature extraction module, the fusion module and the classification module, and based on deep learning. The classification network consists of a multi-channel feature extraction network layer, a feature fusion layer and a classification layer.
[0105] Compared with Example 1, the preprocessing module includes a normalization unit, an imbalance processing unit, an RR interval sequence extraction unit, and a P wave region time-frequency diagram generation unit.
[0106] The normalization unit is used to normalize the original ECG signal.
[0107] The imbalance processing unit is used to perform dynamic sliding window cutting on the normalized data to perform data imbalance processing.
[0108] The RR interval sequence extraction unit is used to extract each ECG data x i The R wave detection algorithm in the WFDB (waveform database) software package is used to detect the R wave and record the R wave position sequence r iw , and then the R wave position sequence r iw Subtract the adjacent sequence elements to get the RR interval sequence rr i .
[0109] The P wave area time-frequency diagram generating unit is used to convert each ECG data x i Medium iw The regional signal of 0.4 seconds before the corresponding point is retained, and the rest of the signals are all set to zero to form the P wave area data, which is regarded as the atrial activity data X i ; Then use the short-time Fourier transform method to iPerform time-frequency conversion to obtain the P wave area time-frequency diagram Ps i .
[0110] The multi-domain feature extraction module includes a heart rhythm feature representation extraction unit, an atrial activity feature representation extraction unit and a global spatiotemporal feature representation extraction unit.
[0111] The heart rhythm feature representation extraction unit is used to input the RR interval sequence into a timing feature extraction network to obtain the heart rhythm feature representation of the electrocardiogram signal.
[0112] The atrial activity feature representation extraction unit is used to input the P wave region time-frequency diagram into a non-temporal feature extraction network to obtain an atrial activity feature representation.
[0113] The global spatiotemporal feature representation extraction unit is used to input the electrocardiogram signal into a global feature extraction network to obtain a global spatiotemporal feature representation.
[0114] It should be understood that the specific implementation process of the above-mentioned unit modules refers to the method content, and the present invention will not be specifically repeated here, and the division of the above-mentioned functional module units is only a division of logical functions. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. At the same time, the above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0115] Embodiment 3:
[0116] This embodiment provides an electronic terminal, which includes one or more processors; and one or more memories; the processor calls the computer program stored in the memory to execute: the steps of an electrocardiogram signal classification method based on multi-domain feature learning.
[0117] Comparative Example 1, specifically implement:
[0118] Step 1: Preprocessing the ECG signal In this embodiment, the preprocessing includes the steps of normalization, imbalance processing, R wave detection, and local spectrum conversion.
[0119] Step 2: Extract multi-domain features of ECG signals based on a multi-channel feature extraction network layer, wherein the multi-channel feature extraction network layer includes a temporal feature extraction network for the heart rhythm feature channel, a non-temporal feature extraction network for the atrial feature channel, and a global feature extraction network;
[0120] The method includes inputting the RR interval sequence into the timing feature extraction network to obtain the heart rhythm feature representation of the electrocardiogram, inputting the P wave area time-frequency diagram into the non-timing feature extraction network to obtain the atrial activity feature representation; and inputting the electrocardiogram into the global feature extraction network to obtain the global spatiotemporal feature representation.
[0121] Step 3: Use the feature fusion layer to fuse the multi-domain features of the ECG signal to obtain a fused feature, and input the fused feature of the ECG signal into the classification layer to obtain the classification result of the ECG signal. That is, the fused feature of the ECG signal is obtained by fusing the heart rhythm feature representation, the atrial activity feature representation and the global spatiotemporal feature representation.
[0122] Among them, the multi-channel feature extraction network layer, the feature fusion layer and the classification layer constitute a classification network; using the ECG signal samples and their classification labels, the ECG signal samples are processed in the manner of steps 1 to 3 and the classification network training is completed based on deep learning; then the trained classification network and the ECG signal to be classified are used, and the classification results corresponding to the ECG signal to be classified are obtained by processing in the manner of steps 1 to 3.
[0123] The terminal also includes: a communication interface for communicating with external devices and performing data exchange transmission, such as communicating with external ECG equipment to obtain ECG data.
[0124] The memory may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.
[0125] If the memory, processor and communication interface are implemented independently, the memory, processor and communication interface can be connected to each other through a bus and communicate with each other. The bus can be an industrial standard architecture bus, a peripheral device interconnection bus or an extended industrial standard architecture bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0126] Optionally, in a specific implementation, if the memory, processor and communication interface are integrated on a chip, the memory, processor and communication interface can communicate with each other through an internal interface.
[0127] For the specific implementation process of each step, please refer to the description of the above method.
[0128] It should be understood that in the embodiments of the present invention, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The memory may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the type of device.
[0129] Embodiment 4:
[0130] This embodiment provides a readable storage medium storing a computer program, wherein the computer program is called by a processor to implement: steps of an electrocardiogram signal classification method based on multi-domain feature learning.
[0131] Comparative Example 1, specifically implement:
[0132] Step 1: Preprocess the ECG signal. In this embodiment, the preprocessing includes the steps of normalization, imbalance processing, R wave detection, and local spectrum conversion.
[0133] Step 2: Extract multi-domain features of ECG signals based on a multi-channel feature extraction network layer, wherein the multi-channel feature extraction network layer includes a temporal feature extraction network for the heart rhythm feature channel, a non-temporal feature extraction network for the atrial feature channel, and a global feature extraction network;
[0134] The method includes inputting the RR interval sequence into the timing feature extraction network to obtain the heart rhythm feature representation of the electrocardiogram, inputting the P wave area time-frequency diagram into the non-timing feature extraction network to obtain the atrial activity feature representation; and inputting the electrocardiogram into the global feature extraction network to obtain the global spatiotemporal feature representation.
[0135] Step 3: Use the feature fusion layer to fuse the multi-domain features of the ECG signal to obtain a fused feature, and input the fused feature of the ECG signal into the classification layer to obtain the classification result of the ECG signal. That is, the rhythm feature representation, the atrial activity feature representation and the global spatiotemporal feature representation are fused to obtain the fused feature of the ECG signal, and the fused feature of the ECG signal is input into the classification layer to obtain the classification result of the ECG signal;
[0136] Among them, the multi-channel feature extraction network layer, the feature fusion layer and the classification layer constitute a classification network; using the ECG signal samples and their classification labels, the ECG signal samples are processed in the manner of steps 1 to 3 and the classification network training is completed based on deep learning; then the trained classification network and the ECG signal to be classified are used, and the classification results corresponding to the ECG signal to be classified are obtained by processing in the manner of steps 1 to 3.
[0137] For the specific implementation process of each step, please refer to the description of the above method.
[0138] The readable storage medium is a computer-readable storage medium, which may be an internal storage unit of the controller described in any of the foregoing embodiments, such as a hard disk or memory of the controller. The readable storage medium may also be an external storage device of the controller, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the controller. Further, the readable storage medium may also include both an internal storage unit of the controller and an external storage device. The readable storage medium is used to store the computer program and other programs and data required by the controller. The readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0139] Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned readable storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0140] Experimental verification
[0141] 1. Evaluation indicators
[0142] The goal of the present invention is to construct an ECG signal classification method based on multi-domain feature learning, especially when it is applied to atrial fibrillation classification, that is, to construct a practical and efficient atrial fibrillation automatic detection method (KOME) to improve the classification performance of atrial fibrillation patients. For all models, accuracy (ACC), recall, specificity (SPE), F1-Score (F1-Score, the harmonic mean of precision and recall) and AUC (Area UnderCurve, the area under the ROC curve and the coordinate axis) are used to evaluate the final prediction performance. For all experiments, the average value of multiple experimental results is used to reduce the impact of errors.
[0143] 2. Comparison with other methods
[0144] In order to evaluate the performance of the prediction method proposed in the present invention, it is compared with the following methods, and all experimental results are shown in Table 1.
[0145] HAN-ECG: This method uses a hierarchical attention mechanism to classify electrocardiogram (ECG) signals into three levels: waveform, heartbeat, and uses three attention mechanism levels to perform multi-resolution analysis of ECG patterns that cause atrial fibrillation (AF).
[0146] TAC-LSTM: Similar to DCNN, this method uses wavelet transform to convert ECG into a spectrogram, which is input into CNN and LSTM networks for time-frequency feature extraction. At the same time, the original ECG signal is used as another input to another parallel network with the same structure. The two parallel networks extract time series and time-frequency series information simultaneously.
[0147] DCNN: This method uses stationary wavelet transform and short-time Fourier transform to convert 5 seconds of ECG data into a spectrogram, and the converted spectrogram captures the time-frequency features through a deep convolutional neural network.
[0148] ANN: This method uses the correlation function of wavelet packet transform and random process theory to design a feature extraction strategy. Multivariate statistical features based on the correlation between wavelet coefficient sequences are extracted from the corresponding histogram and input into the artificial neural network classifier.
[0149] The data in Table 1 are as follows:
[0150] Table 1
[0151]
[0152]
[0153] From the results in Table 1, it can be seen that the method of the present invention achieved the best performance compared with other models, with an accuracy of 99.33%, a sensitivity of 99.36%, and a specificity of 99.407%. The above results show that the method of the present invention uses relevant medical knowledge to guide the model to perform directional feature learning on multiple channels, which can more effectively capture key disease-specific information and improve classification capabilities.
[0154] 3. Validity verification of each channel module
[0155] In order to verify the effectiveness of the research on the fusion of multiple feature channel modules, we first compare the performance differences of the proposed KOME and its variants on the binary classification task (AF / NAF). As can be seen from Table 2, KOME TCN is a variant of the proposed model that uses only the global feature learning channel and removes the other two channels. P and KOME RRI It is a simplified version of KOME, which only uses the atrial activity enhancement channel and the rhythm characteristic channel. TCN and KOME TCN+R In KOME TCN It is obtained by adding the atrial activity enhancement channel and the rhythm characteristic channel. CNN+P+RRI It is obtained by replacing the TCN used in the global feature channel of the model of the present invention with a 5-layer 1D-CNN. It can be clearly seen from Table 2 that the performance of the three models using only a single feature channel is relatively low. After fusing multiple feature channels, the performance of the model has been significantly improved. It proves that each channel module is a valid module. The data in Table 2 are as follows:
[0156] Table 2
[0157] Model ACC Sen=recall SPE / SPF F1 <![CDATA[KOME TCN ]]> 0.9000 0.8593 0.9409 0.8999 <![CDATA[KOME P ]]> 0.8796 0.8505 0.9096 0.8796 <![CDATA[KOME RRI ]]> 0.8920 0.8750 0.9099 0.8920 <![CDATA[KOME TCN+RRI ]]> 0.9140 0.8690 0.9583 0.9138 <![CDATA[KOME TCN+P ]]> 0.9159 0.8776 0.9535 0.9157 <![CDATA[KOME CNN+P+RRI ]]> 0.8777 0.8327 0.9227 0.8775 KOME 0.9212 0.9020 0.9416 0.9212
[0158] 4. Verification of the effectiveness of the attention fusion mechanism
[0159] This invention uses a fusion method based on the attention mechanism to integrate the features extracted by the three feature learning channels. In order to prove the effectiveness of the method proposed in this study, this study compares the performance of KOME when using different fusion modes. As shown in Table 3 below, KOME concatenate It is a variant of KOME, which uses a direct connection operation instead of an attention mechanism to fuse the representation vectors generated by the three feature learning channels; voting The majority voting is used to integrate the classification results obtained from the three channels. Experimental results show that KOME concatenateIt performs poorly among all the compared models, achieving only 88.35% accuracy, 83.62% sensitivity, 93.08 specificity, and 87.62% F1 score. voting It attempts to combine the results of different feature learning channels through voting ensemble, but its accuracy, sensitivity, specificity and F1 score only reach 90.96%, 89.39%, 92.49% and 90.61%, which is slightly higher than KOME concatenate . The main reason may be that both methods only perform a simple shallow combination of features learned from different channels, without fully capturing the relationship between feature channels. In contrast, the KOME with the attention mechanism adopted in the present invention can effectively achieve deep fusion of multi-domain features and optimize the final feature representation. This shows that the introduction of the attention mechanism fusion method can indeed enhance the classification accuracy of the model and achieve the best performance. The data in Table 3 are as follows:
[0160] Table 3
[0161] Method ACC Sen=recall SPE / SPF F1 <![CDATA[KOME concatenate ]]> 0.8835 0.8362 0.9308 0.8762 <![CDATA[KOME voting ]]> 0.9086 0.8939 0.9249 0.9061 KOME 0.9212 0.9020 0.9416 0.9212 Method ACC Sen=recall SPE / SPF F1
[0162] It should be emphasized that the examples described in the present invention are illustrative rather than restrictive, and therefore the present invention is not limited to the examples described in the specific embodiments. Any other embodiments derived by those skilled in the art based on the technical solution of the present invention that do not depart from the purpose and scope of the present invention, whether modified or replaced, also fall within the scope of protection of the present invention.
Claims
1. A method for classifying electrocardiogram signals based on multi-domain feature learning, characterized in that: The following steps are involved: Step 1: preprocessing the ECG signal, the preprocessing at least comprising: extracting the RR interval sequence and P wave area data of the ECG signal, and performing time-frequency conversion on the P wave area data to obtain a P wave area time-frequency diagram; Step 2: extracting multi-domain features of the ECG signal based on a multi-channel feature extraction network layer, wherein the multi-channel feature extraction network layer includes a temporal feature extraction network of a heart rhythm feature channel, a non-temporal feature extraction network of an atrial feature channel, and a global feature extraction network; The method comprises inputting the RR interval sequence into the timing feature extraction network to obtain a cardiac rhythm feature representation of an electrocardiogram, inputting the P wave region time-frequency diagram into the non-timing feature extraction network to obtain atrial activity feature representation; and inputting the electrocardiogram into the global feature extraction network to obtain a global spatiotemporal feature representation; The global spatiotemporal feature representation is obtained by inputting the ECG signal into a learning network composed of a plurality of TCN blocks, each TCN block having the same structure, and the learning network composed of the TCN blocks serves as the global feature extraction network; The output of the previous TCN block is the input of the next TCN block, and the output of the last TCN block is the global spatiotemporal feature representation of the ECG signal; the output of any TCN block is expressed as: In the formula, x i is the initial ECG signal of the learning network composed of several TCN blocks, the initial ECG signal is the original ECG signal or the ECG signal after normalization and / or imbalance preprocessing of the original ECG signal, i is the number of the ECG signal, Represents the ECG data input to the I+1th TCN block, is the ECG data after inputting the I-th TCN block and undergoing dilated convolution, weight normalization, linear rectification function RELU, and Dropout layer to prevent overfitting. I is the block number of the TCN block. Dilated CNN represents the dilated convolutional network layer, Activation is the activation function, and W i represents the weight matrix of layer I; Step 3: Use the feature fusion layer to fuse the multi-domain features of the ECG signal to obtain the fusion feature, and input the fusion feature of the ECG signal into the classification layer to obtain the classification result of the ECG signal; The fusion feature is expressed as: In the formula, H i Represents the ECG signal x i The fusion features of, i is the number of ECG signals, V i is the value vector, Q i is the query vector, is the scaling factor, K i is the key vector, T is the transposed symbol; the query vector Q i , the key vector K i Sum value vector V i The representation is as follows: Q i =W Q r i ' K i =W K p i ' V i =W V x i ' in, is the parameter matrix, m is the feature r i '、p i ', x i ' dimension, r i ' is the ECG signal x i The corresponding heart rhythm feature representation, p i ' is the ECG signal x i The corresponding atrial activity feature representation, x i ' is the ECG signal x i The corresponding global spatiotemporal feature representation; Among them, the multi-channel feature extraction network layer, the feature fusion layer and the classification layer constitute a classification network; using the ECG signal samples and their classification labels, the ECG signal samples are processed in the manner of steps 1 to 3 and the classification network training is completed based on deep learning; then the trained classification network and the ECG signal to be classified are used, and the classification results corresponding to the ECG signal to be classified are obtained by processing in the manner of steps 1 to 3.
2. The electrocardiogram signal classification method according to claim 1, characterized in that: The process of extracting the RR interval sequence and P wave area data of the electrocardiogram signal and performing time-frequency conversion on the P wave area data to obtain the P wave area time-frequency diagram is as follows: Cut the ECG signal according to the defined window size and retain the ECG signal of the window size; Perform R wave detection on the ECG signal and record the R wave position sequence, and then subtract adjacent sequence elements of the R wave position sequence to obtain the RR interval sequence; The interval signal of Z seconds before the corresponding point of the R wave position sequence in the electrocardiogram signal is retained, and the remaining signals are all set to zero to obtain the P wave area data, and the P wave area data is regarded as atrial activity data; then the atrial activity data is time-frequency converted to obtain the P wave area time-frequency diagram.
3. The electrocardiogram signal classification method according to claim 2, characterized in that: When cutting ECG signals according to the defined window size, select dynamic sliding window to cut ECG signals; Among them, the cutting stride b is set to: Where B is the maximum cutting stride length, C is the category label, and θ is the preset coefficient.
4. The method according to claim 1, characterized in that: The atrial activity feature representation is obtained by inputting the P wave region time-frequency diagram into a 2D-CNN network, and the 2D-CNN network is used as a non-temporal feature extraction network for an atrial feature channel; The network layers of the 2D-CNN network are composed of a first two-dimensional convolutional layer, a first maximum pooling layer, a second two-dimensional convolutional layer, a second maximum pooling layer, a Flatten layer, a Dropout layer and two fully connected layers connected in sequence.
5. The method according to claim 1, characterized in that: The heart rhythm feature representation of the electrocardiogram signal is obtained by padding the RR interval sequence of the electrocardiogram signal to a preset length and then inputting it into an LSTM network or a Transformer network. The LSTM network or the Transformer network serves as a timing feature extraction network for the heart rhythm feature channel.
6. A system based on the electrocardiogram signal classification method according to any one of claims 1 to 5, characterized in that: include: A preprocessing module is used to preprocess the ECG signal, wherein the preprocessing at least includes: extracting the RR interval sequence and P wave area data of the ECG signal, and performing time-frequency conversion on the P wave area data to obtain a P wave area time-frequency diagram; A multi-domain feature extraction module is used to extract multi-domain features from an ECG signal based on a multi-channel feature extraction network layer, wherein the multi-channel feature extraction network layer includes a temporal feature extraction network for a cardiac rhythm feature channel, a non-temporal feature extraction network for an atrial feature channel, and a global feature extraction network; the multi-domain feature extraction module is used to input the RR interval sequence into the temporal feature extraction network to obtain a cardiac rhythm feature representation of the ECG signal, input the P wave region time-frequency diagram into the non-temporal feature extraction network to obtain an atrial activity feature representation; and input the ECG signal into the global feature extraction network to obtain a global spatiotemporal feature representation; A fusion module is used to fuse multi-domain features of ECG signals using a feature fusion layer to obtain fusion features; A classification module, used for inputting the fusion features of the ECG signal into a classification layer to obtain a classification result of the ECG signal; A training module is used to utilize ECG signal samples and their classification labels, and complete classification network training based on data processing of the preprocessing module, the multi-domain feature extraction module, the fusion module and the classification module, and based on deep learning. The classification network consists of a multi-channel feature extraction network layer, a feature fusion layer and a classification layer.
7. An electronic terminal, characterized in that: At least: one or more processors; one or more memories; The processor calls the computer program stored in the memory to execute: The steps of an electrocardiogram signal classification method based on multi-domain feature learning as described in any one of claims 1-5.
8. A readable storage medium, characterized in that: A computer program is stored, which is called by a processor to implement: The steps of an electrocardiogram signal classification method based on multi-domain feature learning as described in any one of claims 1-5.
