Electrocardiosignal identification method based on diffusion model and Bi-LSTM

By generating similar data using a diffusion model and combining CNN and Bi-LSTM, the problem of data imbalance in ECG signal classification is solved, the accuracy of abnormal heartbeat detection is improved, and effective identification of ECG signals and real-time health status assessment are achieved.

CN121858979APending Publication Date: 2026-04-14AFFILIATED HOSPITAL OF SHAOXING UNIV OF ARTS & SCI +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410127832.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-30
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing deep learning methods struggle to effectively identify rare arrhythmias in electrocardiogram (ECG) signal classification due to data imbalance, causing the model to ignore predictions for a minority of classes.

Method used

By generating data with a distribution similar to real data features using a diffusion model, the dataset is expanded. Convolutional neural networks and bidirectional long short-term memory networks (Bi-LSTM) are then used to learn ECG signal features, thereby enabling ECG signal recognition.

Benefits of technology

It alleviates the data imbalance problem, improves the accuracy of abnormal heartbeat detection, and enables effective identification of electrocardiogram signals and real-time health status assessment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121858979A_ABST
    Figure CN121858979A_ABST
Patent Text Reader

Abstract

The invention discloses an electrocardiosignal identification method based on a diffusion model and Bi-LSTM (Bidirectional Long Short Term Memory). The method comprises the steps that firstly, an electrocardiosignal is preprocessed, and wavelet transform is used for conducting noise reduction on the electrocardiosignal; then learning real electrocardiosignal data characteristics by using a diffusion model; the method comprises the following steps of: firstly, acquiring heart beat data, then utilizing a convolutional neural network and a Bi-LSTM feature extractor to learn heart beat features, finally, inputting the learned features into a full connection layer, and then utilizing softmax to obtain the probability that the heart beat data belong to a corresponding category, thereby realizing classification of electrocardiosignals. Finally, in order to detect the heart state of the patient in real time, the fully trained classification model is stored and migrated to a cloud end, then signals, collected by electrocardiosignal collecting equipment in real time, of the patient are input into the model, whether the heart rhythm of the patient is normal or not is judged, a result is fed back to a user, and therefore the patient can conveniently see a doctor and treat the patient in time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electrocardiogram (ECG) signal recognition, and more specifically to an ECG signal classification method based on a diffusion model and Bi-LSTM. Background Technology

[0002] Cardiovascular disease is a chronic condition with a high rate of sudden death, making the diagnosis and research of its closely related arrhythmias crucial. Arrhythmias are typically abnormalities in heart rhythm. Electrocardiogram (ECG) signals record the bioelectrical signals of the heart's electrical activity; therefore, identifying a patient's ECG signal is essential to determine if they have arrhythmias. However, manual diagnosis of arrhythmias is time-consuming and labor-intensive, while computer-aided diagnosis of ECG signals is constantly evolving, with deep learning methods showing particularly strong performance in ECG signal recognition.

[0003] While deep learning methods perform well in ECG signal classification tasks, they often require a large number of training samples for each class. In real life, abnormal heartbeats associated with arrhythmias are extremely rare compared to normal heartbeats. Learning discriminative features for rare classes in imbalanced datasets is very difficult; in extreme cases, trained models may completely ignore predictions for minority groups. Therefore, it is essential to mitigate the problems caused by data imbalance by learning real ECG signal features to generate ECG signals with similar feature distributions. Summary of the Invention

[0004] To address the shortcomings of existing technologies, the present invention aims to provide an electrocardiogram (ECG) signal classification method based on a diffusion model and Bi-LSTM. This method uses a diffusion model to generate data with a distribution similar to real data to alleviate the problem of data imbalance, and then uses a convolutional neural network (CNN) and Bi-LSTM to learn its features to achieve ECG signal recognition.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a method for ECG signal recognition based on diffusion model and Bi-LSTM, characterized by comprising the following steps:

[0006] Step 1: Preprocess the acquired ECG signal by using wavelet transform to reduce noise in the ECG signal, and then extract the heartbeat data from the continuous ECG signal.

[0007] Step 2: Use the diffusion model to learn the features of existing real data, generate new heartbeat data that are similar to the feature distribution of real data, and expand the dataset;

[0008] Step 3: Use a convolutional neural network and a Bi-LSTM feature extractor to learn the features of the heartbeat data extracted in Step 1 and the heartbeat data generated in Step 2.

[0009] Step four: Input the features learned in step three into the fully connected layer to train the model, and then use softmax to obtain the probability that the heartbeat data belongs to the corresponding category.

[0010] Step 5: Migrate the fully trained model to the cloud, use the model to determine whether the real-time collected ECG signals are healthy, and feed the results back to the user.

[0011] As a further improvement of the present invention, the step of extracting heartbeat data from the continuous electrocardiogram signal in step one is as follows: 140 sample points are extracted forward and 180 sample points are extracted backward according to the position of the R wave peak as a heartbeat, thereby realizing the extraction of heartbeats from the continuous electrocardiogram signal.

[0012] As a further improvement of the present invention, the diffusion model in step two includes forward diffusion and reverse noise reduction, wherein the specific steps of forward diffusion are as follows:

[0013] Gaussian noise is gradually added to the existing electrocardiogram signal data E0~q(e), as shown below:

[0014]

[0015]

[0016] Where T is the number of forward diffusion steps, β t ∈(0,1) represents the variance used in each step, and β1<β2<...<β t , This represents a Gaussian distribution with mean μ and variance σ; as t increases, the original data e0 will gradually lose its characteristics.

[0017] Adding independent Gaussian distributions together, for any time t, results in a noisy image e. t have:

[0018]

[0019] Where α t =1-β t , Then e t It can be represented as: and As a further improvement of the present invention, the specific process of diffusion model inverse noise reduction in step two is as follows:

[0020]

[0021]

[0022] And p θ (e t-1 |e t The specific calculations are as follows:

[0023]

[0024] Specifically, for e at time t t To put it another way:

[0025]

[0026] Where, ∈ θ (e t ,t) is a learnable denoising function, that is, it learns the parameters in the U-Net model;

[0027] Use the following function to learn the parameters in the model:

[0028]

[0029] As a further improvement of the present invention, the specific steps for extracting the features of the heartbeat data in step three are as follows: Step three one, the data generated in step two and the data in step one are mixed to obtain data ED. data Using N c The process of using a multi-layered CNN to extract the ECG signal feature ECF can be represented as follows:

[0030] ECF Nc =relu(BN(Cov1d(ECF) Nc-1 )))

[0031] Where Cov1d(*) represents a 1D convolution operation, BN represents a Batch Normalization operation, ReLU is the activation function, and its initial features are the input data ED. data The characteristic representation, i.e., ECF0 = ED data Step 3.2: The ECF of features extracted by the CNN module can be segmented into τ vectors V of length l:

[0032] ECF = [V1, V2, ... V τ ]

[0033] Then, the sequence features of the ECG signal, ELF, are learned by further using Bi-LSTM. Bi-LSTM consists of a forward and a backward LSTM, and the learned features are obtained by concatenating the two parts, as shown below:

[0034] ELF = LSTM1(ECF) || LSTM2(ECF)

[0035] In this context, LSTM1 represents the forward process, LSTM2 represents the backward process, and || represents the concatenation operation.

[0036] As a further improvement of the present invention, the LSTM in step three-two is a special type of recurrent neural network, which introduces a total of input gates In τ Forgotten Gate f τ Output gate τ The three gating mechanisms are described in detail below:

[0037] Forgetting Gate f τ In other words:

[0038] f τ =sigmoid(W f .h τ-1 +U f V τ +b f )

[0039] k τ =c τ-1 ⊙f τ

[0040] For input gate In τ part:

[0041] In τ =sigmoid(W In .h τ-1 +U In V τ +b In )

[0042] c τ =tanh(Wh) τ-1 +UV τ +b)⊙In τ +k τ

[0043] For the output gate Out τ part:

[0044] Out τ =sigmoid(W Out .h τ-1 +U Out V τ +b out )

[0045] h τ =tanh(c τ )⊙Out τ

[0046] Where Vτ h is the current input. τ-1 The hidden state at τ-1, W * U * These are all learnable weight parameters, b * It's a bias, c τ Used for message passing; ⊙ represents the dot product operation.

[0047] As a further improvement of the present invention, the specific steps for obtaining the probability that the heartbeat data belongs to the corresponding category using softmax in step four are as follows: After obtaining the feature ELF of the electrocardiogram signal through the feature extractor, the probability that the heartbeat belongs to the corresponding category is further quantified through a fully connected layer and softmax, as shown below:

[0048] prob = softmax(linear(ELF, k))

[0049] Where k is the number of heartbeat categories;

[0050] The following equation can be used to optimize the parameters in the classification model:

[0051]

[0052] Among them, y ij The value of y is 0 or 1 if the true label of sample i is category j. ij =1, otherwise y ij =0, prob ij Let represent the predicted probability that sample i belongs to category j, and n be the total number of heartbeat samples.

[0053] As a further improvement of the present invention, the specific method of migrating the fully trained model to the cloud in step five, and using the model to determine whether the real-time collected electrocardiogram signal is healthy, and feeding the result back to the user is as follows: first, extract the fully trained model parameters, save them and transmit them to the cloud, then transmit the real-time collected electrocardiogram signal data to the model, and then return the computer's analysis results to the client, so that the patient can obtain the real-time status of the heart through the client.

[0054] The beneficial effects of this invention are that it learns the feature distribution of real data through a diffusion model, thereby generating new data similar to the feature distribution of real data, thus alleviating the problem of imbalance between normal heartbeat and abnormal heartbeat data. Then, it uses CNN and Bi-LSTM to further learn the features of ECG signals, thereby realizing the recognition of ECG signals. Attached Figure Description

[0055] Figure 1 This is a flowchart of the ECG signal classification based on the diffusion model and Bi-LSTM of the present invention;

[0056] Figure 2 This is a schematic diagram of the diffusion model used in this invention;

[0057] Figure 3 This is a schematic diagram of the feature extractor used in this invention;

[0058] Figure 4 This is a schematic diagram of the LSTM framework used in this invention. Detailed Implementation

[0059] The present invention will now be described in further detail with reference to the embodiments shown in the accompanying drawings.

[0060] like Figures 1 to 4 As shown in this embodiment, an ECG signal classification method based on a diffusion model and Bi-LSTM is described, and the method steps are as follows:

[0061] Step 1: Preprocess the acquired ECG signal, use wavelet transform to reduce noise in the ECG signal, and then extract heartbeat data from the continuous ECG signal.

[0062] ECG signal acquisition is often affected by external environment and the user's own activity, resulting in noise. Therefore, wavelet transform is first used to reduce noise in the ECG signal. While the data acquired by the device is continuous ECG signal data, most arrhythmic signals with abnormal heartbeats are usually manifested in a single heartbeat. Therefore, it is necessary to extract the continuous heartbeat signal for identification. The most common method is to extract a segment forward and backward from the position of the R-wave peak as a heartbeat. Considering that the R-wave peak is biased towards the P wave rather than the center of the heartbeat, 140 sample points were extracted forward and 180 sample points were extracted backward, thus achieving the extraction of continuous ECG heartbeat signals.

[0063] Step 2: Use the diffusion model to learn the features of existing real data, generate new data with similar feature distribution to the real data, and expand the dataset;

[0064] In the collected electrocardiogram (ECG) signals, the number of normal heartbeats is often far greater than the number of abnormal heartbeats associated with arrhythmias. This data imbalance significantly impacts ECG signal recognition. In many cases, model predictions tend to favor the class with the larger number of beats, thus affecting the detection of abnormal heartbeats. Therefore, this study utilizes a diffusion model to learn the feature distribution of abnormal heartbeat data, thereby generating data with a feature distribution similar to the real data, resulting in an expanded dataset DM. data This is used for training. The diffusion model consists of two processes: forward diffusion and inverse noise reduction. Its main steps are as follows:

[0065] Gaussian noise is gradually added to the existing electrocardiogram signal data E0~q(e), as shown below:

[0066]

[0067]

[0068] Where T is the number of forward diffusion steps, β t ∈(0,1) represents the variance used in each step, and β1<β2<...<β t . This represents a Gaussian distribution with mean μ and variance σ; as t increases, the original data e0 will gradually lose its characteristics.

[0069] The sum of independent Gaussian distributions is still a Gaussian distribution. Therefore, for any time t, the noisy image e t have:

[0070]

[0071] Where α t =1-β t , Then e t It can be represented as: and

[0072] The reverse noise reduction process is about learning how to reduce noise from e T The process of restoring to e0 involves sampling e. T , The noise reduction process can be represented as:

[0073]

[0074]

[0075] And p θ (e t-1 |e t The specific calculations are as follows:

[0076]

[0077] Specifically, for e at time t t To put it another way:

[0078]

[0079] Where ∈ θ (e t,t) is a learnable denoising function. Here, U-Net is used to learn this process, that is, the parameters that need to be learned are the parameters in the U-Net model.

[0080] Therefore, the following function is used to learn the parameters in the model:

[0081]

[0082] Step 3: Use CNN and Bi-LSTM feature extractors to learn the features of heartbeats;

[0083] By using the original data E data New ECG data DM generated by diffusion model data The training data obtained after mixing is ED data Then, a feature extractor is used to extract features from each category of ECG signals. The feature extractor mainly consists of CNN and Bi-LSTM, and its main steps are as follows:

[0084] First, use N c The process of using a multi-layered CNN to extract the ECG signal feature ECF can be represented as follows:

[0085] ECF Nc =relu(BN(Cov1d(ECF) Nc-1 )))

[0086] Where Cov1d(*) represents a 1D convolution operation, BN represents a Batch Normalization operation, ReLU is the activation function, and its initial features are the input data ED. data The characteristic representation, i.e., ECF0 = ED data .

[0087] The ECF, whose features are extracted using a CNN module, can be segmented into τ vectors V of length l:

[0088] ECF = [V1, V2, ... V τ ]

[0089] Then, the sequence features of the ECG signal, ELF, are learned by further using Bi-LSTM, which consists of a forward and a backward LSTM; the learned features are obtained by concatenating the two parts, as shown below:

[0090] ELF = LSTM1(ECF) || LSTM2(ECF)

[0091] Where LSTM1 represents the forward process, LSTM2 represents the backward process, and || represents the concatenation operation.

[0092] LSTM is a special type of recurrent neural network that introduces a total of input gates In τ Forgotten Gate f τ Output gate τ The three gating mechanisms are described in detail below:

[0093] Forgetting Gate f τ In other words:

[0094] f τ =sigmoid(W f .h τ-1 +U f V τ +b f )

[0095] k τ =c τ-1 ⊙f τ

[0096] For input gate In τ part:

[0097] In τ =sigmoid(W In .h τ-1 +U In V τ +b In )

[0098] c τ =tanh(Wh) τ-1 +UV τ +b)⊙In τ +k τ

[0099] For the output gate Out τ part:

[0100] Out τ =sigmoid(W Out .h τ-1 +U Out V τ +b out )

[0101] h τ =tanh(c τ )⊙Out τ

[0102] Where V τ h is the current input. τ-1 The hidden state at τ-1, W * U * These are all learnable weight parameters, b *It's a bias, c τ Used for message passing; ⊙ represents the dot product operation.

[0103] Step 4: Input the learned feature ELF into the fully connected layer, and then use softmax to obtain the probability that the heartbeat data belongs to the corresponding category.

[0104] After obtaining the feature ELF of the ECG signal through the feature extractor, the probability of the heartbeat belonging to the corresponding category is further quantified through a fully connected layer and softmax, as shown below:

[0105] prob = softmax(linear(ELF, k))

[0106] Where k is the number of heartbeat categories.

[0107] Finally, the following equation is applied to optimize the parameters in the classification model:

[0108]

[0109] Where y ij The value of y is 0 or 1 if the true label of sample i is category j. ij =1, otherwise y ij =0, prob ij Let represent the predicted probability that sample i belongs to category j, and n be the total number of heartbeat samples.

[0110] Step 5: Migrate the fully trained model to the cloud, use the model to determine whether the real-time collected ECG signals are healthy, and feed the results back to the user.

[0111] First, the fully trained model parameters are extracted, saved, and uploaded to the cloud. Then, the real-time collected electrocardiogram (ECG) signal data is transmitted to the model, and the computer's analysis results are returned to the client. The patient can then obtain the real-time status of their heart through the client.

[0112] In summary, this embodiment presents an ECG signal classification method based on a diffusion model and Bi-LSTM. The method includes: considering that the acquired ECG signals are continuous data and may contain noise, the ECG signals are first preprocessed using wavelet transform for noise reduction, and then heartbeats are extracted from the continuous ECG signals; next, a diffusion model is used to learn the features of the actual ECG signal data, synthesizing new data with a feature distribution similar to the actual data; then, a convolutional neural network and a Bi-LSTM feature extractor are used to learn the features of the heartbeats; finally, the learned features are input into a fully connected layer, and softmax is used to obtain the probability that the heartbeat data belongs to the corresponding category, thereby achieving ECG signal classification. Finally, to monitor the patient's cardiac status in real time, the fully trained classification model is saved and migrated to the cloud. The ECG signal acquisition device then collects the patient's signals in real time and inputs them into the model to determine whether the patient's heart rhythm is normal, and the results are fed back to the user, facilitating timely medical attention and treatment for the patient.

[0113] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.

Claims

1. A method for ECG signal recognition based on diffusion model and Bi-LSTM, characterized in that: Includes the following steps: Step 1: Preprocess the acquired ECG signal by using wavelet transform to reduce noise in the ECG signal, and then extract the heartbeat data from the continuous ECG signal. Step 2: Use the diffusion model to learn the features of existing real data, generate new heartbeat data that are similar to the feature distribution of real data, and expand the dataset; Step 3: Use a convolutional neural network and a Bi-LSTM feature extractor to learn the features of the heartbeat data extracted in Step 1 and the heartbeat data generated in Step 2. Step four: Input the features learned in step three into the fully connected layer to train the model, and then use softmax to obtain the probability that the heartbeat data belongs to the corresponding category. Step 5: Migrate the fully trained model to the cloud, use the model to determine whether the real-time collected ECG signals are healthy, and feed the results back to the user.

2. The ECG signal recognition method based on diffusion model and Bi-LSTM according to claim 1, characterized in that: The steps for extracting heartbeat data from continuous electrocardiogram (ECG) signals in step one are as follows: based on the position of the R-wave peak, 140 sample points are extracted forward and 180 sample points are extracted backward as a heartbeat, thereby realizing the extraction of heartbeats from continuous ECG signals.

3. The ECG signal recognition method based on diffusion model and Bi-LSTM according to claim 2, characterized in that: The diffusion model in step two includes forward diffusion and inverse noise reduction, wherein the specific steps of forward diffusion are as follows: Gaussian noise is gradually added to the existing electrocardiogram signal data E0~q(e), as shown below: Where T is the number of forward diffusion steps, β t ∈(0,1) represents the variance used in each step, and β1<β2<...<β t , This represents a Gaussian distribution with mean μ and variance σ; as t increases, the original data e0 will gradually lose its characteristics. Adding independent Gaussian distributions together, for any time t, results in a noisy image e. t have: Where α t =1-β t , Then e t It can be represented as: and 4. The ECG signal recognition method based on diffusion model and Bi-LSTM according to claim 3, characterized in that: The specific process of inverse noise reduction using the diffusion model in step two is as follows: And p θ (e t-1 |e t The specific calculations are as follows: Specifically, for e at time t t To put it another way: Where, ∈ θ (e t ,t) is a learnable denoising function, that is, it learns the parameters in the U-Net model; Use the following function to learn the parameters in the model:

5. The ECG signal recognition method based on diffusion model and Bi-LSTM according to claim 4, characterized in that: The specific steps for extracting features from heart rate data in step three are as follows: Step 31: Combine the data generated in Step 2 with the data from Step 1 to obtain data ED. data Using N c The process of using a multi-layered CNN to extract the ECG signal feature ECF can be represented as follows: ECF Nc =relu(BN(Cov1d(ECF Nc-1 ))) Where Cov1d(*) represents a 1D convolution operation, BN represents a Batch Normalization operation, ReLU is the activation function, and its initial features are the input data ED. data The characteristic representation, i.e., ECF0 = ED data ; Step 32: The ECF, which extracts features through the CNN module, can be segmented into τ vectors V of length l: ECF=[V1,V2,...V τ ] Then, the sequence features of the ECG signal, ELF, are learned by further using Bi-LSTM. Bi-LSTM consists of a forward and a backward LSTM, and the learned features are obtained by concatenating the two parts, as shown below: ELF = LSTM1(ECF) || LSTM2(ECF) In this context, LSTM1 represents the forward process, LSTM2 represents the backward process, and || represents the concatenation operation.

6. The ECG signal recognition method based on diffusion model and Bi-LSTM according to claim 5, characterized in that: The LSTM in step 3.2 is a recurrent neural network, which introduces a total of input gates In τ Forgotten Gate f τ Output gate τ The three gating mechanisms are described in detail below: Forgetting Gate f τ In other words: f τ =sigmoid(W f .h τ-1 +U f V τ +b f ) k τ =c τ-1 ⊙f τ For input gate In τ part: In τ =sigmoid(W In .h τ-1 +U In V τ +b In ) c τ = tanh(Wh τ-1 +UV τ +b)⊙In τ +k τ For the output gate Out τ part: Out τ =sigmoid(W Out .h τ-1 +U Out V τ +b out ) h τ = tanh(c τ )⊙Out τ Where V τ h is the current input. τ-1 The hidden state at τ-1, W * U * These are all learnable weight parameters, b * It's a bias, c τ Used for message passing; ⊙ represents the dot product operation.

7. The ECG signal recognition method based on diffusion model and Bi-LSTM according to claim 6, characterized in that: The specific steps for obtaining the probability that the heartbeat data belongs to the corresponding category using softmax in step four are as follows: After obtaining the feature ELF of the electrocardiogram signal through the feature extractor, the probability that the heartbeat belongs to the corresponding category is further quantified through a fully connected layer and softmax, as shown below: prob = softmax(linear(ELF, k)) Where k is the number of heartbeat categories; The following equation can be used to optimize the parameters in the classification model: Among them, y ij The value of y is 0 or 1 if the true label of sample i is category j. ij =1, otherwise y ij =0, prob ij Let represent the predicted probability that sample i belongs to category j, and n be the total number of heartbeat samples.

8. The ECG signal recognition method based on diffusion model and Bi-LSTM according to claim 7, characterized in that: In step five, the fully trained model is migrated to the cloud, and the model is used to determine whether the real-time collected electrocardiogram (ECG) signal is healthy. The results are then fed back to the user in the following way: First, the fully trained model parameters are extracted, saved, and uploaded to the cloud. Then, the real-time collected ECG signal data is transmitted to the model. Finally, the computer's analysis results are returned to the client, and the patient can obtain the real-time status of their heart through the client.