{"id":19549314,"url":"https://github.com/cbrnr/heartbeats.jl","last_synced_at":"2025-04-26T20:31:00.722Z","repository":{"id":37385648,"uuid":"451148215","full_name":"cbrnr/HeartBeats.jl","owner":"cbrnr","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-09T12:04:05.000Z","size":158,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T17:47:45.735Z","etag":null,"topics":["ecg","heartrate","julia","peak-detection"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cbrnr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-23T15:35:51.000Z","updated_at":"2024-09-09T11:46:02.000Z","dependencies_parsed_at":"2024-08-14T15:29:24.787Z","dependency_job_id":"bbc26556-fcc5-4baa-9b16-c915f73f595a","html_url":"https://github.com/cbrnr/HeartBeats.jl","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"625f34ba7ae91c39cde81f2da794152137368701"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbrnr%2FHeartBeats.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbrnr%2FHeartBeats.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbrnr%2FHeartBeats.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbrnr%2FHeartBeats.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cbrnr","download_url":"https://codeload.github.com/cbrnr/HeartBeats.jl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251051298,"owners_count":21528786,"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":["ecg","heartrate","julia","peak-detection"],"created_at":"2024-11-11T03:59:45.082Z","updated_at":"2025-04-26T20:31:00.054Z","avatar_url":"https://github.com/cbrnr.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"![License](https://img.shields.io/github/license/cbrnr/HeartBeats.jl)\n\nHeartBeats.jl\n=============\nHeartBeats.jl provides a heartbeat detector based on the approach described by [Pan \u0026 Tompkins (1985)](https://ieeexplore.ieee.org/document/4122029). It is based on the implementation available in the Python package [SleepECG](https://github.com/cbrnr/sleepecg).\n\n## Installation\nUse the package manager to add HeartBeats.jl by typing `] add HeartBeats` in the Julia REPL.\n\n\n## Example\nHeartBeats.jl contains a short example ECG dataset taken from [`scipy.misc.electrocardiogram()`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.misc.electrocardiogram.html). The function `example_ecg()` returns this data, which was sampled with a sampling frequency of 360\u0026nbsp;Hz, as a `Vector{Float64}`. We can use this dataset to showcase the `detect_heartbeats()` function:\n\n```julia\nusing HeartBeats\n\necg = example_ecg()\nfs = 360  # sampling frequency\n\nbeats = detect_heartbeats(ecg, fs)\n```\n\nThe `beats` array will contain all detected R peak locations.\n\n## Benchmark\nThe detector is based on the Python implementation available in [SleepECG](https://github.com/cbrnr/sleepecg). It is about 18× faster than the Python implementation and only 2× slower than the C implementation. Follow these steps to reproduce the benchmark:\n\n1. Export all data records used in the `'runtime'` benchmark by including `export_records = True` in `config.yml` (refer to the [SleepECG documentation](https://sleepecg.readthedocs.io/en/stable/heartbeat_detection.html) for details on how to set up and run the benchmarks). This will generate 15 text files.\n2. Move those text files to a folder that you can access from Julia (i.e. set the Julia working directory accordingly).\n3. Run the following code snippet to benchmark the runtime for 60 minute data segments (note that you need to add the `CSV` package):\n\n```julia\nusing CSV, HeartBeats\n\nfunction run_benchmark()\n    total = 0\n    fs = 128\n    files = filter(x -\u003e endswith(x, \".txt\"), readdir(\".\", join=true))\n    for file in files\n        println(file)\n        data = CSV.File(file, comment=\"#\")\n        ecg = view(data[:ecg], 1:60*60*fs)  # 60 minutes\n        stats = @timed detect_heartbeats(ecg, fs)\n        total += stats.time\n    end\n    println(\"Total: $total, Average: $(total / length(files))\")\n    total\nend\n\nrun_benchmark()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbrnr%2Fheartbeats.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbrnr%2Fheartbeats.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbrnr%2Fheartbeats.jl/lists"}