This project was originally developed jointly by Miguel Martín Domínguez and Adriana Moreno Naranjo as an academic assignment in Biomedical Engineering.
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.
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.
A configurable ECG segment is extracted from the available recording using:
- Sampling frequency: 360 Hz
- Default segment duration: 10 seconds
- Default channel: Channel 1
The ECG spectrum is obtained using the Fast Fourier Transform (FFT). Only the single-sided spectrum is represented.
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
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.
A Pan-Tompkins-inspired processing sequence is applied:
- Differentiation
- Squaring
- Moving-window integration
- 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.
The ECG is decomposed using the biorthogonal wavelet bior3.5.
The highest-frequency detail components are excluded during reconstruction to reduce high-frequency noise.
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.
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
.matfile named100.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.
- MATLAB
- Signal Processing Toolbox
- Wavelet Toolbox
Main MATLAB functions used:
butterfiltfiltfindpeaksfftwavedecwrcoefwmaxlev
- Clone or download this repository.
- Place an authorised compatible ECG file at:
data/100.mat
- Open MATLAB.
- Set the repository folder as the current working directory.
- Open:
src/run_ecg_analysis.m
- 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
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.
- 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.
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
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.
Biomedical Engineering
University of Las Palmas de Gran Canaria
This repository is provided for educational and portfolio purposes only. It is not intended for diagnosis, treatment decisions or clinical use.