This is the official repository for the paper
Enhancing the diagnosis of functionally relevant coronary artery disease with machine learning.
Before cloning the repository, make sure you have git lfs installed. This is necessary to be able to check out the model checkpoints exceeding 100MB due to github's file size limit.
Once git lfs
is installed, clone the repository and install all dependencies with pip install -r requirements.txt
. The code is tested with Python 3.8
.
Take a look at our sample notebook to learn how to use
To preprocess your custom ECG signals, you will have to write your own data loader depending on your file format. We recommend inheriting from THEWParser
. The main function you have to implement is _get_raw
which loads the raw ECG signal according to your data format. Loading should result in a numpy
array of dimensions [T, num_leads]
, where
import numpy as np
parser = THEWParser(filepath) # Replace with your parser
# Preprocess
band = [0.05, 150.0]
parser.apply_butter(parser.data, [band[0]/(parser.freq/2), band[1]/(parser.freq/2)])
parser.apply_median(parser.data)
parser.apply_smoothing(parser.data)
parser.apply_winsorizing(parser.data, 0.05, 100 - 0.05)
downsampled = signal.decimate(parser.data, 2, axis=0)
np.savez(OUTPUT_PATH, data=downsampled.T)
You will likely not have access to the exact times when the stress phase started/ended. Instead, you can use the the time point of the maximum heart rate as the last point from which stress windows are extracted. To extract the first 2-6-2 sequence, take the first 2 seconds of the ECG signal, the last 6 seconds that preceed the time point with maximal HR, and the last 2 seconds of the ECG signal. For the second 2-6-2 sequence, stride the first window forward by 2 seconds, the second window back by 6 seconds, and the third window back by 2 seconds. Continue until you extracted all 2-6-2 sequences. Take a look at this function for an implementation.