ECG Signal Processing Laboratory

An interactive laboratory session for undergraduate electrical engineering students covering ECG signal generation, processing, and classification.

Biomedical Signal Processing Lab

ECE 331 - Introduction to Biomedical Engineerng

Laboratory Objectives

This laboratory session introduces fundamental concepts of electrocardiogram (ECG) signal analysis through hands-on simulation and experimentation. By the end of this session, students will be able to:

Signal Generation

Understand and simulate synthetic ECG signals with controllable parameters for P, QRS, and T waves.

Noise Introduction

Simulate common ECG artifacts including baseline wander, powerline interference, and EMG noise.

Signal Processing

Apply digital filters to remove noise and enhance signal quality for accurate feature extraction.

Feature Extraction

Identify and measure key ECG features including R-peaks, RR intervals, and waveform amplitudes.

Classification

Implement a simple classifier to differentiate between normal and abnormal ECG rhythms.

1. ECG Signal Generation

ECG signals represent the electrical activity of the heart. A typical ECG waveform consists of P, QRS, and T waves. In this section, we'll generate a synthetic ECG signal using mathematical functions.

The synthetic ECG signal can be modeled as:

\[ ECG(t) = \alpha_P \cdot e^{-\frac{(t-\mu_P)^2}{2\sigma_P^2}} - \alpha_{QRS} \cdot e^{-\frac{(t-\mu_{QRS})^2}{2\sigma_{QRS}^2}} + \alpha_T \cdot e^{-\frac{(t-\mu_T)^2}{2\sigma_T^2}} \]

Where \(\alpha\) represents amplitude, \(\mu\) represents position, and \(\sigma\) represents width of each wave component.

Signal Parameters

Synthetic ECG Signal

Clean synthetic ECG signal with adjustable parameters. The x-axis represents time in seconds, and the y-axis represents voltage in millivolts.

Noisy ECG Signal

ECG signal with simulated noise artifacts including baseline wander, powerline interference (50/60 Hz), and EMG noise.

2. ECG Signal Processing

Raw ECG signals are often contaminated with various types of noise. In this section, we'll apply digital filters to remove noise and enhance signal quality for accurate feature extraction.

Common filters used in ECG processing:

  • Bandpass filter (0.5-40 Hz): Removes baseline wander and high-frequency noise
  • Notch filter (50/60 Hz): Removes powerline interference
  • Moving average filter: Smooths the signal while preserving key features

Filter Parameters

Original Noisy Signal

Original ECG signal with simulated noise. SNR = 12.5 dB

Filtered Signal

Filtered ECG signal after applying the selected filter. Improved SNR = 18.7 dB

Filter Performance Metrics

Signal-to-Noise Ratio (SNR)

12.5 dB

Mean Squared Error (MSE)

0.023

Peak Signal-to-Noise Ratio (PSNR)

34.2 dB

Computational Time

4.2 ms

3. Feature Extraction

After filtering, we extract key features from the ECG signal that are clinically relevant for diagnosis. These features include R-peaks, RR intervals, and waveform amplitudes/durations.

Feature Detection Parameters

ECG with Detected Features

ECG signal with detected R-peaks (red), P waves (blue), and T waves (green).

Extracted Features

Heart Rate

72 BPM

R-R Interval

833 ms

QRS Duration

100 ms

PR Interval

160 ms

QT Interval

360 ms

QRS Amplitude

1.0 mV

Key ECG Intervals:

  • RR Interval: Time between successive R peaks, used to calculate heart rate
  • PR Interval: Time from start of P wave to start of QRS complex (normal: 120-200 ms)
  • QRS Duration: Duration of QRS complex (normal: 80-120 ms)
  • QT Interval: Time from QRS start to end of T wave (corrected for heart rate)

4. ECG Classification

Using the extracted features, we can classify ECG signals into different categories. In this section, we'll implement a simple classifier to differentiate between normal sinus rhythm and abnormal rhythms.

Classification Parameters

Normal Rhythm

75%

Criteria: HR 60-100 BPM, regular rhythm, normal intervals

Abnormal Rhythm

25%

Criteria: HR <60 or >100 BPM, irregular rhythm, abnormal intervals

Classification Results

Predicted Class

Normal Sinus Rhythm

Confidence

85%

Classifier Used

Rule-based

Classification Time

2.3 ms

Rule-based Classification Criteria:

  • Normal: HR 60-100 BPM, RR interval variance < 50 ms, QRS duration 80-120 ms
  • Tachycardia: HR > 100 BPM with regular rhythm
  • Bradycardia: HR < 60 BPM with regular rhythm
  • Arrhythmia: RR interval variance > 100 ms

LAB REPORT STRUCTURE

1. Introduction

2. Theoretical Background

3. Methodology

Organize this section into four subsections corresponding to the lab parts:

3.1 Signal Generation

3.2 Signal Processing

3.3 QRS Detection

3.4 Beat Classification

4. Results and Analysis

Present your findings with appropriate figures and tables: