Reading RR intervals from EliteHRV with Pandas

Published Categorised as Data Science, Python, Tutorial Tagged , , , ,

Heart Rate Variability (HRV) is a measure of the time interval between each heart beat and is a measure that in contrast to beats per minute can quantify the variation between each heartbeat. This blog post explains how HRV readings done with the mobile application EliteHRV can be read and plotted with Pandas and Python. More information about HRV can be found here (external link).

The EliteHRV application is a popular app for measuring RR peaks and HRV measures, but the app itself is rather limited if one want to investigate the RR peaks in detail. Luckily, the application easily allows the user to export data as .txt files which opens it up for using Python and Pandas to drill down into the data and get further insight into the measurements.

The first step is to export the data containing RR intervals by clicking on the settings menu and choose Export Data. The data will now be e-mailed to you in the form of a link where you can download a zipped file with all your measurements.

The next step is to read the data into a Pandas DataFrame as a Time Series. The exported text files only contain RR intervals without a timestamp for each sample, so the interval values themselves are used to create the time, this is possible as the RR intervals annotate the time between two successive heart beats. To create the timestamps, the start time of the first sample is set to the timestamp given in the file name, then for each sample, the value of the RR interval is appended to the time of the previous sample. The code to do this is found in my GitHub repository for this project and is abstracted as a function named importDriveData in the_ importhrv.py _file.
This function can easily be called upon.

import importhrv as imp
df = imp.importDriveData()

The function first sorts all text files based on their date, so that the oldest one is read first, then it reads the .txt files one by one. By default the functions reads files from “data/eliteHRV/export/”, but the function can also read from other sources and files by specifying these as input parameters.

df = imp.importDriveData(‘data/eliteHRV/export/‘, “*.txt”)

The resulting DataFrame should look something like the picture below, where each sample has a corresponding timestamp.

upload successful
RR peaks from EliteHRV read into a pandas DataFrame

The file_ eliteHRVReader.py_ already has these codes and are ready to run.

The DataFrame can then be plotted and examined by using normal pandas commands.

df.reset_index().plot(x=”time”, y=[‘interval in seconds’])

Time series of RR samples

upload successful

By Christopher Ottesen

Chris is a data scientist based in London, UK.

8 comments

  1. Hi Christopher,
    just found this article when browsing Github repos regarding EliteHRV. Great stuff, and I hope to use that since I would like to use this data to feed GoldenCheetah with HRV input.

    Have you managed to automate the download? – It seems, there is no API available (still in the making?) to fetch data directly.

    Thank you.
    Kind regards,
    Marcus

    1. Hi Marcus,

      I’m glad you found the article and code useful! To be honest, I haven’t used EliteHRV since I wrote this article four years ago. They didn’t offer an API back then and based on your comment it sounds like that is still the case. The easiest way to export data was to send a txt file from the device (which obviously is not ideal). Maybe you can look into some sort of on-device cloud sync using Onedrive/Gdrive etc from the EliteHRV output folder (given that you are running on Android)?

      Btw, just had a look at GoldenCheetah! Impressive application, and great intentions. I’m a big supporter of “own your own data” projects! Maybe worth reaching out to EliteHRV? They might be open to collaborating with such an established non-profit application.

    2. Hey Marcus,
      I’ve been using EliteHRV for a while now.
      in the settings page on the app, clicking export will have an email sent to you with your entire history of recordings.

  2. Hola! I’ve been following your weblog for some time now and finally got the courage to
    go ahead and give you a shout out from Porter Texas! Just wanted to mention keep up the great work!

  3. I blog quite often and I truly appreciate your information. This great article has truly
    peaked my interest. I will take a note of your website and keep
    checking for new details about once a week. I opted in for
    your RSS feed as well.

Leave a comment

Your email address will not be published. Required fields are marked *