Giter Site home page Giter Site logo

awni / ecg Goto Github PK

View Code? Open in Web Editor NEW
658.0 658.0 262.0 2.41 MB

Cardiologist-level arrhythmia detection and classification in ambulatory electrocardiograms using a deep neural network

Home Page: https://stanfordmlgroup.github.io/projects/ecg2/

License: GNU General Public License v3.0

Shell 1.34% Python 98.66%

ecg's People

Contributors

awni avatar dependabot[bot] avatar mashagh avatar rajpurkar 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  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

ecg's Issues

Padding needed when using other data to support odd number of input data

First of all, I would like to thank you to publish the code of the interesting study you made. I'm trying to do something similar with PPG signals so I tried your code on my data but I got an issue:

Traceback (most recent call last):
  File "ecg/train.py", line 117, in <module>
    train(args, params)
  File "ecg/train.py", line 103, in train
    callbacks=[checkpointer, reduce_lr, stopping])
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1039, in fit
    validation_steps=validation_steps)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/training_arrays.py", line 199, in fit_loop
    outs = f(ins_batch)
  File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 2715, in __call__
    return self._call(inputs)
  File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 2675, in _call
    fetched = self._callable_fn(*array_vals)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1439, in __call__
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/errors_impl.py", line 528, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [16,15437,32] vs. [16,15438,32]
	 [[{{node add_4/add}} = Add[T=DT_FLOAT, _class=["loc:@training/Adam/gradients/add_4/add_grad/Reshape_1"], _device="/job:localhost/replica:0/task:0/device:GPU:0"](max_pooling1d_4/Squeeze, conv1d_9/add)]]
	 [[{{node loss/mul/_1985}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_20932_loss/mul", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
srun: error: cn09: task 0: Exited with exit code 1

I've modified the line 62 in network.py in order to pad the inputs of the pooling layer

shortcut = MaxPooling1D(pool_size=subsample_length, padding='same')(layer)

This solved the issue.

evaluation standard

The Physionet 2017 Challenge uses the F1 evaluation criteria,but the code uses the accuracy, it
is ok?

Testing

Hello,
I download data from https://irhythm.github.io/cardiol_test_set/ as the testing data. When I run "python ecg/predict.py .json .hdf5", I get error that "labels.append(d['labels']) Exception KeyError: KeyError". I find that the testing data does not have the 'labels' and 'ecg'.
I hope you can tell me how to use it!
Thank you!

How can I solve this problem?

I use python3.6 to run the example of cinc17. When I run the code 'python ecg/train.py examples/cinc17/config.json -e cinc17' in 'README', I got this error:

$ python ecg/train.py examples/cinc17/config.json -e cinc17
Loading training set...
Using TensorFlow backend.
Traceback (most recent call last):
File "ecg/train.py", line 93, in
train(args, params)
File "ecg/train.py", line 33, in train
train = load.load_dataset(params['train'])
File "C:\Users\Administrator\ecg\ecg\load.py", line 65, in load_dataset
with open(data_json, 'r') as fid:
PermissionError: [Errno 13] Permission denied: 'examples/cinc17/data/training2017'

Could you please tell me how can I solve this probelm? Thanks a lot.

PhysioNet Challenge issue

I run the example of PhysioNet challenge I got this error:

Traceback (most recent call last):
  File "build_datasets.py", line 48, in <module>
    dataset = load_all(data_path)
  File "build_datasets.py", line 26, in load_all
    dataset.append((ecg_file, [label]*num_labels))
TypeError: can't multiply sequence by non-int of type 'float'

I believe this issue is coming from the fact that we cant multiply a float with a list of strings.. instead we can multiple an int with a list of strings. Should I cast it the num_labels to int? or it is related to something how I'm reading the ECG file?

Thanks in advance.

Config in MaxPooling 1d

Hi Awni Y. Hannun, I have been reproducing you paper published on Nature medicine.

I am confused about your settings of MaxPooling 1d.

Here is the function for building the whole network.

ecg/ecg/network.py

Lines 42 to 81 in c97bb96

def resnet_block(
layer,
num_filters,
subsample_length,
block_index,
**params):
from keras.layers import Add
from keras.layers import MaxPooling1D
from keras.layers.core import Lambda
def zeropad(x):
y = K.zeros_like(x)
return K.concatenate([x, y], axis=2)
def zeropad_output_shape(input_shape):
shape = list(input_shape)
assert len(shape) == 3
shape[2] *= 2
return tuple(shape)
shortcut = MaxPooling1D(pool_size=subsample_length)(layer)
zero_pad = (block_index % params["conv_increase_channels_at"]) == 0 \
and block_index > 0
if zero_pad is True:
shortcut = Lambda(zeropad, output_shape=zeropad_output_shape)(shortcut)
for i in range(params["conv_num_skip"]):
if not (block_index == 0 and i == 0):
layer = _bn_relu(
layer,
dropout=params["conv_dropout"] if i > 0 else 0,
**params)
layer = add_conv_weight(
layer,
params["conv_filter_length"],
num_filters,
subsample_length if i == 0 else 1,
**params)
layer = Add()([shortcut, layer])
return layer

You created the shortcut on line 62, where the subsample_length can only be 1 or 2 in your settings.

    shortcut = MaxPooling1D(pool_size=subsample_length)(layer) 

when subsample_length = 1, MaxPooling1D applies 1x1 window on input data, therefore, no change made to the input.
Is this intended?

Where do i get data for irhythm?

I am not able to get data for irhythm which is at /deep/group/med/irhythm/ecg/clean_30sec_recs/
where do i get the data?
please share the link

Cinc 17 submit problem

Hello, there~
I want to submit cinc 17 to test the model online, but cinc17 official website requires the maximum size for entries is 50MB. If the entry.zip includes packages, the size almost is 150 MB, I'm mad at it...How can I solve this, plzzzz

预测测试集的结果在哪?

(py2) D:\Pycharm\project\ecg-master>python ecg/predict.py result/train.json saved/cinc17/1575801585-588/ep001-loss1.299-val_loss7.181.h5
Using TensorFlow backend.
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████████████████| 5/5 [00:00<00:00, 2446.80it/s]
2019-12-09 15:52:30.414239: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
5/5 [==============================] - 1s 196ms/step
我从训练集中生成了5个数据 来验证测试结果 可是什么也不显示
我想问一下,我这样算成功了么?或者说成功的结果/概率在哪显示呢?

训练集创建数据不成功

我在D:\Pycharm\project\ecg-master\examples\irhythm 文件夹下 调用build_datasets.py文件生成训练集。结果显示:
D:/Pycharm/project/ecg-master/examples/irhythm/CARDIOL_MAY_2017\label_review/CARDIOL_MAY_2017
D:/Pycharm/project/ecg-master/examples/irhythm/CARDIOL_MAY_2017\batches/kids_blacklist
D:/Pycharm/project/ecg-master/examples/irhythm/CARDIOL_MAY_2017\batches/vf_blacklist
Constructing train...
Constructing dev...
0it [00:00, ?it/s]
Constructing test...
0it [00:00, ?it/s]
0it [00:00, ?it/s]
Constructing test...
Constructing test...
0it [00:00, ?it/s]
0it [00:00, ?it/s]
0it [00:00, ?it/s]
Constructing test...
Constructing test...
0it [00:00, ?it/s]
Constructing test...
0it [00:00, ?it/s]Constructing test...
0it [00:00, ?it/s]
0it [00:00, ?it/s]
在相应文件夹中出现了5个json数据以及其他,但是里面全部是空白?
请问一下是什么原因呢?

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.