# lubdub #

A Python toolkit for calculating heartrate variability (HRV) and many other derivative usages of ECG/EKG data.

### Theory ###

* [https://www.physionet.org/tutorials/hrv/]
* [https://en.wikipedia.org/wiki/Heart_rate_variability]
* [https://bestguessorbetter.wordpress.com/2014/11/26/rmssd-and-sdnn/]


### Data Formats ###

Right now the only data format lubdub knows how to work with is a newline-separated
list of RR-intervals (e.g. as generated by a Polar heart rate monitor device).

Planned formats include:

* raw ECG / EKG data
* other RR formats
* NN interval formats

### Requirements ###

* Intended for Python 2.7 and Python 3.5 (other versions, YMMV)
* ...?
* profit!

### Generate an HRV plot over time ###

The entirety of what you can do with LubDub right now consists of taking a list of plaintext formatted
RR intervals (e.g. from a Polar H7) and graphing *heartrate variability over time*. Here's how it's done::

    from lubdub import load_plaintext_rrs, PlotHRV
    rrs = load_plaintext_rrs('data/Polar/H7/60s_sitting_calm.rr.txt')
    print(PlotHRV(rrs))

The above formula results in a dictionary that shows how heartrate variability over this session is
changing over time.  Only y-values are provided, as the time-distance between each HRV calculation
does vary, but only slightly.

### Jupyter Notebook Examples ###

In the source repository for this library is a "jupyter" directory.  If you install
the libraries in dev_requirements.txt, you can play with the "GraphMeditation" notebook 
for a simple example of generating an HRV graph and plotting it using matplotlib.

### About ###

Lubdub was created by Naomi Most (@nthmost) who can be reached at Naomi at CoreWellness dot io.

Contributions, questions, suggestions, and swear words are all welcome.
