A multi-lead ECG classification method based on self-supervised learning
Through self-supervised learning and multi-lead ECG classification methods, combined with data enhancement and attention mechanisms, the problem of existing ECG signal classification methods' dependence on annotated data and data set differences is solved, and the generalization ability and classification accuracy of the model are improved. rate, achieving more efficient feature extraction and ECG signal classification.
Patent Information
- Application Number
- CN202311479336.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-08
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2043-11-08
AI Technical Summary
Existing ECG signal classification methods rely on supervised learning and a large amount of labeled data, making it difficult to utilize unlabeled data. Moreover, the generalization ability of the model is affected by differences in data sets, making it difficult to maintain high efficiency between different data sets.
A multi-lead ECG classification method based on self-supervised learning is used to extract For ECG signal features, the Adam optimizer is used for comparative learning training to improve the model's generalization ability and classification accuracy.
It improves the accuracy and generalization ability of the ECG classification model and enhances the model's adaptability to different data sets. Through the attention mechanism and data enhancement technology, it improves the efficiency and accuracy of feature extraction and enhances the analysis of ECG signals. Timing information capture capabilities.
Smart Images

Figure CN117958831B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electrocardiogram signal classification, and in particular to a multi-lead electrocardiogram classification method based on self-supervised learning. Background Art
[0002] ECG signals are important electrical signals used to record cardiac activity information. Different ECG signals have different meanings, so it is crucial to correctly classify ECG signals. With the development of artificial intelligence, neural networks can be used to extract and classify ECG signals. However, these network architectures are often based on supervised learning tasks and rely on a large amount of labeled data, ignoring the fact that unlabeled data can also be helpful for ECG signal classification. Moreover, traditional neural networks are often affected by the differences in data sets when used in different data sets, which weakens the generalization ability of the model and makes it difficult to give full play to the advantages of the model. Summary of the invention
[0003] In order to overcome the deficiencies of the above technologies, the present invention provides a multi-lead ECG classification method for improving the accuracy and generalization ability of the classification model.
[0004] The technical solution adopted by the present invention to overcome the technical problems is:
[0005] A multi-lead ECG classification method based on self-supervised learning includes the following steps:
[0006] a) obtaining original ECG signal data X;
[0007] b) performing a preprocessing operation on the original ECG signal data X to obtain a preprocessed ECG signal X′;
[0008] c) Establish a data enhancement unit, input the preprocessed ECG signal X′ into the data enhancement module, and output the enhanced positive sample X a And the enhanced negative sample Y a ;
[0009] d) Establish an encoder module to transform the enhanced positive sample X a Input into the encoder module, and output the encoded sequence X c , the enhanced negative sample Y a Input into the encoder module and output the encoded sequence Y c ; e) Establish a feature dimension reconstruction module to convert the encoding sequence X c Input into the feature dimension reconstruction module, and output the reconstructed lead feature X g , the coding sequence Y c Input into the feature dimension reconstruction module, and output the reconstructed lead feature Y g ;
[0010] f) using the Adam optimizer to train the encoder module through contrastive learning loss to obtain a trained encoder module;
[0011] g) replacing the original ECG signal data X in step b) with the ECG signal data Z to be classified, and then repeating step b) to obtain a preprocessed ECG signal Z′;
[0012] h) Input the preprocessed ECG signal Z′ into the trained encoder module and output the encoded sequence Z c ;
[0013] i) The coding sequence Z c Substituting the coding sequence X in step e) c Then repeat step e) to obtain the reconstructed dimension lead feature Z g ;
[0014] j) According to the lead feature Z g Get the final category.
[0015] Furthermore, in step a), an ECG signal is obtained from the PhysioNet2020 dataset, and the obtained ECG signal is resampled using the resample() function in the Python library sklearn.utils, and the length of the ECG signal is adjusted to L sample points to obtain the original ECG signal data X, X∈R C×L , R is the real number space, and C is the number of channels.
[0016] Preferably, C=12, L=1000.
[0017] Further, step b) comprises the following steps:
[0018] b-1) Use python to call the signal.butter method in the scipy module to perform Butterworth bandpass filter denoising and baseline drift removal on the original ECG signal data X with a cutoff frequency of 0.5 Hz for low frequency and 49 Hz for high frequency;
[0019] b-2) Resample the acquired ECG signal for each lead in the original ECG signal data X after noise reduction and baseline drift removal using the resample() function in the Python library sklearn.utils, adjust the ECG signal length to L, and obtain the preprocessed ECG signal X′.
[0020] Further, step c) comprises the following steps:
[0021] c-1) The data enhancement unit includes a first enhancement module and a second enhancement module;
[0022] c-2) Input the preprocessed ECG signal X′ into the first enhancement module, multiply the value of each lead signal in the preprocessed ECG signal X′ by -1, and obtain the enhanced positive sample X a ;
[0023] c-3) Input the preprocessed ECG signal X′ into the second enhancement module, and use Gaussian noise to perform data enhancement on the preprocessed ECG signal X′ to obtain the enhanced negative sample Y a .
[0024] Further, step d) comprises the following steps:
[0025] d-1) The encoder module consists of a one-dimensional convolutional layer, a time domain fusion module TCFN, an average pooling layer, and a Dropout layer;
[0026] d-2) The enhanced positive sample X a Input into the one-dimensional convolution layer and output the feature X c1 , the enhanced negative sample Y a Input into the one-dimensional convolution layer and output the feature Y c1 ;
[0027] d-3) The time domain fusion module TCFN consists of a first branch, a second branch, and a third branch;
[0028] d-4) The first branch consists of the first convolution block, the second convolution block, the third convolution block, and the fourth convolution block. The first convolution block, the second convolution block, the third convolution block, and the fourth convolution block are respectively composed of the first convolution layer, the second convolution layer, the BatchNormal1d layer, the ReLU layer, the MaxPool1d layer, and the Dropout layer. The feature X c1 Input into the first convolution block of the first branch, and output the feature The characteristics Input into the second convolution block of the first branch, and output the feature The characteristics Input into the third convolution block of the first branch, and output the feature The characteristics Input into the fourth convolution block of the first branch, and output the feature X c ′1, feature Y c1 Input into the first convolution block of the first branch, and output the feature The characteristics Input into the second convolution block of the first branch, and output the feature The characteristics Input into the third convolution block of the first branch, and output the feature The characteristics Input into the fourth convolution block of the first branch, and output the feature Y c '1;
[0029] d-5) The second branch consists of a lead memory module LM_Block and a skip connection module. The lead memory module LM_Block is composed of a global pooling layer, an LSTM layer, a one-dimensional convolution layer, and a Relu activation function. c1 Input into the lead memory module LM_Block, and output the feature X c11 , the feature X c11 With feature X c1 Input to the skip connection module for addition operation to obtain feature X c ″1, feature Y c1 Input into the lead memory module LM_Block, and output the feature Y c11 , the feature Y c11 With feature Y c1 Input to the skip connection module for addition operation to obtain feature Y c '1';
[0030] d-6) The third branch consists of an attention module, a first one-dimensional convolutional layer, a second one-dimensional convolutional layer, a third one-dimensional convolutional layer, and a maximum pooling layer. c1 The input is input into the attention module, and the attention operation is performed through the torch.nn.MultiheadAttention function in Python. Then it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer in turn, and the output is the encoded sequence X c ″1′, the feature Y c1 The input is input into the attention module, and then the attention operation is performed by the torch.nn.MultiheadAttention function in Python, and then it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer in turn, and the output is the encoded sequence Y c '1";
[0031] d-7) Change feature X c ′1. Feature X c ″1. Coding sequence X c ″1′ and then take the average value to get the feature X c2 , the feature Y c ′1. Feature Y c '1', coding sequence Y c ′1″ and take the average value to get feature Y c2 , the feature X c2It is input into the average pooling layer and Dropout layer of the encoder module in sequence, and the output is the encoded sequence X c , the feature Y c2 It is input into the average pooling layer and the Dropout layer of the encoder module in sequence, and the output is the encoded sequence Y c .
[0032] Preferably, in step d-1), the convolution kernel size of the one-dimensional convolution layer of the encoder module is 3; in step d-4), the convolution kernel sizes of the first convolution layer and the second convolution layer of the first convolution block are both 64, the convolution kernel sizes of the first convolution layer and the second convolution layer of the second convolution block are both 32, the convolution kernel sizes of the first convolution layer and the second convolution layer of the third convolution block are both 16, and the convolution kernel sizes of the first convolution layer and the second convolution layer of the fourth convolution block are both 3; in step d-5), the hidden_size of the LSTM layer of the lead memory module LM_Block is 256, and the convolution kernel size of the one-dimensional convolution layer of the lead memory module LM_Block is 3; in step d-6), the convolution kernel size of the first one-dimensional convolution layer of the third branch is 32, the convolution kernel size of the second one-dimensional convolution layer is 16, and the convolution kernel size of the third one-dimensional convolution layer is 3.
[0033] Further, step e) comprises the following steps:
[0034] e-1) The feature dimension reconstruction module is composed of convolutional layer, linear layer and ReLU activation function in sequence;
[0035] e-2) The coding sequence X c Input into the feature dimension reconstruction module, and output the reconstructed lead feature X g , the coding sequence Y c Input into the feature dimension reconstruction module, and output the reconstructed lead feature Y g .
[0036] Further, step h) comprises the following steps:
[0037] h-1) Input the preprocessed ECG signal Z′ into the one-dimensional convolutional layer of the trained encoder module, and output the feature Z c1 ;
[0038] h-2) The feature Z c1 Input it into the first convolution block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input it into the second convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input it into the third convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input to the fourth convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature Z c '1;
[0039] h-3) The feature Z c1 Input it into the lead memory module LM_Block of the second branch of the time domain fusion module TCFN of the trained encoder module, and output the feature Z c11 , the feature Z c11 With feature Z c1 The input is then added to the skip connection module of the second branch of the time domain fusion module TCFN of the trained encoder module to obtain the feature Z c ″1;
[0040] h-4) The feature Z c1 The input is input into the attention module of the third branch of the time domain fusion module TCFN of the trained encoder module. After the attention operation is performed through the torch.nn.MultiheadAttention function in python, it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer of the third branch of the time domain fusion module TCFN of the trained encoder module in sequence, and the encoding sequence Z is output. c ″1′;
[0041] h-5) The feature Z c ′1. Feature Z c ″1. Coding sequence Z c ″1′ and then take the average value to get the feature Z c2 , the feature Z c2 It is input into the average pooling layer and the Dropout layer of the trained encoder module in sequence, and the encoded sequence Z is output. c .
[0042] Further, step j) comprises the following steps:
[0043] j-1) Set the lead feature Z g It is input into the fully connected layer and the softmax activation function in sequence, and the output is a probability distribution between 0 and 1.
[0044] j-2) Use the argmax function in the python library numpy to process the probability distribution and output it to the final category.
[0045] The beneficial effects of the present invention are:
[0046] (1) The present invention performs ECG classification prediction by means of self-supervised learning, which can reduce the problem of poor generalization ability of the model caused by differences in data sets and increase the versatility of the ECG classification model.
[0047] (2) The present invention designs a residual-like structure with an attention module to extract information from multiple leads in ECG signals through self-supervised learning. The attention mechanism can enable the encoder module to focus more on the important signal parts, adaptively adjust the weight parameters, weight the information of different leads, and improve the efficiency and ability of the encoder module in extracting ECG signal features.
[0048] (3) The present invention combines the characteristics of ECG signals to carry out targeted processing on the data enhancement part, Gaussian noise and time-space flip. ECG acquisition is susceptible to interference from factors such as electrode position and muscle activity, and some noise exists. Therefore, during data enhancement, a certain amount of Gaussian noise interference is selectively added to the overall signal to offset the impact of local noise on the overall characteristics of the signal. ECG signals have a certain degree of time-space invariance. According to this characteristic of ECG signals, the data enhancement method uses the time-space flip method to make the ECG features more prominent and easier to extract.
[0049] (4) The self-supervised learning network uses a combination of long short-term memory network and multi-layer perceptron when classifying predictive codes. Compared with the ordinary convolution method, it can extract and capture more time series information of the ECG signal, thereby improving the classification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0051] The following is combined with Figure 1 The present invention is further described.
[0052] A multi-lead ECG classification method based on self-supervised learning includes the following steps:
[0053] a) Obtain the original ECG signal data X.
[0054] b) Preprocessing the original ECG signal data X to obtain a preprocessed ECG signal X′.
[0055] c) Establish a data enhancement unit, input the preprocessed ECG signal X′ into the data enhancement module, and output the enhanced positive sample X a And the enhanced negative sample Y a .
[0056] d) Establish an encoder module to transform the enhanced positive sample X aInput into the encoder module, and output the encoded sequence X c , the enhanced negative sample Y a Input into the encoder module and output the encoded sequence Y c e) Establish a feature dimension reconstruction module to transform the encoding sequence X c Input into the feature dimension reconstruction module, and output the reconstructed lead feature X g , the coding sequence Y c Input into the feature dimension reconstruction module, and output the reconstructed lead feature Y g .
[0057] f) Use the Adam optimizer to train the encoder module through contrastive learning loss to obtain the trained encoder module.
[0058] g) replacing the original ECG signal data X in step b) with the ECG signal data Z to be classified, and then repeating step b) to obtain a preprocessed ECG signal Z′.
[0059] h) Input the preprocessed ECG signal Z′ into the trained encoder module and output the encoded sequence Z c .
[0060] i) The coding sequence Z c Substituting the coding sequence X in step e) c Then repeat step e) to obtain the reconstructed dimension lead feature Z g .
[0061] j) According to the lead feature Z g Get the final category.
[0062] The present invention is divided into upstream and downstream tasks. The upstream task is to train the encoder module. First, the original ECG sample is enhanced by different data to generate positive and negative sample pairs. The encoder module encodes them respectively to obtain the corresponding encoding results. The loss function is used to compare the difference between the encodings to calculate the loss and then form a back propagation to update the encoder parameters to achieve the purpose of finding the optimal encoder. The downstream task is to predict the training results. The trained encoder module can be used for ECG signal classification.
[0063] In one embodiment of the present invention, in step a), an ECG signal is obtained from the PhysioNet2020 dataset, and the obtained ECG signal is resampled using the resample() function in the Python library sklearn.utils, and the length of the ECG signal is adjusted to L sample points to obtain the original ECG signal data X, X∈R C×L, R is the real number space, C is the number of channels, which is the same as the number of ECG signal leads, so C = 12. In this embodiment, preferably, L = 1000.
[0064] In one embodiment of the present invention, step b) comprises the following steps:
[0065] b-1) Use Python to call the signal.butter method in the scipy module to perform Butterworth bandpass filter denoising and baseline drift removal on the original ECG signal data X with a cutoff frequency of 0.5 Hz for low frequency and 49 Hz for high frequency.
[0066] b-2) Resample the acquired ECG signal for each lead in the original ECG signal data X after noise reduction and baseline drift removal using the resample() function in the Python library sklearn.utils, adjust the ECG signal length to L, and obtain the preprocessed ECG signal X′.
[0067] In one embodiment of the present invention, step c) comprises the following steps:
[0068] c-1) The data enhancement unit includes a first enhancement module and a second enhancement module.
[0069] c-2) Input the preprocessed ECG signal X′ into the first enhancement module, multiply the value of each lead signal in the preprocessed ECG signal X′ by -1 to achieve the purpose of vertically flipping the signal and obtaining the enhanced positive sample X a .
[0070] c-3) Input the preprocessed ECG signal X′ into the second enhancement module, and use Gaussian noise (GN) to perform data enhancement on the preprocessed ECG signal X′ to obtain the enhanced negative sample Y a .
[0071] In one embodiment of the present invention, step d) comprises the following steps:
[0072] d-1) The encoder module consists of a one-dimensional convolutional layer, a time domain fusion module TCFN, an average pooling layer, and a Dropout layer.
[0073] d-2) The enhanced positive sample X a Input into the one-dimensional convolution layer and output the feature X c1 , the enhanced negative sample Y a Input into the one-dimensional convolution layer and output the feature Y c1 .
[0074] d-3) The time domain fusion module TCFN consists of a first branch, a second branch, and a third branch.
[0075] d-4) The first branch consists of the first convolution block, the second convolution block, the third convolution block, and the fourth convolution block. The first convolution block, the second convolution block, the third convolution block, and the fourth convolution block are respectively composed of the first convolution layer, the second convolution layer, the BatchNormal1d layer, the ReLU layer, the MaxPool1d layer, and the Dropout layer. The feature X c1 Input into the first convolution block of the first branch, and output the feature The characteristics Input into the second convolution block of the first branch, and output the feature The characteristics Input into the third convolution block of the first branch, and output the feature The characteristics Input into the fourth convolution block of the first branch, and output the feature X c ′1, feature Y c1 Input into the first convolution block of the first branch, and output the feature The characteristics Input into the second convolution block of the first branch, and output the feature The characteristics Input into the third convolution block of the first branch, and output the feature The characteristics Input into the fourth convolution block of the first branch, and output the feature Y c ′1.
[0076] d-5) The second branch consists of a lead memory module LM_Block and a skip connection module. The lead memory module LM_Block is composed of a global pooling layer, an LSTM layer, a one-dimensional convolution layer, and a Relu activation function. c1 Input into the lead memory module LM_Block, and output the feature X c11 , the feature X c11 With feature X c1 Input to the skip connection module for addition operation to obtain feature X c ″1, feature Y c1 Input into the lead memory module LM_Block, and output the feature Y c11 , the feature Y c11 With feature Y c1 Input to the skip connection module for addition operation to obtain feature Y c '1'.
[0077] d-6) The third branch consists of an attention module, a first one-dimensional convolutional layer, a second one-dimensional convolutional layer, a third one-dimensional convolutional layer, and a maximum pooling layer, which is used to improve the global perception ability and convert the feature X c1The input is input into the attention module, and the attention operation is performed through the torch.nn.MultiheadAttention function in Python. Then it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer in turn, and the output is the encoded sequence X c ″1′, the feature Y c1 The input is input into the attention module, and then the attention operation is performed by the torch.nn.MultiheadAttention function in Python, and then it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer in turn, and the output is the encoded sequence Y c '1". d-7) The feature X c ′1. Feature X c ″1. Coding sequence X c ″1′ and then take the average value to get the feature X c2 , the feature Y c ′1. Feature Y c '1', coding sequence Y c ′1″ and take the average value to get feature Y c2 , the feature X c2 It is input into the average pooling layer and the Dropout layer of the encoder module in sequence, and the encoded sequence X is output. c , the feature Y c2 It is input into the average pooling layer and the Dropout layer of the encoder module in sequence, and the output is the encoded sequence Y c .
[0078] In this embodiment, preferably, in step d-1), the convolution kernel size of the one-dimensional convolution layer of the encoder module is 3; in step d-4), the convolution kernel sizes of the first convolution layer and the second convolution layer of the first convolution block are both 64, the convolution kernel sizes of the first convolution layer and the second convolution layer of the second convolution block are both 32, the convolution kernel sizes of the first convolution layer and the second convolution layer of the third convolution block are both 16, and the convolution kernel sizes of the first convolution layer and the second convolution layer of the fourth convolution block are both 3; in step d-5), the hidden_size of the LSTM layer of the lead memory module LM_Block is 256, and the convolution kernel size of the one-dimensional convolution layer of the lead memory module LM_Block is 3; in step d-6), the convolution kernel size of the first one-dimensional convolution layer of the third branch is 32, the convolution kernel size of the second one-dimensional convolution layer is 16, and the convolution kernel size of the third one-dimensional convolution layer is 3.
[0079] In one embodiment of the present invention, step e) comprises the following steps:
[0080] e-1) The feature dimension reconstruction module is composed of a convolutional layer, a linear layer, and a ReLU activation function in sequence.
[0081] e-2) The coding sequence X c Input into the feature dimension reconstruction module, and output the reconstructed lead feature X g , the coding sequence Y c Input into the feature dimension reconstruction module, and output the reconstructed lead feature Y g .
[0082] In one embodiment of the present invention, step h) comprises the following steps:
[0083] h-1) Input the preprocessed ECG signal Z′ into the one-dimensional convolutional layer of the trained encoder module, and output the feature Z c1 .
[0084] h-2) The feature Z c1 Input it into the first convolution block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input it into the second convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input it into the third convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input to the fourth convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature Z c ′1.
[0085] h-3) The feature Z c1 Input it into the lead memory module LM_Block of the second branch of the time domain fusion module TCFN of the trained encoder module, and output the feature Z c11 , the feature Z c11 With feature Z c1 The input is then added to the skip connection module of the second branch of the time domain fusion module TCFN of the trained encoder module to obtain the feature Z c ″1.
[0086] h-4) The feature Z c1 The input is input into the attention module of the third branch of the time domain fusion module TCFN of the trained encoder module. After the attention operation is performed through the torch.nn.MultiheadAttention function in python, it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer of the third branch of the time domain fusion module TCFN of the trained encoder module in sequence, and the encoding sequence Z is output.c ″1′.
[0087] h-5) The feature Z c ′1. Feature Z c ″1. Coding sequence Z c ″1′ and then take the average value to get the feature Z c2 , the feature Z c2 It is input into the average pooling layer and the Dropout layer of the trained encoder module in sequence, and the encoded sequence Z is output. c .
[0088] In one embodiment of the present invention, step j) comprises the following steps:
[0089] j-1) The lead feature Z g It is input into the fully connected layer and the softmax activation function in sequence, and the output is a probability distribution between 0 and 1.
[0090] j-2) Use the argmax function in the python library numpy to process the probability distribution and output it to the final category.
[0091] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A multi-lead ECG classification method based on self-supervised learning, characterized in that: The steps include: a) obtaining original ECG signal data X; b) performing a preprocessing operation on the original ECG signal data X to obtain a preprocessed ECG signal X′; c) Establish a data enhancement unit, input the preprocessed ECG signal X′ into the data enhancement module, and output the enhanced positive sample X a And the enhanced negative sample Y a ; d) Establish an encoder module to transform the enhanced positive sample X a Input into the encoder module, and output the encoded sequence X c , the enhanced negative sample Y a Input into the encoder module and output the encoded sequence Y c ; e) Establish a feature dimension reconstruction module to convert the encoding sequence X c Input into the feature dimension reconstruction module, and output the reconstructed lead feature X g , the coding sequence Y c Input into the feature dimension reconstruction module, and output the reconstructed lead feature Y g ; f) using the Adam optimizer to train the encoder module through contrastive learning loss to obtain a trained encoder module; g) replacing the original ECG signal data X in step b) with the ECG signal data Z to be classified, and then repeating step b) to obtain a preprocessed ECG signal Z′; h) Input the preprocessed ECG signal Z′ into the trained encoder module and output the encoded sequence Z c ; i) The coding sequence Z c Substituting the coding sequence X in step e) c Then repeat step e) to obtain the reconstructed dimension lead feature Z g ; j) According to the lead feature Z g Get the final category; Step d) comprises the following steps: d-1) The encoder module consists of a one-dimensional convolutional layer, a time domain fusion module TCFN, an average pooling layer, and a Dropout layer; d-2) The enhanced positive sample X a Input into the one-dimensional convolution layer and output the feature X c1 , the enhanced negative sample Y a Input into the one-dimensional convolution layer and output the feature Y c1 ; d-3) The time domain fusion module TCFN consists of the first branch, the second branch, and the third branch; d-4) The first branch consists of the first convolution block, the second convolution block, the third convolution block, and the fourth convolution block. The first convolution block, the second convolution block, the third convolution block, and the fourth convolution block are respectively composed of the first convolution layer, the second convolution layer, the BatchNormal1d layer, the ReLU layer, the MaxPool1d layer, and the Dropout layer. The feature X c1 Input into the first convolution block of the first branch, and output the feature The characteristics Input into the second convolution block of the first branch, and output the feature The characteristics Input into the third convolution block of the first branch, and output the feature The characteristics Input into the fourth convolution block of the first branch, and output the feature X c ′1, feature Y c1 Input into the first convolution block of the first branch, and output the feature The characteristics Input into the second convolution block of the first branch, and output the feature The characteristics Input into the third convolution block of the first branch, and output the feature The characteristics Input into the fourth convolution block of the first branch, and output the feature Y c '1; d-5) The second branch consists of a lead memory module LM_Block and a skip connection module. The lead memory module LM_Block is composed of a global pooling layer, an LSTM layer, a one-dimensional convolution layer, and a Relu activation function. c1 Input into the lead memory module LM_Block, and output the feature X c11 , the feature X c11 With feature X c1 Input to the skip connection module for addition operation to obtain feature X c ″1, feature Y c1 Input into the lead memory module LM_Block, and output the feature Y c11 , the feature Y c11 With feature Y c1 Input to the skip connection module for addition operation to obtain feature Y c '1'; d-6) The third branch consists of an attention module, a first one-dimensional convolutional layer, a second one-dimensional convolutional layer, a third one-dimensional convolutional layer, and a maximum pooling layer. c1 The input is input into the attention module, and the attention operation is performed through the torch.nn.MultiheadAttention function in Python. Then it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer in turn, and the output is the encoded sequence X c ″1′, the feature Y c1 The input is input into the attention module, and then the attention operation is performed by the torch.nn.MultiheadAttention function in Python, and then it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer in turn, and the output is the encoded sequence Y c '1"; d-7) Change feature X c ′1. Feature X c ″1. Coding sequence X c ″1′ and then take the average value to get the feature X c2 , the feature Y c ′1. Feature Y c '1', coding sequence Y c ′1″ and take the average value to get feature Y c2 , the feature X c2 It is input into the average pooling layer and the Dropout layer of the encoder module in sequence, and the encoded sequence X is output. c , the feature Y c2 It is input into the average pooling layer and the Dropout layer of the encoder module in sequence, and the output is the encoded sequence Y c .
2. The multi-lead ECG classification method based on self-supervised learning according to claim 1, characterized in that: In step a), the ECG signal is obtained from the PhysioNet2020 dataset, and the obtained ECG signal is resampled using the resample() function in the Python library sklearn.utils, and the length of the ECG signal is adjusted to L sample points to obtain the original ECG signal data X, X∈R C×L , R is the real number space, and C is the number of channels.
3. The multi-lead ECG classification method based on self-supervised learning according to claim 2, characterized in that: C=12, L=1000.
4. The multi-lead ECG classification method based on self-supervised learning according to claim 1, characterized in that: Step b) comprises the following steps: b-1) Use python to call the signal.butter method in the scipy module to perform Butterworth bandpass filter denoising and baseline drift removal on the original ECG signal data X with a cutoff frequency of 0.5 Hz for low frequency and 49 Hz for high frequency; b-2) Resample the acquired ECG signal for each lead in the original ECG signal data X after noise reduction and baseline drift removal using the resample() function in the Python library sklearn.utils, adjust the ECG signal length to L, and obtain the preprocessed ECG signal X′.
5. The multi-lead ECG classification method based on self-supervised learning according to claim 1, characterized in that: Step c) comprises the following steps: c-1) The data enhancement unit includes a first enhancement module and a second enhancement module; c-2) Input the preprocessed ECG signal X′ into the first enhancement module, multiply the value of each lead signal in the preprocessed ECG signal X′ by -1, and obtain the enhanced positive sample X a ; c-3) Input the preprocessed ECG signal X′ into the second enhancement module, and use Gaussian noise to perform data enhancement on the preprocessed ECG signal X′ to obtain the enhanced negative sample Y a .
6. The multi-lead ECG classification method based on self-supervised learning according to claim 1, characterized in that: In step d-1), the convolution kernel size of the one-dimensional convolution layer of the encoder module is 3; in step d-4), the convolution kernel size of the first convolution layer and the second convolution layer of the first convolution block is 64, the convolution kernel size of the first convolution layer and the second convolution layer of the second convolution block is 32, the convolution kernel size of the first convolution layer and the second convolution layer of the third convolution block is 16, and the convolution kernel size of the first convolution layer and the second convolution layer of the fourth convolution block is 3; in step d-5), the hidden_size of the LSTM layer of the lead memory module LM_Block is 256, and the convolution kernel size of the one-dimensional convolution layer of the lead memory module LM_Block is 3; in step d-6), the convolution kernel size of the first one-dimensional convolution layer of the third branch is 32, the convolution kernel size of the second one-dimensional convolution layer is 16, and the convolution kernel size of the third one-dimensional convolution layer is 3.
7. The multi-lead ECG classification method based on self-supervised learning according to claim 1, characterized in that: Step e) comprises the following steps: e-1) The feature dimension reconstruction module is composed of convolutional layer, linear layer and ReLU activation function in sequence; e-2) The coding sequence X c Input into the feature dimension reconstruction module, and output the reconstructed lead feature X g , the coding sequence Y c Input into the feature dimension reconstruction module, and output the reconstructed lead feature Y g .
8. The multi-lead ECG classification method based on self-supervised learning according to claim 1, characterized in that: Step h) comprises the following steps: h-1) Input the preprocessed ECG signal Z′ into the one-dimensional convolutional layer of the trained encoder module, and output the feature Z c1 ; h-2) The feature Z c1 Input it into the first convolution block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input it into the second convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input it into the third convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature The characteristics Input to the fourth convolutional block of the first branch of the time domain fusion module TCFN of the trained encoder module, and output the feature Z c '1; h-3) The feature Z c1 Input it into the lead memory module LM_Block of the second branch of the time domain fusion module TCFN of the trained encoder module, and output the feature Z c11 , the feature Z c11 With feature Z c1 The input is then added to the skip connection module of the second branch of the time domain fusion module TCFN of the trained encoder module to obtain the feature Z c ″1; h-4) The feature Z c1 The input is input into the attention module of the third branch of the time domain fusion module TCFN of the trained encoder module. After the attention operation is performed through the torch.nn.MultiheadAttention function in python, it is input into the first one-dimensional convolution layer, the second one-dimensional convolution layer, the third one-dimensional convolution layer, and the maximum pooling layer of the third branch of the time domain fusion module TCFN of the trained encoder module in sequence, and the encoding sequence Z is output. c ″1′; h-5) The feature Z c ′1. Feature Z c ″1. Coding sequence Z c ″1′ and then take the average value to get the feature Z c2 , the feature Z c2 It is input into the average pooling layer and the Dropout layer of the trained encoder module in sequence, and the encoded sequence Z is output. c .
9. The multi-lead ECG classification method based on self-supervised learning according to claim 1, characterized in that: Step j) comprises the following steps: j-1) The lead feature Z g It is input into the fully connected layer and softmax activation function in sequence, and the output is a probability distribution between 0 and 1; j-2) Use the argmax function in the python library numpy to process the probability distribution and output it to the final category.
Citation Information
Patent Citations
Electrocardiogram characteristic wave segmentation method, system and device and readable storage medium
CN115607164A
Subject-aware contrastive learning for biosignals
US20210374570A1
