Skip to content

juzailmlwork/ECG

Repository files navigation

ecg-identifier

why this project

According to the World Health Organization (WHO), cardiovascular diseases (CVDs) are the number one cause of death today. Over 17.7 million people died from CVDs in the year 2017 all over the world which is about 31% of all deaths, and over 75% of these deaths occur in low and middle income countries. Arrhythmia is a representative type of CVD that refers to any irregular change from the normal heart rhythms. There are several types of arrhythmia including atrial fibrillation, premature contraction, ventricular fibrillation, and tachycardia. Although single arrhythmia heartbeat may not have a serious impact on life, continuous arrhythmia beats can result in fatal circumstances. For example, prolonged premature ventricular contraction (PVCs) beats occasionally turn into a ventricular tachycardia (VT) or ventricular fibrillation (VF) beats which can immediately lead to heart failure. Thus, it is important to periodically monitor the heart rhythms to manage and prevent the CVDs. Electrocardiogram (ECG) is a non-invasive medical tool that displays the rhythm and status of the heart. Therefore, automatic detection of irregular heart rhythms from ECG signals is a significant task in the field of cardiology.

Why automated ECG classification is necessary?

  • Identification of arrhythmia condition from ECG signal takes a lot of experience even for experienced cardiologists.
  • Harmful arrhythmia conditions occur rarely so less data for analysis and prediction
  • Neural networks are good at signal classification.
  • lot of wearable devices available to monitor ECG of the user

scope of the project

This project is intended to identify and classify various heart conditions using a 2-D convolutional neural network in which we classify ECG into five categories, one being normal and the other four being different types of arrhythmia beats.The user will have a website to upload the raw ecg signal and the website will diplay the result of classification

previously used approach

  • Wavelet transform/Fourier transform
  • Conv1D neural network
  • Window based approach

my approach

  • Conv2D network was used for classification and cnn is trained using grayscale images of ECG signals
  • r-r interval is used instead of window based apporach
  • The system is able to take ECG signal at various sampling frequency
  • The system has a display and store unit which can be used by physicians for further reference

subtasks of the projects

  • Peak detection.
  • Dividing the signal into multiple sub parts using peaks obtained from peak detection.
  • Converting the segmented signal into image.
  • Training of the CNN neural network using images of signals
  • Classification of ECG signal whether it is normal or harmful
  • Website to load and visualize the classification results

peak detection

  • Pantombkins algorithm(my choice)
  • Wavelet transformation
  • Two moving averages
  • Hamilton algorithm

I tested neurokit2 python package for detection of r peaks.checked the annotation provided with original annotation.neurokit2 was able to predict annotation with 99.8% accuracy.also documentation of neurokit2 has functions to take ecg signal of various sampling ffrequency.I am currently developing pantombkins algorithm using python

MIT-Arrythmia Database

[dataset](https://physionet.org/content/mitdb/1.0.0/)

360HZ

48 Samples of 30 minutes, 2 leads 47 Patients:

  • 100 series: 23 samples
  • 200 series: 25 samples. Contains uncommon but clinically important arrhythmias
Symbol Meaning
· or N Normal beat
L Left bundle branch block beat
R Right bundle branch block beat
A Atrial premature beat
a Aberrated atrial premature beat
J Nodal (junctional) premature beat
S Supraventricular premature beat
V Premature ventricular contraction
F Fusion of ventricular and normal beat
[ Start of ventricular flutter/fibrillation
! Ventricular flutter wave
] End of ventricular flutter/fibrillation
e Atrial escape beat
j Nodal (junctional) escape beat
E Ventricular escape beat
/ Paced beat
f Fusion of paced and normal beat
x Non-conducted P-wave (blocked APB)
Q Unclassifiable beat

beats and rhythms

AAMI recomendation for MIT

There are 15 recommended classes for arrhythmia that are classified into 5 superclasses:

SuperClass
N (Normal) N L R
SVEB (Supraventricular ectopic beat) A a J S e j
VEB (Ventricular ectopic beat) V E
F (Fusion beat) F
Q (Unknown beat) P / f u

deliverables

  1. 2d cnn model that is able to classify ecg signals
  2. website that can take the ecg signal as input and output the classification result

tools used

  1. python
  2. tensorflow
  3. html
  4. css
  5. numpy
  6. tensorflow
  7. pandas
  8. wfdb
  9. neurokit2

progress

  1. week1,2:litreature review
  2. week3:training of a 1d cnn model using kaggle dataset and demonstration
  3. week4:converting the raw signal and annotation into csv and txt file
  4. week5:learn html,css,javascrpt
  5. week6:website development,stanford idea implementation(fitbit)
  6. week6:converting the ecg signal into grayscale images,dividing of images into 5 super classes for training purposes
  7. week7,week8,week 9:training of the neural network and optimization of neural network
  8. week 10,week 11:implementation of pan tompkins algorithm to detect r peaks,testing of neurokit2 library
  9. week 12:setting up a jupyter notebook for mid evaluation

project architucture

![image](https://github.com/juzailml98/ecg-identifier/blob/master/readme-photos/architecture.JPG)

cnn model architucture

![image](https://github.com/juzailml98/ecg-identifier/blob/master/readme-photos/model.JPG)

to be done

  1. training the neural network with V1 lead
  2. fine tuning the neural network
  3. setting up the GUI using Tkinter for demonstration

segmentation of signal

  • initially the signal and annotations were converted into csv file for easy formatting.
  • then the signal is segmented into segments.each segment represent R-R intervalof a signal
  • then segments are grouped into 5 categories namely normal,fusion,sveb,veb and unknown beats
  • ![segmented-samples](https://github.com/juzailml98/ecg-identifier/blob/master/readme-photos/png-file/samples.png?raw=true)
  • the data samples used for training are [101,106, 108, 109, 112, 114, 115, 116, 118, 119, 122, 124, 201, 203, 205, 207, 208, 209, 215, 220, 223, 230]
  • the data samples used for testing are [100, 103, 105, 111, 113, 117, 121, 123, 200, 202, 210, 212, 213, 214, 219, 221, 222, 228, 231, 232, 233, 234]
  • hold out validation is used so that to identify how the neural network performs well for new dataset and restricted computation power

jupyter notebook used for segmenting and grouping of ecg signal is

[annotator](https://github.com/juzailml98/ecg-identifier/blob/master/annotator.ipynb)

training of model

for better identifying the abnormal beats classification is done on 4 classes they are sveb,veb,usion ,normal two state architecture is to be used

nature of dataset

the original mit-bih dataset consists of

  • normal beats:83000
  • sveb beats:3013
  • veb beats:6335
  • fusion beats:801
  • other beats:2309

the dataset is very unbalanced due to high availability of normal beats and low availability of other classes

normal beats are divided into 45035 and 38032 as training set and testing set

the training set normal beats are downsampled to 10000 from 45000

website

the ecg-classifer website is built using css,javascript and html.the website takes the raw ecg signal or csv converted ecg signal as input.the file uploaded will be sent to backend where the classification happens.the backend is being built using flask.

![sample](https://github.com/juzailml98/ecg-identifier/blob/master/readme-photos/png-file/website.png?raw=true)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published