ECG classification using MIT-BIH dataset
and focus on training using a MIT-BIH dataset. If you want to train using CINC or open irhythm data, see the open source which the authors of the original research paper have coded at https://github.com/awni/ecg
Introduction to MIT-BIH dataset at physionet : https://physionet.org/physiobank/database/mitdb/
Consistent with the environment of Google colab with wfdb, deepdish installations and numpy reinstallation.
- Python >= 3.6.7
Data setup and train
I recommend using a vitual enviroment for Python, so run setup.sh in order to install and to activate it.
$ git clone https://github.com/physhik/ecg-mit-bih.git $ cd ecg-mit-bih $ sh setup sh.
Now you have a trained model for ECG classification
Predict an annotation of CINC2017 data or your own data(csv file)
It randomly chooses one of data, and predict the slices of the signal.
Run predict.py in the virtual environment we have already set up.
(flaskapp) $ ./flaskapp/bin/python predict.py --cinc_download True
--cinc_download branch is used at first to download the CINC2017 data.
See config.py and customize your parameters or learn better way to train and test
Jupyter notebook example
In case, you do not have a GPU above a decent performance, you might be able to use Google colab. Follow the Jupyter notebook.
Flask web app
The flask web app is based on the 500 stared Github repo.
(flaskapp) $ ./flaskapp/bin/python app.py
and choose a csv heart heat signal and click predict, and see the result.
I have put one csv file in static/asset directory. The first value of the column become sample rate of the web app. If you use your own heart beat csv file, insert the sample at the first, too.
Using Docker, Buld and run an image for the ECG trained model.
After installation of Docker,
$ docker build -t ecg-app . $ docker run -d -p 5000:5000 ecg-app
Pull an built-image from Docker hub
Or for your convenience, pull the image from Docker hub by
$ docker pull physhik/ecg-app:1 $ docker run -d -p 5000:5000 physhik/ecg-app:1
and then open http://localhost:5000 after a while installing the app in the container.
Introduction to ECG
I presented a bit more about ECG classfications on my personal blog, http://physhik.com
Find the posts from tags or categories easily.
The open source by authors https://github.com/awni/ecg