Git Product home page Git Product logo

ecg-heartbeat-classification-seq2seq-model's Introduction

Inter- and intra- patient ECG heartbeat classification for arrhythmia detection: a sequence to sequence deep learning approach

Paper

Our paper can be downloaded from the arxiv website

  • The Network architecture Alt text

Requirements

  • Python 2.7
  • tensorflow/tensorflow-gpu
  • numpy
  • scipy
  • scikit-learn
  • matplotlib
  • imbalanced-learn (0.4.3)

Dataset

We evaluated our model using the PhysioNet MIT-BIH Arrhythmia database

  • To download our pre-processed datasets use this link, then put them into the "data" folder.
  • Or you can follow the instructions of the readme file in the "data preprocessing_Matlab" folder to download the MIT-BIH database and perform data pre-processing. Then, put the pre-processed datasets into the "data" folder.

Train

  • Modify args settings in seq_seq_annot_aami.py for the intra-patient ECG heartbeat classification

  • Modify args settings in seq_seq_annot_DS1DS2.py for the inter-patient ECG heartbeat classification

  • Run each file to reproduce the model described in the paper, use:

python seq_seq_annot_aami.py --data_dir data/s2s_mitbih_aami --epochs 500
python seq_seq_annot_DS1DS2.py --data_dir data/s2s_mitbih_aami_DS1DS2 --epochs 500

Results

Alt text

Citation

If you find it useful, please cite our paper as follows:

@article{mousavi2018inter,
  title={Inter-and intra-patient ECG heartbeat classification for arrhythmia detection: a sequence to sequence deep learning approach},
  author={Mousavi, Sajad and Afghah, Fatemeh},
  journal={arXiv preprint arXiv:1812.07421},
  year={2018}
}

References

deepschool.io

Licence

For academtic and non-commercial usage

ecg-heartbeat-classification-seq2seq-model's People

Contributors

mousavisajad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ecg-heartbeat-classification-seq2seq-model's Issues

__init__() got an unexpected keyword argument 'ratio

Hello, when I run the seq_seq_annot_aami.py, the terminal shows
" sm = SMOTE(random_state=12, ratio=ratio)
File "E:\Sensor\tensor\envs\tensorflow\lib\site-packages\imblearn\utils_validation.py", line 594, in inner_f
return f(**kwargs)
TypeError: init() got an unexpected keyword argument 'ratio'
"

Is there something wrong in"ratio = {0: n_oversampling, 1: nums[1], 2: n_oversampling, 3: n_oversampling}"?

ECGNet Code

Hey is the code to the ECGNET: Learning where to attend for detection of atrial fibrillation with deep visual attention paper made public.

Error

Hi Sajad

I get the following error when running the code.

Traceback (most recent call last):
  File "seq_seq_annot_DS1DS2.py", line 441, in <module>
    main()
  File "seq_seq_annot_DS1DS2.py", line 226, in main
    run_program(args)
  File "seq_seq_annot_DS1DS2.py", line 242, in run_program
    X_train, y_train = read_mitbih(filename, max_time, classes=classes, max_nlabel=50000,trainset=1)
  File "seq_seq_annot_DS1DS2.py", line 78, in read_mitbih
    data = _data[:(len(_data)/ max_time) * max_time, :]
TypeError: slice indices must be integers or None or have an __index__ method

data pre-processed

Could you upload the code of data pre-process? I want to know how to pre-process.Thank you!

About the identification of class F

Hello author, may I ask why class F is so difficult to identify? I have tried a lot of methods, as well as the code on github, basically have difficulty recognizing F, but which do not open source code can be recognized and recall is also high.

Argument `inputs` must be a sequence.

I have this error with lstm_enc, I didn't understand if the problem was with the input size or with LSTMCell.
data_input_embed Tensor("Reshape_3:0", shape=(?, 10, 384), dtype=int32)
Argument inputs must be a sequence. Received: Tensor("Reshape_3:0", shape=(?, 10, 384), dtype=int32)

is this just a copy/paste typo?

hi ,
in file "seq_seq_annot_aami.py" line 299,

shouldn't 1:nums[1] be 1:n_oversampling like the other elements of the dictionary?
or there's a logic behind this?

regards
Ed

data read

First of all, thank you very much for your code! When I read your code, I found the process of generating ECG sequence in the original code is as follows.
Firstly, the heartbeat segmented by ECG records in the training set is stored into a two-dimensional
array, then the heartbeats of each kind (one of N S V) are selected and shuffled to get three smaller
two-dimensional arrays. Next, the three two-dimensional arrays are concatenated by rows to get a
larger two-dimensional array. Finally, the array is split into a sequence every max_time(the default is
10) line.
So I would like to ask why you want to group all the heartbeats according to categories in advance?
If you do this, the labels of each sequence are almost the same, and the heartbeats contained in each
sequence are not split from the same record at all (due to shuffle). This seems very different from the
actual situation, where the sequences should be composed of heartbeats from the same ECG record.
I wonder if this is a hidden trick of data processing? Why do we do that? Thank you very much for your reply! Here are some of the code that puzzles me.
data = np.asarray(data)
shape_v = data.shape
data = np.reshape(data, [shape_v[0], -1])
t_lables = np.array(t_lables)
_data = np.asarray([],dtype=np.float64).reshape(0,shape_v[1])
_labels = np.asarray([],dtype=np.dtype('|S1')).reshape(0,)
for cl in classes:
_label = np.where(t_lables == cl)
permute = np.random.permutation(len(_label[0]))
_label = _label[0][permute[:max_nlabel]]
_data = np.concatenate((_data, data[_label]))
_labels = np.concatenate((_labels, t_lables[_label]))

data = _data[:(len(_data)// max_time) * max_time, :]
_labels = _labels[:(len(_data) // max_time) * max_time]
data = [data[i:i + max_time] for i in range(0, len(data), max_time)]
labels = [_labels[i:i + max_time] for i in range(0, len(_labels), max_time)]
permute = np.random.permutation(len(labels))
data = np.asarray(data)
labels = np.asarray(labels)
data= data[permute]
labels = labels[permute]

Tensorflow version ?

Hi, we're trying to replicate the result of the paper. Could you tell us which version of tensorflow you used for the training ?

Number of parameters

Does the number of parameters mentioned in your paper refer to the number of parameters / 1024/1024?

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.