{"id":13935894,"url":"https://github.com/niekverw/Deep-Learning-Based-ECG-Annotator","last_synced_at":"2025-07-19T21:31:00.020Z","repository":{"id":109119091,"uuid":"115745338","full_name":"niekverw/Deep-Learning-Based-ECG-Annotator","owner":"niekverw","description":"Annotation of ECG signals using deep learning, tensorflow’ Keras","archived":false,"fork":false,"pushed_at":"2020-01-09T15:21:16.000Z","size":166,"stargazers_count":146,"open_issues_count":4,"forks_count":48,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-27T03:35:00.227Z","etag":null,"topics":["annotations","deep-learning","ecg","ecg-data","electrocardiogram","example","keras-tutorials","lstm","peak","peaks","qrs-detection","segmentation","tensorflow","time-series","tutorial","wfdb"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niekverw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-29T18:32:53.000Z","updated_at":"2024-06-27T07:01:12.000Z","dependencies_parsed_at":"2023-03-20T20:03:47.511Z","dependency_job_id":null,"html_url":"https://github.com/niekverw/Deep-Learning-Based-ECG-Annotator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/niekverw/Deep-Learning-Based-ECG-Annotator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niekverw%2FDeep-Learning-Based-ECG-Annotator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niekverw%2FDeep-Learning-Based-ECG-Annotator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niekverw%2FDeep-Learning-Based-ECG-Annotator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niekverw%2FDeep-Learning-Based-ECG-Annotator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niekverw","download_url":"https://codeload.github.com/niekverw/Deep-Learning-Based-ECG-Annotator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niekverw%2FDeep-Learning-Based-ECG-Annotator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266019657,"owners_count":23864916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annotations","deep-learning","ecg","ecg-data","electrocardiogram","example","keras-tutorials","lstm","peak","peaks","qrs-detection","segmentation","tensorflow","time-series","tutorial","wfdb"],"created_at":"2024-08-07T23:02:10.780Z","updated_at":"2025-07-19T21:31:00.016Z","avatar_url":"https://github.com/niekverw.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Annotation (or segmentation) of the electrocardiogram (ECG) with a long short-term memory neural network. \nHere, I experimented with annotating peaks of the ECG using a recurrent neural network in tensorflow's Keras.\nIn the beginning I struggled a bit to get the input/output right, which had to do with the way I tried to format ECG-peaks (as a sparse vector containing peaks (1) vs no peaks (0)). Aproaching it as a semantic segmentation problem (e.g. Seq2Seq) solved it for me. \n\u003cbr\u003eIt seems to work well on the QT database of physionet, but there are some cases that it has never seen where it fails; I haven't played with augmenting the ecgs yet.\n \n[5oct 2019]\nSince posting this 3 years ago, I noticed several publications using the (exact) same principle:\n- Matlab: https://www.mathworks.com/help/signal/examples/waveform-segmentation-using-deep-learning.html\n- IEEE: https://ieeexplore.ieee.org/document/8333406\n\n\n## Model\n\n```\nmodel = Sequential()\nmodel.add(Dense(32,W_regularizer=regularizers.l2(l=0.01), input_shape=(seqlength, features)))\nmodel.add(Bidirectional(LSTM(32, return_sequences=True)))#, input_shape=(seqlength, features)) ) ### bidirectional ---\u003e\u003c---\nmodel.add(Dropout(0.2))\nmodel.add(BatchNormalization())\nmodel.add(Dense(64, activation='relu',W_regularizer=regularizers.l2(l=0.01)))\nmodel.add(Dropout(0.2))\nmodel.add(BatchNormalization())\nmodel.add(Dense(dimout, activation='softmax'))\nadam = optimizers.adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08, decay=0.0)\nmodel.compile(loss='categorical_crossentropy', optimizer=adam, metrics=['accuracy']) \n```\n\n## Getting Started\n- Download ECG data using something like \u003ccode\u003ewget -r -l1 --no-parent https://physionet.org/physiobank/database/qtdb/\u003c/code\u003e\n- Run, with as the first argument the directory where the ECG data is stored; or set \u003ccode\u003eqtdbpath\u003c/code\u003e.\n\n## Output\nA 2 lead ECG, the colors indicate P-Pend(yellow),Pend-Q(green), Q-R(red),R-S(purple),S-Tend(brown),Tend-P(pink). Training took about an hour on 6 cores. \n![example output](https://github.com/niekverw/Deep-Learning-Based-ECG-Annotator/blob/master/images/example.png?raw=true)\n- Colors at the top show true annotations\n- Colors at the bottom show predicted annotations\n\n## Dependencies\nI haven't got a list of all dependencies; but use this:  \n- wfdb 1.3.4 ( not the newest \u003e2.0, thanks BrettMontague); pip install wfdb==1.3.4\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniekverw%2FDeep-Learning-Based-ECG-Annotator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniekverw%2FDeep-Learning-Based-ECG-Annotator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniekverw%2FDeep-Learning-Based-ECG-Annotator/lists"}