Model training method, electrocardiosignal generation method, device, and electronic device
By adding noise to real ECG signals and introducing R-wave information, a target ECG generation model is trained, which solves the problems of existing models generating data that do not conform to clinical rules and privacy leaks, and realizes high-quality generation of personalized ECG signals.
Patent Information
- Application Number
- CN202510243447.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2045-03-03
AI Technical Summary
Existing deep generative models lack consideration for personalized R-wave information when generating electrocardiogram signals, resulting in generated data that does not conform to actual clinical patterns and poses a risk of patient privacy leakage.
By adding noise to real electrocardiogram (ECG) signals multiple times, training samples containing ECG physiological type, R-wave information, and diffusion time steps are obtained. The target ECG generation model is trained using a denoised diffusion probability model. The model is then adjusted by combining R-wave information and diagnostic category to generate personalized simulated ECG signals that conform to clinical patterns.
The generated simulated electrocardiogram signals do not contain patients' personal privacy information, have personalized features, better conform to actual clinical practices, improve the quality and focus of the generated data, and reduce the risk of sample imbalance and privacy leakage.
Smart Images

Figure CN119886268B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data generation, and more specifically, to a method for training a simulated electrocardiogram (ECG) generation model, a method for generating ECG signals, an apparatus, an electronic device, and a storage medium. Background Technology
[0002] The field of electrocardiogram (ECG) signal generation focuses on generating high-quality ECG signals for medical or algorithm development purposes without concern for annotation costs or clinical data privacy restrictions. Currently, automated ECG diagnostic models developed using deep learning and other technologies require large amounts of real-world ECG data. However, real-world ECG data inevitably suffers from imbalanced samples and difficulties in protecting patient privacy. Therefore, a method is needed that can acquire large amounts of ECG data while ensuring balanced data samples and not infringing on patient privacy.
[0003] Currently, deep generative models, such as variational autoencoders, generative adversarial networks, and denoised diffusion probabilistic models, have emerged. These models can generate high-quality generated data without patient information by learning the distribution of training samples, which can protect patient privacy to some extent. However, these models do not take into account the differences between individual patients when generating data, lack focus on data from a particular patient or type, and the generated data sometimes does not conform to actual clinical patterns. Summary of the Invention
[0004] The purpose of this application is to at least solve one of the aforementioned technical defects. The technical solution provided by the embodiments of this application is as follows:
[0005] In a first aspect, embodiments of this application provide a model training method, including:
[0006] Obtain multiple training samples and their corresponding training labels. Each training sample includes the electrophysiological type, first R-wave information, initial noisy electrocardiogram signal, and first diffusion time step T. m The training labels are real ECG signals, and the initial noisy ECG signal in each training sample is obtained by performing T+0 processing on the corresponding training label. m The result obtained after adding noise;
[0007] For each training sample, the training sample is input into the initial model, and the output is the simulated electrocardiogram signal corresponding to the training sample;
[0008] Based on the simulated electrocardiogram signals corresponding to each training sample and the first diffusion time step T m The training labels are used to determine the training loss of the initial model, and the parameters of each model in the initial model are adjusted based on the training loss until the preset training termination condition is met, thus obtaining the target ECG generation model.
[0009] Secondly, embodiments of this application provide a method for generating electrocardiogram (ECG) signals, including:
[0010] The generation parameters of the target electrocardiogram signal are obtained, including the first R wave information, initial random Gaussian noise, electrocardiographic type, and the third diffusion time step T of the initial random Gaussian noise. o ;
[0011] The target ECG signal generation parameters are input into the target ECG generation model, and a simulated ECG signal is output; wherein, the target ECG generation model is obtained based on the model training method provided in the above embodiments.
[0012] Thirdly, embodiments of this application provide a training device for a simulated electrocardiogram (ECG) generation model, comprising:
[0013] The training sample acquisition module is used to acquire multiple training samples and the corresponding training label for each training sample. Each training sample includes the electrophysiological type, the first R wave information, the initial noisy electrocardiogram signal, and the first diffusion time step T. m The training labels are real ECG signals, and the initial noisy ECG signal in each training sample is obtained by performing T+0 processing on the corresponding training label. m The result obtained after adding noise;
[0014] The model training module is used to input the training sample into the initial model for each training sample and output the simulated electrocardiogram signal corresponding to the training sample.
[0015] The training loss determination module is used to determine the training loss based on the simulated electrocardiogram signal corresponding to each training sample and the first diffusion time step T. m The training labels are used to determine the training loss of the initial model, and the parameters of each model in the initial model are adjusted based on the training loss until the preset training termination condition is met, thus obtaining the target ECG generation model.
[0016] Fourthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory;
[0017] The processor executes a computer program to implement the method provided in the first aspect embodiment or any alternative embodiment of the first aspect.
[0018] Fifthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method provided in the first aspect embodiment or any optional embodiment of the first aspect.
[0019] The beneficial effects of the technical solutions provided in this application are:
[0020] The model training method provided in this application first adds noise to the real electrocardiogram (ECG) signal multiple times before the model training process, obtaining a noisy ECG signal. Then, the model is trained using information including the electrophysiological type, first R-wave information, the noisy real ECG signal, and the diffusion time step during the noisy addition as input conditions. This allows the model to learn the correlation between R-wave information, electrophysiological type, and ECG signal during training. The simulated ECG signal output by the model is compared with the real ECG signal to determine the training loss and continuously adjust the model parameters, ultimately obtaining a well-trained target ECG generation model. By introducing R-wave information to train the ECG generation model, the simulated ECG signal generated by the trained model does not contain patients' personal privacy information. Furthermore, because the target ECG generation model incorporates R-wave information when generating simulated ECG signals, the generated simulated ECG signals have personalized characteristics and can focus on data from a specific patient type, ensuring high data quality while better reflecting actual clinical patterns. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0022] Figure 1 A schematic flowchart illustrating a model training method provided in an embodiment of this application;
[0023] Figure 2 This is a schematic diagram of an example center electrical signal according to an embodiment of this application;
[0024] Figure 3 This is a schematic diagram of the structure of the first sub-model in one example of an embodiment of this application;
[0025] Figure 4 A flowchart illustrating an electrocardiogram (ECG) signal generation method provided in this application embodiment;
[0026] Figure 5 This is a schematic diagram of the overall steps of a method for generating simulated electrocardiogram signals in an example of an embodiment of this application;
[0027] Figure 6 This is a flowchart illustrating a training loss determination method in one example of an embodiment of this application.
[0028] Figure 7 A structural block diagram of a simulated electrocardiogram generation model training device provided in this application embodiment;
[0029] Figure 8A structural block diagram of a simulated electrocardiogram signal generation device provided in this application embodiment;
[0030] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0031] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0032] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”
[0033] The prior art relating to the embodiments of this application will be briefly described below:
[0034] The field of electrocardiogram (ECG) signal generation focuses on generating high-quality ECG signals for medical or algorithm development purposes without concern for annotation costs or clinical data privacy restrictions. Currently, automated ECG diagnostic models developed using deep learning and other technologies require a large amount of real ECG signals. However, real-world ECG signals inevitably suffer from imbalanced samples and difficulties in protecting patient privacy. Deep generative models, such as variational autoencoders, generative adversarial networks, and denoising diffusion probability models, can generate high-quality generated signals without patient information by learning the distribution of training samples, thus protecting patient privacy to some extent. Introducing specific diagnostic category conditions during training allows the model to generate ECG data for specific cardiovascular diseases, thereby expanding the sample dataset and balancing the sample distribution.
[0035] R-wave information: This can be a component of an electrocardiogram (ECG) signal. The morphological characteristics of an ECG signal lie in its various waveform components, primarily including the P wave, QRS complex, T wave, and U wave, each reflecting changes in electrode potential at different locations. The vector component with the highest amplitude is the QRS complex, which reflects the potential changes during depolarization of the left and right ventricles (including the interventricular septum). The first downward wave is the Q wave, followed by an upward high wave as the R wave, and then a downward wave as the S wave. A schematic diagram of the various waveforms of a heartbeat can be seen as follows... Figure 2 As shown. Since R-wave information can characterize the electrocardiographic type of a particular patient, it can reveal the personalized aspects of the electrocardiogram signal.
[0036] Currently, the ECG signals generated by ECG generation models (hereinafter referred to as ECG data) can be broadly divided into two types: beat data (or short-term ECG data) and long-term ECG data. Since most clinically collected ECG data is long-term (over 10 seconds), automatic ECG diagnostic models trained using beat data require pre-segmentation of the clinically acquired long-term ECG data into specific beat data before further classification. This diminishes the clinical significance of beat generation models to some extent. Existing 12-lead 10-second long-term ECG generation models mostly generate ECGs based solely on diagnostic categories, resulting in relatively random results. These models do not yet consider incorporating personalized R-wave information to generate ECG signals that conform to clinical patterns. This invention proposes a training method for ECG generation models that incorporates personalized R-wave information, improving the quality of generated ECG signals and making them as consistent as possible with real-world clinical patterns.
[0037] The purpose of this invention is to provide a training method for a personalized R-wave electrocardiogram (ECG) generation model. This method utilizes existing real ECG signals for training the ECG generation model, introducing R-wave information and diagnostic categories (i.e., ECG physiological types as described below) as conditions during the training process. This enables the generation of personalized R-waves and specific categories of ECG signals, improving the clinical significance of the generated ECG signals, reducing generation randomness, and thereby expanding the training dataset, balancing sample distribution, and reducing the risk of patient privacy breaches. This has significant implications for the development and application of subsequent automated ECG diagnostic models.
[0038] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0039] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0040] Figure 1 This application provides a flowchart illustrating a method for training an electrocardiogram (ECG) generation model. The execution entity of this method can be a terminal (e.g., a computer, mobile phone, etc.). Figure 1 As shown, the method may include:
[0041] Step S101: Obtain multiple training samples and the training label corresponding to each training sample.
[0042] In some embodiments, each training sample includes an electrophysiological type, first R-wave information, an initial noisy electrocardiogram signal, and a first diffusion time step T. m The training labels are real ECG signals, and the initial noisy ECG signal in each training sample is obtained by performing T+0 processing on the corresponding training label. m The result is obtained after adding noise.
[0043] The actual electrocardiogram (ECG) signal in this embodiment can be 12-lead ECG signal data. The electrophysiological type can be a diagnostic result obtained after extracting the ECG signal, such as normal, myocardial infarction, ST-T changes (slow ventricular repolarization), conduction disturbances, and ventricular hypertrophy. To enable the model to recognize these electrophysiological types, corresponding one-hot encoded labels can be created for these types as inputs that the model can recognize, such as normal: [1,0,0,0,0], myocardial infarction: [0,1,0,0,0], ST-T changes: [0,0,1,0,0], conduction disturbances: [0,0,0,1,0], ventricular hypertrophy: [0,0,0,0,1]. The initial noisy ECG signal can be an ECG signal obtained by adding noise to the actual ECG signal a certain number of times. The method used for adding noise can be random Gaussian noise, and the number of noise additions is the first diffusion time step T. m T m It can reflect the degree of added noise. Generally speaking, T m The larger the value, the more steps are required, and the more noise is added.
[0044] Specifically, before training the model, it is necessary to obtain the training samples and corresponding training labels for each sample. Since the final output of the model provided in this embodiment is an electrocardiogram (ECG) signal, the training label of the model should be a (real) ECG signal. The real ECG signal can be obtained by collecting ECG signals from real patients in clinical practice. At the same time, the collected real ECG signals are also diagnosed and R-waves are extracted to obtain the electrocardiographic type and the first R-wave information. The first R-wave information can be extracted by using a waveform detection toolkit to perform R-wave detection on each lead of the training ECG dataset, the validation ECG dataset, and the test ECG dataset. After the first R-wave information is extracted, several leads can be randomly selected for manual confirmation to ensure that the extraction of the first R-wave information is basically accurate.
[0045] Since the model provided in this embodiment is essentially a process of learning to progressively denoise the noisy signal, it is necessary to first add noise to the real ECG signal. The noise addition method used in this embodiment can be random Gaussian noise addition, that is, performing a first diffusion time step T on the real ECG signal based on a random Gaussian noise distribution. m After adding noise, an initial noisy ECG signal is obtained. Then, the ECG physiological type, the first R wave information, the initial noisy ECG signal, and the first diffusion time step T are combined. m They are used together as training samples, and real electrocardiogram signals are used as the training labels corresponding to these training samples.
[0046] It should be noted that, in this embodiment of the application, a portion of the training samples can be used as the validation set and test set, while the remaining training samples remain as the training set. The validation set is used to verify the training results of the model during training. If the training effect is found to be unsatisfactory, model training can be terminated and adaptive adjustments made to save resources. The test set is used to verify the training effect of the trained model after training is completed. For example, the ratio of the training set, validation set, and test set can be set to 8:1:1.
[0047] Step S102: For each training sample, input the training sample into the initial model and output the simulated electrocardiogram signal corresponding to the training sample.
[0048] The simulated electrocardiogram (ECG) signal is the denoised ECG signal obtained by the model after performing multiple denoising operations on the initial noisy ECG signal.
[0049] Step S103: Based on the simulated electrocardiogram signal corresponding to each training sample and the first diffusion time step T mThe training labels are used to determine the training loss of the initial model, and the parameters of each model in the initial model are adjusted based on the training loss until the preset training termination condition is met, thus obtaining the target ECG generation model.
[0050] In this application embodiment, the training termination condition can be reaching a fixed number of training iterations, or the training loss being less than a preset threshold, etc. This application embodiment does not limit this. The training loss can be used to measure the training effect of the model. Generally speaking, the smaller the training loss, the better the training effect of the model. However, too small a training loss may cause the model to overfit, which may have the opposite effect. Therefore, this application can limit the training effect of the model by setting a preset threshold, so as to ensure that the model can get a good output while preventing the model output from overfitting. Alternatively, the change of training loss during the training process can be observed in a fixed number of training iterations to actively prevent overfitting.
[0051] The model training method provided in this application first adds noise to the real electrocardiogram (ECG) signal multiple times before the model training process, obtaining a noisy ECG signal. Then, the model is trained using information including the electrophysiological type, first R-wave information, the noisy real ECG signal, and the diffusion time step during the noisy addition as input conditions. This allows the model to learn the correlation between R-wave information, electrophysiological type, and ECG signal during training. The simulated ECG signal output by the model is compared with the real ECG signal to determine the training loss and continuously adjust the model parameters, ultimately obtaining a well-trained target ECG generation model. By introducing R-wave information to train the ECG generation model, the simulated ECG signal generated by the trained model does not contain patients' personal privacy information. Furthermore, because the target ECG generation model incorporates R-wave information when generating simulated ECG signals, the generated simulated ECG signals have personalized characteristics and can focus on data from a specific patient type, ensuring high data quality while better reflecting actual clinical patterns.
[0052] Based on the above embodiments, as an optional embodiment, training samples are input into the initial model, and the simulated electrocardiogram signal corresponding to the training samples is output, specifically including:
[0053] Based on the training samples, a first preset number of iterations is performed, and the denoised ECG signal output from the last iteration is used as the simulated ECG signal. The first preset number of iterations is the first diffusion time step T. m ;
[0054] Each iteration includes:
[0055] Obtain the denoised ECG signal for this iteration; the denoised ECG signal for the first iteration is the initial denoised ECG signal.
[0056] Based on the denoised ECG signal of this iteration and the second diffusion time step T of this iteration n The first R-wave information and electrophysiological type are used to obtain the first predicted noise of this iteration. The first predicted noise is the noise to be removed from the denoised electrocardiogram signal of this iteration.
[0057] Based on the first predicted noise of this iteration, the denoised ECG signal of this iteration is denoised to obtain the denoised ECG signal of the next iteration.
[0058] In this embodiment, the denoised ECG signal in each iteration is the ECG signal that needs to be denoised. Second diffusion time step T n In this embodiment of the application, T is related to the current iteration round. n equal to T m Subtract the number of iterations completed (e.g., T) m =50, if no iteration has started yet, then the number of completed iterations is 0, then T n =50-0=50; If 20 iterations have been completed, then T n =50-20=30).
[0059] The model in this embodiment uses a principle similar to the Denoising Diffusion Probabilistic Models (DDPM). Therefore, for ease of understanding, the principle of the Denoising Diffusion Probabilistic Model will be briefly introduced below:
[0060] The principle of DDPM: The denoising probability diffusion model mainly includes two processes: forward denoising and reverse denoising. The forward denoising process uses a defined noise conditioner. Internal data Gradually add noise until the ECG signal is completely covered by Gaussian noise. At this point, the data... Only compared with the data from the previous time point Related. The formula for the forward process is as follows:
[0061] (1)
[0062] in, Indicates the given raw data In the case of, from arrive The joint probability distribution of the latent variable sequences, Let represent the conditional probability of each step in the forward process, and let represent the latent variable given the previous time step. Generate latent variables for the current time step. The probability of. Following a normal distribution, this formula represents the conditional probability distribution of each step in the forward process, that is, given... In this case, how to deduce . The product from t=1 to t=T represents the product of the conditional probabilities of generating latent variables at each step in the forward propagation process. For fixed or learnable forward process variance, used to adjust noise levels. This represents the number of time steps in the diffusion process.
[0063] when And 0, i.e., in DDPM Yes Obtained after making minor changes.
[0064] In the reverse diffusion process, the diffusion model starts from a set of random noise. Gradually denoise and restore the data The process. The formula for the reverse process is as follows:
[0065] (2)
[0066] in, Follows a normal distribution. The variance of the backward process is fixed or learnable. The calculation process is similar to the forward process, except that the data is known. In this case, data from the previous time step will be gradually released. Therefore, suitable parameters can be obtained by training a neural network. , making It is possible to reconstruct the data. .
[0067] Returning to this example, specifically, each training sample needs to be processed by the model using T... m Only after several rounds of denoising can a training cycle be considered complete. Each iteration can be seen as a process of denoising the initial noisy ECG signal. After all rounds of iteration are completed, the fully denoised ECG signal can be obtained, which is the restored "real ECG signal".
[0068] The electrocardiogram (ECG) generation model provided in this application embodiment can be considered as being composed of two sub-models, wherein:
[0069] The first sub-model is used to predict the noise that needs to be removed in each iteration (i.e., the first predicted noise), and the first predicted noise in each round can be obtained from the denoised ECG signal in each iteration and the second diffusion time step T. n The prediction is obtained by taking into account inputs such as the first R wave information and the electrophysiological type.
[0070] The second sub-model removes the first predicted noise from the denoised ECG signal in the current iteration based on the first predicted noise output by the first sub-model, and outputs the denoised ECG signal input by the first sub-model in the next iteration.
[0071] Based on the above embodiments, as an optional embodiment, the initial model includes multiple sequentially connected layer structures;
[0072] Based on the denoised ECG signal of this iteration and the second diffusion time step T of this iteration n Based on the first R-wave information and the electrophysiological type, the first predictive noise for this iteration is obtained, specifically including:
[0073] For each layer of the initial model, the first feature X1 of the layer structure is obtained. Based on the electrophysiological type, the first feature X1 is further extracted and processed to obtain the second feature X2. Based on the first R wave information, the second feature X2 is enhanced to obtain the enhanced second feature Y. SE1 ;
[0074] The enhanced second feature Y at each level SE1 Feature fusion is performed to obtain the first prediction noise feature, and prediction is performed based on the first prediction noise feature to obtain the first prediction noise.
[0075] The first feature X1 of the first layer structure is determined in the following way:
[0076] Based on the second diffusion time step T n The features of the non-overlapping parts between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration are predicted and used as the first feature X1.
[0077] The first feature X1, outside the first layer of structure, is determined in the following way:
[0078] Based on the second diffusion time step T n The enhanced second feature Y of the upper layer structure SE1 The features of the non-overlapping parts between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration are predicted and used as the first feature X1.
[0079] Specifically, such as Figure 3 As shown, Figure 3This is a schematic diagram of the structure of the first sub-model in the ECG generation model provided in this application embodiment. The sub-model is constructed based on the denoising diffusion probability model, the SE attention mechanism (Squeeze-and-Excitation Attention Mechanism, SE Mechanism), and two structured state space models—the Structured State Space Sequence Model (S4) and the Selective State Space Model (Mamba).
[0080] This sub-model is a combination of multiple residual layers. Each residual layer employs a hybrid structure combining S4, Mamba, and SE attention mechanisms. This structure utilizes two state-space model channels (SSMs) to enhance the model's long-term learning capability, while the SE attention mechanism improves its ability to learn the morphological structure of ECG signals. Within the theoretical framework of the denoising probabilistic diffusion model, the noise prediction output at each step is a crucial intermediate step in generating a high-quality signal. The ultimate goal is to progressively remove noise to obtain the desired ECG signal. The first state-space channel consists of an S4 module, which is primarily used to receive and process the input features and the second diffusion time step T. n For the first layer structure, the input features of the S4 module are the denoised ECG signal of this iteration and the second diffusion time step T of this iteration. n For the layers other than the first layer, the input features of the S4 module are the output features of the previous layer and the second diffusion time step T of the current iteration. n The first state space channel outputs a time-series modeled feature representation, X1. The second state space channel, composed of a Mamba module, primarily receives the first feature X1 from the first state space channel and diagnostic category conditions (i.e., ECG physiological type) as input, generating a feature representation, X2, fused with the diagnostic category conditions. Following the two state space model channels, an SE attention module is added to receive and process the ECG signal R-wave information and the second feature X2 from the second state space model channel. Through the channel attention mechanism, the SE module generates an enhanced feature representation Y. SE1 This enhances the first sub-model's ability to learn information from the first R-wave (also known as R-wave features).
[0081] The output of the SE module is Y. SE1This design comprises two aspects: firstly, it directly feeds back to the next residual layer as input to the S4 module of that layer, ensuring feature transfer and updating during generation; secondly, it is added to the outputs of all residual layers via residual connections to form a comprehensive feature representation X0 (i.e., the first predicted noise feature). This comprehensive feature X0 is further processed by a one-dimensional convolutional layer and used to predict noise in the noisy signal (i.e., the first predicted noise). This design not only effectively preserves the feature information of different residual layers but also enhances the ability to reproduce the details of the generated ECG signal by accumulating multi-layer features, ultimately improving the quality and accuracy of the generated signal.
[0082] The overall network framework of the first sub-model is a residual network framework. Each residual layer is equipped with the two structured state space model channels and the attention channel mentioned above to process information. As for the total number of residual layers, it can be freely selected according to actual needs. For example, the number of residual network layers in this embodiment can be set to 36 layers.
[0083] The raw ECG and R-wave information are processed by a one-dimensional convolutional layer before being input into the network to extract features. The convolutional kernel size is 1×1. The diffusion time step and diagnosis category are processed by their respective embedding layers and fully connected layers before being input into the network. The output dimension after processing can also be adjusted according to actual needs. For example, in the embodiment of this application, the output dimension of each input of the first sub-model after being processed by the embedding layer is 128.
[0084] It should be noted that the input noisy ECG signal in this embodiment can be in the form of a tensor array with a size of [batch, 12, 1000], where 12 is the number of leads and 1000 is the duration of each lead. At the same time, the first predicted noise output by the model can also be a tensor array of the same size, which can be obtained by performing one-dimensional convolution processing on the first predicted noise features output by the last layer structure.
[0085] Based on the above embodiments, as an optional embodiment, based on the simulated electrocardiogram signal corresponding to each training sample and the first diffusion time step T, m And training labels, determining the initial model's training loss, specifically including:
[0086] Based on the first diffusion time step T m Obtain the target time step T, where the target time step T is less than the first diffusion time step T. m ;
[0087] Obtain the first predicted noise in the iteration round corresponding to the target time step T, and determine the first difference between the first predicted noise and the actual noise corresponding to the target time step T; wherein, the actual noise is the noise added when adding noise to the training labels for the Tth time; the second diffusion time step T in the iteration round corresponding to the target time step T. n Same as the target time step T;
[0088] Acquire the second R wave information from the simulated electrocardiogram signal and determine the second difference between the second R wave information and the first R wave information;
[0089] The training loss is determined based on the first and second differences.
[0090] In some embodiments, the first difference can be used to measure the difference between the first predicted noise predicted by the model in each iteration and the noise actually added in the corresponding diffusion time step of adding noise.
[0091] The second difference is the R-wave loss between the first R-wave information and the second R-wave information. In this embodiment, it can be used to measure the difference in R-wave information between the fully denoised simulated ECG signal output by the model and the real ECG signal before denoising.
[0092] Specifically, the most accurate method for calculating the first difference is to calculate the difference between the first predicted noise output in each iteration and the actual noise added in the corresponding diffusion time step. Then, the first and second differences corresponding to all iterations are used together as a reference to calculate the total training loss. However, this calculation method is relatively cumbersome, and when the first diffusion time step T... m When the size is large, resulting in a large number of iteration rounds, the massive amount of computation can actually lead to low efficiency in model training.
[0093] Since this embodiment uses random Gaussian noise addition, and the Gaussian noise added in each round follows a certain pattern (i.e., a random Gaussian distribution), the first difference of each iteration can be roughly calculated based on the first difference of just one iteration. Based on the above principle, this embodiment can use noise from the interval [0, T] m Randomly select an iteration cycle corresponding to a target time step T as the iteration cycle to be calculated, and the second diffusion time step T with the same T value. n The corresponding iteration round is the target iteration round.
[0094] Since the model in this embodiment needs to learn how to integrate R-wave information into the generated simulated ECG signal, it is necessary to compare the first R-wave information in the simulated ECG signal generated by the model with the second R-wave information in the real ECG signal. Therefore, it is necessary to extract the first R-wave information of the simulated ECG signal output by the model and the second R-wave information of the real ECG signal and calculate the second difference between them.
[0095] The training loss of the model is then calculated by adding the first and second differences together.
[0096] Figure 4 This is a flowchart illustrating a method for generating simulated electrocardiogram signals provided in an embodiment of this application. The execution subject of this method can be a terminal (such as a computer, mobile phone, etc.). Figure 4 As shown, the method may include:
[0097] Step S401: Obtain the generation parameters of the target electrocardiogram signal.
[0098] The generated parameters include the first R-wave information, initial random Gaussian noise, electrophysiological type, and the third diffusion time step T of the initial random Gaussian noise. o .
[0099] Specifically, in this embodiment of the application, when it is necessary to generate a target electrocardiogram (ECG) signal, the conditions for the target ECG signal to be generated can be obtained first. These conditions need to include the first R-wave information of the target ECG signal to be generated, the electrocardiographic type, the initial random Gaussian noise sampled randomly, and the third diffusion time step T corresponding to the initial random Gaussian noise. o .
[0100] Step S402: Input the target ECG signal generation parameters into the target ECG generation model and output the simulated ECG signal.
[0101] The target ECG generation model is obtained based on the model training methods provided in the above embodiments.
[0102] Specifically, in the embodiments of this application, after the target ECG generation model is trained, the generation parameters are input into the model, and the model can output a personalized simulated ECG signal that meets the requirements of the generation parameters and contains the first R wave information.
[0103] Based on the above embodiments, as an optional embodiment, the target ECG signal generation parameters are input into the target ECG generation model, and the target ECG signal is output, specifically including:
[0104] Based on the target ECG signal generation parameters, a second preset number of iterations is performed, and the denoised Gaussian noise output from the last iteration is used as the target ECG signal. The second preset number is the third diffusion time step T. o ;
[0105] Each iteration includes:
[0106] Obtain the denoised Gaussian noise for this iteration; the denoised Gaussian noise for the first iteration is the initial random Gaussian noise.
[0107] Based on the denoised Gaussian noise of this iteration and the fourth diffusion time step T of this iteration p The first R-wave information and electrophysiological type are used to obtain the second predictive noise for this iteration. The second predictive noise is the part to be removed from the denoised Gaussian noise in this iteration.
[0108] Based on the second predicted noise of this iteration, the denoised Gaussian noise of this iteration is denoised to obtain the denoised Gaussian noise of the next iteration.
[0109] In this embodiment, the Gaussian noise used in each iteration is the Gaussian noise that needs to be denoised. The fourth diffusion time step T p In this embodiment of the application, T is related to the current iteration round. p equal to T o Subtract the number of iterations that have been completed.
[0110] Specifically, similar to the training process described above, after the generated parameters are input into the target ECG generation model, the model needs to undergo multiple iterations to output the desired simulated ECG signal. The concept of this embodiment is to acquire initial random Gaussian noise obtained through random sampling, and then sequentially perform denoising operations on the initial random Gaussian noise through the target ECG generation model. Thus, after all iterations of denoising are completed, the simulated ECG signal can be extracted from the initial random Gaussian noise. The specific process of each iteration is the same as the iteration process in the training method described above, and will not be elaborated further here.
[0111] Based on the above embodiments, as an optional embodiment, the target ECG generation model includes multiple sequentially connected layer structures;
[0112] Based on the denoised Gaussian noise of this iteration and the fourth diffusion time step T of this iteration p Based on the first R-wave information and the electrophysiological type, the second predictive noise for this iteration is obtained, specifically including:
[0113] For each layer of the target ECG generation model, the third feature X3 of the layer structure is obtained. Based on the electrocardiographic features, the third feature X3 is further extracted and processed to obtain the fourth feature X4. Based on the first R wave information, the fourth feature X4 is enhanced to obtain the enhanced fourth feature Y. SE2 ;
[0114] The enhanced fourth feature Y at each level SE2 Feature fusion is performed to obtain the second prediction noise feature, and prediction is performed based on the second prediction noise feature to obtain the second prediction noise;
[0115] The third feature X3 of the first layer structure is determined in the following way: based on the fourth diffusion time step T. p The features of the non-overlapping parts between the denoised Gaussian noise of the current iteration and the denoised Gaussian noise of the next iteration, along with the denoised ECG signal of the current iteration, are predicted and used as the third feature X3.
[0116] The third feature X3, outside the first layer structure, is determined as follows: based on the fourth diffusion time step T. p The enhanced fourth feature Y of the previous layer structure SE2 The features of the non-overlapping parts between the denoised Gaussian noise of the current iteration and the denoised Gaussian noise of the next iteration are predicted and used as the third feature X3.
[0117] Specifically, such as Figure 3 As shown, unlike the model training process, in the application of the target ECG generation model, the input of the S4 module in the first layer structure is the denoised Gaussian noise of each iteration and the fourth diffusion time step T corresponding to the current iteration. p The input of the S4 module in the layers other than the first layer is the output feature of the previous layer and the fourth diffusion time step T corresponding to the current iteration. p The output of module S4 is the third feature X3 (not shown in the figure, corresponding to X1 in the model training process). The input of module Mamba is the third feature X3 output by module S4 and the electrophysiological type (i.e., diagnosis category) in the generation parameters. After fusing the third feature X3 and the electrophysiological type through module Mamba, the fourth feature X4 is output (not shown in the figure, corresponding to X2 in the model training process). Then, the fourth feature X4 and the first R wave information are input into module SE to generate the added feature representation Y. SE2 And Y SE2On one hand, it can be used as input to the S4 module of the next layer structure, and on the other hand, it can be used to add the outputs of each residual layer structure to form a comprehensive feature representation Y0 (not shown in the figure, corresponding to X0 in the training process, i.e., the second predicted noise feature). Finally, the comprehensive feature Y0 is further processed by a one-dimensional convolutional layer and used to predict the noise in the noisy signal (i.e., the second predicted noise).
[0118] It should be noted that, as Figure 3 As shown in the diagram, similar to the inputs during model training, the initial random Gaussian noise and the first R-wave information are processed through a one-dimensional convolutional layer before being input into the model; while the fourth diffusion time step T... p The diagnostic category conditions must first be processed through a preset embedding layer and a fully connected layer.
[0119] The following is combined with Figure 5 and Figure 6 This paper provides a brief overview of the overall process of this application, such as... Figure 5 As shown, the proposed solution can be divided into the following four main steps:
[0120] Step 1: Collect a certain number of real 12-lead ECG signal data, extract their electrophysiological type (or diagnostic category) and R wave information, then convert the electrophysiological type into a one-hot encoded label, and use each real ECG signal data, its corresponding electrophysiological type label and corresponding R wave information as a training sample, and use all training samples in an 8:1:1 ratio as the training set, validation set and test set respectively.
[0121] Step 2: Use the waveform detection toolkit to detect each R-wave information extracted separately, and randomly select a number of leads for manual confirmation to ensure that the R-wave information extraction is basically accurate.
[0122] Step 3: Train the initial model based on the training set obtained in steps (1) and (2) to obtain an ECG generation model that can be used to generate personalized R-wave ECG signals;
[0123] The specific training process can be as follows: Figure 6As shown, firstly, the acquired original electrocardiogram (real electrocardiogram signal) is subjected to Gaussian noise t times to obtain a noisy electrocardiogram (noisy electrocardiogram signal, i.e., the noisy electrocardiogram at step t in the figure). Then, the noisy electrocardiogram, electrophysiological type (i.e., diagnostic category conditions in the figure), diffusion time step (i.e., t), and R-wave information (corresponding to the first R-wave information in the previous embodiment, which is extracted from the real electrocardiogram signal) are input into the initial model (i.e., the electrocardiogram generation model in the figure) for inverse denoising. The first sub-model in the initial model outputs the predicted Gaussian noise added in the selected iteration round, and the second sub-model outputs the simulated electrocardiogram signal (i.e., the generated electrocardiogram part in the figure), and extracts the R-wave information (i.e., the second R-wave information) from the simulated electrocardiogram signal. Then, the R-wave loss (calculated using the first R-wave information and the second R-wave information) and the noise loss (calculated using the predicted Gaussian noise and the actual Gaussian noise) are calculated and added together to obtain the total training loss. The model parameters of the first sub-model are then adjusted based on the total training loss until training is completed.
[0124] It should be noted that the specific parameters of the model are based on the Diffwave framework. In this embodiment, several dilated convolutions in Diffwave are replaced with S4, Mamba, and SE attention mechanism modules, with each layer containing these modules. The model input in this embodiment is a noisy 12-lead electrocardiogram (in tensor array form, size [batch, 12, 1000], where 12 is the number of leads and 1000 is the duration of each lead). The final output of the model is also a tensor of the same size. However, based on the principle of diffusion models, the generative model learns to predict the noise added at a given diffusion time step. By learning the noise at different diffusion time steps, during the generation stage, noise can be gradually removed from the complex noise to obtain the desired simulated electrocardiogram signal.
[0125] Step (4) uses the ECG generation model trained in step (3) to generate ECG signals. By inputting the diagnostic category label and the pre-designed first R wave information into the model, a personalized R wave simulated ECG signal can be generated.
[0126] The solution provided in this application has the following advantages over existing solutions:
[0127] 1. Personalized R-wave Information Generation: For 12-lead 10s ECG signal data, this invention incorporates R-wave information (including position and amplitude) into the ECG signal during model training, completing the task of personalized R-wave information generation. Existing 12-lead 10s ECG signal generation models only generate signals based on the diagnostic category of the ECG signal, which leads to relatively random generated ECG signals and makes it difficult to generate ECG signals that meet the requirements. This invention introduces an SE attention mechanism, enabling the model to more effectively focus on the R-wave information of the ECG signal and strengthening the learning of personalized R-wave information. This design allows the generated ECG signal to better match the input R-wave position and amplitude requirements, thereby ensuring that the R-wave characteristics of the generated ECG signal and clinical electrophysiological parameters such as heart rate conform to clinical norms.
[0128] 2. Hybrid use of structured state-space models: Compared with the existing 12-lead 10s ECG signal generation model, this invention enhances the long-term sequence learning capability of the model by using a hybrid of selective structured state-space model (Mamba) and structured state-space sequence model (S4).
[0129] 3. This invention can generate a high-quality 12-lead, 10-second ECG signal based on the input ECG signal diagnostic category label and pre-designed R-wave information. This generated data can be used as an augmented training dataset to improve the accuracy of the automatic ECG diagnostic model. This is because, during model training, the ECG signal diagnostic category and the corresponding sample's R-wave information are used as model input.
[0130] 4. This invention was tested on the PTB-XL (Physikalisch-Technischen Bundesanstalt XL, a database name) database, demonstrating its excellent sample generation capabilities. When testing the performance of the ECG generation model provided in this application embodiment, 400 ECG signals for each of the five electrophysiological types were generated using this model. It was found that the difference between the generated simulated ECG signals and the real ECG signals was superior to some existing generation models in terms of distance evaluation metrics. This is because the ECG generation model in this application embodiment introduces two state-space models in its structure and uses them interchangeably, thereby achieving the goal of high-quality generation.
[0131] 5. Through experimental simulation verification, by comparing and analyzing the distance measures (root mean square error (RMSE), Fréchet distance (FD), and dynamic time warping (DTW)) between the simulated ECG signal generated by the ECG generation model proposed in this application embodiment and the real ECG signal, it was found that the generation effect of this application embodiment is better. Through qualitative analysis, it can be found that the R wave position of the simulated 12-lead ECG signal generated by the ECG generation model of this application embodiment is almost the same as the R wave position of the real 12-lead ECG signal. It can be considered that the model provided by this application embodiment has successfully completed the task of generating personalized R wave information ECG signals.
[0132] Figure 7 A structural block diagram of a model training device provided in an embodiment of this application is shown below. Figure 7 As shown, the model training device 700 may include: a training sample acquisition module 701, a model training module 702, and a training loss determination module 703, wherein,
[0133] The training sample acquisition module 701 is used to acquire multiple training samples and the training label corresponding to each training sample. Each training sample includes the electrophysiological type, the first R wave information, the initial noisy electrocardiogram signal, and the first diffusion time step T. m The training labels are real ECG signals, and the initial noisy ECG signal in each training sample is obtained by performing T+0 processing on the corresponding training label. m The result obtained after adding noise;
[0134] The model training module 702 is used to input the training sample into the initial model for each training sample and output the simulated electrocardiogram signal corresponding to the training sample.
[0135] The training loss determination module 703 is used to determine the training loss based on the simulated electrocardiogram signal corresponding to each training sample and the first diffusion time step T. m The training labels are used to determine the training loss of the initial model, and the parameters of each model in the initial model are adjusted based on the training loss until the preset training termination condition is met, thus obtaining the target ECG generation model.
[0136] The model training method provided in this application first adds noise to the real electrocardiogram (ECG) signal multiple times before the model training process, obtaining a noisy ECG signal. Then, the model is trained using information including the electrophysiological type, first R-wave information, the noisy real ECG signal, and the diffusion time step during the noisy addition as input conditions. This allows the model to learn the correlation between R-wave information, electrophysiological type, and ECG signal during training. The simulated ECG signal output by the model is compared with the real ECG signal to determine the training loss and continuously adjust the model parameters, ultimately obtaining a well-trained target ECG generation model. By introducing R-wave information to train the ECG generation model, the simulated ECG signal generated by the trained model does not contain patients' personal privacy information. Furthermore, because the target ECG generation model incorporates R-wave information when generating simulated ECG signals, the generated simulated ECG signals have personalized characteristics and can focus on data from a specific patient type, ensuring high data quality while better reflecting actual clinical patterns.
[0137] Based on the above embodiments, as an optional embodiment, the model training module is specifically used for:
[0138] Based on the training samples, a first preset number of iterations is performed, and the denoised ECG signal output from the last iteration is used as the simulated ECG signal. The first preset number of iterations is the first diffusion time step T. m ;
[0139] Each iteration includes:
[0140] Obtain the denoised ECG signal for this iteration; the denoised ECG signal for the first iteration is the initial denoised ECG signal.
[0141] Based on the denoised ECG signal of this iteration and the second diffusion time step T of this iteration n The first R-wave information and electrophysiological type are used to obtain the first predicted noise of this iteration. The first predicted noise is the noise to be removed from the denoised electrocardiogram signal of this iteration.
[0142] Based on the first predicted noise of this iteration, the denoised ECG signal of this iteration is denoised to obtain the denoised ECG signal of the next iteration.
[0143] Based on the above embodiments, as an optional embodiment, the initial model includes multiple sequentially connected layer structures;
[0144] The model training module is further used for:
[0145] For each layer of the initial model, the first feature X1 of the layer structure is obtained. Based on the electrophysiological type, the first feature X1 is further extracted and processed to obtain the second feature X2. Based on the first R wave information, the second feature X2 is enhanced to obtain the enhanced second feature Y. SE1 ;
[0146] The enhanced second feature Y at each level SE1 Feature fusion is performed to obtain the first prediction noise feature, and prediction is performed based on the first prediction noise feature to obtain the first prediction noise;
[0147] The first feature X1 of the first layer structure is determined in the following way: based on the second diffusion time step T. n The features of the non-overlapping parts between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration are predicted and used as the first feature X1.
[0148] The first feature X1, outside the first layer structure, is determined as follows: based on the second diffusion time step T. n The enhanced second feature Y of the upper layer structure SE1 The features of the non-overlapping parts between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration are predicted and used as the first feature X1.
[0149] Based on the above embodiments, as an optional embodiment, the training loss determination module is specifically used for:
[0150] Based on the first diffusion time step T m Obtain the target time step T, where the target time step T is less than the first diffusion time step T. m ;
[0151] Obtain the first predicted noise in the iteration round corresponding to the target time step T, and determine the first difference between the first predicted noise and the actual noise corresponding to the target time step T; wherein, the actual noise is the noise added when adding noise to the training labels for the Tth time; the second diffusion time step T in the iteration round corresponding to the target time step T. n Same as the target time step T;
[0152] Acquire the second R wave information from the simulated electrocardiogram signal and determine the second difference between the second R wave information and the first R wave information;
[0153] The training loss is determined based on the first and second differences.
[0154] Figure 8 A structural block diagram of an electrocardiogram (ECG) signal generation device provided in an embodiment of this application is shown below. Figure 8As shown, the simulated electrocardiogram signal generation device 800 may include: a generation parameter acquisition module 801 and a model signal generation module 802, wherein,
[0155] The parameter acquisition module 801 is used to acquire the generation parameters of the target electrocardiogram signal. The generation parameters include the first R wave information, the initial random Gaussian noise, the electrocardiographic type, and the third diffusion time step T of the initial random Gaussian noise. o ;
[0156] The model signal generation module 802 is used to input the target ECG signal generation parameters into the target ECG generation model and output a simulated ECG signal; wherein, the target ECG generation model is obtained based on the simulated ECG generation model training method provided by the above embodiments.
[0157] Based on the above embodiments, as an optional embodiment, the analog signal generation module is specifically used for:
[0158] Based on the target ECG signal generation parameters, a second preset number of iterations is performed, and the denoised Gaussian noise output from the last iteration is used as the target ECG signal. The second preset number is the third diffusion time step T. o ;
[0159] Each iteration includes:
[0160] Obtain the denoised Gaussian noise for this iteration; the denoised Gaussian noise for the first iteration is the initial random Gaussian noise.
[0161] Based on the denoised Gaussian noise of this iteration and the fourth diffusion time step T of this iteration p The first R-wave information and electrophysiological type are used to obtain the second predictive noise for this iteration. The second predictive noise is the part to be removed from the denoised Gaussian noise in this iteration.
[0162] Based on the second predicted noise of this iteration, the denoised Gaussian noise of this iteration is denoised to obtain the denoised Gaussian noise of the next iteration.
[0163] Based on the above embodiments, as an optional embodiment, the target ECG generation model includes multiple sequentially connected layer structures;
[0164] The analog signal generation module is further used for:
[0165] For each layer of the target ECG generation model, the third feature X3 of the layer structure is obtained. Based on the electrocardiographic features, the third feature X3 is further extracted and processed to obtain the fourth feature X4. Based on the first R wave information, the fourth feature X4 is enhanced to obtain the enhanced fourth feature Y. SE2 ;
[0166] The enhanced fourth feature Y at each level SE2 Feature fusion is performed to obtain the second prediction noise feature, and prediction is performed based on the second prediction noise feature to obtain the second prediction noise;
[0167] The third feature X3 of the first layer structure is determined in the following way: based on the fourth diffusion time step T. p The features of the non-overlapping parts between the denoised Gaussian noise of the current iteration and the denoised Gaussian noise of the next iteration, along with the denoised ECG signal of the current iteration, are predicted and used as the third feature X3.
[0168] The third feature X3, outside the first layer structure, is determined as follows: based on the fourth diffusion time step T. p The enhanced fourth feature Y of the previous layer structure SE2 The features of the non-overlapping parts between the denoised Gaussian noise of the current iteration and the denoised Gaussian noise of the next iteration are predicted and used as the third feature X3.
[0169] The following is for reference. Figure 9 It illustrates an electronic device suitable for implementing embodiments of this application (e.g., performing...). Figure 1 The diagram shows the structure of the terminal device or server 900 of the method shown. The electronic devices in the embodiments of this application may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), wearable devices, etc., as well as fixed terminals such as digital TVs, desktop computers, etc. Figure 9 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0170] The electronic device includes a memory and a processor. The memory stores a program for performing the methods described in the various method embodiments above. The processor is configured to execute the program stored in the memory. The processor may be referred to as processing device 901 as described below. The memory may include at least one of read-only memory (ROM) 902, random access memory (RAM) 903, and storage device 908 as described below, as follows:
[0171] like Figure 9As shown, electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 902 or a program loaded from storage device 908 into random access memory (RAM) 903. RAM 903 also stores various programs and data required for the operation of electronic device 900. Processing device 901, ROM 902, and RAM 903 are interconnected via bus 904. Input / output (I / O) interface 905 is also connected to bus 904.
[0172] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic device 900 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0173] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by a processing device 901, it performs the functions defined in the methods of the embodiments of this application.
[0174] It should be noted that the computer-readable storage medium described above in this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0175] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0176] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0177] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to:
[0178] Obtain multiple training samples and their corresponding training labels. Each training sample includes the electrophysiological type, first R-wave information, initial noisy electrocardiogram signal, and first diffusion time step T. m The training labels are real ECG signals, and the initial noisy ECG signal in each training sample is obtained by performing T+0 processing on the corresponding training label. m The noise is added after each iteration; for each training sample, the training sample is input into the initial model, and the output is the simulated ECG signal corresponding to the training sample; based on the simulated ECG signal corresponding to each training sample and the first diffusion time step T m The training labels are used to determine the training loss of the initial model, and the parameters of each model in the initial model are adjusted based on the training loss until the preset training termination condition is met, thus obtaining the target ECG generation model.
[0179] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0180] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0181] The modules or units described in the embodiments of this application can be implemented in software or hardware. The names of modules or units do not necessarily limit the specific unit; for example, a first constraint acquisition module can also be described as a "module for acquiring the first constraint".
[0182] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0183] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0184] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0185] The above description is only a partial embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A model training method, characterized in that, include: Obtain multiple training samples and their corresponding training labels. Each training sample includes the electrophysiological type, first R-wave information, initial noisy electrocardiogram signal, and first diffusion time step T. m The training labels are real ECG signals, and the initial noisy ECG signal in each training sample is obtained by performing T+0 processing on the corresponding training label. m The result obtained after adding noise; For each training sample, the training sample is input into the initial model, and the simulated electrocardiogram signal corresponding to the training sample is output. Based on the simulated electrocardiogram signal corresponding to each training sample, and the first diffusion time step T m The training loss of the initial model is determined by the training labels, and the parameters of each model of the initial model are adjusted based on the training loss until the preset training termination condition is met, thereby obtaining the target ECG generation model. The step of inputting the training samples into the initial model and outputting the simulated electrocardiogram signal corresponding to the training samples specifically includes: Based on the training samples, a first preset number of iterations are performed, and the denoised ECG signal output from the last iteration is used as the simulated ECG signal. The first preset number of iterations is the first diffusion time step T. m ; Each iteration includes: Obtain the denoised ECG signal for this iteration; the denoised ECG signal for the first iteration is the initial denoised ECG signal. Based on the denoised ECG signal of this iteration and the second diffusion time step T of this iteration. n The first R-wave information and electrocardiographic type are used to obtain the first predicted noise for this iteration. The first predicted noise is the noise to be removed from the denoised electrocardiogram signal in this iteration. Based on the first predicted noise of this iteration, the denoised ECG signal of this iteration is denoised to obtain the denoised ECG signal of the next iteration. The initial model contains multiple sequentially connected layer structures; The denoised ECG signal from the current iteration and the second diffusion time step T of the current iteration are used as the basis for this iteration. n Based on the first R-wave information and the electrophysiological type, the first predictive noise for this iteration is obtained, specifically including: For each layer of the initial model, a first feature X1 is obtained. Based on the electrophysiological type, the first feature X1 is further extracted to obtain a second feature X2. Based on the first R-wave information, the second feature X2 is enhanced to obtain the enhanced second feature Y. SE1 ; The enhanced second feature Y at each level SE1 Feature fusion is performed to obtain the first prediction noise feature, and prediction is performed based on the first prediction noise feature to obtain the first prediction noise; The first feature X1 of the first layer structure is determined in the following way: based on the second diffusion time step T. n The features of the non-overlapping portion between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration, and the denoised ECG signal of the current iteration, are predicted and used as the first feature X1. The first feature X1 outside the first layer structure is determined by: based on the second diffusion time step T n The enhanced second feature Y of the upper layer structure SE1 The features of the non-overlapping parts between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration are predicted and used as the first feature X1.
2. The method according to claim 1, characterized in that, The simulated electrocardiogram signal corresponding to each training sample, and the first diffusion time step T m And training labels, determining the training loss of the initial model, including: Based on the first diffusion time step T m Obtain the target time step T, wherein the target time step T is less than the first diffusion time step T. m ; Obtain the first predicted noise in the iteration round corresponding to the target time step T, and determine the first difference between the first predicted noise and the actual noise corresponding to the target time step T; wherein, the actual noise is the noise added when the training label is denoised for the Tth time; the second diffusion time step T in the iteration round corresponding to the target time step T n Same as the target time step T; Acquire the second R-wave information from the simulated electrocardiogram signal, and determine the second difference between the second R-wave information and the first R-wave information; The training loss is determined based on the first difference and the second difference.
3. A method for generating electrocardiogram (ECG) signals, characterized in that, include: The generation parameters of the target electrocardiogram signal are obtained, wherein the generation parameters include first R-wave information, initial random Gaussian noise, electrocardiographic type, and the third diffusion time step T of the initial random Gaussian noise. o ; The target ECG signal generation parameters are input into the target ECG generation model, and a simulated ECG signal is output; wherein, the target ECG generation model is obtained based on the training method of any one of claims 1-2.
4. The method according to claim 3, characterized in that, The step of inputting the target ECG signal generation parameters into the target ECG generation model and outputting the target ECG signal includes: Based on the target ECG signal generation parameters, a second preset number of iterations are performed, and the denoised Gaussian noise output from the last iteration is taken as the target ECG signal. The second preset number of iterations is the third diffusion time step T. o ; Each iteration includes: Obtain the denoised Gaussian noise for this iteration; the denoised Gaussian noise for the first iteration is the initial random Gaussian noise. Based on the denoised Gaussian noise of this iteration and the fourth diffusion time step T of this iteration. p The first R-wave information and electrophysiological type are used to obtain the second predictive noise for this round of iteration. The second predictive noise is the part to be removed from the denoised Gaussian noise of this round of iteration. Based on the second predicted noise of this iteration, the denoised Gaussian noise of this iteration is denoised to obtain the denoised Gaussian noise of the next iteration.
5. The method according to claim 4, characterized in that, The target electrocardiogram generation model contains multiple sequentially connected layer structures; The noise is denoised based on the Gaussian noise of this iteration and the fourth diffusion time step T of this iteration. p Based on the first R-wave information and the electrophysiological type, the second predictive noise for this iteration is obtained, including: For each layer of the target ECG generation model, the third feature X3 of the layer is obtained. Based on electrocardiographic features, the third feature X3 is further extracted and processed to obtain the fourth feature X4. Based on the first R-wave information, the fourth feature X4 is enhanced to obtain the enhanced fourth feature Y. SE2 ; The enhanced fourth feature Y at each level SE2 Feature fusion is performed to obtain a second prediction noise feature, and prediction is performed based on the second prediction noise feature to obtain the second prediction noise; The third feature X3 of the first layer structure is determined in the following way: based on the fourth diffusion time step T. p The features of the non-overlapping portion between the denoised Gaussian noise of the current iteration and the denoised Gaussian noise of the next iteration, and the denoised ECG signal of the current iteration, are predicted as the third feature X3. The third feature X3, outside the first layer structure, is determined by: based on the fourth diffusion time step T. p The enhanced fourth feature Y of the previous layer structure SE2 The features of the non-overlapping parts between the denoised Gaussian noise of the current iteration and the denoised Gaussian noise of the next iteration are predicted and used as the third feature X3.
6. A model training device, characterized in that, include: The training sample acquisition module is used to acquire multiple training samples and the corresponding training label for each training sample. Each training sample includes the electrophysiological type, the first R wave information, the initial noisy electrocardiogram signal, and the first diffusion time step T. m The training labels are real ECG signals, and the initial noisy ECG signal in each training sample is obtained by performing T+0 processing on the corresponding training label. m The result obtained after adding noise; The model training module is used to input the training sample into the initial model for each training sample and output the simulated electrocardiogram signal corresponding to the training sample. The training loss determination module is used to determine the training loss based on the simulated electrocardiogram signal corresponding to each training sample and the first diffusion time step T. m The training loss of the initial model is determined by the training labels, and the parameters of each model of the initial model are adjusted based on the training loss until the preset training termination condition is met, thereby obtaining the target ECG generation model. The model training module is specifically used for: Based on the training samples, a first preset number of iterations are performed, and the denoised ECG signal output from the last iteration is used as the simulated ECG signal. The first preset number of iterations is the first diffusion time step T. m ; Each iteration includes: Obtain the denoised ECG signal for this iteration; the denoised ECG signal for the first iteration is the initial denoised ECG signal. Based on the denoised ECG signal of this iteration and the second diffusion time step T of this iteration. n The first R-wave information and electrocardiographic type are used to obtain the first predicted noise for this iteration. The first predicted noise is the noise to be removed from the denoised electrocardiogram signal in this iteration. Based on the first predicted noise of this iteration, the denoised ECG signal of this iteration is denoised to obtain the denoised ECG signal of the next iteration. The initial model contains multiple sequentially connected layer structures; For each layer of the initial model, a first feature X1 is obtained. Based on the electrophysiological type, the first feature X1 is further extracted to obtain a second feature X2. Based on the first R-wave information, the second feature X2 is enhanced to obtain the enhanced second feature Y. SE1 ; The enhanced second feature Y at each level SE1 Feature fusion is performed to obtain the first prediction noise feature, and prediction is performed based on the first prediction noise feature to obtain the first prediction noise; The first feature X1 of the first layer structure is determined in the following way: based on the second diffusion time step T. n The features of the non-overlapping portion between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration, and the denoised ECG signal of the current iteration, are predicted and used as the first feature X1. The first feature X1 outside the first layer structure is determined by: based on the second diffusion time step T n The enhanced second feature Y of the upper layer structure SE1 The features of the non-overlapping parts between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration are predicted and used as the first feature X1.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-5.
Citation Information
Patent Citations
Method for training classification model for cardiovascular and cerebrovascular disease classification and related products
CN118053040A
Noise processing method and device for electrocardiosignal, electronic equipment and storage medium
CN118319237A