This repo contains my submission for the Biomedical Data Science Capstone Project. It was inspired by the 2020 edition of the Computers for Cardiology Challenge . The objective was to classify patients with different heart rythm disorders based on their ECG recordings. For more information about the challenge, please consult the official challenge paper. For a codeless review of my project, please review my report.
The setup described here was optimised for Linux users. MacOS/Windows users might need to change some of the commands/procedures.
The libraries used in this project are standard libraries in data science and machin learning, except for Neurokit2 which is specific to the analysis of ECG data. Hence, a requirements.yml file is provided to create a conda environment specific to the prroject.
Creating the environment:
conda env create -f requirements.ymlActivating the environment:
conda activate ghassan_abboud_capstoneThe data consists of ECG recordings in .mat files associated to a patient id and information on the patient's age and diagnosis in a .hea file. The records can all be retrieved from the challenge's website. For the analysis described in the report, the code was run only on the CPSC_2018 part of the database. To download this part of the database, you can navigate to a newly created ECG/ folder and run:
wget -r -N -c -np https://physionet.org/files/challenge-2020/1.0.2/training/cpsc_2018/Please note that importing the data into the notebooks is time-consuming. Hence, the pickle_data.py script imports all of the data into Python once and for all. It creates a data.pkl file in the main directory which is then imported back into the workspace.ipynb notebook.
Please note that the pickle_data.py script and its functions rely on the data structure set by the challenge. Hence, one might ensure that the data was downloaded into the correct hierarchy before using the pickle_data.py script. The hierarchy is as follows:
.
│
└───ECG
└───cpsc_2018
└───g1
| RECORDS
| A0001.mat
| A0001.hea
| A0002.mat
| A0002hea
| ...
└───g2
| RECORDS
| A1000.mat
| A1000.hea
| ...
...
pickle_data.py
README.md
...
Note: The presence of the RECORDS file is essential to the parsing of the data by the pickle_data.py. This file should thus not be edited manually.
pickle_data.py: parses the data downloaded from the website into a Pandas Dataframe for further analysis. This should be the first step exectued to run the analysis. It creates adata.pklfile that will be imported into other notebooks. The path to the data folder and the name of the pickle file can be changed within the script.utils.py: contains utility functions both for parsing the data and extracting features from the ECG recordings with Neurokit2.workspace.ipynb: contains the bulk of the analysis. Creates aanalysis_info.pklfile that saves the feature extraction results. All graphs displayed in the notebook are also saved toimg/.final_report.ipynb: provides an overview of the project's goals, results and discussion.
- All figures can be downloaded from the
imgfolder - Here is a pdf version of the report.
- Here is a link to my video presentation.