Electrocardiogram generation method for synthesizing customizable heart cycle based on diffusion model

Through the deep generation model based on diffusion model, the problems of data imbalance and poor privacy protection in electrocardiogram generation are solved, accurate signal generation and high-quality electrocardiogram output under different heart conditions are achieved, the scope of application is expanded and personalized medical care is promoted development.

CN118948293AActive Publication Date: 2024-11-15HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)

Patent Information

Application Number
CN202411056546.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2024-11-15
Estimated Expiration
2044-08-02

AI Technical Summary

Technical Problem

The existing electrocardiogram generation methods have problems such as data imbalance, poor privacy protection and inability to generate specific pathological signals, which limits its application in automated heart disease diagnosis.

Method used

Using a deep generation model based on diffusion model, the electrocardiogram signal is generated by taking the semantic label of the ECG as the input sequence and combining noise and diffusion time steps, which specifically includes the converter model, embedding layer, normalization module, gated processing module and decoding optimize parameters to generate customizable ECG.

Benefits of technology

It improves the clinical relevance and customizability of electrocardiogram generation, can accurately generate signals under different heart conditions, enhances patient privacy protection, expands the scope of application of electrocardiogram, and is superior to existing methods in terms of quality and authenticity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118948293A_ABST
    Figure CN118948293A_ABST
Patent Text Reader

Abstract

The invention discloses an electrocardiogram generation method for synthesizing a customizable heart cycle based on a diffusion model, relates to an electrocardiogram generation method, and aims to solve the problems that electrocardiogram signals generated by an existing electrocardiogram generation method are unbalanced in data, poor in privacy protection and incapable of generating specific pathological signals. Electrocardiogram semantic tags are used as condition input, noise and diffusion time steps are input to a depth generation model at the same time, and an electrocardiogram is generated; the deep generation model takes a diffusion model as an overall architecture, introduces a converter model to learn a long-term dependency relationship in an electrocardiogram signal, and introduces a semantic electrocardiogram batch normalization module to accurately learn local ECG semantic features. The method has the beneficial effects that the generated electrocardiogram signal can precisely follow provided electrocardiogram semantic information, an electrocardiogram with real physiological significance can be customized, the problem of data imbalance can be improved, and privacy protection is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to an electrocardiogram generating method. Background Art

[0002] Cardiovascular disease is one of the major health challenges facing the world. It has a significant impact on morbidity and mortality, and has brought tremendous pressure to public health and medical systems. Electrocardiogram (ECG), as a non-invasive, painless and easy-to-use technology for recording cardiac electrophysiological activity, has been widely used in the diagnosis and monitoring of heart disease. ECG signals are usually quasi-periodic, consisting of a series of repeated heartbeats, including P waves, QRS complexes (including Q waves, R waves and S waves) and T waves, and sometimes U waves. Doctors can evaluate heart function and diagnose cardiovascular diseases by analyzing these waveform changes, but this method has the limitations of high cost and high specialization. In recent years, the development of artificial intelligence technology has significantly reduced the professional requirements and costs of ECG analysis, but this progress relies on large-scale data sets. Existing ECG databases still face the problems of low data availability and data imbalance, which limits the application of deep learning technology in automated heart disease diagnosis, and establishing a complete large-scale ECG dataset is time-consuming and labor-intensive. Data augmentation through ECG generation is an effective solution to this problem. Some ECG signal generation methods mainly focus on simulating cardiac dynamics and cardiac mechanics, but these methods are costly, inefficient, and difficult to generate diverse ECG signals on a large scale; ECG signals generated by signal processing and simple machine learning methods have limited variability and cannot ensure patient privacy; in recent years, deep learning has shown great potential in ECG signal generation, especially methods based on deep generative models, such as variational autoencoders and generative adversarial networks; these methods can generate high-quality samples, but still face the problems of mode collapse, unstable training, and inability to generate clinically credible ECG signals; diffusion models have been applied to ECG generation in recent years, which can effectively capture the long-term dependencies of ECG data and generate clinically credible ECG signals that are stably trained; however, existing methods do not take into account detailed physiological characteristics and cardiac cycle conditions, and due to the scarcity of rare disease data, existing ECG generation methods still face many challenges in customization and synthesis of specific pathological signals; therefore, there is an urgent need for a solution that can overcome these defects to further expand the application scope of synthetic ECG. Summary of the invention

[0003] The purpose of the present invention is to solve the problems of data imbalance, poor privacy protection and inability to generate specific pathological signals in electrocardiogram signals generated by existing electrocardiogram generation methods, and proposes an electrocardiogram generation method based on diffusion model synthesis with customizable cardiac cycles.

[0004] The present invention provides a method for generating an electrocardiogram based on a diffusion model to synthesize a customizable cardiac cycle. The electrocardiogram generation method is as follows:

[0005] The ECG semantic label is input as the input sequence, and the noise and diffusion time step are input to the deep generative model to generate the ECG;

[0006] The deep generative model includes a converter model, an embedding layer, a third linear layer, a normalization module, a gate processing module, a first convolution module, a second convolution module and an adder;

[0007] The converter model includes an encoder and a decoder;

[0008] An encoder, used for encoding the input noise to generate an encoded noise signal;

[0009] The embedding layer includes a first linear layer and a second linear layer;

[0010] The first linear layer and the second linear layer are used to encode the time information of the input diffusion time step to obtain the time step embedding vector;

[0011] The third linear layer is used to match the time step embedding vector to the same length as the encoded noise signal, and add it to the encoded noise signal element by element to fuse the time step information to obtain the noisy signal fused with the time embedding vector;

[0012] A first convolution module, used for applying a convolution layer to the noisy signal fused with the time embedding vector to change the number of channels, thereby obtaining a convolution-processed signal;

[0013] A normalization module is used to input the convolution processing signal and the semantic information label corresponding to the input electrocardiogram data, and output a vector embedded with the semantic information;

[0014] A gated processing module, used for performing gated hyperbolic tangent nonlinear processing on the vector embedded with semantic information to obtain a gated processing signal;

[0015] The second convolution module is used to perform convolution processing on the gated processing signal, project the residual channel back to the original channel dimension, and obtain the output signal of the current layer;

[0016] An adder, configured to add the output signal of the current layer and the encoded noise signal element by element to form a residual, and connect the residual as an input to the next residual block to obtain a predicted noise;

[0017] The decoder is used to obtain the denoised signal by using the predicted noise, and decode the denoised signal to generate an electrocardiogram.

[0018] Furthermore, the parameters of the deep generative model are determined by training optimization, and the specific optimization steps are:

[0019] Step 1: divide the ECG data set into a training set and a test set, annotate the ECG data set, and generate an ECG semantic label corresponding to each ECG record according to the annotation results;

[0020] Step 2: Using the training set as input and the ECG semantic label as a condition, optimize the parameters of the initial deep generative model to obtain the final deep generative model.

[0021] Furthermore, the specific method of dividing the electrocardiogram data set in step 1 is: dividing it into a training set and a test set in a ratio of 7.5:2.5.

[0022] Furthermore, the specific method for annotating the electrocardiogram data set is: dividing each electrocardiogram record in the electrocardiogram data set into a P wave area, a T wave area, a QRS complex area and other partial areas; wherein the P wave area is marked as 1; the T wave area is marked as 2; the QRS complex area is marked as 3; and other partial areas are marked as 0.

[0023] Furthermore, in step 2, before optimizing the parameters of the initial deep generative model, the training set and the ECG semantic label are subjected to Hank processing; wherein each ECG record in the training set is denoted as X; and the ECG semantic label corresponding to each ECG record is denoted as Y;

[0024] The Hank processing is to convert the electrocardiogram record X in the training set into a two-dimensional Hank matrix x; and convert the electrocardiogram semantic label Y corresponding to each electrocardiogram record into a two-dimensional Hank matrix y.

[0025] Furthermore, the specific process of converting the electrocardiogram record X in the training set into the two-dimensional Hank matrix x is:

[0026] Each ECG record X in the training set is a one-dimensional sequence d of length N, denoted by X = {d 1 ,d 2 ,d 3 ,...,d N}; where d 1 is the first element in the one-dimensional sequence d, d 2 is the second element in the one-dimensional sequence d, d 3 is the third element in the one-dimensional sequence d, d N is the Nth element in the one-dimensional sequence d;

[0027] Select a window length L, where 1≤L≤N; the size of the two-dimensional Hank matrix x is L×K, where K is the number of windows and K=N-L+1; each element of the two-dimensional Hank matrix x is represented by an element of the one-dimensional sequence d as:

[0028] x ij =d i+j-1 , where 1≤i≤L, 1≤j≤K;

[0029] Therefore, we get the two-dimensional Hank matrix x:

[0030]

[0031] In the two-dimensional Hank matrix x, the elements on each anti-diagonal line are the same.

[0032] Furthermore, the specific process of converting the electrocardiogram semantic label Y corresponding to each electrocardiogram record into a two-dimensional Hank matrix y is:

[0033] The ECG semantic label Y corresponding to each ECG record is a one-dimensional sequence f of length N, denoted as Y = {f 1 ,f 2 ,f 3 ,...,f N}; where f 1 is the first element in the one-dimensional sequence f, f 2 is the second element in the one-dimensional sequence f, f 3 is the third element in the one-dimensional sequence f, f N is the Nth element in the one-dimensional sequence f;

[0034] Select a window length L, where 1≤L≤N; the size of the two-dimensional Hank matrix y is L×K, where K is the number of windows and K=N-L+1; each element of the two-dimensional Hank matrix y is represented by an element of the one-dimensional sequence f as:

[0035] y ij =f i+j-1 , where 1≤i≤L, 1≤j≤K;

[0036] Therefore, we get the two-dimensional Hank matrix y:

[0037]

[0038] In the two-dimensional Hank matrix y, the elements on each anti-diagonal line are the same.

[0039] Furthermore, the specific method for optimizing the parameters of the initial deep generative model in step 2 is:

[0040] Step (1), for the two-dimensional Hank matrix x, from the noise-free x 0 To pure Gaussian noise x T , generate multiple noise signals x t ; Among them, α t is the scaling factor at each time step t in the forward process of the diffusion model; t is the diffusion time step; β is the diffusion rate;

[0041] Step (2), for each corresponding diffusion time step t, the time information is encoded by the time embedding layer; the output of the time embedding layer is obtained by transforming the formula 1; the formula 1 is:

[0042] TE=Swish(Linear 2 (Swish(Linear 1 (TimeEmbed(t))))) Formula 1

[0043] Among them, TimeEmbed is the time embedding layer; Linear 1 Is the first linear layer; Linear 2 is the second linear layer; TE is the time step embedding vector; Swish(·) is the first activation function, which is defined as:

[0044] Step (3), use the encoder to input the noise signal x t Encode to generate the encoded noise signal x′ t ;

[0045] Step (4), the time step embedding vector TE is matched to the encoded noise signal x′ through the third linear layer t The same length as the encoded noise signal x′ t Add elements by element to fuse the time step information; get the noisy signal z fused with the time embedding vector t ;

[0046] z t = x′ t +Linear 3 (TE)

[0047] Among them, Linear 3 is the third linear layer;

[0048] Step (5), obtain the noisy signal z fused with the time embedding vector t Apply the convolution layer to change the number of channels and obtain the convolution processing signal z′ t ;

[0049] z′t =Conv1D(z t )

[0050] Among them, Conv1D is the convolution operation symbol;

[0051] Step (6), convolution processing signal z' t The semantic information label y corresponding to the ECG in the training set after Hank processing is passed to the normalization module, and the normalization module outputs the vector z″ embedded with semantic information t ;

[0052] Step (7), the normalization module outputs the vector z″ that embeds the semantic information t After gated hyperbolic tangent nonlinear processing, the gated processing signal is obtained

[0053]

[0054] Among them, tanh(·) is the second activation function, σ(·) is the third activation function,

[0055] Step (8), gated processing signal The residual channel is projected back to the original channel dimension through the convolution layer to obtain the output signal of the current layer

[0056] Step (9), the output signal of the current layer and the processed noise signal x′ generated in step (3) t Add element by element to form the residual Residual Connected to the next residual block as input;

[0057] in:

[0058] Step (10), after passing through multiple layers of residual blocks, the features transmitted from different residual blocks are fused element by element through skip connections to obtain a prediction noise ∈ θ (x t ,t), where θ is the diffusion model parameter; the training goal is to minimize the loss function, that is, the mean square error between the predicted noise and the real noise is minimized; the specific calculation formula of the training goal is:

[0059]

[0060] in, is the loss function, ∈ is the real noise; x 0 ~D represents the noise-free x sampled from the training data distribution D 0; represents the real noise ∈ sampled from a standard normal distribution with mean 0 and variance 1; t~U(1,T) represents the time step t sampled from the uniform distribution U(1,T);

[0061] Step (11), use back propagation and gradient descent algorithm to optimize the diffusion model parameters θ to obtain the final deep generative model.

[0062] Furthermore, the specific formula for the decoder to obtain the denoised signal using the predicted noise is:

[0063]

[0064] Among them, α t is the scaling factor at each time step t during the diffusion process, is the cumulative product of the α parameters from time step 1 to time step t, s is the cumulative product variable; σ t is the coefficient of random noise introduced in the denoising process.

[0065] Furthermore, the specific calculation formula of the training target in step (10) is obtained by the following method:

[0066] The diffusion model includes two processes: forward process and reverse process;

[0067] In the forward process, the diffusion model gradually introduces noise in the form of a Markov chain. The parameterization formula of this process is as follows:

[0068]

[0069] Among them, no noise x 0 is the original data sample without noise interference, pure Gaussian noise x T is the data after T noise addition steps, where T is the number of diffusion steps; the specific noise introduction formula is: Among them, β t is the noise variance of the forward process; is a normal distribution; I represents the identity matrix; x t Use the following formula:

[0070]

[0071] In the reverse process, the diffusion model gradually removes noise and reconstructs the original data from the given data sample; the specific reconstruction process is: the model is trained using the objective function; the parameterization formula of the reverse process is as follows:

[0072]

[0073] Among them, x T Obey the standard normal distribution; loss function It is used to train the neural network in the reverse process, so that the neural network can be given the diffusion time step t and the current noise signal x t The prediction noise ∈ θ (x t ,t), so the specific calculation formula of the training target is as follows:

[0074]

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

[0076] The present invention uses a deep generative model based on a diffusion model to synthesize customizable biomedical ECG signals. By embedding ECG semantic information (including the positions of P waves, QRS waves and T waves), the ECG generation method effectively improves the clinical relevance of the model; the ECG generation method is a method for incorporating key cardiac information such as cardiac cycle phase and waveform position into the conditional label of the deep generative model; unlike previous ECG generation methods, the ECG generation method can manually set the ECG semantic label when annotating the ECG data set and generating the ECG semantic label corresponding to each ECG record according to the annotation results. Manually setting the ECG semantic label allows fine-tuning of the cardiac cycle phase and can accurately generate ECG signals under various cardiac conditions, thereby achieving higher customizability. This progress effectively expands the application scope of synthetic ECGs, further strengthens patient privacy protection, and promotes the development of personalized medicine; the generation method described in the present invention can synthesize ECG signals that accurately follow the real cardiac cycle information, and is superior to existing methods in terms of quality and authenticity, and quantitatively analyzes the quality of the customized ECG model from different angles by calculating indicators based on distance and correlation. In addition, the authenticity evaluation of the ECG generation method also includes the use of a segmentation model to verify whether the generated ECG waveform accurately follows the provided cardiac cycle information and can effectively replace the real signal in training; the results show that the ECG generation method can not only accurately customize the cardiac cycle phase, but also has obvious advantages in generating ECG. The ECG generation method of the present invention can synthesize ECG signals that accurately follow the real cardiac cycle information, and is superior to existing methods in terms of quality and authenticity; the generation method can generate accurate and interpretable ECG waveforms under various cardiac conditions such as different heart rates and QTc intervals, which highlights its potential in clinical relevance; by modulating the cardiac cycle phase and generating ECGs under rare physiological conditions, it solves the major challenges of data scarcity and patient privacy; by synthesizing tailored ECG signals, the deep generation model provides a valuable tool for medical research and application, so the ECG signal generated by the ECG generation method of the present invention is data-balanced and privacy-protected, and the ECG generation method can generate specific pathological signals. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] Figure 1 A schematic diagram of the specific structure of the deep generative model described in the first specific implementation mode;

[0078] Figure 2 It is a schematic diagram of the parameter optimization process of the deep generative model of the second specific implementation mode;

[0079] Figure 3 It is a structural schematic diagram of a normalization module in a specific implementation mode eight;

[0080] Figure 4 It is a schematic diagram of the directed graph structure of the diffusion model in the tenth specific implementation method. DETAILED DESCRIPTION

[0081] Specific implementation method 1. Combination Figure 1 This embodiment describes a method for generating an electrocardiogram based on a diffusion model to synthesize a customizable cardiac cycle. The electrocardiogram generating method is:

[0082] The ECG semantic label is input as the input sequence, and the noise and diffusion time step are input to the deep generative model to generate the ECG;

[0083] The deep generative model includes a converter model, an embedding layer, a third linear layer, a normalization module, a gate processing module, a first convolution module, a second convolution module and an adder;

[0084] The converter model includes an encoder and a decoder;

[0085] An encoder, used for encoding the input noise to generate an encoded noise signal;

[0086] The embedding layer includes a first linear layer and a second linear layer;

[0087] The first linear layer and the second linear layer are used to encode the time information of the input diffusion time step to obtain the time step embedding vector;

[0088] The third linear layer is used to match the time step embedding vector to the same length as the encoded noise signal, and add it to the encoded noise signal element by element to fuse the time step information to obtain the noisy signal fused with the time embedding vector;

[0089] A first convolution module, used for applying a convolution layer to the noisy signal fused with the time embedding vector to change the number of channels, thereby obtaining a convolution-processed signal;

[0090] A normalization module is used to input the convolution processing signal and the semantic information label corresponding to the input electrocardiogram data, and output a vector embedded with the semantic information;

[0091] A gated processing module, used for performing gated hyperbolic tangent nonlinear processing on the vector embedded with semantic information to obtain a gated processing signal;

[0092] The second convolution module is used to perform convolution processing on the gated processing signal, project the residual channel back to the original channel dimension, and obtain the output signal of the current layer;

[0093] An adder, configured to add the output signal of the current layer and the encoded noise signal element by element to form a residual, and connect the residual as an input to the next residual block to obtain a predicted noise;

[0094] The decoder is used to obtain the denoised signal by using the predicted noise, and decode the denoised signal to generate an electrocardiogram.

[0095] In this embodiment, if Figure 1 As shown in the figure, the specific structure of the deep generative model is given. The deep generative model uses the diffusion model as the overall architecture, introduces the converter model to learn the long-term dependencies in the ECG signal, and introduces the semantic electrocardiogram batch normalization module (SEBN) to accurately learn the local ECG semantic features; the converter model consists of two parts: the encoder and the decoder. The encoder is used to process the input sequence and the decoder is used to generate the output sequence. The encoder uses a multi-head self-attention mechanism to allow the model to focus on different positions in the input sequence, and then independently applies a feedforward neural network at each position. Each sublayer is followed by a residual connection and layer normalization; in order to prevent overfitting, a dropout layer is added between the sublayer and the feedforward network. The structure of the decoder is similar to that of the encoder, where the self-attention mechanism uses a mask to block future positions, and the input of the encoder-decoder attention mechanism is the self-attention output of the decoder and the output of the encoder.

[0096] The ECG generation method is the first method to incorporate key cardiac information such as cardiac cycle phase and waveform position into the conditional labels of the deep generative model; unlike previous ECG generation methods, this ECG generation method can manually set the ECG data set when annotating it and generating the ECG semantic labels corresponding to each ECG record based on the annotation results. Manually setting the ECG semantic labels allows fine-tuning of the cardiac cycle phase and can accurately generate ECG signals under various cardiac conditions, thereby achieving higher customizability. This progress effectively expands the application scope of synthetic ECGs, further strengthens patient privacy protection, and promotes the development of personalized medicine; the generation method described in the present invention can synthesize ECG signals that accurately follow the real cardiac cycle information, and is superior to existing methods in terms of quality and authenticity, and quantitatively analyzes the quality of the customized ECG model from different angles by calculating distance- and correlation-based indicators. In addition, the authenticity evaluation of the ECG generation method also includes the use of a segmentation model to verify whether the generated ECG waveform accurately follows the provided cardiac cycle information and can effectively replace the real signal in training; the results show that the ECG generation method can not only accurately customize the cardiac cycle phase, but also has obvious advantages in generating ECG. The ECG generation method described in the present invention can synthesize ECG signals that accurately follow the real cardiac cycle information, and is superior to existing methods in terms of quality and authenticity; the generation method can generate accurate and interpretable ECG waveforms under various cardiac conditions such as different heart rates and QTc intervals, which highlights its clinical relevance; by modulating the cardiac cycle phase and generating ECGs under rare physiological conditions, it solves the major challenges of data scarcity and patient privacy; by synthesizing tailored ECG signals, the deep generation model provides a valuable tool for medical research and application, therefore, the ECG signal generated by the ECG generation method described in the present invention is data-balanced and privacy-protected, and the ECG generation method can generate specific pathological signals.

[0097] Specific implementation method 2: Combination Figure 2 This embodiment is described. This embodiment further limits the electrocardiogram generation method based on the diffusion model to synthesize a customizable cardiac cycle described in the specific embodiment 1. In this embodiment, the parameters of the deep generative model are determined by training optimization. The specific optimization steps are:

[0098] Step 1: divide the ECG data set into a training set and a test set, annotate the ECG data set, and generate an ECG semantic label corresponding to each ECG record according to the annotation results;

[0099] Step 2: Using the training set as input and the ECG semantic label as a condition, optimize the parameters of the initial deep generative model to obtain the final deep generative model.

[0100] In this embodiment, the training set and the ECG semantic labels are used as input and conditions, and the parameters of the initial deep generative model are optimized by gradually adding noise training to generate the final deep generative model.

[0101] Specific implementation method three: This implementation method further limits the electrocardiogram generation method based on diffusion model synthesis of customizable cardiac cycles described in specific implementation method two. In this implementation method, the specific method of dividing the electrocardiogram data set in step one is: dividing it into a training set and a test set in a ratio of 7.5:2.5.

[0102] In this embodiment, dividing the training set and the test set according to the above-mentioned ratio can not only meet the purpose of training a deep generative model, but also when the test set and the electrocardiogram semantic labels corresponding to each electrocardiogram record are input into the obtained deep generative model, a customizable ECG with real physiological significance can be output.

[0103] Specific implementation method four, this implementation method further limits the electrocardiogram generation method based on diffusion model synthesis of customizable cardiac cycle described in specific implementation method two. In this implementation method, the specific method of annotating the electrocardiogram data set is: each electrocardiogram record in the electrocardiogram data set is divided into a P wave area, a T wave area, a QRS complex area and other partial areas; wherein the P wave area is marked as 1; the T wave area is marked as 2; the QRS complex area is marked as 3; and other partial areas are marked as 0.

[0104] In this embodiment, each electrocardiogram record in the electrocardiogram dataset is reasonably annotated and then participates in the training of the diffusion model, thereby enhancing the physiological significance of the ECG signal generated by the deep generative model.

[0105] Specific implementation method 5. This implementation method further limits the electrocardiogram generation method based on the diffusion model to synthesize a customizable cardiac cycle described in specific implementation method 2. In this implementation method, in step 2, before optimizing the parameters of the initial deep generation model, the training set and the electrocardiogram semantic label are subjected to Hank processing; wherein each electrocardiogram record in the training set is denoted as X; and the electrocardiogram semantic label corresponding to each electrocardiogram record is denoted as Y;

[0106] The Hank processing is to convert the electrocardiogram record X in the training set into a two-dimensional Hank matrix x; and convert the electrocardiogram semantic label Y corresponding to each electrocardiogram record into a two-dimensional Hank matrix y.

[0107] In this embodiment, the one-dimensional ECG signal and the ECG semantic label corresponding to each ECG record are converted into a two-dimensional matrix form using the Hankelization method, thereby enhancing the model's ability to learn the semantic information of the ECG signal.

[0108] Specific implementation method 6: This implementation method further limits the method for generating an electrocardiogram based on a diffusion model to synthesize a customizable cardiac cycle described in specific implementation method 5. In this implementation method, the specific process of converting the electrocardiogram record X in the training set into a two-dimensional Hank matrix x is:

[0109] Each ECG record X in the training set is a one-dimensional sequence d of length N, denoted by X = {d 1 ,d 2 ,d 3 ,...,d N}; where d 1 is the first element in the one-dimensional sequence d, d 2 is the second element in the one-dimensional sequence d, d 3 is the third element in the one-dimensional sequence d, d N is the Nth element in the one-dimensional sequence d;

[0110] Select a window length L, where 1≤L≤N; the size of the two-dimensional Hank matrix x is L×K, where K is the number of windows and K=N-L+1; each element of the two-dimensional Hank matrix x is represented by an element of the one-dimensional sequence d as:

[0111] x ij =d i+j-1 , where 1≤i≤L, 1≤j≤K;

[0112] Therefore, we get the two-dimensional Hank matrix x:

[0113]

[0114] In the two-dimensional Hank matrix x, the elements on each anti-diagonal line are the same.

[0115] In this embodiment, the electrocardiogram record X is Hank-ized in this way, so that it becomes a two-dimensional Hank matrix x, so as to perform the next step of diffusion model training and signal generation.

[0116] Specific implementation method 7: This implementation method further limits the electrocardiogram generation method based on diffusion model synthesis with customizable cardiac cycle described in specific implementation method 6. In this implementation method, the specific process of converting the electrocardiogram semantic label Y corresponding to each electrocardiogram record into a two-dimensional Hank matrix y is:

[0117] The ECG semantic label Y corresponding to each ECG record is a one-dimensional sequence f of length N, denoted as Y = {f 1 ,f 2 ,f 3 ,...,f N}; where f 1 is the first element in the one-dimensional sequence f, f 2 is the second element in the one-dimensional sequence f, f 3 is the third element in the one-dimensional sequence f, f N is the Nth element in the one-dimensional sequence f;

[0118] Select a window length L, where 1≤L≤N; the size of the two-dimensional Hank matrix y is L×K, where K is the number of windows and K=N-L+1; each element of the two-dimensional Hank matrix y is represented by an element of the one-dimensional sequence f as:

[0119] y ij =f i+j-1 , where 1≤i≤L, 1≤j≤K;

[0120] Therefore, we get the two-dimensional Hank matrix y:

[0121]

[0122] In the two-dimensional Hank matrix y, the elements on each anti-diagonal line are the same.

[0123] In this embodiment, in this way, the ECG semantic label Y corresponding to each ECG record is Hank-ized to become a two-dimensional Hank matrix y for the next step of diffusion model training and signal generation.

[0124] Specific implementation method 8. Combination Figure 3 This embodiment is described. This embodiment further limits the electrocardiogram generation method based on the diffusion model synthesis of customizable cardiac cycles described in the specific embodiment 7. In this embodiment, the specific method of obtaining the deep generation model in step 2 is:

[0125] Step (1), for the two-dimensional Hank matrix x, from the noise-free x 0 To pure Gaussian noise x T , generate multiple noise signals x t ; Among them, α t is the scaling factor at each time step t in the forward process of the diffusion model; t is the diffusion time step; β is the diffusion rate;

[0126] Step (2), for each corresponding diffusion time step t, the time information is encoded by the time embedding layer; the output of the time embedding layer is obtained by transforming the formula 1; the formula 1 is:

[0127] TE=Swish(Linear 2 (Swish(Linear 1 (TimeEmbed(t))))) Formula 1

[0128] Among them, TimeEmbed is the time embedding layer; Linear 1 Is the first linear layer; Linear 2 is the second linear layer; TE is the high-dimensional time-step embedding vector; Swish(·) is the first activation function, which is defined as:

[0129] Step (3), use the converter model to calculate the input noise signal x t Encode to generate the encoded noise signal x′ t ;

[0130] Step (4), the high-dimensional time step embedding vector TE is matched to the encoded noise signal x′ through the third linear layer t The same length as the encoded noise signal x′ t Add elements by element to fuse the time step information; get the noisy signal z fused with the time embedding vector t ;

[0131] z t = x′ t +Linear 3 (TE)

[0132] Among them, Linear 3 is the third linear layer;

[0133] Step (5), obtain the noisy signal z fused with the time embedding vector t Apply the convolution layer to change the number of channels and obtain the first convolution processing signal z′ t ;

[0134] z′ t =Conv1D(z t )

[0135] Among them, Conv1D is the convolution operation symbol;

[0136] Step (6), convolution processing signal z' tThe semantic information label y corresponding to the ECG in the training set after Hank processing is passed to the normalization module, and the normalization module outputs the vector z″ embedded with semantic information t ; Enable deep generative models to adapt to the semantic content and spatial layout of the input;

[0137] Step (7), the normalization module outputs the vector z″ that embeds the semantic information t After gated hyperbolic tangent nonlinear processing, the gated processing signal is obtained

[0138]

[0139] Among them, tanh(·) is the second activation function, σ(·) is the third activation function,

[0140] Step (8), gated processing signal The residual channel is projected back to the original channel dimension through the convolution layer to obtain the output signal of the current layer

[0141] Step (9), the output signal of the current layer and the processed noise signal x generated in step (3) t 'Add element by element to form the residual Residual Connected to the next residual block as input; alleviates the gradient vanishing problem and helps the model train deeper networks;

[0142] in:

[0143] Step (10), after passing through multiple layers of residual blocks, the features transmitted from different residual blocks are fused element by element through skip connections to obtain a prediction noise ∈ θ (x t ,t), where θ is the diffusion model parameter; the training goal is to minimize the loss function, that is, the mean square error between the predicted noise and the real noise is minimized; the specific calculation formula of the training goal is:

[0144]

[0145] in, is the loss function, ∈ is the real noise; x 0 ~D represents the noise-free x sampled from the training data distribution D 0 ; represents the real noise ∈ sampled from a standard normal distribution with mean 0 and variance 1; t~U(1,T) represents the time step t sampled from the uniform distribution U(1,T);

[0146] Step (11), use back propagation and gradient descent algorithm to optimize the diffusion model parameters θ, and finally obtain a deep generative model.

[0147] In this embodiment, the specific structure of the normalization module is as follows: Figure 3 As shown; the normalization module learns the P wave, QRS complex and T band information in the electrocardiogram signal by adjusting the normalization parameters, thereby enhancing the physiological significance of the generated ECG signal. First, the normalization module projects the input Hankelized ECG semantic information mask into an embedding space, and generates the first modulation parameter γ and the second modulation parameter δ with spatial awareness through convolution operation; the generated first modulation parameter γ and the second modulation parameter δ tensor are element-wise multiplied and added with the normalized activation value, which enhances the spatial details and contextual information in the output; the formula is as follows:

[0148] z″ t =γ·z norm +δ

[0149] Among them, z norm is the normalized activation value, z″ t is the output of the normalization module.

[0150] By adaptively adjusting the normalization parameters, the normalization module enables the deep generative model to adapt to the semantic content and spatial layout of the input. This adaptability improves the authenticity and accuracy of the generated ECG signal. The design of the normalization module enables the deep generative model to finely control each stage of the cardiac cycle and synthesize ECG signals with specific cardiac information. This feature greatly enhances the performance of the deep generative model in the electrocardiogram generation task, can provide physiologically meaningful ECG signals, enhance fine-grained control of different cardiac cycle stages, effectively improve the authenticity and accuracy of the generated signal, and make the output of the deep generative model more in line with clinical practice.

[0151] Specific implementation method 9: This implementation method further limits the electrocardiogram generation method based on diffusion model synthesis with customizable cardiac cycle described in specific implementation method 8. In this implementation method, the decoder uses the predicted noise to obtain the denoised signal using the specific formula:

[0152]

[0153] Among them, α t is the scaling factor at each time step t during the diffusion process, is the cumulative product of the α parameters from time step 1 to time step t, s is the cumulative product variable; σ t is the coefficient of random noise introduced in the denoising process.

[0154] In this embodiment, the denoised signal output by the decoder is subjected to De-Hankelization processing to complete the generation of the electrocardiogram; the generated two-dimensional matrix is ​​converted into a one-dimensional synthetic ECG signal by de-Hankelizing the output, which accurately follows the test set ECG label semantic information and has real physiological significance; De-Hankelization is the inverse process of Hankelization, which restores the Hankel matrix to the original data form.

[0155] Specific implementation method 10. Combination Figure 4 This embodiment is described. This embodiment further limits the electrocardiogram generation method based on the diffusion model synthesis of customizable cardiac cycles described in the specific embodiment 6. In this embodiment, the specific calculation formula of the training target in step (10) is obtained by the following method:

[0156] The diffusion model includes two processes: forward process and reverse process;

[0157] In the forward process, the diffusion model gradually introduces noise in the form of a Markov chain. The parameterization formula of this process is as follows:

[0158]

[0159] Among them, no noise x 0 is the original data sample without noise interference, pure Gaussian noise x T is the data after T noise addition steps, where T is the number of diffusion steps; the specific noise introduction formula is: Among them, β t is the noise variance of the forward process; is a normal distribution; I represents the identity matrix; x t Use the following formula:

[0160]

[0161] In the reverse process, the diffusion model gradually removes noise and reconstructs the original data from the given data sample; the specific reconstruction process is: the model is trained using the objective function; the parameterization formula of the reverse process is as follows:

[0162]

[0163] Among them, x T Obey the standard normal distribution; loss function It is used to train the neural network in the reverse process, so that the neural network can be given the diffusion time step t and the current noise signal x t The prediction noise ∈θ (x t ,t), so the specific calculation formula of the training target is as follows:

[0164]

[0165] In this embodiment, the diffusion model includes two processes: a forward process and a reverse process, such as Figure 4 As shown in Figure 2, in the forward process, the diffusion model gradually introduces noise in a Markov manner. In contrast, in the reverse process, the diffusion model gradually removes noise to achieve the purpose of reconstructing the original data from the given data samples.

[0166] The technical effects of the present invention are verified by specific embodiments below:

[0167] Embodiment 1:

[0168] 1. Preprocessing: The open ECG dataset QT database in PhysioNet was selected, which contains 105 15-minute dual-channel ECG records sampled at 250Hz; ECG experts annotated the start, peak, and end of the P wave, QRS complex, and T wave of each record. The semantic information label of each ECG record is generated based on the annotations, that is, the P wave area is marked as 1, the QRS complex is marked as 3, the T wave is marked as 2, and the other parts are marked as 0. The data was downsampled to 125Hz and divided into sample segments with 500 sampling points. The dataset was divided into training and test sets in a ratio of 7.5:2.5, with 17,379 and 5,757 ECG segments, respectively, for model training and test generation of ECGs. Each ECG record and label is a one-dimensional sequence with a length of N=500. The ECG record X is recorded as: X={d 1 ,d 2 ,d 3 ,...,d 500}; ECG semantic label Y is recorded as: Y = {f 1 ,f 2 ,f 3 ,...,f 500}; Then, the ECG record X and the ECG semantic label Y are processed by Hank conversion, and the ECG record X in the training set is converted into a two-dimensional Hank matrix x; and the ECG semantic label Y corresponding to each ECG record is converted into a two-dimensional Hank matrix y; a window length L = 201 is selected, and the size of the two-dimensional Hank matrix x and the two-dimensional Hank matrix y will both be L×K, where K = N-L+1 = 300. The two-dimensional Hank matrix x and the two-dimensional Hank matrix y are obtained:

[0169]

[0170]

[0171] The elements on each anti-diagonal line in the two-dimensional Hank matrix x and the two-dimensional Hank matrix y are the same. In this way, the original data and labels are pre-processed and Hank-ized for the next step of diffusion model training and signal generation.

[0172] 2. Model training: The Hanked training set signals and labels are used as input and conditions, and the deep generative model is trained by gradually adding noise.

[0173] The specific deep generative model training process is as follows:

[0174] (1) Step (1), for a two-dimensional Hank matrix x, from the noise-free x 0 To pure Gaussian noise x T , generate multiple noise signals x t ; Among them, α t is the scaling factor at each time step t in the forward process of the diffusion model; t is the diffusion time step; β is the diffusion rate; specifically, 600 diffusion time steps were used and β values ​​ranged from 0.0001 to 0.02.

[0175] Step (2), for each corresponding diffusion time step t, the time information is encoded through the time embedding layer; the output of the time embedding layer is obtained by transformation through formula 1; the model includes three stages of diffusion embedding, with dimensions of 128, 201 and 201 respectively; the formula 1 is:

[0176] TE=Swish(Linear 2 (Swish(Linear 1 (TimeEmbed(t))))) Formula 1

[0177] Among them, TimeEmbed is the time embedding layer; Linear 1 Is the first linear layer; Linear 2 is the second linear layer; TE is the high-dimensional time-step embedding vector; Swish(·) is the first activation function, which is defined as:

[0178] Step (3), input noise signal x t Apply the converter model to generate the processed noise signal x′ t ; Specifically, the converter model includes 5 attention heads, a feed-forward network with 2048 hidden units, a dropout probability of 0.1, and a 5-layer stacking structure;

[0179] Step (4), the high-dimensional time step embedding vector TE is matched to the processed noise signal x′ through the third linear layer t The same length as the processed noise signal x′ t Add elements by element to fuse the time step information; get the noisy signal z fused with the time embedding vector t ;

[0180] z t = x′ t +Linear 3 (TE)

[0181] Among them, Linear 3 is the third linear layer;

[0182] Step (5), obtain the noisy signal z fused with the time embedding vector t Apply the convolution layer to change the number of channels and obtain the convolution processing signal z′ t ;

[0183] z′ t =Conv1D(z t )

[0184] Among them, Conv1D is the convolution operation symbol;

[0185] Step (6), convolution processing signal z' t The semantic information label y corresponding to the ECG in the training set after Hank processing is passed to the normalization module, and the normalization module outputs the vector z″ embedded with semantic information t ;

[0186] Step (7), the normalization module outputs the vector z″ that embeds the semantic information t After gated hyperbolic tangent nonlinear processing, the gated processing signal is obtained

[0187]

[0188] Among them, tanh(·) is the second activation function, σ(·) is the third activation function,

[0189] Step (8), gated processing signal The residual channel is projected back to the original channel dimension through the convolution layer to obtain the output signal of the current layer

[0190] Step (9), the output signal of the current layer and the processed noise signal x′ generated in step (3) t Add element by element to form the residual Residual Connected as input to the next residual block; the specific deep generation model has 36 residual layers and 201 residual and skip channels;

[0191] in:

[0192] Step (10), after passing through multiple layers of residual blocks, the features transmitted from different residual blocks are fused element by element through skip connections to obtain a prediction noise ∈ θ (x t ,t), where θ is the diffusion model parameter; the training goal is to minimize the loss function, that is, the mean square error between the predicted noise and the real noise is minimized; the specific calculation formula of the training goal is:

[0193]

[0194] in, is the loss function, ∈ is the real noise; x 0 ~D represents the noise-free x sampled from the training data distribution D 0 ; represents the real noise ∈ sampled from a standard normal distribution with mean 0 and variance 1; t~U(1,T) represents the time step t sampled from the uniform distribution U(1,T);

[0195] Step (11), use the back propagation and gradient descent algorithm to optimize the diffusion model parameter θ, and finally obtain the deep generative model; specifically, the learning rate of the Adam optimizer is 2×10 -4 .

[0196] 3. Signal generation:

[0197] Step 31. Generate and remove noise x 0 Pure Gaussian noise x of the same size T , gradually remove noise from diffusion time step T to 1;

[0198] Step 32: Convert the current noise signal x t Combined with the corresponding diffusion time step t, we can get the noisy signal z that integrates the time embedding vector t , and the semantic information label y corresponding to the ECG in the test set after Hank processing, the model predicts the noise ∈ θ (x t ,t), and use the predicted noise to calculate the denoised signal x t-1

[0199]

[0200] Among them, αt is the scaling factor at each time step t during the diffusion process, is the cumulative product of the α parameters from time step 1 to time step t, s is the cumulative product variable; σ t is the coefficient of random noise introduced in the denoising process;

[0201] Step 3. The final denoised output is obtained through the converter model, and the denoised output is de-Hankered to generate an electrocardiogram.

[0202] Quality evaluation: In order to comprehensively evaluate the quality of the synthesized ECG, the proposed final deep generative model is quantitatively evaluated. Commonly used distance and correlation-based metrics, including maximum mean difference (MMD) and Pearson correlation coefficient (PC), are used to comprehensively evaluate the ECG performance generated by the model from different perspectives and dimensions.

[0203] The Maximum Mean Difference (MMD) measures the difference between two data distributions. It calculates the maximum difference in the means of these distributions in a specific feature space, and its formula is as follows:

[0204]

[0205] Among them, the Gaussian kernel function Smaller MMD values ​​indicate greater similarity in the distributions.

[0206] The Pearson correlation coefficient (PC) measures the linear correlation between two variables, with a value range between -1 and 1. Its formula is:

[0207]

[0208] Among them, x i and i represent the data points of synthetic and real signals, respectively. and is their mean. The closer the PC value is to 1, the stronger the correlation is.

[0209] The proposed ECG generation method generates synthetic ECGs using the test set labels and compares them with the corresponding real ECGs. The average of all similarity results is taken as the final evaluation result. Before calculating the metric, the synthetic and real ECGs are normalized to eliminate the influence of amplitude differences and accurately reflect the morphological similarity. The results are shown in Table 1.

[0210]

[0211] From the results, the deep generative model used in this paper performs well in terms of distance and correlation metrics, demonstrating its superior ability to generate physiologically meaningful ECG signals adapted to the cardiac cycle. For MMD, the value of the deep generative model is 9.33×10 -3 , indicating that the model captures the data distribution more accurately. When evaluating PC, the correlation coefficient of the model reached 0.7357, indicating that the model is close to the true signal in terms of morphological correlation. This highlights the excellent ability of the invented model in learning ECG semantic information and customizing the cardiac cycle.

[0212] Authenticity evaluation: In order to verify whether the generated ECG waveform accurately follows the provided cardiac cycle information, an authenticity evaluation was performed, which was divided into two parts. First, the generated signal was segmented using the segmentation model trained on the real signal, and the segmentation prediction was compared with the P, QRS, and T segment positions generated by the guidance signal. A high degree of match indicates that the generated ECG signal accurately follows the provided instructions. Secondly, a segmentation model is trained using the generated signal and the real segment positions as labels, and then the model is used to segment the real signal, and the prediction results are compared with the real labels. If the prediction results are close to the real labels, it means that the generated signal can effectively train the model for real signal segmentation. The results of the segmentation effectiveness evaluation are shown in Table 2.

[0213]

[0214] Table 2 shows that when the segmentation model is trained with real ECG and tested with synthetic ECG, high recall and precision are achieved in the detection of start and end points, which are 93.45% and 94.24%, and 95.20% and 96.78%, respectively. This shows that the deep generative model accurately follows the provided cardiac cycle information, enhancing clinical relevance and diagnostic accuracy. When the segmentation model is trained with synthetic ECG and tested with real ECG, the model has a recall of 98.20% and a precision of 97.33% at the start point; the recall of 96.67% and the precision of 97.59% at the end point, achieving a segmentation effect close to the real ECG. This shows that pre-training synthetic data can achieve close to real performance, which is of great significance for ECG analysis algorithms under strict privacy requirements.

[0215] Customized cardiac cycle phases: With the accurate reproduction of ECG semantic information, the deep generative model is able to precisely customize the cardiac cycle phase and accurately generate ECGs under various cardiac conditions, including different heart rates and QTc intervals. The model synthesizes customized ECGs based on waveform segmentation, interval length, and other information embedded in the label. The model can synthesize ECGs with normal heart rate (60-100bpm), bradycardia (less than 60bpm), and tachycardia (greater than 100bpm), and has the ability to generate high-quality ECGs with pathological features. In addition, the model can synthesize normal (QTc 350-470 milliseconds) and abnormal QTc intervals, highlighting the model's significant advantage in synthesizing ECGs of rare physiological conditions. Although mainly trained on normal ECGs, the final deep generative model performs well in generating abnormal ECGs, demonstrating its generalization ability beyond the training set. By manually setting label information, the ECG generation method can customize ECGs for specific conditions, thereby addressing the problem of data scarcity while ensuring a high degree of protection of patient privacy.

[0216] In summary, a deep generative model based on a diffusion model is used to synthesize customizable biomedical ECG signals. By embedding ECG semantic information (including the positions of P waves, QRS waves, and T waves), the ECG generation method effectively improves the clinical relevance of the model. This is the first method to incorporate key cardiac information such as cardiac cycle phase and waveform position into the conditional labels of a deep generative model. Unlike previous ECG generation methods, when annotating the ECG dataset and generating the ECG semantic labels corresponding to each ECG record based on the annotation results, it can be manually set. Manually setting the ECG semantic labels allows fine-tuning of the cardiac cycle phase and can accurately generate ECG signals under various cardiac conditions, thereby achieving higher customizability. This advancement effectively expands the application scope of synthetic ECGs, further strengthens patient privacy protection, and promotes the development of personalized medicine. The present invention can synthesize ECG signals that accurately follow the real cardiac cycle information, and outperforms existing methods in terms of quality and authenticity. By calculating distance- and correlation-based indicators, the quality of the customized ECG model is quantitatively analyzed from different perspectives. In addition, the authenticity evaluation of the ECG generation method also includes the use of a segmentation model to verify whether the generated ECG waveform accurately follows the provided cardiac cycle information and can effectively replace the real signal in training. The results show that the ECG generation method can not only accurately customize the cardiac cycle phase, but also has obvious advantages in generating ECGs. The present invention can synthesize ECG signals that accurately follow the real cardiac cycle information, and outperform existing methods in terms of quality and authenticity. The ability of this method to generate accurate and interpretable ECG waveforms under various cardiac conditions such as different heart rates and QTc intervals highlights its clinical relevance. By controlling the cardiac cycle phase and generating ECGs under rare physiological conditions, the major challenges of data scarcity and patient privacy are addressed. By synthesizing tailored ECG signals, the model provides a valuable tool for medical research and applications, and helps to develop more powerful and effective ECG generation methods.

[0217] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for generating an electrocardiogram based on a diffusion model to synthesize a customizable cardiac cycle, characterized in that: The electrocardiogram generation method is: The ECG semantic label is input as the input sequence, and the noise and diffusion time step are input to the deep generative model to generate the ECG; The deep generative model includes a converter model, an embedding layer, a third linear layer, a normalization module, a gate processing module, a first convolution module, a second convolution module and an adder; The converter model includes an encoder and a decoder; An encoder, used for encoding the input noise to generate an encoded noise signal; The embedding layer includes a first linear layer and a second linear layer; The first linear layer and the second linear layer are used to encode the time information of the input diffusion time step to obtain the time step embedding vector; The third linear layer is used to match the time step embedding vector to the same length as the encoded noise signal, and add it to the encoded noise signal element by element to fuse the time step information to obtain the noisy signal fused with the time embedding vector; A first convolution module, used for applying a convolution layer to the noisy signal fused with the time embedding vector to change the number of channels, thereby obtaining a convolution-processed signal; A normalization module is used to input the convolution processing signal and the semantic information label corresponding to the input electrocardiogram data, and output a vector embedded with the semantic information; A gated processing module, used for performing gated hyperbolic tangent nonlinear processing on the vector embedded with semantic information to obtain a gated processing signal; The second convolution module is used to perform convolution processing on the gated processing signal, project the residual channel back to the original channel dimension, and obtain the output signal of the current layer; An adder, configured to add the output signal of the current layer and the encoded noise signal element by element to form a residual, and connect the residual as an input to the next residual block to obtain a predicted noise; The decoder is used to obtain the denoised signal by using the predicted noise, and decode the denoised signal to generate an electrocardiogram.

2. The electrocardiogram generation method based on diffusion model synthesis of customizable cardiac cycles according to claim 1, characterized in that: The parameters of the deep generative model are determined by training optimization. The specific optimization steps are: Step 1: divide the ECG data set into a training set and a test set, annotate the ECG data set, and generate an ECG semantic label corresponding to each ECG record according to the annotation results; Step 2: Using the training set as input and the ECG semantic label as a condition, optimize the parameters of the initial deep generative model to obtain the final deep generative model.

3. The electrocardiogram generation method based on diffusion model synthesis of customizable cardiac cycles according to claim 2, characterized in that: The specific method for dividing the ECG data set in step 1 is: dividing it into a training set and a test set in a ratio of 7.5:2.

5.

4. The electrocardiogram generation method based on diffusion model synthesis of customizable cardiac cycles according to claim 2, characterized in that: The specific method for annotating the electrocardiogram data set is: each electrocardiogram record in the electrocardiogram data set is divided into a P wave area, a T wave area, a QRS complex area and other partial areas; wherein the P wave area is marked as 1; the T wave area is marked as 2; the QRS complex area is marked as 3; and other partial areas are marked as 0.

5. The electrocardiogram generation method based on diffusion model synthesis of customizable cardiac cycles according to claim 2, characterized in that: In step 2, the training set and the ECG semantic label are subjected to Hank processing before the parameters of the initial deep generative model are optimized; wherein each ECG record in the training set is denoted as X; and the ECG semantic label corresponding to each ECG record is denoted as Y; The Hank processing is to convert the electrocardiogram record X in the training set into a two-dimensional Hank matrix x; and convert the electrocardiogram semantic label Y corresponding to each electrocardiogram record into a two-dimensional Hank matrix y.

6. The electrocardiogram generation method based on diffusion model synthesis and customizable cardiac cycle according to claim 5, characterized in that: The specific process of converting the electrocardiogram record X in the training set into a two-dimensional Hank matrix x is: Each ECG record X in the training set is a one-dimensional sequence d of length N, denoted by X = {d1, d2, d3, ..., d N }; where d1 is the first element in the one-dimensional sequence d, d2 is the second element in the one-dimensional sequence d, d3 is the third element in the one-dimensional sequence d, and d N is the Nth element in the one-dimensional sequence d; Select a window length L, where 1≤L≤N; the size of the two-dimensional Hank matrix x is L×K, where K is the number of windows and K=N-L+1; each element of the two-dimensional Hank matrix x is represented by an element of the one-dimensional sequence d as: x ij =d i+j-1 , where 1≤i≤L, 1≤j≤K; Therefore, we get the two-dimensional Hank matrix x: In the two-dimensional Hank matrix x, the elements on each anti-diagonal line are the same.

7. The electrocardiogram generation method based on diffusion model synthesis and customizable cardiac cycle according to claim 6, characterized in that: The specific process of converting the electrocardiogram semantic label Y corresponding to each electrocardiogram record into a two-dimensional Hank matrix y is as follows: The ECG semantic label Y corresponding to each ECG record is a one-dimensional sequence f of length N, denoted as Y = {f1,f2,f3,...,f N }; where f1 is the first element in the one-dimensional sequence f, f2 is the second element in the one-dimensional sequence f, f3 is the third element in the one-dimensional sequence f, and f N is the Nth element in the one-dimensional sequence f; Select a window length L, where 1≤L≤N; the size of the two-dimensional Hank matrix y is L×K, where K is the number of windows and K=N-L+1; each element of the two-dimensional Hank matrix y is represented by an element of the one-dimensional sequence f as: y ij =f i+j-1 , where 1≤i≤L, 1≤j≤K; Therefore, we get the two-dimensional Hank matrix y: In the two-dimensional Hank matrix y, the elements on each anti-diagonal line are the same.

8. The electrocardiogram generation method based on diffusion model synthesis of customizable cardiac cycles according to claim 7, characterized in that: The specific method for optimizing the parameters of the initial deep generative model in step 2 is: Step (1), for the two-dimensional Hank matrix x, from noise-free x0 to pure Gaussian noise x T , generate multiple noise signals x t ; Among them, α t is the scaling factor at each time step t in the forward process of the diffusion model; t is the diffusion time step; β is the diffusion rate; Step (2), for each corresponding diffusion time step t, the time information is encoded by the time embedding layer; the output of the time embedding layer is obtained by transforming the formula 1; the formula 1 is: TE=Swish(Linear2(Swish(Linear1(TimeEmbed(t))))) Formula 1 Where TimeEmbed is the time embedding layer; Linear1 is the first linear layer; Linear2 is the second linear layer; TE is the time step embedding vector; Swish(·) is the first activation function, which is defined as: Step (3), use the encoder to input the noise signal x t Encode to generate the encoded noise signal x′ t ; Step (4), the time step embedding vector TE is matched to the encoded noise signal x′ through the third linear layer t The same length as the encoded noise signal x′ t Add elements by element to fuse the time step information; get the noisy signal z fused with the time embedding vector t ; Among them, Linear3 is the third linear layer; Step (5), obtain the noisy signal z fused with the time embedding vector t Apply the convolution layer to change the number of channels and obtain the convolution processing signal z′ t ; With' t =Conv1D(from t ) Among them, Conv1D is the convolution operation symbol; Step (6), convolution processing signal z' t The semantic information label y corresponding to the ECG in the training set after Hank processing is passed to the normalization module, and the normalization module outputs the vector z″ embedded with semantic information t ; Step (7), the normalization module outputs the vector z″ that embeds the semantic information t After gated hyperbolic tangent nonlinear processing, the gated processing signal is obtained Among them, tanh(·) is the second activation function, σ(·) is the third activation function, Step (8), gated processing signal The residual channel is projected back to the original channel dimension through the convolution layer to obtain the output signal of the current layer Step (9), the output signal of the current layer and the processed noise signal x′ generated in step (3) t Add element by element to form the residual Residual Connected to the next residual block as input; in: Step (10), after passing through multiple layers of residual blocks, the features transmitted from different residual blocks are fused element by element through skip connections to obtain a prediction noise ∈ θ (x t ,t), where θ is the diffusion model parameter; the training goal is to minimize the loss function, that is, the mean square error between the predicted noise and the real noise is minimized; the specific calculation formula of the training goal is: in, is the loss function, ∈ is the real noise; x0~D represents the noise-free x0 sampled from the training data distribution D; represents the real noise ∈ sampled from a standard normal distribution with mean 0 and variance 1; t~U(1,T) represents the time step t sampled from the uniform distribution U(1,T); Step (11), use back propagation and gradient descent algorithm to optimize the diffusion model parameters θ to obtain the final deep generative model.

9. The electrocardiogram generation method based on diffusion model synthesis and customizable cardiac cycle according to claim 8, characterized in that: The specific formula for the decoder to obtain the denoised signal using the predicted noise is: Among them, α t is the scaling factor at each time step t during the diffusion process, is the cumulative product of the α parameters from time step 1 to time step t, s is the cumulative product variable; σ t is the coefficient of random noise introduced in the denoising process.

10. The electrocardiogram generation method based on diffusion model synthesis and customizable cardiac cycle according to claim 8, characterized in that: The specific calculation formula of the training target in step (10) is obtained by the following method: The diffusion model includes two processes: forward process and reverse process; In the forward process, the diffusion model gradually introduces noise in the form of a Markov chain. The parameterization formula of this process is as follows: Among them, the noise-free x0 is the original data sample without noise interference, and the pure Gaussian noise x T is the data after T noise addition steps, where T is the number of diffusion steps; the specific noise introduction formula is: Among them, β t is the noise variance of the forward process; is a normal distribution; I represents the identity matrix; x t Use the following formula: In the reverse process, the diffusion model gradually removes noise and reconstructs the original data from the given data sample; the specific reconstruction process is: the model is trained using the objective function; the parameterization formula of the reverse process is as follows: Among them, x T Obey the standard normal distribution; loss function It is used to train the neural network in the reverse process, so that the neural network can be given the diffusion time step t and the current noise signal x t The prediction noise ∈ θ (x t ,t), so the specific calculation formula of the training target is as follows:

Citation Information

Patent Citations

  • Electrocardiogram generation system and method based on deep learning algorithm

    CN116744850A

  • Method and system for removing random mixed noise in dynamic electrocardiogram

    CN117009743A

  • Multi-view plant generation method and device based on cross-modal image generation

    CN117314755A

  • Method, program, and device for diagnosing left ventricular systolic dysfunction on basis of electrocardiogram

    CN117940071A

  • Physiological signal denoising

    US20140005988A1

Cited By

  • Heart sound signal processing method and device, electronic equipment and storage medium

    CN119446195A

  • Cardiovascular physiological electric signal recovery and prediction method and device

    CN120585344A