Electrocardiosignal processing method and related product
The ECG signal is enhanced and de-noised using a diffusion model, which solves the problem of noise interference in the ECG signal, improves the accuracy of signal segmentation and visualization, and ensures the clarity and reliability of the ECG.
Patent Information
- Application Number
- CN202510783826.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-09-23
AI Technical Summary
Strong noise interference in ECG signals affects the accuracy of signal segmentation, resulting in ECG distortion or unclearness, which in turn affects diagnosis and treatment decisions.
A pre-trained diffusion model is used to perform white noise enhancement processing on the ECG signal. Feature fusion is performed through the noise feature extraction module and the signal feature extraction module to generate a noisy signal, which is then de-noised to obtain a clear ECG signal for image segmentation and visualization.
It significantly improves the segmentation accuracy of ECG signals, ensures clear visualization of ECGs, reduces the risk of misdiagnosis or missed diagnosis, and provides reliable clinical support.
Smart Images

Figure CN120687733A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of signal processing technology, and in particular to a method for processing electrocardiogram signals and related products. Background Art
[0002] An electrocardiogram (ECG) is an important medical examination method that records the heart's electrical activity. Obtaining an ECG is crucial for diagnosing and researching heart disease. An ECG is a visualization of the segmented ECG signal.
[0003] However, when there is strong noise interference in the ECG signal, the accuracy of ECG signal segmentation will be greatly affected, which in turn affects the visualization of the ECG signal, making the visualized ECG distorted or unclear, leading to misdiagnosis or missed diagnosis, affecting clinical judgment and treatment decisions. Summary of the Invention
[0004] Based on the above problems, this application provides an ECG signal processing method and related products, the purpose of which is to effectively remove noise interference in ECG signals to improve the accuracy of ECG signal segmentation, thereby ensuring clear and accurate ECG visualization, avoiding distortion, and reducing the risk of misdiagnosis or missed diagnosis, thereby providing more reliable support for clinical diagnosis and treatment.
[0005] The embodiments of this application disclose the following technical solutions:
[0006] A method for processing an electrocardiogram signal, the method comprising:
[0007] Acquire a signal to be processed; the signal to be processed includes an electrocardiogram signal to be processed containing noise interference;
[0008] A pre-trained diffusion model is used to add white noise to the signal to be processed to obtain a noisy signal; the backbone network of the diffusion model includes a noise feature extraction module, a signal feature extraction module and a fusion module; the noise feature extraction module is used to extract features from white noise; the signal feature extraction module is used to extract features from the signal to be processed; and the fusion module is used to fuse the two extracted features;
[0009] Performing denoising on the noisy signal to obtain a denoised signal; the denoised signal includes the electrocardiogram signal to be processed that is free of the noise interference after denoising the signal to be processed;
[0010] Image segmentation and visualization are performed on the denoised signal to obtain an electrocardiogram waveform visualization image.
[0011] In one possible implementation, the noise feature extraction module includes a first preliminary feature extraction module, a first deep feature enhancement module, and a feature highlighting module; the signal feature extraction module includes a second preliminary feature extraction module and a second deep feature enhancement module; the fusion module includes a fifth summation module and a third convolutional layer;
[0012] The output end of the first preliminary feature extraction module is connected to the input end of the first deep feature enhancement module; the output end of the first deep feature enhancement module and the output end of the feature highlighting module are both connected to the input end of the fifth summation module; the output end of the fifth summation module is connected to the input end of the third convolutional layer.
[0013] In one possible implementation, in the noise feature extraction module, the first preliminary feature extraction module includes a first convolutional layer and a first rectified linear unit (ReLU) activation layer; the first deep feature enhancement module includes first to fourth X-Transformer layers; and the feature highlighting module includes first to fifth attention layers.
[0014] The output end of the first convolutional layer is connected to the input end of the first ReLU activation layer; the output end of the first ReLU activation layer is connected to the input end of the first attention layer; the output end of the first ReLU activation layer is also connected to the first to fourth X-Transformer layers in sequence, and the output ends of the first to fourth X-Transformer layers are also connected to the input ends of the second to fifth attention layers respectively; the output ends of the first to fifth attention layers are connected to the input ends of the first to fifth summation modules respectively.
[0015] In a possible implementation, in the signal feature extraction module, the second preliminary feature extraction module includes a second convolutional layer and a second ReLU activation layer; the second deep feature enhancement module includes fifth to eighth X-Transformer layers and first to fourth summation modules;
[0016] The output end of the second convolutional layer is connected to the input end of the second ReLU activation layer; the output end of the second ReLU activation layer is connected to the input end of the first summation module; the output end of the first summation module is connected to the fifth to eighth X-Transformer layers in sequence, and the i-th X-Transformer layer is connected to the i+1th X-Transformer layer through the i-3th summation module, the input end of the i-3th summation module is connected to the output end of the i-th X-Transformer layer, and the output end of the i-3th summation module is connected to the output end of the i+1th X-Transformer layer, and the value of i is 5, 6, and 7.
[0017] In one possible implementation, the structures of the first to fifth attention layers are the same, including: a fourth convolutional layer, a position encoding layer, a feature affine layer, and a fifth convolutional layer;
[0018] For any attention layer: the input end of the fourth convolutional layer in the attention layer is the input end of the attention layer; the output end of the fourth convolutional layer is connected to the input end of the feature affine layer; the output end of the position encoding layer is connected to the input end of the feature affine layer; the output end of the feature affine layer is connected to the input end of the fifth convolutional layer; the output end of the fifth convolutional layer is the output end of the attention layer;
[0019] The input of the input end of the position encoding layer is a constant noise embedding signal.
[0020] In one possible implementation, the structures of the first to eighth X-Transformer layers are the same, including: a forward embedding layer, a backward embedding layer, a first self-attention layer, a second self-attention layer, a first projection layer, a second projection layer, a sixth summation module, a sixth convolutional layer, a seventh convolutional layer, a normalization layer, a denormalization layer, a third ReLU activation layer, and a seventh summation module;
[0021] For any X-Transformer layer: the input end of the forward embedding layer in the X-Transformer layer is connected to the input end of the reverse embedding layer as the input end of the X-Transformer layer; the output end of the forward embedding layer is connected to the input end of the first self-attention layer; the output end of the reverse embedding layer is connected to the input end of the second self-attention layer; the output end of the j-th self-attention layer is connected to the input end of the j-th projection layer, where j is 1 or 2; the output ends of the first and second projection layers are both connected to the input end of the sixth summation module; the output end of the sixth summation module is respectively connected to the input end of the normalization layer and the input end of the non-normalization layer; the output end of the normalization layer and the output end of the non-normalization layer are both connected to the input end of the seventh convolutional layer; the output end of the seventh convolutional layer is connected to the input end of the third ReLU activation layer; the output end of the third ReLU activation layer is connected to the input end of the seventh summation module; the output end of the seventh summation module is the output end of the X-Transformer layer;
[0022] Among them, the outputs of the forward embedding layer and the reverse embedding layer both include three paths: Q, K and V; the output of the second projection layer is flipped and input into the sixth summation module; the output of the normalization layer and the output of the non-normalization layer are spliced and input into the seventh convolutional layer; the seventh summation module is used to fuse the output of the third ReLU activation layer with the overall input of the X-Transformer layer.
[0023] In one possible implementation, the training process of the diffusion model includes:
[0024] Construct multiple pairs of training samples; one pair of training samples includes a historical noisy signal and a first Gaussian white noise of the historical noisy signal; the historical noisy signal is obtained by adding the noise interference to the original clean signal; the first Gaussian white noise of the historical noisy signal is obtained by iteratively diffusing the original clean signal of the historical noisy signal using a noise addition formula; the original clean signal is a noise-free historical ECG signal;
[0025] Taking the multiple pairs of training samples as input, training the model parameters of the backbone network to obtain the diffusion model;
[0026] In which, during the training process, for each pair of training samples, the historical noisy signal in the training sample is input into the backbone network through the second preliminary feature extraction module, and the first Gaussian white noise of the historical noisy signal is input into the backbone network through the first preliminary feature extraction module, so as to perform model training based on the historical noisy signal and the first Gaussian white noise of the historical noisy signal.
[0027] In a possible implementation, the adding white noise to the signal to be processed using a pre-trained diffusion model to obtain a noisy signal includes:
[0028] Obtain a second Gaussian white noise; the second Gaussian white noise is a universal Gaussian white noise, and the universal Gaussian white noise includes a Gaussian distributed random signal with zero mean and fixed variance;
[0029] The second Gaussian white noise is used as the input of the noise feature extraction module, the signal to be processed is used as the input of the signal feature extraction module, and Gaussian white noise is added through the diffusion model to obtain the noisy signal.
[0030] A device for processing an electrocardiogram signal, comprising:
[0031] A first acquiring unit is configured to acquire a signal to be processed; the signal to be processed includes an electrocardiogram signal to be processed containing noise interference;
[0032] A noise adding unit is used to add white noise to the signal to be processed using a pre-trained diffusion model to obtain a noisy signal; the backbone network of the diffusion model includes a noise feature extraction module, a signal feature extraction module and a fusion module; the noise feature extraction module is used to extract features from white noise; the signal feature extraction module is used to extract features from the signal to be processed; and the fusion module is used to fuse the two extracted features;
[0033] a de-noising unit, configured to perform a de-noising process on the noisy signal to obtain a denoised signal; the denoised signal comprises the electrocardiogram signal to be processed which is free of the noise interference after the signal to be processed is de-noised;
[0034] The segmentation and visualization unit is used to perform image segmentation and visualization on the denoised signal to obtain an electrocardiogram waveform visualization image.
[0035] A processor is used to run a computer program, which executes the above-mentioned electrocardiogram signal processing method when the program is run.
[0036] Compared with the existing technology, this application has the following beneficial effects:
[0037] When the data analysis workflow of the embodiment of the present application starts working, first, the signal to be processed is obtained: the ECG signal to be processed containing noise interference (i.e., the signal to be processed) is obtained. Then, white noise processing is added: the pre-trained diffusion model is used to add white noise processing to the signal to be processed to obtain a noisy signal. Next, denoising processing is performed: the noisy signal obtained through the above steps is subjected to denoising processing to obtain a denoised signal. The denoised signal is the original signal to be processed that does not contain noise interference. Finally, image segmentation and visualization: the denoised signal is subjected to image segmentation and visualization processing to generate a clear ECG waveform. The present application uses a pre-trained diffusion model to add white noise processing to the ECG signal to be processed, which can effectively simulate and enhance the noise characteristics, thereby better removing the noise and obtaining an ECG signal with clear boundaries. The present application can significantly improve the quality of ECG signals and reduce the interference of noise on signal segmentation and visualization. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0039] Figure 1 A schematic diagram of an application scenario provided in an embodiment of the present application;
[0040] Figure 2 A flowchart of an implementation method for processing an electrocardiogram signal provided in an embodiment of the present application;
[0041] Figure 3 A structural diagram of a diffusion model network structure provided in an embodiment of the present application;
[0042] Figure 4 A schematic diagram of the structure of an attention layer provided in an embodiment of the present application;
[0043] Figure 5 A schematic diagram of the structure of an X-Transformer provided in an embodiment of the present application;
[0044] Figure 6 A schematic diagram of the structure of an electrocardiogram signal processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] As previously mentioned, the electrocardiogram (ECG), an important medical examination method for recording cardiac electrical activity, is widely used in the diagnosis, monitoring, and research of clinical heart disease. By detecting and recording the electrical signals generated by the heart with each beat, it can reflect the heart's health and function. The process of acquiring an ECG involves extracting, processing, and visualizing the ECG signal. By analyzing the ECG, doctors can identify the type of heart disease, locate lesions, and even predict possible heart problems such as arrhythmias and myocardial ischemia.
[0046] However, in the actual ECG acquisition process, ECG signals are often affected by various noise interferences, such as electromagnetic interference, myoelectric drift, and myoelectric interference. These noise interferences can mix with the actual ECG signal, affecting its quality. In this case, the ECG signal segmentation process will be significantly affected. ECG signal segmentation is the process of dividing the original signal into individual heartbeats. The accuracy of this process directly determines the effectiveness of subsequent analysis. If the noise is too strong, the accuracy of signal segmentation will be significantly reduced, making it difficult to correctly identify the start and end points of each heartbeat, further affecting the visualization of the ECG.
[0047] Since ECG visualization is a graphical representation of the ECG signal, errors in the segmentation process can result in distorted or unclear ECG images. This distortion can make it difficult for doctors to accurately interpret the ECG, leading to misdiagnosis or missed diagnosis. For example, ECG accuracy is crucial in the diagnosis of arrhythmias. Incorrect signal segmentation can lead to missed or misdiagnosis of arrhythmias, delaying treatment and even endangering the patient's life.
[0048] Based on this, the embodiment of the present application provides a method for processing an ECG signal and related products, which first obtains an ECG signal to be processed containing noise interference as input. Then, a pre-trained diffusion model is used to perform white noise enhancement processing on the signal to be processed, thereby obtaining a noisy signal. Then, a de-noising processing technology is used to purify the noisy signal to obtain a denoised signal, that is, a clear ECG signal with noise interference removed. Finally, the denoised signal is converted into a visualization of the ECG waveform using image segmentation technology and visualization technology. The present application performs white noise enhancement on the ECG signal to be processed by applying a pre-trained diffusion model, thereby better removing noise and obtaining an ECG signal with clear boundaries. This method significantly improves the quality of the ECG signal and reduces the interference of noise on signal segmentation and visualization.
[0049] In order to help those skilled in the art better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0050] It should be understood that the technical solution of this application can be applied to the following scenarios, but is not limited to:
[0051] In one possible implementation, Figure 1 An application scenario diagram provided in an embodiment of the present application, such as Figure 1 As shown, the application scenario may include an electronic device 110 and a network device 120. The electronic device 110 may establish a connection with the network device 120 via a wired network or a wireless network.
[0052] For example, the electronic device 110 may be a desktop computer, a laptop computer, a tablet computer, etc., but is not limited thereto. The network device 120 may be a terminal device or a server, but is not limited thereto. In one embodiment of the present application, the electronic device 110 may send a request message to the network device 120, where the request message may be used to request an electrocardiogram waveform visualization corresponding to the to-be-processed electrocardiogram signal containing noise interference. Furthermore, the electronic device 110 may receive a response message sent by the network device 120, where the response message includes the to-be-processed electrocardiogram signal without noise interference after denoising the to-be-processed signal.
[0053] also, Figure 1 An electronic device 110 and a network device 120 are exemplarily provided. In practice, other numbers of electronic devices and network devices may be included, and this application does not impose any limitation thereto.
[0054] In another possible implementation, the technical solution of the present application may also be executed by the above-mentioned electronic device 110, or the technical solution of the present application may also be executed by the above-mentioned network device 120, and the present application does not impose any restrictions on this.
[0055] To facilitate understanding of the present application, a method for processing an electrocardiogram signal provided in an embodiment of the present application is described below with reference to the accompanying drawings.
[0056] See also Figure 2 As shown in FIG, this figure is a flow chart of a method for processing an electrocardiogram signal provided by an embodiment of the present application, as shown in FIG. Figure 2 As shown, the method may include S201-S204:
[0057] S201: Obtain a signal to be processed.
[0058] In the process of ECG signal processing, we first need to obtain the signal to be processed. This signal typically originates from an ECG monitoring device. However, due to the device environment, human motion, or other factors, the original ECG signal is often subject to noise interference. This noise interference, including electromagnetic interference, myoelectric drift, and myoelectric interference, can mask or distort the characteristics of the original ECG signal, thereby affecting subsequent signal analysis and diagnosis. Therefore, before segmenting and visualizing the ECG signal, these noise interferences must be considered so that appropriate measures can be taken for effective noise suppression and signal recovery.
[0059] It should be noted that electromagnetic interference, myoelectric drift, and myoelectric interference are common types of noise that affect ECG signal quality:
[0060] Electromagnetic interference: Electromagnetic interference often originates from electrical devices or external electromagnetic fields in the environment, such as power lines, mobile phones, computers, and other electronic devices. These interferences enter ECG monitoring equipment through cables or power lines, causing signal fluctuations or irregular noise. This can obscure ECG details and even mislead diagnostic results. Electromagnetic interference typically manifests as high-frequency spikes.
[0061] Myoelectric drift: Myoelectric drift refers to the effect of low-frequency electrical signals generated by other parts of the body (such as breathing or muscle contraction) on the quality of the ECG signal. This phenomenon manifests as a low-frequency, slowly fluctuating drift in the ECG. This interference is usually gentle and changes gradually over time, potentially obscuring subtle changes in the ECG signal and affecting accurate ECG analysis.
[0062] Myoelectric interference: Myoelectric interference is caused by electrical signals generated by the electrical activity of muscles (such as exercise, speaking, and coughing), which interferes with the ECG signal. It usually manifests as a high-frequency, sharp signal. Myoelectric interference can cause clutter or artifacts in the ECG, affecting the authenticity and accuracy of the signal. It is especially noticeable during exercise or frequent muscle activity.
[0063] These noise sources can seriously affect the clarity and accuracy of ECG signals. Therefore, effective denoising methods need to be adopted during signal processing to filter out these interference signals, thereby ensuring the quality of ECG signals and the accuracy of subsequent diagnosis.
[0064] S202: Using a pre-trained diffusion model, add white noise to the signal to be processed to obtain a noisy signal.
[0065] During signal processing, in order to enhance the robustness of the signal, a pre-trained diffusion model is used to add white noise to the signal to be processed, thereby generating a noisy signal. The backbone network of the diffusion model adopts a backbone network with a dual-stream architecture, which can process the characteristics of the signal and noise separately. Specifically, the diffusion model includes a noise feature extraction module, a signal feature extraction module, and a fusion module. The noise feature extraction module is specifically responsible for feature extraction of latent variables (i.e., white noise), while the signal feature extraction module is used to extract its inherent features from noisy conditions (i.e., the signal to be processed). The extracted noise and signal features are then merged through a fusion module to generate a more accurate noisy signal. This dual-stream design of the fusion noise feature extraction module and the signal feature extraction module allows the network to simultaneously consider the intrinsic characteristics of the signal and the external noise conditions, thereby achieving more accurate denoising and reconstruction, further improving the effect of the diffusion model in noise processing.
[0066] S203: Performing denoising processing on the noisy signal to obtain a denoised signal.
[0067] After the noisy signal is generated, denoising is performed to remove the noise interference, ultimately obtaining a noise-free ECG signal (i.e., denoised signal) after denoising the signal to be processed. The core goal of denoising is to remove unnecessary noise components from the noisy signal through algorithm or model optimization, thereby restoring a clearer and more accurate original signal. The signal after denoising not only retains the effective information of the signal to be processed, but also eliminates all noise interference. Therefore, the resulting denoised signal is a restored version of the original signal, no longer affected by noise. Such processing ensures the reliability and accuracy of the signal in subsequent analysis and application.
[0068] It should be noted that the denoising process is usually implemented using a common diffusion model denoising formula, for example: Pθ(Xt)=N(μθ(Xt, t), Σθ(Xt, t));
[0069] Among them, Pθ(Xt) represents the probability distribution of variable Xt at time step t, where θ represents the parameters of the model; N(μθ(Xt, t), Σθ(Xt, t)) represents a normal distribution (Gaussian distribution) with mean μθ(Xt, t) and covariance matrix Σθ(Xt, t); μθ(Xt, t) represents the conditional mean of variable Xt at time step t, which is determined by the model parameters θ; Σθ(Xt, t) represents the conditional covariance matrix of variable Xt at time step t, which is also determined by the model parameters θ.
[0070] Through the trained models μθ and Σθ, the noise can be gradually removed and the original signal can be restored.
[0071] S204: performing image segmentation and visualization on the denoised signal to obtain an electrocardiogram waveform visualization image.
[0072] Finally, the processed ECG signal can be further converted into a meaningful image. First, image segmentation is performed to divide the processed signal into several time segments representing different phases or features of the ECG, such as the P wave, QRS complex, and T wave. Then, using visualization technology, these segmented waveforms are presented as images, forming a visual representation of the ECG. This allows for more intuitive observation of the details and features of the ECG waveform, aiding in the assessment and analysis of heart health.
[0073] The core of steps S201-S204 is to optimize the quality of the ECG signal through a series of steps. First, the noisy signal is extracted from the ECG signal to be processed. Then, with the help of a pre-trained diffusion model, the signal is noise-enhanced to generate a noisy signal with noise. Subsequently, the noisy signal is processed by a de-noising algorithm to remove noise interference and obtain a clean, noise-free ECG signal. Finally, image segmentation and visualization technology are used to convert the purified signal into a clear ECG waveform. This application can improve the quality of ECG signals and reduce the interference of noise on signal segmentation and visualization.
[0074] In a possible implementation, the present application also provides a network structure of a diffusion model, such as Figure 3 As shown, Figure 3A structural schematic diagram of a diffusion model structure provided in an embodiment of the present application, wherein the network structure of the diffusion model includes a noise feature extraction module, a signal feature extraction module and a fusion module. The noise feature extraction module includes a first preliminary feature extraction module, a first deep feature enhancement module and a feature highlighting module. The signal feature extraction module includes a second preliminary feature extraction module and a second deep feature enhancement module. The fusion module includes a fifth summation module and a third convolution layer. The output end of the first preliminary feature extraction module is connected to the input end of the first deep feature enhancement module, the output end of the first deep feature enhancement module and the output end of the feature highlighting module are both connected to the input end of the fifth summation module, and the output end of the fifth summation module is connected to the input end of the third convolution.
[0075] Specifically, in the noise feature extraction module, the first preliminary feature extraction module includes: a first convolutional layer (such as 5×1Conv(80)) and a first rectified linear unit (Rectified LinearUnit, ReLU) activation layer; the first deep feature enhancement module includes: a first X-Transformer, a second X-Transformer, a third X-Transformer and a fourth X-Transformer layer; the feature highlighting module includes: a first attention layer, a second attention layer, a third attention layer, a fourth attention layer and a fifth attention layer.
[0076] In the signal feature extraction module, the second deep feature enhancement module includes: a second convolution layer (such as 9×1Conv(80)) and a second ReLU activation layer; the second deep feature enhancement module includes: a fifth X-Transformer, a sixth X-Transformer, a seventh X-Transformer, an eighth X-Transformer layer, a first summation module, a second summation module, a third summation module and a fourth summation module ( Figure 3 ⊕ from bottom to top, they are the first summing module, the second summing module, the third summing module, the fourth summing module and the fifth summing module).
[0077] The structure of the fusion module includes: a fifth summation module and a third convolutional layer (such as 11×1Conv(1)).
[0078] The connection method of each module and layer structure in the above noise feature extraction module, signal feature extraction module and fusion module includes: the output end of the first convolutional layer is connected to the input end of the first ReLU activation layer; the output end of the first ReLU activation layer is connected to the input end of the first attention layer; the output end of the first ReLU activation layer is also connected to the first to fourth X-Transformer layers in sequence, and the output ends of the first to fourth X-Transformer layers are also connected to the input ends of the second to fifth attention layers respectively; the output ends of the first to fifth attention layers are connected to the input ends of the first to fifth summation modules respectively;
[0079] The output end of the second convolutional layer is connected to the input end of the second ReLU activation layer; the output end of the second ReLU activation layer is connected to the input end of the first summation module; the output end of the first summation module is connected to the fifth to eighth X-Transformer layers in sequence, and the i-th X-Transformer layer is connected to the i+1th X-Transformer layer through the i-3th summation module, the input end of the i-3th summation module is connected to the output end of the i-Transformer layer, and the output end of the i-3th summation module is connected to the output end of the i+1th X-Transformer layer, where i is 5, 6, and 7; the input end of the fifth summation module is also connected to the output end of the eighth X-Transformer layer, and the output end of the fifth summation module is connected to the input end of the third convolutional layer.
[0080] It should be noted that "the i-th X-Transformer layer is connected to the i+1-th X-Transformer layer through the i-3-th summation module, the input of the i-3-th summation module is connected to the output of the i-th X-Transformer layer, and the output of the i-3-th summation module is connected to the output of the i+1-th X-Transformer layer, and the value of i is 5, 6, or 7" means:
[0081] The fifth X-Transformer layer is connected to the sixth X-Transformer layer through the second summation module, the sixth X-Transformer layer is connected to the seventh X-Transformer layer through the third summation module, and the seventh X-Transformer layer is connected to the eighth X-Transformer layer through the fourth summation module; the input end of the second summation module is connected to the output end of the fifth X-Transformer layer, and the output end of the second summation module is connected to the output end of the sixth X-Transformer layer; the input end of the third summation module is connected to the output end of the sixth X-Transformer layer, and the output end of the third summation module is connected to the output end of the seventh X-Transformer layer; the input end of the fourth summation module is connected to the output end of the seventh X-Transformer layer, and the output end of the fourth summation module is connected to the output end of the eighth X-Transformer layer; the input end of the fifth summation module is connected to the output end of the eighth X-Transformer layer.
[0082] It should also be noted that the functions of each module and layer structure in the noise feature extraction module, signal feature extraction module and fusion module include:
[0083] (1) In the noise feature extraction module:
[0084] First convolutional layer: This layer is used to extract low-level features from the input signal, such as edges, textures, etc. Its output is the feature map obtained by the convolution operation.
[0085] First ReLU activation layer: This layer performs nonlinear activation on the output of the first convolutional layer to increase the model's expressiveness. ReLU (Rectified Linear Unit) converts negative values to 0 and retains positive values.
[0086] X-Transformer layers (layers 1 to 4): These Transformer layers are primarily used to model high-level features of the signal. Transformer uses a self-attention mechanism to enable the model to capture long-range dependencies in the sequence. Each layer processes features from the previous layer and produces an output.
[0087] Attention layers (layers 1-5): The attention mechanism in each layer helps the model focus on key parts of the input, increasing the model's focus area and handling long-range dependencies. These attention layers (except the fifth attention layer, which is connected to the first ReLU activation layer) are connected to the previous X-Transformer layers to help capture richer signal features.
[0088] (2) In the signal feature extraction module:
[0089] Second convolutional layer: Similar to the first convolutional layer, but it processes signal features and helps extract high-level features of the signal.
[0090] Second ReLU activation layer: performs nonlinear activation on the output of the second convolutional layer to increase the model's expressive power.
[0091] X-Transformer layer (layers 5 to 8): Similar to the X-Transformer layer of the noise feature extraction module, but this part focuses on signal features and captures more complex structural information.
[0092] Summation module (first to fourth summation modules): adds the output of the attention layer in the noise feature extraction module and the output of another layer structure connected to the summation module (for example, the first summation module adds the output of the first attention layer to the output of the second ReLU activation layer, the second summation module adds the output of the second attention layer to the output of the fifth X-Transformer layer, the third summation module adds the output of the third attention layer to the output of the sixth X-Transformer layer, and the fourth summation module adds the output of the fourth attention layer to the output of the seventh X-Transformer layer), which is used to merge the signal features output by different X-Transformer layers.
[0093] (3) In the fusion module:
[0094] Fifth summation module: adds the output of the fifth attention layer to the output of the eighth X-Transformer layer.
[0095] The third convolutional layer: convolution is performed on the fused features output by the fifth summation module to generate comprehensive features for the final output.
[0096] This model is designed to simultaneously extract noise and signal features, processing them through two independent streams (noise feature stream and signal feature stream), and modeling complex temporal relationships through Transformer layers. After being processed by multiple Transformer layers, the noise and signal features are finally merged in the fusion module to obtain a richer and more comprehensive feature representation. These features are then passed to subsequent processing layers for further decision making or output.
[0097] Through this structure, the network can effectively extract and fuse information from different sources, improve the ability to understand signal and noise characteristics, and perform deep learning and feature reconstruction at multiple levels.
[0098] In a possible implementation, the present application also provides a network structure of an attention layer, and the structures of the first to fifth attention layers are the same, such as Figure 4 As shown, Figure 4 A schematic diagram of the structure of an attention layer provided in an embodiment of the present application, wherein the structure of the attention layer includes a fourth convolutional layer (such as 13×1Conv(80)), a position encoding layer, a feature affine layer and a fifth convolutional layer (such as 15×1Conv(80)).
[0099] For any attention layer: the input of the fourth convolutional layer in the attention layer is the input of the attention layer; the output of the fourth convolutional layer is connected to the input of the feature affine layer; the output of the position encoding layer is connected to the input of the feature affine layer; the output of the feature affine layer is connected to the input of the fifth convolutional layer; the output of the fifth convolutional layer is the output of the attention layer;
[0100] Among them, for any position encoding layer, the input of its input end is always a noise embedded signal (such as, ).
[0101] In one possible implementation, the affine transformation formula of the feature affine layer includes result = (1 + γ) * x + β, where result is the affine result, x is the output of the fourth convolutional layer, and γ and β are obtained by dividing the output of the position encoding layer based on the channel dimension.
[0102] It should be noted that the functions of each module and layer structure in the attention layer include:
[0103] The fourth convolutional layer: This layer performs convolution operations on the input signal to extract low-level features of the signal. These features can be some local patterns or structural features.
[0104] Position encoding layer: The main function of the position encoding layer is to embed the input noise signal (e.g. ) adds position information, enabling the network to perceive the order or positional relationship of the input data. It adds position information to the input signal and outputs a position-encoded signal. Here, the noise embedding signal can be a fixed or predefined signal used to impart position-related features to each input signal.
[0105] Feature Affine Layer: The feature affine layer adjusts the signal through an affine transformation, combining the output of the fourth convolutional layer and the output of the position encoding layer. The affine transformation formula is: result = (1 + γ) * x + β, where γ and β are parameters obtained by segmenting the output of the position encoding layer. This mechanism allows the network to dynamically adjust features based on varying noise levels, improving the model's adaptability and robustness.
[0106] The fifth convolutional layer further convolves the output of the feature affine layer to extract higher-level features. At this point, the network extracts information from a wider range of features through convolution operations.
[0107] The output of the attention layer is the final result obtained after the signals from the above layers are fused. It will be passed to other modules or layers in the subsequent network for further processing. Therefore, this attention layer gradually extracts the features of the input signal through the operation of multiple modules, and enhances the contextual information of the signal through positional encoding, ultimately generating an output with rich feature representation.
[0108] In a possible implementation, the present application also provides a network structure of an X-Transformer, where the structures of the first to eighth X-Transformer layers are the same, such as Figure 5 As shown, Figure 5 A schematic diagram of the structure of an X-Transformer provided in an embodiment of the present application, wherein the X-Transformer introduces a novel cross-Transformer mechanism. This mechanism includes two parallel branches that can process input data from different angles, greatly enhancing the feature extraction capability of the model. The X-Transformer includes: a forward embedding layer, a reverse embedding layer, a first self-attention layer, a second self-attention layer, a first projection layer, a second projection layer, a sixth summation module, a sixth convolutional layer (such as 5×1Conv(80)), a seventh convolutional layer (such as 3×1Conv(80)), a normalization layer, a non-normalization layer, a third ReLU activation layer, and a seventh summation module. Figure 5 From bottom to top, ⊕ represents the sixth summation module and the seventh summation module.
[0109] For any X-Transformer layer: the input end of the forward embedding layer in the X-Transformer layer is connected to the input end of the reverse embedding layer as the input end of the X-Transformer layer; the output end of the forward embedding layer is connected to the input end of the first self-attention layer; the output end of the reverse embedding layer is connected to the input end of the second self-attention layer; the output end of the j-th self-attention layer is connected to the input end of the j-th projection layer, where j is 1 or 2; the output ends of the first and second projection layers are both connected to the input end of the sixth summation module; the output end of the sixth summation module is respectively connected to the input end of the normalization layer and the input end of the non-normalization layer; the output end of the normalization layer and the output end of the non-normalization layer are both connected to the input end of the seventh convolutional layer; the output end of the seventh convolutional layer is connected to the input end of the third ReLU activation layer; the output end of the third ReLU activation layer is connected to the input end of the seventh summation module; the output end of the seventh summation module is the output end of the X-Transformer layer;
[0110] Among them, the outputs of the forward embedding layer and the reverse embedding layer both include three paths: Q, K and V; the output of the second projection layer is flipped and input into the sixth summation module; the output of the normalization layer and the output of the non-normalization layer are spliced and input into the seventh convolutional layer; the seventh summation module is used to fuse the output of the third ReLU activation layer with the overall input of the X-Transformer layer.
[0111] It should be noted that the functions of each module and layer structure in X-Transformer include:
[0112] Forward Embedding Layer and Backward Embedding Layer: These two embedding layers are responsible for embedding the input data into the representation space, generating three different representations: Q, K, and V. The forward embedding layer encodes the forward propagation data. The back embedding layer encodes the backward propagation data. Through the forward and backward paths, the model can process data from different perspectives.
[0113] The first and second self-attention layers use a self-attention mechanism to capture relationships between elements in the sequence. The first self-attention layer processes the output of the forward embedding layer, while the second self-attention layer processes the output of the backward embedding layer. The self-attention mechanism adjusts the representation of each element by calculating the relationship between the query, key, and value to better understand the internal structure of the input data.
[0114] The first and second projection layers receive the output of the self-attention layer and perform a linear transformation on it. The output of the projection layer is the processed and adjusted feature representation. The first projection layer is connected to the first self-attention layer, and the second projection layer is connected to the second self-attention layer. Their outputs are fed into subsequent modules for further processing.
[0115] Sixth summation module: This module sums the outputs of the first and second projection layers. The purpose of the summation operation is to merge the information from the two branches (forward and reverse paths) to better capture the characteristics of the model.
[0116] The functions of normalization and denormalization layers: Normalization layers standardize inputs, accelerating training and improving model stability; denormalization layers maintain the original feature representation. The outputs of both layers are used in subsequent convolutional layers. Normalization layers help improve training efficiency, while denormalization layers preserve the original features of the data.
[0117] Seventh convolutional layer: This convolutional layer extracts higher-level features from the outputs of the normalized and denormalized layers through convolution operations. The function of the convolutional layer is to capture the spatial information of the data through local perception and enhance the feature expression capability. The seventh convolutional layer (such as 5×1Conv(80)) is used here, which can capture local features in sequence data.
[0118] The third ReLU activation layer: The ReLU activation function sets all negative values in the input to zero and leaves positive values unchanged, thereby introducing nonlinear features. The purpose of this layer is to increase the nonlinearity of the network and help the model learn complex patterns.
[0119] The seventh summation module: This module combines and sums the output from the third ReLU activation layer with the overall input of the X-Transformer layer (i.e., the input of the forward embedding layer and the input of the reverse embedding layer), further fusing features and generating the final output. The output of the seventh summation module serves as the final output of the X-Transformer layer for further processing by subsequent layers or networks.
[0120] It should also be noted that in the forward and backward embedding layers, representations of the query (Q), key (K), and value (V) are generated, respectively, for use by the self-attention mechanism. The output of the second projection layer is flipped and input into the sixth summation module. This flipping is intended to break the order bias and enhance the model's expressive power. The outputs of the normalization layer and the denormalization layer are concatenated before entering the seventh convolutional layer. This allows the features of the two processing methods to be combined and enrich the model's feature information. The seventh summation module fuses the output of the third ReLU activation layer with the overall input of the X-Transformer layer. Through this fusion, information obtained from multiple paths (such as forward and backward propagation) can be combined, thereby enhancing the model's representational power and the comprehensiveness of feature extraction.
[0121] This X-Transformer architecture introduces a cross-Transformer mechanism, utilizing a parallel structure of forward and backward paths, combined with multiple modules such as self-attention, projection, convolution, and activation layers, to comprehensively enhance feature extraction and representation capabilities. Each module enhances the model's feature processing capabilities through specialized operations, ultimately providing the model with a richer and more powerful representation of input features.
[0122] In one possible implementation, the training process of the diffusion model includes:
[0123] First, multiple pairs of training samples are constructed, and then the multiple pairs of training samples are used as input to train model parameters of the backbone network to obtain the diffusion model.
[0124] A pair of training samples includes: a historical noisy signal and the first Gaussian white noise of the historical noisy signal.
[0125] Historical noisy signal: This is obtained by adding noise perturbations to the original clean signal. This clean signal is usually the target signal (such as a historical ECG signal), while the noise is added in some way (such as Gaussian noise).
[0126] First Gaussian white noise: This noise is generated by iterative diffusion based on the clean signal in the historical noisy signal using a noise addition formula to simulate the signal under different noise interference conditions. This noise is part of the training model to enable the model to learn how to recover the clean signal from the noisy signal.
[0127] In one possible implementation, the Gaussian white noise generation process involves gradually and randomly adding noise interference to the original clean signal. This process simulates the gradual accumulation of noise in real environments. Specifically, a noise pattern can be initialized, where the noise intensity β1 at the beginning of the diffusion process is set to 0.0001, the noise intensity βT at the end of the diffusion process is set to 0.5, and the total number of steps is set to 50. These parameters were selected through repeated experimentation and optimization to effectively simulate various noise environments while preserving signal characteristics. Next, a carefully tuned quadratic function (such as βt = at2 + bt + c) is used to generate the complete noise sequence {β1, ..., βn}. This method better simulates the actual noise accumulation process than linear or exponential functions. Noise addition is then applied to achieve the diffusion of the noise sequence {β1, ..., βn} into the original clean signal. After multiple iterations, when the value of t is sufficiently large, an approximate random Gaussian white noise is ultimately obtained. This gradual noise addition process lays the foundation for subsequent denoising and reconstruction.
[0128] In one possible implementation, the noise addition formula is: q(Xt|X0) represents the probability distribution of signal X at time step t given the original signal X0 (i.e., the original clean signal); represents a Gaussian distribution, is the mean of the Gaussian distribution, is the covariance matrix of the Gaussian distribution, I is the identity matrix; It is a cumulative factor at time step t, usually representing the cumulative product from the initial time step to the current time step t. is the square root of this accumulation factor and is used to calculate the mean of Xt.
[0129] Furthermore, during training, for each pair of training samples, the historical noisy signal in that training sample is input into the backbone network via the second preliminary feature extraction module. Simultaneously, the first Gaussian white noise in that historical noisy signal is input into the backbone network via the first preliminary feature extraction module. This allows the noise and signal features to be extracted separately through the noise feature extraction module and effectively integrated and represented through the fusion module. This allows the model to fully learn the complex relationship between the noisy ECG signal and the corresponding noise, as well as their characteristic distribution, during training. Ultimately, a diffusion model is developed that effectively adds noise to the processed signal, providing an accurate noise estimation foundation for subsequent signal denoising.
[0130] In a possible implementation, the step S202 of adding white noise to the signal to be processed using a pre-trained diffusion model to obtain a noisy signal includes:
[0131] First, by obtaining the second Gaussian white noise (xt), these noises will be used as the input of the noise feature extraction module. At the same time, the signal to be processed This serves as the input to the signal feature extraction module. These two inputs are then processed simultaneously by a trained diffusion model, which fuses the noise with the signal. Ultimately, Gaussian white noise is added to the processed signal to produce the noisy signal (ε). This process effectively enhances the noise characteristics of the signal, providing a foundation for subsequent denoising.
[0132] The second Gaussian white noise is a universal Gaussian white noise, which includes a Gaussian distributed random signal with zero mean and fixed variance.
[0133] Based on the method for processing an ECG signal provided in the above method embodiment, the embodiment of the present application further provides an ECG signal processing device, which will be described below with reference to the accompanying drawings.
[0134] See also Figure 6 As shown, Figure 6 This is a structural diagram of an electrocardiogram signal processing provided in an embodiment of the present application. Figure 6 As shown, the electrocardiogram signal processing device includes:
[0135] The first acquisition unit 601 is configured to acquire a signal to be processed; the signal to be processed includes an electrocardiogram signal to be processed containing noise interference;
[0136] Noise adding unit 602 is used to add white noise to the signal to be processed using a pre-trained diffusion model to obtain a noisy signal; the backbone network of the diffusion model includes a noise feature extraction module, a signal feature extraction module and a fusion module; the noise feature extraction module is used to extract features from white noise; the signal feature extraction module is used to extract features from the signal to be processed; and the fusion module is used to fuse the two extracted features;
[0137] The de-noising unit 603 is configured to perform a de-noising process on the noisy signal to obtain a denoised signal; the denoised signal includes the ECG signal to be processed which is free of the noise interference after the signal to be processed is de-noised;
[0138] The segmentation and visualization unit 604 is configured to perform image segmentation and visualization on the denoised signal to obtain an electrocardiogram waveform visualization image.
[0139] In one possible implementation, the noise feature extraction module includes a first preliminary feature extraction module, a first deep feature enhancement module, and a feature highlighting module; the signal feature extraction module includes a second preliminary feature extraction module and a second deep feature enhancement module; the fusion module includes a fifth summation module and a third convolutional layer;
[0140] The output end of the first preliminary feature extraction module is connected to the input end of the first deep feature enhancement module; the output end of the first deep feature enhancement module and the output end of the feature highlighting module are both connected to the input end of the fifth summation module; the output end of the fifth summation module is connected to the input end of the third convolutional layer.
[0141] In one possible implementation, in the noise feature extraction module, the first preliminary feature extraction module includes a first convolutional layer and a first rectified linear unit (ReLU) activation layer; the first deep feature enhancement module includes first to fourth X-Transformer layers; and the feature highlighting module includes first to fifth attention layers.
[0142] The output end of the first convolutional layer is connected to the input end of the first ReLU activation layer; the output end of the first ReLU activation layer is connected to the input end of the first attention layer; the output end of the first ReLU activation layer is also connected to the first to fourth X-Transformer layers in sequence, and the output ends of the first to fourth X-Transformer layers are also connected to the input ends of the second to fifth attention layers respectively; the output ends of the first to fifth attention layers are connected to the input ends of the first to fifth summation modules respectively.
[0143] In a possible implementation, in the signal feature extraction module, the second preliminary feature extraction module includes a second convolutional layer and a second ReLU activation layer; the second deep feature enhancement module includes fifth to eighth X-Transformer layers and first to fourth summation modules;
[0144] The output end of the second convolutional layer is connected to the input end of the second ReLU activation layer; the output end of the second ReLU activation layer is connected to the input end of the first summation module; the output end of the first summation module is connected to the fifth to eighth X-Transformer layers in sequence, and the i-th X-Transformer layer is connected to the i+1th X-Transformer layer through the i-3th summation module, the input end of the i-3th summation module is connected to the output end of the i-th X-Transformer layer, and the output end of the i-3th summation module is connected to the output end of the i+1th X-Transformer layer, and the value of i is 5, 6, and 7.
[0145] In one possible implementation, the structures of the first to fifth attention layers are the same, including: a fourth convolutional layer, a position encoding layer, a feature affine layer, and a fifth convolutional layer;
[0146] For any attention layer: the input end of the fourth convolutional layer in the attention layer is the input end of the attention layer; the output end of the fourth convolutional layer is connected to the input end of the feature affine layer; the output end of the position encoding layer is connected to the input end of the feature affine layer; the output end of the feature affine layer is connected to the input end of the fifth convolutional layer; the output end of the fifth convolutional layer is the output end of the attention layer;
[0147] The input of the input end of the position encoding layer is a constant noise embedding signal.
[0148] In one possible implementation, the structures of the first to eighth X-Transformer layers are the same, including: a forward embedding layer, a backward embedding layer, a first self-attention layer, a second self-attention layer, a first projection layer, a second projection layer, a sixth summation module, a sixth convolutional layer, a seventh convolutional layer, a normalization layer, a denormalization layer, a third ReLU activation layer, and a seventh summation module;
[0149] For any X-Transformer layer: the input end of the forward embedding layer in the X-Transformer layer is connected to the input end of the reverse embedding layer as the input end of the X-Transformer layer; the output end of the forward embedding layer is connected to the input end of the first self-attention layer; the output end of the reverse embedding layer is connected to the input end of the second self-attention layer; the output end of the j-th self-attention layer is connected to the input end of the j-th projection layer, where j is 1 or 2; the output ends of the first and second projection layers are both connected to the input end of the sixth summation module; the output end of the sixth summation module is respectively connected to the input end of the normalization layer and the input end of the non-normalization layer; the output end of the normalization layer and the output end of the non-normalization layer are both connected to the input end of the seventh convolutional layer; the output end of the seventh convolutional layer is connected to the input end of the third ReLU activation layer; the output end of the third ReLU activation layer is connected to the input end of the seventh summation module; the output end of the seventh summation module is the output end of the X-Transformer layer;
[0150] Among them, the outputs of the forward embedding layer and the reverse embedding layer both include three paths: Q, K and V; the output of the second projection layer is flipped and input into the sixth summation module; the output of the normalization layer and the output of the non-normalization layer are spliced and input into the seventh convolutional layer; the seventh summation module is used to fuse the output of the third ReLU activation layer with the overall input of the X-Transformer layer.
[0151] In a possible implementation, the apparatus further includes:
[0152] A sample construction unit is configured to construct multiple pairs of training samples; each pair of training samples includes a historical noisy signal and a first Gaussian white noise of the historical noisy signal; the historical noisy signal is obtained by adding the noise interference to an original clean signal; the first Gaussian white noise of the historical noisy signal is obtained by iteratively diffusing the original clean signal of the historical noisy signal using a noise addition formula; the original clean signal is a noise-free historical ECG signal;
[0153] A model training unit, configured to take the multiple pairs of training samples as input and perform model parameter training on the backbone network to obtain the diffusion model;
[0154] In which, during the training process, for each pair of training samples, the historical noisy signal in the training sample is input into the backbone network through the second preliminary feature extraction module, and the first Gaussian white noise of the historical noisy signal is input into the backbone network through the first preliminary feature extraction module, so as to perform model training based on the historical noisy signal and the first Gaussian white noise of the historical noisy signal.
[0155] In a possible implementation, the noise adding unit 602 specifically includes:
[0156] A second acquisition unit is configured to acquire a second Gaussian white noise; the second Gaussian white noise is a universal Gaussian white noise, and the universal Gaussian white noise includes a Gaussian distributed random signal with zero mean and fixed variance;
[0157] The noisy signal acquisition unit is used to use the second Gaussian white noise as the input of the noise feature extraction module, use the signal to be processed as the input of the signal feature extraction module, and add Gaussian white noise through the diffusion model to obtain the noisy signal.
[0158] In addition, an embodiment of the present application further provides a processor for running a computer program, which executes the above-mentioned method for processing electrocardiogram signals when the program is running.
[0159] The embodiment of the present application aims to improve the quality and visualization of electrocardiogram signals. First, by obtaining a signal to be processed, the signal to be processed is an electrocardiogram signal containing noise interference. Next, a pre-trained diffusion model is used to perform white noise enhancement processing on the signal to be processed, thereby generating a noisy signal. Ensure that the signal characteristics can be effectively captured and the noise can be increased. This process helps in subsequent signal repair. Then, the noisy signal is denoised to remove the noise interference therein, and finally a denoised signal is obtained, that is, it is restored to a clean electrocardiogram signal. Finally, the denoised signal is processed using image segmentation and visualization technology to generate a clear and accurate electrocardiogram waveform visualization diagram for further analysis and diagnosis. The present application uses a pre-trained diffusion model to add white noise to the electrocardiogram signal to be processed, effectively simulate and enhance the noise characteristics, thereby better removing the noise and obtaining an electrocardiogram signal with clear boundaries. This method improves the quality of the electrocardiogram signal and reduces the interference of noise on signal segmentation and visualization.
[0160] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.
[0161] The above is merely one specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A method for processing an electrocardiogram signal, characterized in that: The method comprises: Acquire a signal to be processed; the signal to be processed includes an electrocardiogram signal to be processed containing noise interference; A pre-trained diffusion model is used to add white noise to the signal to be processed to obtain a noisy signal; the backbone network of the diffusion model includes a noise feature extraction module, a signal feature extraction module and a fusion module; the noise feature extraction module is used to extract features from white noise; the signal feature extraction module is used to extract features from the signal to be processed; and the fusion module is used to fuse the two extracted features; Performing denoising on the noisy signal to obtain a denoised signal; the denoised signal includes the electrocardiogram signal to be processed that is free of the noise interference after denoising the signal to be processed; Image segmentation and visualization are performed on the denoised signal to obtain an electrocardiogram waveform visualization image.
2. The method according to claim 1, characterized in that The noise feature extraction module includes a first preliminary feature extraction module, a first depth feature enhancement module and a feature highlighting module; the signal feature extraction module includes a second preliminary feature extraction module and a second depth feature enhancement module; The fusion module includes a fifth summation module and a third convolutional layer; The output end of the first preliminary feature extraction module is connected to the input end of the first deep feature enhancement module; the output end of the first deep feature enhancement module and the output end of the feature highlighting module are both connected to the input end of the fifth summation module; the output end of the fifth summation module is connected to the input end of the third convolutional layer.
3. The method according to claim 2, characterized in that In the noise feature extraction module, the first preliminary feature extraction module includes a first convolutional layer and a first rectified linear unit (ReLU) activation layer; the first deep feature enhancement module includes first to fourth X-Transformer layers; and the feature highlighting module includes first to fifth attention layers; The output end of the first convolutional layer is connected to the input end of the first ReLU activation layer; the output end of the first ReLU activation layer is connected to the input end of the first attention layer; the output end of the first ReLU activation layer is also connected to the first to fourth X-Transformer layers in sequence, and the output ends of the first to fourth X-Transformer layers are also connected to the input ends of the second to fifth attention layers respectively; the output ends of the first to fifth attention layers are connected to the input ends of the first to fifth summation modules respectively.
4. The method according to claim 2, characterized in that In the signal feature extraction module, the second preliminary feature extraction module includes a second convolutional layer and a second ReLU activation layer; the second deep feature enhancement module includes fifth to eighth X-Transformer layers and first to fourth summation modules; The output end of the second convolutional layer is connected to the input end of the second ReLU activation layer; the output end of the second ReLU activation layer is connected to the input end of the first summation module; the output end of the first summation module is connected to the fifth to eighth X-Transformer layers in sequence, and the i-th X-Transformer layer is connected to the i+1th X-Transformer layer through the i-3th summation module, the input end of the i-3th summation module is connected to the output end of the i-th X-Transformer layer, and the output end of the i-3th summation module is connected to the output end of the i+1th X-Transformer layer, and the value of i is 5, 6, and 7.
5. The method according to claim 3, characterized in that The structures of the first to fifth attention layers are the same, including: the fourth convolutional layer, the position encoding layer, the feature affine layer and the fifth convolutional layer; For any attention layer: the input end of the fourth convolutional layer in the attention layer is the input end of the attention layer; the output end of the fourth convolutional layer is connected to the input end of the feature affine layer; the output end of the position encoding layer is connected to the input end of the feature affine layer; the output end of the feature affine layer is connected to the input end of the fifth convolutional layer; the output end of the fifth convolutional layer is the output end of the attention layer; The input of the input end of the position encoding layer is a constant noise embedding signal.
6. The method according to claim 3 or 4, characterized in that The structures of the first to eighth X-Transformer layers are the same, including: forward embedding layer, backward embedding layer, first self-attention layer, second self-attention layer, first projection layer, second projection layer, sixth summation module, sixth convolutional layer, seventh convolutional layer, normalization layer, denormalization layer, third ReLU activation layer and seventh summation module; For any X-Transformer layer: the input end of the forward embedding layer in the X-Transformer layer is connected to the input end of the reverse embedding layer as the input end of the X-Transformer layer; the output end of the forward embedding layer is connected to the input end of the first self-attention layer; the output end of the reverse embedding layer is connected to the input end of the second self-attention layer; the output end of the j-th self-attention layer is connected to the input end of the j-th projection layer, where j is 1 or 2; the output ends of the first and second projection layers are both connected to the input end of the sixth summation module; the output end of the sixth summation module is respectively connected to the input end of the normalization layer and the input end of the non-normalization layer; the output end of the normalization layer and the output end of the non-normalization layer are both connected to the input end of the seventh convolutional layer; the output end of the seventh convolutional layer is connected to the input end of the third ReLU activation layer; the output end of the third ReLU activation layer is connected to the input end of the seventh summation module; the output end of the seventh summation module is the output end of the X-Transformer layer; Among them, the outputs of the forward embedding layer and the reverse embedding layer both include three paths: Q, K and V; the output of the second projection layer is flipped and input into the sixth summation module; the output of the normalization layer and the output of the non-normalization layer are spliced and input into the seventh convolutional layer; the seventh summation module is used to fuse the output of the third ReLU activation layer with the overall input of the X-Transformer layer.
7. The method according to claim 2, characterized in that The training process of the diffusion model includes: Construct multiple pairs of training samples; one pair of training samples includes a historical noisy signal and a first Gaussian white noise of the historical noisy signal; the historical noisy signal is obtained by adding the noise interference to the original clean signal; the first Gaussian white noise of the historical noisy signal is obtained by iteratively diffusing the original clean signal of the historical noisy signal using a noise addition formula; the original clean signal is a noise-free historical ECG signal; Taking the multiple pairs of training samples as input, training the model parameters of the backbone network to obtain the diffusion model; In which, during the training process, for each pair of training samples, the historical noisy signal in the training sample is input into the backbone network through the second preliminary feature extraction module, and the first Gaussian white noise of the historical noisy signal is input into the backbone network through the first preliminary feature extraction module, so as to perform model training based on the historical noisy signal and the first Gaussian white noise of the historical noisy signal.
8. The method according to claim 1, characterized in that The method of using a pre-trained diffusion model to add white noise to the signal to be processed to obtain a noisy signal includes: Obtain a second Gaussian white noise; the second Gaussian white noise is a universal Gaussian white noise, and the universal Gaussian white noise includes a Gaussian distributed random signal with zero mean and fixed variance; The second Gaussian white noise is used as the input of the noise feature extraction module, the signal to be processed is used as the input of the signal feature extraction module, and Gaussian white noise is added through the diffusion model to obtain the noisy signal.
9. A device for processing electrocardiogram signals, characterized in that: The device comprises: A first acquiring unit is configured to acquire a signal to be processed; the signal to be processed includes an electrocardiogram signal to be processed containing noise interference; A noise adding unit is used to add white noise to the signal to be processed using a pre-trained diffusion model to obtain a noisy signal; the backbone network of the diffusion model includes a noise feature extraction module, a signal feature extraction module and a fusion module; the noise feature extraction module is used to extract features from white noise; the signal feature extraction module is used to extract features from the signal to be processed; and the fusion module is used to fuse the two extracted features; a de-noising unit, configured to perform a de-noising process on the noisy signal to obtain a denoised signal; the denoised signal comprises the electrocardiogram signal to be processed which is free of the noise interference after the signal to be processed is de-noised; The segmentation and visualization unit is used to perform image segmentation and visualization on the denoised signal to obtain an electrocardiogram waveform visualization image.
10. A processor, characterized in that: Used to run a computer program, which, when running, executes the method for processing electrocardiogram signals according to any one of claims 1 to 8.