Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECG Signal Processing and QRS Analysis in MATLAB

This project was originally developed jointly by Miguel Martín Domínguez and Adriana Moreno Naranjo as an academic assignment in Biomedical Engineering.

Overview

This project implements a MATLAB workflow for the processing and analysis of an electrocardiogram (ECG) signal.

The analysis includes:

  • ECG visualisation in the time and frequency domains
  • Band-pass filtering between 0.5 and 40 Hz
  • Automatic R-peak detection
  • RR interval and heart-rate estimation
  • Basic heart-rate variability metrics
  • Pan-Tompkins-inspired QRS enhancement
  • Wavelet-based high-frequency noise reduction
  • Automatic export of figures and numerical results

The repository is intended as an educational biomedical signal-processing project. It is not a clinically validated diagnostic tool.

Clinical and Biomedical Context

The electrocardiogram records the electrical activity of the heart and is widely used to assess cardiac rhythm and conduction.

Automatic ECG processing can support tasks such as:

  • Heart-rate estimation
  • Beat detection
  • Rhythm analysis
  • Heart-rate variability assessment
  • QRS complex analysis
  • Noise reduction and signal-quality improvement

In this project, the ECG is analysed using conventional digital signal-processing techniques implemented in MATLAB.

Methodology

1. ECG segment selection

A configurable ECG segment is extracted from the available recording using:

  • Sampling frequency: 360 Hz
  • Default segment duration: 10 seconds
  • Default channel: Channel 1

2. Frequency-domain analysis

The ECG spectrum is obtained using the Fast Fourier Transform (FFT). Only the single-sided spectrum is represented.

3. Band-pass filtering

A fourth-order Butterworth band-pass filter between 0.5 and 40 Hz is applied using zero-phase filtering.

This frequency range is commonly used to reduce:

  • Low-frequency baseline drift
  • High-frequency muscular and electronic noise

4. R-peak and RR interval analysis

R peaks are detected using MATLAB's findpeaks function with minimum-distance and prominence restrictions.

The detected peaks are used to calculate:

  • RR intervals
  • Mean heart rate
  • SDNN
  • RMSSD

A simple rule-based comparison of the mean RR interval is also included for educational purposes.

5. QRS enhancement

A Pan-Tompkins-inspired processing sequence is applied:

  1. Differentiation
  2. Squaring
  3. Moving-window integration
  4. Peak detection

The width measured on the integrated signal is included only as a signal-processing indicator. It must not be interpreted as a clinically validated QRS duration.

6. Wavelet denoising

The ECG is decomposed using the biorthogonal wavelet bior3.5.

The highest-frequency detail components are excluded during reconstruction to reduce high-frequency noise.

Repository Structure

ecg-signal-processing-matlab/
├── .gitignore
├── AUTHORS.md
├── README.md
├── data/
│   └── README.md
├── src/
│   ├── README.md
│   └── run_ecg_analysis.m
└── results/
    ├── analysis_summary.csv
    ├── rr_intervals.csv
    └── figures/

The results/ directory is generated automatically when the script is executed.

Dataset

The ECG recording used in the original academic assignment was provided by the course instructor through the virtual learning platform of the University of Las Palmas de Gran Canaria.

The original file, 100.mat, is not included because its original source and redistribution licence could not be verified.

The current script expects:

  • A MATLAB .mat file named 100.mat
  • A variable named signal_mv
  • A sampling frequency of 360 Hz

The data file must be placed locally at:

data/100.mat

A public ECG dataset may also be used after adapting the data-loading section.

Requirements

  • MATLAB
  • Signal Processing Toolbox
  • Wavelet Toolbox

Main MATLAB functions used:

  • butter
  • filtfilt
  • findpeaks
  • fft
  • wavedec
  • wrcoef
  • wmaxlev

How to Run

  1. Clone or download this repository.
  2. Place an authorised compatible ECG file at:
data/100.mat
  1. Open MATLAB.
  2. Set the repository folder as the current working directory.
  3. Open:
src/run_ecg_analysis.m
  1. Run the script.

The script automatically creates the results/ folder and exports:

  • ECG figures
  • Detected R-peak visualisation
  • QRS-enhancement stages
  • Wavelet-denoising comparison
  • Summary metrics in CSV format
  • Individual RR intervals in CSV format

Results

The script reports:

  • Number of detected R peaks
  • Mean RR interval
  • Mean heart rate
  • SDNN
  • RMSSD
  • Number of detected QRS activity peaks
  • Mean integrated-pulse width
  • Educational RR-range assessment

Specific numerical results are not included in this README because they depend on the local ECG recording and the selected analysis segment.

Limitations

  • The original dataset cannot currently be redistributed.
  • R-peak detection parameters may require adjustment for other ECG recordings.
  • The QRS section is an educational approximation inspired by Pan-Tompkins, not a complete validated implementation.
  • The integrated-pulse width is not equivalent to a clinically measured QRS duration.
  • The rule-based RR assessment does not diagnose arrhythmias.
  • The project has not been clinically validated.

Future Improvements

Possible extensions include:

  • Support for public PhysioNet datasets
  • Automatic signal-quality assessment
  • Adaptive R-peak detection
  • Validation against annotated ECG records
  • Comparison with a standard Pan-Tompkins implementation
  • Beat segmentation and morphological analysis
  • Arrhythmia classification using Machine Learning
  • Unit tests for the main processing functions
  • A graphical user interface or interactive application

Authors

The original academic project was jointly developed by:

  • Miguel Martín Domínguez
  • Adriana Moreno Naranjo

Both authors contributed to the original design, implementation, analysis and documentation.

See AUTHORS.md for additional information.

Academic Context

Biomedical Engineering
University of Las Palmas de Gran Canaria

Disclaimer

This repository is provided for educational and portfolio purposes only. It is not intended for diagnosis, treatment decisions or clinical use.

Releases

Packages

Contributors

Languages