Giter Site home page Giter Site logo

phautamaki / thequantifyingstack Goto Github PK

View Code? Open in Web Editor NEW
25.0 2.0 0.0 12 KB

Collection of shortcuts and scripts for self quantification purposes.

License: MIT License

health lifelogging quantified-self self-tracking oura-cloud-api oura-ring apple-health

thequantifyingstack's Introduction

!!! Unfortunately this is currently out of date and thus the provided shortcut will not work because it utilizes a deprecated Oura API endpoint. See issues for more details and alternative versions (at your own risk), which I do not take any responsibility of because I am not the author of any of those. This repo may also be updated at some point but for now, don't hold your breath !!!

Oura to Apple Health Sync

The following iOS shortcuts add the functionality for syncing Oura Ring heart rate variablility (HRV) and resting heart rate (RHR) data from the Oura API to Apple Health.

Important notice

Oura Ring provides HRV values calculated as "root Mean Square of Successive Differences" (rMSSD) whereas Apple Health assumes the saved HRV values represent "Standard Deviation of NN intervals" (SDNN) as that is what the Apple Watch is using. By utilising the shortcuts below, you acknowledge they are saving rMSSD values to Health instead of the expected SDNN values, which may cause weird interpretations in some apps utilising HRV data from Health. Furthermore, in case you also have an Apple Watch in addition to Oura Ring, the different types of HRV values will get mixed in Health (although they are still separable by data source if needed).

There is a detailed blog post comparing the differences and similarities between rMSSD and SDNN values regarding stress and recovery estimation and the TL;DR version could be the following: "Both values can be used to track physiological stress over time as they produce similar trends in relation to their baselines. rMSSD is slightly more accurate in sensing acute stressors, which makes it the preferred option." Additionally, a blog post from Oura describes why Oura uses the entire night of HRV data, which is summarised in the last sentence: "...to provide you with the most reliable physiological stress assessment based on HRV".

Because the main usage of the nightly HRV (and HR) values is to estimate physiological stress and recovery, it is highly likely that adding the Oura HRV values to Health will increase the accuracy of recovery estimation because

  1. rMSSD is the more accurate estimator of acute stressors and
  2. the frequency of measurements in Oura is much higher (every 5 min) than with Apple Watch (every 2 hours at best, if not forced with Mindfulness session), which diminishes the variation in measurement conditions (circadian rhythm, sleep stages, see the above blog post from Oura for more details) between each night.

Therefore, calculating the average of all available nightly HRV values regardless of the type (rMSSD/SDNN) will likely yield a very accurate estimation of recovery when compared to baseline of similar combination of data.

Note that because of the difference in measurement frequencies, the volume of rMSSD values is going to be much higher each night, making it the major contributing factor also regarding averages. This should be beneficial because it is the preferred and more accurate value of the two.

Prerequisites

  • Minimum: iPhone, Oura Ring
  • Optional: A specialised app for inspecting and analysing HRV/RHR/recovery data is highly recommended, although the data and trends are visible also in Health. See also Example Stack.

iOS Shortcuts

The functionality consists of 3 separate shortcuts that you should install based on your needs:

  1. Sync Oura RHR & HRV (v2) or Sync Oura RHR & HRV (v2 alternative). The alternative version should be used in case ISO 8601 timezone offset is negative in your location (e.g. -04:00).
    • Does the heavy lifting (syncing). Defaults to today (=previous night) but can also take a custom date as a parameter (utilised in history sync).
    • Can be called manually or via automation multiple times a day; in case the data has already been synced, the shortcut silently exits.
      • Protip: Hook this shortcut to the event of closing the Oura app by creating a personal automation from the Shortcuts app in order to make the data import as seamless as possible. Additionally, toggle the "Notify When Run" option off from the automation's settings to limit the unnecessary notifications to minimum (toggle available since iOS 15.4).
    • The alternative version exists because of a bug in Shortcuts app timezone parsing. The faulty behavior manifests as all data written to Health with midnight timestamp (12 PM). If you are experiencing this problem, please try the alternative version that tries to circumvent the problem.
    • Note: You should have your Oura Personal Access Token at hand (or at clipboard) when importing this: it asks for the token during setup (although you can always update it later inside the shortcut).
  2. Debug Sync Oura RHR & HRV (v2)
    • The Sync Oura RHR & HRV only alerts the user in case the data is not yet available in the Oura API so that the user knows to try again later. Otherwise it does its thing in the background. However, if the sync doesn't seem to work, Debug Sync Oura RHR & HRV can be used to make some sense of the return values gotten from the Sync Oura RHR & HRV shortcut. It's not much but it's honest work.
    • Asks to select your copy of the Sync Oura RHR & HRV shortcut during setup.
    • Note: This debug script will actually run the Sync Oura RHR & HRV and "translate" the return value to a more informative alert.
  3. Sync Oura RHR & HRV History (v2)
    • In case you want to sync also the historical Oura data to Health (e.g. to immediately have a comparable baseline of the last 60 days or so), Sync Oura RHR & HRV History shortcut can help with that. When run, it asks for the inclusive start and end dates, loops through each day in between and uses the Sync Oura RHR & HRV shortcut to sync data for each day by passing the date as a parameter.
    • Asks to select your copy of the Sync Oura RHR & HRV shortcut during setup.
    • Note: This shortcut hasn't been tested with intervals longer than a few days. It may be best to start with an interval of max 2 weeks and go up from there if it works without problems.

Example Stack

For me, it's not convenient to actively take morning HRV measurements because of hectic mornings (and because it's one more task to do each day). Nightly HRV values are easy, passive alternative to this and with the added data from Oura also quite accurate. Therefore, I'm currently relying on the combination of

  1. Oura Ring, the main gadget for tracking sleep and nightly HRV/HR (recovery)
  2. Apple Watch, the main gadget for tracking daily activity and workouts, as well as daily HRV/HR (exertion)
  3. Athlytic, an app that tracks recovery and exertion based on HRV and HR data available in Health.

Wait a minute, doesn't Oura app already export data to Health natively?

Yes, it does! However, it writes the heart rate values to Health's Heart Rate category instead of Resting Heart Rate category as these shortcuts do. Furthermore, the HRV values from Oura are not exported to Health at all, probably because of the abovementioned difference in value types (rMSSD vs. SDNN). It may be the situation changes at some point in the future making these shortcuts obsolete, but in the meantime, they will do the job just fine (with the limitations below).

Limitations

  • Only the data from the first sleep of the day is synced, so no nap support (yet).
  • In case there is HRV data from other sources saved to Health (with the exception of Apple Watch values), the sync shortcut may incorrectly interpret the Oura data has already been synced and exits without doing anything. In this case you may try to increase the threshold for this interpretation from 15 HRV samples to some higher value inside the Sync Oura RHR & HRV shortcut.

thequantifyingstack's People

Contributors

phautamaki 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

Watchers

 avatar  avatar

thequantifyingstack's Issues

HRV Measurement Times Incorrect

Hi @phautamaki [phautamaki]
This shortcut is really exciting, thank you for putting it together.

After following all instructions (downloading by iCloud link, getting into shortcuts, inserting Oura PAT...)
The shortcut successfully imports OURA HRV readings to Apple Health (verified by visual check of health data)

However, the time on the 'Date' field is incorrect.

For example:
Data imported for night of June 5, all readings are imported as 'Jun 5, 2022 at 12:00:00 PM)
See screenshot attached
IMG_0163

Using :
Oura Ring Gen 3
Shortcut v2 (download from iCloud link this week)
iOS 15.5 on iPhone 13 Pro

No longer working

As of 16 January the shortcut is not working for me. See error at attached image. Has the Oura API changed?

Error- Oura data not available yet.

Uploading 9C12943F-11FA-42EB-9137-40DDF25EB03D.png…

Fixes in zip not working for new oura API

Conversion Error
Adjust Date failed because Shortcuts couldn't convert from Text to Date.

If I change date format I get no errors but also ko data

It all become broken on 1st March syncing 29th February.

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.