Skip to content

Assessment of Electrocardiogram Beat Detectors Using Synthetic and Real-World Data

License

Notifications You must be signed in to change notification settings

floriankri/ecg_detector_assessment

Repository files navigation

Assessment of Electrocardiogram Beat Detectors Using Synthetic and Real-World Data

This repository contains three main resources. Algorithm_tester contains databases, algorithms and a script to test them. Annotator has a MATLAB script that allows annotation of WFDB ECG signals. Signal_generator contains MATLAB scripts that can generate synthetic ECG signals.

This code has been created and tested with Visual Studio Code 1.73.0, MATLAB R2022a, and Python 3.9. The versions of other libraries used can be found in requirements.txt.

Authors

Citation/DOI

Kristof et al., 'Detecting beats in the photoplethysmogram: benchmarking open-source algorithms', [under review], https://doi.org/10.1101/2023.11.07.23298202

Installation

Algorithm Tester

  1. Install Visual Studio Code
  2. Install Python 3.9
  3. Install MATLAB R2022a or higher
    • NB: We installed the following toolboxes: 'Fuzzy Logic', 'Statistics and Machine Learning', 'Signal Processing'.
  4. Install MATLAB Engine API for Python available here in Visual Studio Code.
    • NB: When installing matlabengine on a Mac we: (i) installed Matlab_R2022b and added it to the paths using export PATH=<matlabroot>/bin/:$PATH and export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:<matlabroot>/bin/maci64; (ii) created a Miniconda environment running Python version 3.9 (which provided a python interpreter for an intel chip) using the command conda create -n ecgbeats python=3.9; (iii) activated this environment using conda activate ecgbeats; and (iv) installed matlabengine using cd <matlabroot>/extern/engines/python and python3 setup.py install.
  5. Install the VS Code Python extension
  6. Clone the ecg_detector_assessment repository.
  7. Run pip install requirements.txt in Visual Studio Code
  8. Try executing /Algorithm_tester/main.ipynb and see if and where it runs into errors
    • NB: When using the UNSW beat detector we had to recompile the mex files using the following commands: mex <path>/ecg_detector_assessment/Algorithm_tester/detectors/unsw/minmaxfilter.cpp and mex <path>/ecg_detector_assessment/Algorithm_tester/detectors/unsw/medianfilter.cpp

Annotator

  1. Install MATLAB R2022a or higher
  2. Install Waveform Database Software Package (WFDB) for MATLAB and Octave available here
  3. Change all permanent paths in the files to your local paths
  4. Change paths to signals that should be used in /Annotator/MAIN.m

Signal Generator

This part is automatically executed by Algorithm Tester. If you want to setup the unchanged version please visit the initial page called Model for Simulating ECG and PPG Signals with Arrhythmia Episodes.

Usage and Results

Algorithm Tester

After Installation as described above the notebook should run through in one go. All variables that might be necessary to change can be found in the Control Variables part of the Notebook. To evluate databases change the respective value in the Control Variables to True for one run. After successful evaluation change the respective Control Variable back to False as each evaluation takes quite some time.

Real Data

Database Comparison

Database Comparison

Influence of Sex

Influence of Sex

Runtime Investigation

Runtime Investigation

Error Investigation

Error Investigation

Synthetic Data

Comparing Atrial Fibrillation and Sinus Rhythm

Comparing Atrial Fibrillation and Sinus Rhythm

Noise Type Comparison

Noise Type Comparison

Runtime Investigation

Runtime Investigation

Error Investigation

Error Investigation

Annotator

After changing the path to the respective folder that you want to read the signals from you can run /Annotator/MAIN.m and follow the instructions in the terminal. After you have annotated some signals you can review them using the review function by again following the instructions in the terminal.

Signal Generator

As described above this code is used in the /Algorithm_tester/main.ipynb Notebook and is an adapted version of Model for Simulating ECG and PPG Signals with Arrhythmia Episodes. Please refer to the original version for usage instructions.