Coder Social home page Coder Social logo

ecg_detector's Introduction

ECG_Detector

This is an automatic electrocardiogram (ECG) detector using convolutional neural networks.

There are various types of cardiac arrhymias. Among them, atrial fibrillation (AF) is most common. The disease is associated with significant mortality and morbidity through an increasing risk of heart failure, dementia, and stoke. Detection for AF remains problematic, because the signal may be episodic and often episodes have no symptoms.

This dectector focuses on identifying AF from other kinds of records, namely normal sinus rhythm, other abnormal rhythms and noisy recordings.

ECG recordings are usually stored as 1-D waveform, which displays changes in amplitude of electical activies of the heart over time. Through Fourier transformation, the waveform are turned into spectrogram - a 2-D visual representation of the spectrum of frequencies with amplitude represented by brightness.

A deep convolutional network, which is specialized for processing an image, were trained to classify the spectrograms.

I used the keras package with Tensorflow as backend to train the model on AWS p2.xlarge instance with NVIDIA Tesla® K80 GPUs.

Dataset

Total 8331 single short ECG recordings with 30s length were collected (thanks to AliveCor). These recordings were labeled in four classes: normal(59%) , AF(9%), other(30%), and noise(2%).

Data Processing

Transform 1-D waveform into 2-D spetrogram by Fourier transformation. Log transformation and standardization were applied to spectrograms before passed into model.

Model Architecture

Convolutional layers are arranged in blocks. For each block there are four convolutional layers, following each convolutional layer, there is one normalization layer, one relu activation layer and one dropout layer. A max pooling layer is added at the end of each block.

Following the convolutional layers, a customized layer is added to take average of features across time. Then there is a flatten layer to reduce dimension before passing to classifer(fully-connected) layer.

A standard linear layer with Softmax is used to compute the class probabilities.

How to Run

Install python requirements:

pip install --requirement requirements.txt

To process data:

python src/data_processing.py path_to_signal_file path_to_label_file

To train and save model:

python src/model_cnn.py  path_to_processed_data  epochs  path_to_save_evaluation_file

To predict and save predictions:

python src/predict.py model_file signal_file

ecg_detector's People

Contributors

gogowenzhang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.