Model training method and device, electrocardiosignal generation method and device and electronic equipment

By introducing R-wave information and electrocardiophysiology types in the ECG generation model training, combined with the denoising and diffusion probability model, the problem of lack of personalized and clinical regularity in the existing technology's central electrical signal generation is solved, and high-quality and personalized electrocardiogram generation is achieved.

CN119886268AActive Publication Date: 2025-04-25SOUTHERN MEDICAL UNIVERSITY

Patent Information

Application Number
CN202510243447.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-03
Publication Date
2025-04-25
Estimated Expiration
2045-03-03

AI Technical Summary

Technical Problem

The prior art lacks differential processing for different individuals of patients when generating electrocardiogram signals, and the generated data does not conform to actual clinical laws, making it difficult to ensure the balance of data samples and protect patient privacy.

Method used

By introducing R-wave information and electrocardiophysiological types as conditions during model training, combining the denoising and diffusion probability model, we learn the association relationship between R-wave information, electrocardiophysiological types and electrocardiogram signals to generate a simulated electrocardiogram signal with personalized characteristics.

Benefits of technology

The generated analog ECG signals do not contain the patient's personal privacy information, have personalized characteristics, can focus on processing one or a certain type of patient data, and are more in line with actual clinical laws, improving the quality and accuracy of the generation of ECG signals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119886268A_ABST
    Figure CN119886268A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a model training method, an electrocardiosignal generation method and device and electronic equipment, and relates to the field of data generation. The method comprises the following steps: acquiring a plurality of training samples and a training label corresponding to each training sample; for each training sample, inputting the training sample into the initial model, and outputting and obtaining a simulated electrocardiosignal corresponding to the training sample; and determining the training loss of the initial model based on each training sample, and adjusting each model parameter of the initial model based on the training loss until a preset training termination condition is met, thereby obtaining a target electrocardiogram generation model. The model is trained by introducing R-wave information, so that the simulated electrocardiosignal generated by the trained model does not contain personal privacy information of a patient, and the generated simulated electrocardiosignal has personalized characteristics due to the fact that the target electrocardiosignal generation model is combined with the R-wave information when generating the simulated electrocardiosignal; and high quality of data is ensured, and meanwhile, actual clinical laws can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data generation. Specifically, the present application relates to a simulated electrocardiogram generation model training method, an electrocardiogram signal generation method, device, electronic device and storage medium. Background Art

[0002] The field of ECG signal generation is a research field that focuses on generating high-quality ECG signals for medical purposes or algorithm development without worrying about annotation costs or clinical data privacy restrictions. Currently, the ECG automatic diagnosis models developed using technologies such as deep learning require a large amount of real ECG data, but the ECG data obtained in the real world will inevitably have problems such as sample imbalance and difficulty in protecting patient privacy. Therefore, a method is needed that can obtain a large amount of ECG data while ensuring that the acquired data samples are balanced and do not infringe on patient privacy.

[0003] At present, deep generative models represented by variational autoencoders, adversarial generative network models, and denoising diffusion probability 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 a certain extent. However, these models do not take into account the differences between individual patients when generating data, lack focus on the data of a certain patient or a certain type of patient, and the generated data sometimes does not conform to actual clinical laws. Summary of the invention

[0004] The purpose of this application is to solve at least one of the above technical defects. The technical solutions provided by the embodiments of this application are as follows: In a first aspect, an embodiment of the present application provides a model training method, comprising: Get multiple training samples and training labels corresponding to each training sample, each training sample contains electrocardiographic physiological type, first R wave information, initial noisy ECG signal and first diffusion time step number T m , the training label is the real ECG signal, and the initial noisy ECG signal in each training sample is obtained by performing T m The result obtained after adding noise; For each training sample, the training sample is input into the initial model, and the simulated ECG signal corresponding to the training sample is output; Based on the simulated ECG signal corresponding to each training sample, the first diffusion time step T m and training labels, determine the training loss of the initial model, and adjust the model parameters of the initial model based on the training loss until the preset training termination conditions are met to obtain the target ECG generation model.

[0005] In a second aspect, an embodiment of the present application provides a method for generating an electrocardiogram signal, comprising: Obtain the generation parameters of the target ECG signal, wherein the generation parameters include the first R wave information, the initial random Gaussian noise, the electrophysiological type, and the third diffusion time step number 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 model training method provided by the above-mentioned embodiments.

[0006] In a third aspect, an embodiment of the present application provides a simulated electrocardiogram generation model training device, comprising: The training sample acquisition module is used to obtain multiple training samples and the training labels corresponding to each training sample. Each training sample contains the electrocardiographic physiological type, the first R wave information, the initial noisy ECG signal, and the first diffusion time step number T. m , the training label is the real ECG signal, and the initial noisy ECG signal in each training sample is obtained by performing T m The result obtained after adding noise; A model training module is used for inputting each training sample into the initial model and outputting a simulated ECG signal corresponding to the training sample; The training loss determination module is used to determine the simulated ECG signal corresponding to each training sample and the first diffusion time step T. m and training labels, determine the training loss of the initial model, and adjust the model parameters of the initial model based on the training loss until the preset training termination conditions are met to obtain the target ECG generation model.

[0007] In a fourth aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory; The processor executes the computer program to implement the method provided in the embodiment of the first aspect or any optional embodiment of the first aspect.

[0008] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method provided in the embodiment of the first aspect or any optional embodiment of the first aspect is implemented.

[0009] The beneficial effects of the technical solution provided by the embodiment of the present application are: The model training method provided by the present application, before the model training process, first performs multiple noise processing on the real ECG signal to obtain the noisy ECG signal, and then uses the electrocardiographic physiological type, the first R wave information, the real ECG signal after noise, and the diffusion time step when the real ECG signal is noised as the model condition input for training, so that the model learns the correlation between the R wave information, the electrocardiographic physiological type and the ECG signal during the training process, and compares the simulated ECG signal output by the model with the real ECG signal to determine the training loss and continuously adjust the model parameters, and finally obtains the 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 the patient's personal privacy information, and because the target ECG generation model combines the R wave information when generating the simulated ECG signal, the generated simulated ECG signal has personalized characteristics, and can also have a focus on a certain or a certain type of patient data, while ensuring the high quality of the data, it is also more in line with the actual clinical rules. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0011] Figure 1 A flowchart of a model training method provided in an embodiment of the present application; Figure 2 This is a schematic diagram of an exemplary central electrical signal of an embodiment of the present application; Figure 3 A schematic diagram of the structure of the first sub-model in an example of an embodiment of the present application; Figure 4 A schematic diagram of a flow chart of a method for generating an electrocardiogram signal provided in an embodiment of the present application; Figure 5 A schematic diagram of the overall steps of a method for generating a simulated ECG signal in an example of an embodiment of the present application; Figure 6 A flowchart of a method for determining training loss in an example of an embodiment of the present application; Figure 7 A structural block diagram of a simulated ECG generation model training device provided in an embodiment of the present application; Figure 8 A structural block diagram of a simulated ECG signal generating device provided in an embodiment of the present application; Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0012] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0013] It will be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application refer to that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation as other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or it may refer to that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" may be implemented as "A", or as "B", or as "A and B".

[0014] The following is a brief introduction to the prior art regarding the embodiments of the present application: The field of ECG signal generation is a research field that focuses on generating high-quality ECG signals for medical purposes or algorithm development without worrying about annotation costs or clinical data privacy restrictions. The ECG automatic diagnosis models currently developed using deep learning and other technologies require a large number of real ECG signals. ECG signals obtained in the real world will inevitably have problems such as sample imbalance and difficulty in protecting patient privacy. Deep generative models represented by variational autoencoders, adversarial generative network models, and denoising diffusion probability models can generate high-quality generated signals without patient information by learning the distribution of training samples, which can protect patient privacy to a certain extent. By introducing specific diagnostic category conditions during the training process, the model can generate ECG generated data for specific cardiovascular diseases, thereby achieving the purpose of expanding the sample data set and balancing the sample distribution.

[0015] R wave information: It can be a certain component of the ECG signal. The morphological characteristics of the ECG signal are that it has different waveform components, which mainly include P wave, QRS wave, T wave and U wave, which respectively reflect the changes in electrode potentials in different parts. The ECG signal vector component with a high peak amplitude is the QRS wave group, which reflects the potential changes of the left and right ventricles (including the ventricular septum) depolarization. The first downward wave is the Q wave, and the upward high wave after the Q wave is the R wave. The downward wave after the R wave is the S wave. The schematic diagram of each waveform of the heartbeat can be shown as follows Figure 2 As shown in FIG. 1 , R wave information can characterize the electrocardiographic physiological type of a certain type of patient, so the personalized part of the electrocardiographic signal can be reflected through the R wave information.

[0016] The ECG signals (hereinafter also referred to as ECG data) generated by the current ECG generation model can be roughly divided into two types, namely heartbeat data (or short-term ECG data) and long-term ECG data. Since most of the ECG data collected clinically are long-term ECG data of more than 10 seconds, the ECG automatic diagnosis model trained with heartbeat data needs to pre-segment the clinically obtained long-term ECG data into specific heartbeat data before further classification, which weakens the clinical significance of the heartbeat generation model to a certain extent. Most of the existing 12-lead 10s long-term ECG generation models only generate ECGs based on diagnostic categories, and the generated results are relatively random. These models have not yet considered the introduction of personalized R-wave information to generate ECG signals that conform to clinical laws. The present invention proposes a training method for an ECG generation model that integrates personalized R waves, which improves the quality of generated ECG signals and makes them conform to the clinical laws of the real world as much as possible.

[0017] The purpose of the present invention is to provide a method for training an ECG generation model with a collection of personalized R waves. The method can use existing real ECG signals to train the ECG generation model, and introduce R wave information and diagnostic categories (i.e., electrocardiographic physiological types in the following text) as conditions during the training process, so as to achieve the generation task of personalized R waves and specific categories of ECG signals, improve the clinical significance of the generated ECG signals, reduce the randomness of the generation, and thus achieve the purpose of expanding the training data set, balancing the sample distribution, and reducing the risk of patient privacy leakage. This has an important role and significance for the development and application of subsequent ECG automatic diagnosis models.

[0018] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0019] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on or combine with each other, and the same terms, similar features and similar implementation steps in different embodiments will not be described repeatedly.

[0020] Figure 1 A flowchart of a method for training an electrocardiogram generation model is provided for an embodiment of the present application. The execution subject of the method may be a terminal (such as a computer, a mobile phone, etc.). Figure 1 As shown, the method may include: Step S101, obtaining multiple training samples and a training label corresponding to each training sample.

[0021] In some embodiments, each training sample includes an electrophysiological type, first R wave information, an initial noisy electrocardiographic signal, and a first diffusion time step number T m , the training label is the real ECG signal, and the initial noisy ECG signal in each training sample is obtained by performing T m After adding noise.

[0022] The real ECG signal in the embodiment of the present application may be twelve-lead real ECG signal data. The electrophysiological type may be a diagnosis result obtained after extraction from the ECG signal, such as normal, myocardial infarction, ST-T changes (slow ventricular repolarization), conduction disorder, and ventricular hypertrophy. In order to allow the model to recognize the above electrophysiological types, corresponding unique hot encoding labels may be made for these electrophysiological 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 disorder: [0,0,0,1,0], ventricular hypertrophy: [0,0,0,0,1]. The initial noisy ECG signal may be an ECG signal obtained after a certain number of times of noisy addition to the real ECG signal. The method used for noisy addition may be random Gaussian noisy addition, and the number of noisy additions is the first diffusion time step number T. m , T m It can reflect the degree of added noise. Generally speaking, T m The larger it is, the greater the number of steps and the greater the noise added.

[0023] Specifically, before training the model, it is necessary to first obtain samples for training the model and each sample and the corresponding training label. Since the final output of the model provided in the embodiment of the present application is an ECG signal, the training label of the model should be a (real) ECG signal. The real ECG signal can be obtained by clinically collecting the ECG signals of real patients. At the same time, the collected real ECG signals are diagnosed and R-wave extracted to obtain the electrocardiographic physiological 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 data set, the verification ECG data set, and the test ECG data set. After the first R-wave information is extracted, several leads can also be randomly selected for manual confirmation to ensure that the extraction of the first R-wave information is basically accurate.

[0024] Since the model provided in the embodiment of the present application is essentially a process of learning to gradually denoise the noisy signal, it is necessary to first denoise the real ECG signal. The denoising method used in this embodiment can be random Gaussian denoising, that is, the real ECG signal is subjected to a first diffusion time step T based on the random Gaussian noise distribution. m The initial noisy ECG signal is obtained by adding noise again, and then the electrophysiological type, the first R wave information, the initial noisy ECG signal and the first diffusion time step number T are added. m They are used as training samples, and the real ECG signal is used as the training label corresponding to the training sample.

[0025] It should be noted that, in the embodiment of the present application, part of the training samples can also be used as a validation set and a test set, and the remaining training samples continue to be kept as training sets. The role of the validation set is to test the training results of the model midway during the model training process. When it is found that the training effect of the model in training does not meet expectations, the model training can be terminated and adaptive adjustments can be made to save resources. The role of the test set is to test the training effect of the trained model after the model training is completed. Exemplarily, the ratio of the training set, validation set, and test set can be set to 8:1:1.

[0026] Step S102: for each training sample, input the training sample into the initial model, and output a simulated ECG signal corresponding to the training sample.

[0027] The simulated ECG signal is a denoised ECG signal obtained by performing multiple denoising operations on the initial noisy ECG signal.

[0028] Step S103: based on the simulated ECG signal corresponding to each training sample and the first diffusion time step number T mand training labels, determine the training loss of the initial model, and adjust the model parameters of the initial model based on the training loss until the preset training termination conditions are met to obtain the target ECG generation model.

[0029] In an embodiment of the present application, the training termination condition may be reaching a fixed number of training times, or the training loss being less than a preset threshold, etc., which is not limited in the embodiment of the present application. 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, the present application may limit the training effect of the model by setting a preset threshold, thereby ensuring that the model can obtain better output while preventing the model's output from overfitting. It may also be possible to observe the changes in training loss during the training process in a fixed number of training times to actively prevent it from overfitting.

[0030] The model training method provided by the present application, before the model training process, first performs multiple noise processing on the real ECG signal to obtain the noisy ECG signal, and then uses the electrocardiographic physiological type, the first R wave information, the real ECG signal after noise, and the diffusion time step when the real ECG signal is noised as the model condition input for training, so that the model learns the correlation between the R wave information, the electrocardiographic physiological type and the ECG signal during the training process, and compares the simulated ECG signal output by the model with the real ECG signal to determine the training loss and continuously adjust the model parameters, and finally obtains the 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 the patient's personal privacy information, and because the target ECG generation model combines the R wave information when generating the simulated ECG signal, the generated simulated ECG signal has personalized characteristics, and can also have a focus on a certain or a certain type of patient data, while ensuring the high quality of the data, it is also more in line with the actual clinical rules.

[0031] Based on the above embodiments, as an optional embodiment, the training sample is input into the initial model, and the simulated ECG signal corresponding to the training sample is output, which specifically includes: Iterate the training sample for a first preset number of times, and use the denoised ECG signal output from the last iteration as the simulated ECG signal. The first preset number of times is the first diffusion time step number T. m ; Each round of iteration includes: Obtain the denoised ECG signal of this iteration. The denoised ECG signal of the first iteration is the initial noisy ECG signal. According to the denoised ECG signal of this iteration, the second diffusion time step T of this iteration n, the first R wave information and the electrophysiological type, obtaining the first predicted noise of this iteration, the first predicted noise being the part of the noise to be removed in the denoised electrocardiographic signal of this iteration; Based on the first predicted noise of this round of iteration, a denoising operation is performed on the denoised ECG signal of this round of iteration to obtain a denoised ECG signal of the next round of iteration.

[0032] In the embodiment of the present application, the denoised ECG signal in each iteration is the ECG signal that needs to be denoised. The second diffusion time step number T n Related to the current iteration round, in this embodiment of the application, T n Equal to T m Subtract the number of completed iterations (e.g. T m =50, the iteration has not started yet, 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).

[0033] The principle adopted by the model in this embodiment is similar to that of the Denoising Diffusion Probabilistic Models (DDPM). Therefore, for ease of understanding, the principle of the Denoising Diffusion Probabilistic Model is briefly introduced below: The principle of DDPM: The denoising probability diffusion model mainly includes two processes: the forward denoising process and the reverse denoising process. The forward denoising process is determined by the noise regulator. Internal data Gradually apply noise until the ECG signal is completely covered by Gaussian noise. At this time, the data Only the data from the previous time point The forward process formula is as follows: (1) in, Represents the given original data In the case of arrive The joint probability distribution of the latent variable sequence, represents the conditional probability of each step in the forward process, given the latent variable in the previous time step , generates the latent variable of the current time step probability. Obeying the normal distribution, the formula represents the conditional probability distribution of each step in the forward process, that is, when it is known In the case of . The product from t=1 to t=T represents the multiplication of the conditional probabilities of the latent variables generated at each step in the forward process. is a fixed or learnable forward process variance used to adjust the noise level, is the number of time steps of the diffusion process.

[0034] when and 0, that is, Yes Obtained after minor changes.

[0035] In the reverse diffusion process, the diffusion model is transformed from a set of random noise Stepwise denoising and restoration to data The reverse process formula is as follows: (2) in, It follows a normal distribution. is the backward process variance which can be fixed or learnable. The calculation process is similar to the forward process, except that the data is known. In the case of Therefore, the appropriate parameters can be obtained by training the neural network , so that Can be requested, reconstructed data .

[0036] Let's go back to this embodiment. Specifically, each training sample needs to be T m A training session is considered to be completed only after denoising is performed. Each round of iteration can be regarded as a denoising process for the initial noisy ECG signal. When all rounds of iteration are completed, the completely denoised ECG signal can be obtained, which is the restored "real ECG signal".

[0037] The ECG generation model provided in the embodiment of the present application can be regarded as being composed of two sub-models: 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 by the denoised ECG signal in each iteration, the second diffusion time step T n , the first R wave information and electrophysiological type of these inputs to make predictions; The second sub-model removes the first predicted noise contained in the denoised ECG signal of this iteration according to the first predicted noise output by the first sub-model, and outputs the denoised ECG signal input by the first sub-model of the next iteration.

[0038] Based on the above embodiments, as an optional embodiment, the initial model includes a plurality of sequentially connected layer structures; According to the denoised ECG signal of this iteration, the second diffusion time step T of this iteration n , the first R wave information and the electrophysiological type, and obtain the first predicted noise of this round of iteration, specifically including: For each layer of the initial model, obtain the first feature X of the layer structure 1 , based on the electrophysiological type of the first feature X 1 Further extraction processing is performed to obtain the second feature X 2 Based on the first R wave information, the second feature X 2 Perform feature enhancement processing to obtain the enhanced second feature Y SE1 ; The enhanced second feature Y of each level SE1 Feature fusion is performed to obtain a first predicted noise feature, and prediction is performed based on the first predicted noise feature to obtain a first predicted noise.

[0039] The first characteristic X of the first layer structure 1 Determined by: Based on the second diffusion time step T n and the denoised ECG signal of this iteration, predict the features of the non-overlapping part between the denoised ECG signal of this iteration and the denoised ECG signal of the next iteration as the first feature X 1 .

[0040] The first feature X outside the first layer structure 1 Determined by: Based on the second diffusion time step T n And the enhanced second feature Y of the previous structure SE1 , predict the features of the non-overlapping part between the denoised ECG signal of this iteration and the denoised ECG signal of the next iteration as the first feature X 1 .

[0041] Specifically, Figure 3 As shown, Figure 3A schematic diagram of the structure of the first sub-model in the ECG generation model provided in an embodiment of the present application, which is constructed based on a denoising diffusion probability model, a Squeeze-and-Excitation Attention Mechanism (SE Mechanism), and two structured state space models: a structured state space sequence model (Structured State Space Sequence Model, S4) and a selective state space sequence model (Selective State Space Model, Mamba).

[0042] This sub-model is a combination of multiple residual layers. Each residual layer is designed with a hybrid structure of S4, Mamba and SE attention mechanisms. This structure uses two state space model channels (State Space models, SSMs) to improve the model's long-term series learning ability, while the SE attention mechanism can improve the model's learning ability for the morphological structure of ECG signals. In the theoretical framework of the denoising probability diffusion model, the noise prediction of each step output is an important intermediate link in generating high-quality signals. The ultimate goal is to gradually remove noise and obtain the desired ECG signal. The first state space channel consists of the S4 module, which is mainly used to receive and process the input features and the second diffusion time step T n , where 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 number T of this iteration n For other layer structures other than the first layer structure, the input features of the S4 module are the output features of the previous layer structure and the second diffusion time step number T of this round of iteration n , output the feature representation of the first feature X after time series modeling 1 The second state space channel is composed of the Mamba module, which mainly receives the first feature X output by the first state space channel. 1 and diagnostic category conditions (i.e., electrophysiological type) as input to generate the feature representation second feature X after integrating the diagnostic category conditions 2 After the two state-space model channels, the SE attention module is added to receive and process the ECG signal R wave information and the second feature X output by the second state-space model channel. 2 Through the channel attention mechanism, the SE module generates an enhanced feature representation Y SE1 , strengthening the first sub-model’s ability to learn the first R-wave information (also called R-wave features).

[0043] The output Y of the SE module SE1It includes two aspects: on the one hand, it is directly fed back to the next residual layer as the input of the S4 module of the next residual layer to ensure the transmission and update of features during the generation process; on the other hand, it is added to the output of all residual layers through residual connections to form a comprehensive feature representation X 0 (i.e. the first predicted noise feature). Comprehensive feature X 0 After further processing by a one-dimensional convolutional layer, it is used to predict the noise in the noisy signal (i.e., the first predicted noise). This design not only effectively retains the feature information of different residual layers, but also enhances the ability to restore the details of the generated ECG signal by accumulating multiple layers of features, ultimately improving the quality and accuracy of the generated signal.

[0044] The overall network framework of the first sub-model is a residual network framework, and each residual layer is provided with the above two structured state space model channels and attention channels 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 the embodiment of the present application can be set to 36 layers.

[0045] The original ECG and R wave information are processed by a one-dimensional convolution layer to extract features before being input into the network. The convolution kernel size is 1×1. The diffusion time step and diagnostic category are processed by their own embedding layer and fully connected layer 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 the present application, the output dimension of each input of the first sub-model after being processed by the embedding layer is 128.

[0046] It should be noted that the noisy ECG signal input in the embodiment of the present application 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 time length 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 feature output by the last layer structure.

[0047] On the basis of the above embodiments, as an optional embodiment, based on the simulated ECG signal corresponding to each training sample, the first diffusion time step number T m And the training label, determine the training loss of the initial model, including: Based on the first diffusion time step T m Get the target time step number T, where the target time step number T is less than the first diffusion time step number T m ; Obtain the first predicted noise in the iteration round corresponding to the target time step number 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 number T in the iteration round corresponding to the target time step T n Same as the target time step number T; collecting second R wave information in the simulated electrocardiogram signal, and determining a second difference between the second R wave information and the first R wave information; A training loss is determined based on the first difference and the second difference.

[0048] In some embodiments, the first difference may 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 diffusion time step corresponding to the noise addition.

[0049] 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 finally output by the model and the real ECG signal before noise addition.

[0050] Specifically, when calculating the first difference, the most accurate method is to calculate the difference between the first predicted noise output of each round of iteration and the actual noise added in the corresponding diffusion time step of adding noise, and then use the first difference and the second difference corresponding to all iterations as a reference to calculate the total training loss. However, this calculation method is more cumbersome, and when the first diffusion time step T m When the number of iterations is large, the massive amount of calculations will lead to low efficiency of model training.

[0051] Since the embodiment of the present application adopts a random Gaussian noise adding method when adding noise, and in this method, the Gaussian noise added in each round of noise adding obeys a certain rule (i.e., random Gaussian distribution), the first difference of each iteration round can be roughly inferred based on the first difference of one iteration round. Based on the above principle, the embodiment of the present application can adopt the method of calculating the first difference of each iteration round from the interval [0, T m 】A target time step number T is randomly selected as the iteration round to be calculated, and the second diffusion time step number T with the same T value is n The corresponding iteration round is the target iteration round.

[0052] Since the model in the embodiment of the present application needs to learn how to integrate the 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.

[0053] Then the first difference and the second difference are added together to obtain the training loss of the model.

[0054] Figure 4 A schematic diagram of a flow chart of a method for generating a simulated ECG signal provided in an embodiment of the present application, wherein the execution subject of the method may be a terminal (such as a computer, a mobile phone, etc.), such as Figure 4 As shown, the method may include: Step S401, obtaining generation parameters of a target ECG signal.

[0055] The generation parameters include the first R wave information, initial random Gaussian noise, electrophysiological type, and the third diffusion time step number T of the initial random Gaussian noise. o .

[0056] Specifically, in the embodiment of the present application, when it is necessary to generate a target ECG signal, the conditions of the target ECG signal to be generated this time can be obtained first, and the conditions need to include the first R wave information of the target ECG signal generated this time, the electrophysiological type, and the randomly sampled initial random Gaussian noise and the third diffusion time step number T corresponding to the initial random Gaussian noise. o .

[0057] Step S402: input the target ECG signal generation parameters into the target ECG generation model, and output a simulated ECG signal.

[0058] The target ECG generation model is obtained based on the model training methods provided by the above-mentioned embodiments.

[0059] Specifically, in the embodiment of the present application, after the target ECG generation model is trained and various generation parameters are input into the model, the model can output a simulated ECG signal with personalized characteristics that meets the above generation parameter requirements and carries the first R wave information according to the above generation parameters.

[0060] 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, which specifically includes: Based on the target ECG signal generation parameters, a second preset number of iterations are performed, and the denoised Gaussian noise outputted by the last iteration is used as the target ECG signal. The second preset number of iterations is the third diffusion time step number T.o ; Each round of iteration includes: Get the denoised Gaussian noise of this iteration. The denoised Gaussian noise of the first iteration is the initial random Gaussian noise. According to the denoised Gaussian noise of this round of iteration, the fourth diffusion time step T of this round of iteration p , the first R wave information and the electrophysiological type, to obtain the second predicted noise of this round of iteration, where the second predicted noise is the part to be removed in the denoised Gaussian noise of this round of iteration; Based on the second predicted noise of this round of iteration, a denoising operation is performed on the denoised Gaussian noise of this round of iteration to obtain the denoised Gaussian noise of the next round of iteration.

[0061] The denoised Gaussian noise in each iteration in the embodiment of the present application is the Gaussian noise that needs to be denoised. p Related to the current iteration round, in this embodiment of the application, T p Equal to T o Subtract the number of completed iterations.

[0062] Specifically, similar to the training process described above, after the generation parameters are input into the target ECG generation model, the model needs to go through multiple iterations to output the desired simulated ECG signal. The idea of ​​the embodiment of the present application is to obtain the initial random Gaussian noise obtained by random sampling, and to perform step-by-step denoising operations on the initial random Gaussian noise in sequence through the target ECG generation model, so that after all iterative rounds of denoising operations are completed, the simulated ECG signal can be extracted from the initial random Gaussian noise. The specific process of each round of iteration is the same as the iterative process in the training method described above, and will not be repeated here.

[0063] Based on the above embodiments, as an optional embodiment, the target ECG generation model includes a plurality of sequentially connected layer structures; According to the denoised Gaussian noise of this round of iteration, the fourth diffusion time step T of this round of iteration p , the first R wave information and the electrophysiological type, and obtain the second prediction noise of this round of iteration, specifically including: For each layer structure of the target ECG generation model, obtain the third feature X of the layer structure 3 , based on the electrophysiological characteristics of the third feature X 3 Further extraction processing is performed to obtain the fourth feature X 4 Based on the first R wave information, the fourth feature X 4 Perform feature enhancement processing to obtain the enhanced fourth feature Y SE2 ; The fourth feature Y after each level is enhanced SE2Perform feature fusion to obtain a second predicted noise feature, and perform prediction based on the second predicted noise feature to obtain a second predicted noise; Among them, the third characteristic X of the first layer structure 3 Determined by: Based on the fourth diffusion time step T p and the denoised ECG signal of this iteration, predict the features of the non-overlapping part between the denoised Gaussian noise of this iteration and the denoised Gaussian noise of the next iteration as the third feature X 3 ; The third feature X outside the first layer structure 3 Determined by: Based on the fourth diffusion time step T p And the fourth feature Y after the enhancement of the previous structure SE2 , predict the features of the non-overlapping part between the denoised Gaussian noise of this iteration and the denoised Gaussian noise of the next iteration as the third feature X 3 .

[0064] Specifically, Figure 3 As shown in Figure 2, different from the model training process, in the application process 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 this iteration. p The input of the S4 module in the other layers of the structure other than the first layer is the output feature of the previous layer and the fourth diffusion time step T corresponding to this round of iteration p ; The output of the S4 module is the third feature X 3 (Not marked in the figure, and X in the model training process 1 The input of the Mamba module is the third feature X output by the S4 module. 3 As well as the electrophysiological type (i.e., diagnostic category) in the generated parameters, the third feature X 3 After fusion with the electrophysiological type, the fourth feature X is output 4 (Not marked in the figure, and X in the model training process 2 Correspondingly), the fourth feature X 4 Together with the first R wave information, it is input into the SE module to generate the added feature representation Y SE2 . And Y SE2 On the one hand, it can be used as the input of the S4 module of the next layer structure, and it can also be used to add the outputs of each residual layer structure to form a comprehensive feature representation Y 0 (Not marked in the figure, and X during training 0 Corresponding to, that is, the second predicted noise feature). Finally, the comprehensive feature Y 0 After further processing by a one-dimensional convolutional layer, it is used to predict the noise in the noisy signal (i.e., the second predicted noise).

[0065] It should be noted that if Figure 3 As shown in , the initial random Gaussian noise and the first R wave information are processed by a one-dimensional convolution layer before being input into the model, which is the same as the input in the model training process; and the fourth diffusion time step T p And the diagnostic category conditions must first be processed by the preset embedding layer and fully connected layer.

[0066] Combine the following Figure 5 and Figure 6 , briefly introduce the overall process of this application plan, such as Figure 5 As shown, this application scheme can be divided into the following four steps: Step 1: Collect a certain amount of 12-lead real ECG signal data, extract its electrophysiological type (or diagnostic category) and R-wave information, and then convert the electrophysiological type into a one-hot encoding label. At the same time, take each real ECG signal data, its corresponding electrophysiological type label and the corresponding R-wave information as a training sample, and use all training samples as training set, validation set and test set in a ratio of 8:1:1; Step 2: Use the waveform detection toolkit to extract the R wave information for detection, and randomly select several leads for manual confirmation to ensure that the extraction of R wave information is basically accurate; Step 3: Train the initial model based on the training set obtained in step (1) and step (2) to obtain an ECG generation model that can be used to generate personalized R-wave ECG signals; The specific training process can be as follows: Figure 6 As shown, first, the collected original ECG (real ECG signal) is subjected to t times of Gaussian noise processing to obtain a noisy ECG (noisy ECG signal, i.e., the noisy ECG in step t in the figure), and then the noisy ECG, electrophysiological type (i.e., diagnostic category condition in the figure), diffusion time step (i.e., t) and R wave information (corresponding to the first R wave information in the previous embodiment, obtained by extracting the real ECG signal) are input into the initial model (i.e., the ECG generation model in the figure) for reverse denoising process, the first sub-model in the initial model outputs the predicted Gaussian noise added in the selected iteration round, the second sub-model outputs the simulated ECG signal (i.e., the generated ECG part in the figure), and R wave information (i.e., the second R wave information) is extracted from the simulated ECG signal, and then the R wave loss (calculated by the first R wave information and the second R wave information) and the noise loss (calculated by the predicted Gaussian noise and the actual Gaussian noise) are calculated respectively and added to obtain the total training loss, and then the model parameters of the first sub-model are adjusted based on the total training loss until the training is completed.

[0067] It should be noted that the specific parameters of the model refer to the framework of Diffwave. The embodiment of the present application replaces several dilated convolutions in Diffwave with S4, Mamba and SE attention mechanism modules, and each layer has these modules. The model input in the embodiment of the present application is a noisy twelve-lead electrocardiogram (in the form of a tensor array, the size is [batch, 12, 1000], 12 is the number of leads, and 1000 is the time length of each lead.), and the final output of the model is also a tensor of the same size. However, based on the principle of the diffusion model, what the generation model learns is to predict the noise added under the diffusion time step. By learning the noise under different diffusion time steps, in the generation stage, it is possible to gradually denoise from the complex noise and obtain the desired simulated ECG signal.

[0068] Step (4) generates an ECG signal using the ECG generation model trained in step (3). By inputting the diagnostic category label and the pre-designed first R wave information into the model, a simulated ECG signal of a personalized R wave can be generated.

[0069] The solution provided in this application has the following advantages over existing solutions: 1. Personalized R-wave information generation: For 12-lead 10s ECG signal data, the present invention introduces the R-wave information (including position and amplitude) of the ECG signal during the model training process to complete the personalized R-wave information generation task. The existing 12-lead 10s ECG signal generation model is generated only by the diagnostic category of the ECG signal, which will cause the generated ECG signal to be relatively random and difficult to generate an ECG signal that meets the requirements. The present invention introduces the SE attention mechanism to enable the model to more effectively focus on the R-wave information of the ECG signal and strengthen the learning of personalized R-wave information. This design enables the generated ECG signal to better meet 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 are in line with clinical laws.

[0070] 2. Mixed use of structured state space models: Compared with the existing 12-lead 10s ECG signal generation model, the present invention enhances the long-term sequence learning ability of the model by mixing the selective structured state space model (Mamba) and the structured state space sequence model (S4).

[0071] 3. The present invention can generate 12-lead 10s high-quality ECG signals based on the input ECG signal diagnostic category label and pre-designed R wave information, and use the generated data as an augmented training data set to improve the accuracy of the ECG automatic diagnosis model. This is because in the model training process, the ECG signal diagnostic category and the R wave information of the corresponding sample are used as model input for training.

[0072] 4. The present invention was tested on the PTB-XL (Physikalisch-Technischen Bundesanstalt XL, a database name) database, demonstrating its excellent sample generation capability. When testing the performance of the ECG generation model provided in the embodiment of the present application, 400 ECG signals of each of 5 electrophysiological types were generated using the model, and it was found that the difference between the generated simulated ECG signals and the real ECG signals was superior to the existing partial generation models in terms of distance evaluation indicators. This is because the ECG generation model in the embodiment of the present application structurally introduces two state space models and mixes them to achieve the purpose of high-quality generation.

[0073] 5. After experimental simulation verification, by calculating and analyzing the distance measurement (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 the embodiment of the present application and the real ECG signal, it is found that the generation effect of the embodiment of the present application 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 the embodiment of the present application 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 the embodiment of the present application has completed the task of generating personalized R wave information ECG signals well.

[0074] Figure 7 A structural block diagram of a model training device provided in an embodiment of the present application, such as 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: The training sample acquisition module 701 is used to acquire multiple training samples and training labels corresponding to each training sample. Each training sample includes an electrocardiographic physiological type, first R wave information, an initial noisy electrocardiographic signal, and a first diffusion time step number T. m , the training label is the real ECG signal, and the initial noisy ECG signal in each training sample is obtained by performing T m The result obtained after adding noise; The model training module 702 is used for inputting each training sample into the initial model and outputting a simulated ECG signal corresponding to the training sample; The training loss determination module 703 is used to determine the training loss based on the simulated ECG signal corresponding to each training sample, the first diffusion time step number T mand training labels, determine the training loss of the initial model, and adjust the model parameters of the initial model based on the training loss until the preset training termination conditions are met to obtain the target ECG generation model.

[0075] The model training method provided by the present application, before the model training process, first performs multiple noise processing on the real ECG signal to obtain the noisy ECG signal, and then uses the electrocardiographic physiological type, the first R wave information, the real ECG signal after noise, and the diffusion time step when the real ECG signal is noised as the model condition input for training, so that the model learns the correlation between the R wave information, the electrocardiographic physiological type and the ECG signal during the training process, and compares the simulated ECG signal output by the model with the real ECG signal to determine the training loss and continuously adjust the model parameters, and finally obtains the 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 the patient's personal privacy information, and because the target ECG generation model combines the R wave information when generating the simulated ECG signal, the generated simulated ECG signal has personalized characteristics, and can also have a focus on a certain or a certain type of patient data, while ensuring the high quality of the data, it is also more in line with the actual clinical rules.

[0076] Based on the above embodiments, as an optional embodiment, the model training module is specifically used for: Iterate the training sample for a first preset number of times, and use the denoised ECG signal output from the last iteration as the simulated ECG signal. The first preset number of times is the first diffusion time step number T. m ; Each round of iteration includes: Obtain the denoised ECG signal of this iteration. The denoised ECG signal of the first iteration is the initial noisy ECG signal. According to the denoised ECG signal of this iteration, the second diffusion time step T of this iteration n , the first R wave information and the electrophysiological type, obtaining the first predicted noise of this iteration, the first predicted noise being the part of the noise to be removed in the denoised electrocardiographic signal of this iteration; Based on the first predicted noise of this round of iteration, a denoising operation is performed on the denoised ECG signal of this round of iteration to obtain a denoised ECG signal of the next round of iteration.

[0077] Based on the above embodiments, as an optional embodiment, the initial model includes a plurality of sequentially connected layer structures; The model training module is further used to: For each layer of the initial model, obtain the first feature X of the layer structure 1 , based on the electrophysiological type of the first feature X 1Further extraction processing is performed to obtain the second feature X 2 Based on the first R wave information, the second feature X 2 Perform feature enhancement processing to obtain the enhanced second feature Y SE1 ; The enhanced second feature Y of each level SE1 Perform feature fusion to obtain a first predicted noise feature, and perform prediction based on the first predicted noise feature to obtain a first predicted noise; Among them, the first characteristic X of the first layer structure 1 Determined by: Based on the second diffusion time step T n and the denoised ECG signal of this iteration, predict the features of the non-overlapping part between the denoised ECG signal of this iteration and the denoised ECG signal of the next iteration as the first feature X 1 ; The first feature X outside the first layer structure 1 Determined by: Based on the second diffusion time step T n And the enhanced second feature Y of the previous structure SE1 , predict the features of the non-overlapping part between the denoised ECG signal of this iteration and the denoised ECG signal of the next iteration as the first feature X 1 .

[0078] Based on the above embodiments, as an optional embodiment, the training loss determination module is specifically used to: Based on the first diffusion time step T m Get the target time step number T, where the target time step number T is less than the first diffusion time step number T m ; Obtain the first predicted noise in the iteration round corresponding to the target time step number 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 number T in the iteration round corresponding to the target time step T n Same as the target time step number T; collecting second R wave information in the simulated electrocardiogram signal, and determining a second difference between the second R wave information and the first R wave information; A training loss is determined based on the first difference and the second difference.

[0079] Figure 8 A structural block diagram of an electrocardiogram signal generating device provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, the simulated ECG signal generating device 800 may include: a generating parameter acquisition module 801 and a model signal generating module 802, wherein: The generation parameter acquisition module 801 is used to obtain the generation parameters of the target ECG signal, wherein the generation parameters include the first R wave information, the initial random Gaussian noise, the electrophysiological type and the third diffusion time step number T of the initial random Gaussian noise. o ; 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-mentioned embodiments.

[0080] Based on the above embodiments, as an optional embodiment, the analog signal generating module is specifically used for: Based on the target ECG signal generation parameters, a second preset number of iterations are performed, and the denoised Gaussian noise outputted by the last iteration is used as the target ECG signal. The second preset number of iterations is the third diffusion time step number T. o ; Each round of iteration includes: Get the denoised Gaussian noise of this iteration. The denoised Gaussian noise of the first iteration is the initial random Gaussian noise. According to the denoised Gaussian noise of this round of iteration, the fourth diffusion time step T of this round of iteration p , the first R wave information and the electrophysiological type, to obtain the second predicted noise of this round of iteration, where the second predicted noise is the part to be removed in the denoised Gaussian noise of this round of iteration; Based on the second predicted noise of this round of iteration, a denoising operation is performed on the denoised Gaussian noise of this round of iteration to obtain the denoised Gaussian noise of the next round of iteration.

[0081] Based on the above embodiments, as an optional embodiment, the target ECG generation model includes a plurality of sequentially connected layer structures; The analog signal generation module is further used to: For each layer structure of the target ECG generation model, obtain the third feature X of the layer structure 3 , based on the electrophysiological characteristics of the third feature X 3 Further extraction processing is performed to obtain the fourth feature X 4 Based on the first R wave information, the fourth feature X 4 Perform feature enhancement processing to obtain the enhanced fourth feature Y SE2 ; The fourth feature Y after each level is enhanced SE2 Perform feature fusion to obtain a second predicted noise feature, and perform prediction based on the second predicted noise feature to obtain a second predicted noise; Among them, the third characteristic X of the first layer structure 3Determined by: Based on the fourth diffusion time step T p and the denoised ECG signal of this iteration, predict the features of the non-overlapping part between the denoised Gaussian noise of this iteration and the denoised Gaussian noise of the next iteration as the third feature X 3 ; The third feature X outside the first layer structure 3 Determined by: Based on the fourth diffusion time step T p And the fourth feature Y after the enhancement of the previous structure SE2 , predict the features of the non-overlapping part between the denoised Gaussian noise of this iteration and the denoised Gaussian noise of the next iteration as the third feature X 3 .

[0082] Reference below Fig. 9 , which shows an electronic device suitable for implementing the embodiments of the present application (for example, Figure 1 The electronic device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig. 9 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0083] The electronic device includes: a memory and a processor, the memory is used to store a program for executing the method described in each of the above method embodiments; the processor is configured to execute the program stored in the memory. The processor here can be referred to as the processing device 901 described below, and the memory can include at least one of the read-only memory (ROM) 902, the random access memory (RAM) 903, and the storage device 908 described below, as shown below: like Fig. 9 As shown, the 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 a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 are also stored. The processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0084] Typically, the following devices may be connected to the I / O interface 905: an input device 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 908 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic device 900 to communicate with other devices wirelessly or by wire to exchange data. Although Fig. 9 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0085] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 909, or installed from the storage device 908, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present application are executed.

[0086] It should be noted that the computer-readable storage medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0087] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0088] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0089] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: Get multiple training samples and training labels corresponding to each training sample, each training sample contains electrocardiographic physiological type, first R wave information, initial noisy ECG signal and first diffusion time step number T m , the training label is the real ECG signal, and the initial noisy ECG signal in each training sample is obtained by performing T m After adding noise for the first time; for each training sample, the training sample is input into the initial model, and the simulated ECG signal corresponding to the training sample is output; based on the simulated ECG signal corresponding to each training sample, the first diffusion time step number T m and training labels, determine the training loss of the initial model, and adjust the model parameters of the initial model based on the training loss until the preset training termination conditions are met to obtain the target ECG generation model.

[0090] Computer program code for performing the operations of the present application may 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, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may 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 may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0091] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0092] The modules or units involved in the embodiments of the present application may be implemented by software or hardware. The name of a module or unit does not limit the unit itself in some cases. For example, the first constraint acquisition module may also be described as a "module for acquiring the first constraint".

[0093] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0094] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0095] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0096] The above descriptions are only partial implementations of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A model training method, characterized in that: include: Get multiple training samples and training labels corresponding to each training sample, each training sample contains electrocardiographic physiological type, first R wave information, initial noisy ECG signal and first diffusion time step number T m , the training label is the real ECG signal, and the initial noisy ECG signal in each training sample is obtained by performing T m The result obtained after adding noise; For each training sample, the training sample is input into the initial model, and a simulated electrocardiogram signal corresponding to the training sample is output; Based on the simulated ECG signal corresponding to each training sample, the first diffusion time step number T m and a training label, determining the training loss of the initial model, and adjusting each model parameter of the initial model based on the training loss until a preset training termination condition is met to obtain a target ECG generation model.

2. The method according to claim 1, characterized in that The step of inputting the training sample into the initial model and outputting a simulated electrocardiogram signal corresponding to the training sample includes: A first preset number of iterations are performed based on the training sample, and the denoised ECG signal outputted by the last iteration is used as the simulated ECG signal, where the first preset number of iterations is the first diffusion time step number T. m ; Each round of iteration includes: Obtaining a denoised ECG signal of this iteration, wherein the denoised ECG signal of the first iteration is the initial noisy ECG signal; According to the denoised ECG signal of this round of iteration, the second diffusion time step number T of this round of iteration n , the first R wave information and the electrophysiological type, obtaining the first predicted noise of this iteration, wherein the first predicted noise is the part of noise to be removed in the denoised electrocardiographic signal of this iteration; Based on the first predicted noise of this round of iteration, a denoising operation is performed on the denoised ECG signal of this round of iteration to obtain a denoised ECG signal of the next round of iteration.

3. The method according to claim 2, characterized in that The initial model includes a plurality of sequentially connected layer structures; The denoised ECG signal of this round of iteration, the second diffusion time step number T of this round of iteration n , the first R wave information and the electrophysiological type, and obtain the first predicted noise of this round of iteration, including: For each layer structure of the initial model, a first feature X1 of the layer structure is obtained, and the first feature X1 is further extracted and processed based on the electrophysiological type to obtain a second feature X2; and the second feature X2 is enhanced based on the first R wave information to obtain an enhanced second feature Y SE1 ; The enhanced second feature Y of each level SE1 Performing feature fusion to obtain a first predicted noise feature, and performing prediction based on the first predicted noise feature to obtain the first predicted noise; The first characteristic X1 of the first layer structure is determined by: based on the second diffusion time step T n and the denoised ECG signal of the current iteration, predicting the features of the non-overlapping part between the denoised ECG signal of the current iteration and the denoised ECG signal of the next iteration as the first feature X1; The first feature X1 outside the first layer structure is determined in the following manner: based on the second diffusion time step number T n And the enhanced second feature Y of the previous structure SE1 , predict the features of the non-overlapping parts between the denoised ECG signal of this iteration and the denoised ECG signal of the next iteration as the first feature X1.

4. The method according to claim 1, characterized in that The simulated ECG signal corresponding to each training sample, the first diffusion time step number T m and training labels, determining the training loss of the initial model, including: Based on the first diffusion time step T m Obtain a target time step number T, wherein the target time step number T is less than the first diffusion time step number T m ; Obtain the first predicted noise in the iteration round corresponding to the target time step number 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 subjected to the Tth noise addition; the second diffusion time step number T in the iteration round corresponding to the target time step number T n The same as the target time step number T; collecting second R wave information in the simulated electrocardiogram signal, and determining a 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.

5. A method for generating an electrocardiogram signal, characterized in that: include: Obtain the generation parameters of the target ECG signal, wherein the generation parameters include the first R wave information, the initial random Gaussian noise, the electrophysiological type, and the third diffusion time step number 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 described in any one of claims 1-4.

6. The method according to claim 5, characterized in that The step of inputting the target ECG signal generation parameter into the target ECG generation model and outputting the target ECG signal comprises: Based on the target ECG signal generation parameter, a second preset number of iterations are performed, and the denoised Gaussian noise outputted by the last iteration is used as the target ECG signal. The second preset number of iterations is the third diffusion time step number T. o ; Each round of iteration includes: Obtain the denoised Gaussian noise of this round of iteration, where the denoised Gaussian noise of the first round of iteration is the initial random Gaussian noise; According to the denoised Gaussian noise of this round of iteration, the fourth diffusion time step number T of this round of iteration p , the first R wave information and the electrophysiological type, obtaining the second predicted noise of this round of iteration, wherein the second predicted noise is the part to be removed in the denoised Gaussian noise of this round of iteration; Based on the second predicted noise of this round of iteration, a denoising operation is performed on the denoised Gaussian noise of this round of iteration to obtain the denoised Gaussian noise of the next round of iteration.

7. The method according to claim 6, characterized in that The target ECG generation model comprises a plurality of sequentially connected layer structures; The denoised Gaussian noise of the current iteration, the fourth diffusion time step number T of the current iteration p , the first R wave information and the electrophysiological type, and obtain the second prediction noise of this round of iteration, including: For each layer structure of the target ECG generation model, a third feature X3 of the layer structure is obtained, and the third feature X3 is further extracted and processed based on the electrophysiological feature to obtain a fourth feature X4; and the fourth feature X4 is enhanced based on the first R wave information to obtain an enhanced fourth feature Y SE2 ; The fourth feature Y after each level is enhanced SE2 Performing feature fusion to obtain a second predicted noise feature, and performing prediction based on the second predicted noise feature to obtain the second predicted noise; The third characteristic X3 of the first layer structure is determined by: based on the fourth diffusion time step number T p and the denoised ECG signal of the current iteration, predicting the features of the non-overlapping part between the denoised Gaussian noise of the current iteration and the denoised Gaussian noise of the next iteration as the third feature X3; The third feature X3 outside the first layer structure is determined in the following manner: based on the fourth diffusion time step number T p And the fourth feature Y after the enhancement of the previous structure SE2 , predict the features of the non-overlapping part between the denoised Gaussian noise of this iteration and the denoised Gaussian noise of the next iteration as the third feature X3.

8. A model training device, characterized in that: include: The training sample acquisition module is used to obtain multiple training samples and the training labels corresponding to each training sample. Each training sample contains the electrocardiographic physiological type, the first R wave information, the initial noisy ECG signal, and the first diffusion time step number T. m , the training label is the real ECG signal, and the initial noisy ECG signal in each training sample is obtained by performing T m The result obtained after adding noise; A model training module, for each training sample, inputting the training sample into an initial model, and outputting a simulated ECG signal corresponding to the training sample; A training loss determination module is used to determine the training loss based on the simulated ECG signal corresponding to each training sample, the first diffusion time step number T m and a training label, determining the training loss of the initial model, and adjusting each model parameter of the initial model based on the training loss until a preset training termination condition is met to obtain a target ECG generation model.

9. 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 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Multi-modal feature fusion model construction method for automatic classification of electrocardio rhythms

    CN116361688A

  • 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

  • Depression probability determination method, depression probability determination system and related device

    CN119279584A

Cited By

  • Multi-view input tensor construction method and device for dynamic electrocardiogram analysis

    CN122451744A