IOS – How does HealthKit calculate activeEnergyBurned and other variables

apple-watchhealth-kithealth.appioswatchos

I am investigating using HealthKit to supply some data for an application which will run on iOS. We are thinking about using Apple Watch to collect the data. I am especially interested in activeEnergyBurned and some related quantities, namely basalEnergyBurned, respiratoryRate, and vo2Max.

It appears that the sensors on the Apple Watch are just orientation, acceleration, and heart rate. So I guess that the activeEnergyBurned, etc., must be calculated from those items. Can anyone point me to any documentation or other info about how these items are calculated? In particular, any known limitations or constraints would be very helpful to know.

I wasn't able to locate any info about that with a web search. The only info I found that is at all related is this question: How to get Apple Watch 2 to calculate VO2 Max data? Also found this: https://discussions.apple.com/thread/8082402

Are there better articles or descriptions than the ones I cite above to learn how active energy is calculated?

Best Answer

Apple doesn't disclose the algorithms is uses to calculate these so you're going to need to reverse engineer it or hopefully find someone else who has reverse engineered it.

What is publicly known is that Apple has hired and contracted experts to make an entire team of research physiologists, cardiologists, dietitians, nurses as well as likely hundreds to thousands of people to workout with the Apple Watch and other sensors where they calibrate all sorts of measurements and correlate that data collection with metabolic carts (reportedly 50 in this gym alone). Also, this data collection has been going on since 2015 so I would expect Apple has revised the formula over time to make it better and better as they learn which types of activities and which body types and ages don't fit the last version of the algorithm.

I would expect that Apple has severely restricted the code it uses as trade secrets as that high cost to invest in the team is clearly a competitive advantage for it to market and sell and satisfy people with good estimates of health activity. Perhaps they will disclose what you need, but I would guess you should just use the values Apple provides and build your app around the data stream Apple generates as opposed to compete with them unless your aim is to compete with Apple on generating better health data.

As a developer, you also should look into ResearchKit - https://www.apple.com/researchkit/ to get much more technical detail and API than the mainstream press (or even MIT's technology review) will cover in articles about Apple's efforts to make their health data accurate.