ECG Signal Denoising Using Multi-scale Patch Embedding and Transformers

Ding Zhu, Vishnu Kabir Chhabra, Mohammad Mahdi KhaliliarXiv 2024

Abstract

Cardiovascular disease is a major life-threatening condition that is commonly monitored using electrocardiogram (ECG) signals. However, these signals are often contaminated by various types of noise at different intensities, significantly interfering with downstream tasks. Therefore, denoising ECG signals and increasing the signal-to-noise ratio is crucial for cardiovascular monitoring. In this paper, we propose a deep learning method that combines a one-dimensional convolutional layer with transformer architecture for denoising ECG signals. The convolutional layer processes the ECG signal by various kernel/patch sizes and generates an embedding called multi-scale patch embedding. The embedding then is used as the input of a transformer network and enhances the capability of the transformer for denoising the ECG signal.

Introduction

Electrocardiogram (ECG) signals are the primary tool for monitoring cardiovascular health, providing critical insights into heart rhythm and electrical activity. However, in real-world clinical and wearable scenarios, ECG data is frequently corrupted by noise from various sources, including baseline wander (breathing), power line interference, electrode motion, and muscle contractions.

Traditional filtering methods, such as band-pass filters, often struggle to isolate noise that overlaps with the frequency spectrum of the heart signal itself, potentially distorting the clinical features of the ECG. While deep learning approaches like Denoising Autoencoders (DAEs) have shown promise, they often lack the flexibility to handle diverse noise types at low signal-to-noise ratios (SNR). This paper introduces a hybrid architecture that leverages the local feature extraction of convolutional layers and the global context modeling of Transformers to address these challenges.

Methodology

The proposed architecture follows a U-Net-inspired structure, utilizing a sequence of encoder and decoder blocks to process the signal hierarchically. The core innovation lies in the input stage and the internal block design.

Overall architecture of the proposed denoising model, illustrating the flow from a noisy ECG signal through multi-scale embedding and a Transformer-based encoder-decoder pipeline to produce a clean signal.

Multi-scale Patch Embedding

Instead of a standard single-scale embedding, the model employs a Multi-scale Patch Embedding layer. This layer consists of four parallel 1D-convolutional branches with kernel sizes of 3, 5, 7, and 9. This design allows the model to capture features at multiple temporal resolutions simultaneously, effectively identifying both high-frequency artifacts (like muscle noise) and low-frequency drifts (like baseline wander).

Transformer Encoder-Decoder Architecture

The model features four encoder and four decoder blocks. Each block is built around Multi-Head Self-Attention (MHSA) and Feed-Forward Networks (FFN), allowing the model to learn long-range dependencies within the ECG sequence.

  • Encoder Blocks: These blocks utilize "Patch Merging" to reduce the sequence length while increasing feature depth, allowing the model to learn increasingly abstract representations of the heartbeat structure.
  • Decoder Blocks: These blocks use "Patch Separating" to reconstruct the signal to its original temporal resolution.
  • Masked Training: The model is trained using a masked input strategy, forcing it to reconstruct corrupted segments based on the surrounding global context, which is particularly effective for recovering signals under heavy noise.
Detailed breakdown of the model components, including the multi-scale convolutional kernels, the internal structure of the encoder/decoder blocks, and the specific layers within the Transformer block.

Experimental Setup and Datasets

The study utilized the MIT-BIH Arrhythmia Dataset for clean ground-truth signals and the MIT-BIH Stress Test Database for realistic noise samples. A synthetic dataset of over 100,000 samples was created by adding baseline wander, electrode motion, and muscle artifacts to clean signals at a challenging SNR of -4dB.

Results

The proposed model was benchmarked against Discrete Wavelet Transform (DWT), standard U-Net, and Dual Attention Convolutional Neural Networks (DACNN).

  • Signal Quality: The model achieved a superior SNR of 12.62 dB in multi-noise scenarios, compared to 9.18 dB for DACNN and 7.82 dB for U-Net.
  • Error Metrics: The Root Mean Squared Error (RMSE) was consistently lower across all noise types, ranging from 0.21 to 0.28, significantly outperforming traditional DWT (1.58).
  • Downstream Impact: To validate clinical utility, denoised signals were processed by a ResNet classifier. The proposed method enabled a diagnostic accuracy of 79.4%, a substantial improvement over the 59.9% accuracy achieved with raw noisy data.

Conclusion

By combining multi-scale convolutional embeddings with Transformer-based sequence modeling, the proposed method effectively cleans ECG signals even under severe noise conditions. The multi-scale approach ensures that noise at various frequencies is captured, while the Transformer architecture preserves the essential global structure of the heartbeat. Future work will focus on optimizing the model for real-time deployment on low-power wearable devices.

Summary updated

BibTeX
@misc{zhu2024ecg,
  author = {Ding Zhu and Vishnu Kabir Chhabra and Mohammad Mahdi Khalili},
  title = {{ECG Signal Denoising Using Multi-scale Patch Embedding and Transformers}},
  year = {2024},
  eprint = {2407.11065},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.11065},
}
Figure