Fitbit Lab

by Dustyn Roberts on February 7, 2012

Follow this post from the Quantified Self blog

  • DO step 1
  • SKIP steps 2 and 3
  • DO step 4. Use these:
    • Consumer key: 2ccdced480d247828c30a8ee0626636d
    • Consumer secret: ac564afc15aa4cc990c72623794bdf28
  • DO steps 5 and 6

Graphing 101

  • Okay now you have data in a Google spreadsheet. Let’s graph it.
  • Select the first and second columns

image

  •  Navigate to Insert –> Chart –> line charts option

image

  • Insert. Done.

Graphing 102

  • Download as Excel

image

  • Open Excel
  • Highlight first 3 columns

image

  • Navigate to Insert–>Scatter–>Scatter with Straight Lines

image

  • WTF!

image

  • Right click on chart –> Select Data…

image

  • Remove Date

image

  • Edit steps and distance. Each should have dates as X values, and steps or distance as Y values

image

  • Okay that’s better, but we need to change the Y axis values for the distance data

image

  • Right click on the green line at the bottom that represents the distance data and choose –> Format Data Series…

image

  • Choose Secondary Axis

image

  • Much better! We can see how my steps and distance are almost completely overlapping.

image

The Mifflin-St Jeor eqn is used to calculate calorie burn. We then take tracker data and factor that in as well for the users daily calorie burn totals. The exact “math” is not public.

  • M. Mifflin, S. St Jeor, L. Hill, B. Scott, S. Daugherty, and Y. Koh, “A new predictive equation for resting energy expenditure in healthy individuals,” The American Journal of Clinical Nutrition, vol. 51, no. 2, pp. 241 -247, Feb. 1990.

If a user had no Fitbit tracker data for the specific day we take the greater of Logged Activities + BMR (for minutes when there is no activity) and the calories calculated from the EER for that day (if EER enabled for this user’s profile). In case, there was some data from the tracker for the specific day, we use that data where available and for time where data is unavailable we use BMR. If the total is less than 20% greater than BMR then we use EER (cals < EER * 0.8). EER never used to calculate calories for today.

BMR Formula: We use standard MD Mifflin-St Jeor equation:
9.99 * weightKg + 6.25*heightCm – 4.92*ageYears + s, where s is +5 for males and -161 for female

EER Formula (TEE total energy expenditure):
Based on http://www.cdc.gov/pcd/issues/2006/oct/pdf/06_0034.pdf which in turn is based on “Food and Nutrition Board. Dietary reference intakes for energy, carbohydrate, fiber, fat, fatty acids, cholesterol, protein, and amino acids (macronutrients). Washington (DC): National Academy Press; 2005.” http://www.nap.edu/openbook.php?isbn=0309085373&page=204

MALE: TEE = 864 – 9.72 x age (years) + 1.0 x (14.2 x weight(kg) + 503 x height (meters))
FEMALE: TEE = 387 – 7.31 x age (years) + 1.0 x (10.9 x weight(kg) + 660.7 x height (meters))

Other Fitbit resources:

https://wiki.fitbit.com/display/API/Fitbit+API

http://dev.fitbit.com/:

https://github.com/qdot/libfitbit (also see http://www.openyou.org/)

 

 

{ 5 comments… read them below or add one }

1 Holger May 14, 2013 at 3:13 am

I tried to get intraday data from my fitbit into google docs. Thanks for putting the script online. Unfortunately I get an error when running it. On the fitbit website I read I only get intraday data from the API upon request. Did you ask the fitbit team to give you such access or did it just work for you? This is how far I get with your script: The connection to my data seems to work but when running “refreshTimeSeries” from the script editor, I get “TypeError: Cannot read property “dateTime” from undefined. (line 71, file “Code”)”. I changed my Google Spreadsheet interface from German to English to make sure it’s not a quirky date type incompatibility from Googles side. I give up now unless you maybe have a hint on what I could try next. It was fun playing with it, though. 😉

Reply

2 Dustyn Roberts May 14, 2013 at 7:53 am

Yes I did have to ask for this access and was granted it based on educational use for class. Sorry! It is still fun to play with.

Reply

3 John Thompson June 10, 2013 at 6:12 pm

Hello Dustyn,

I’m trying to use the intra day script but I keep getting this error.

Cannot read property “dataset” from undefined. (line 73, file “fitbitdownload”)

and I the spreadsheet only posts data from 11/9/2011.

I appreciate any help.

Thanks,
John

Reply

4 Ben August 19, 2013 at 11:29 pm

I’d love to try to get intra-day data from fitbit. I think some factors of the API have changed because your script does not work for me. I’m not much of a coder, but I tried unsuccessfully to find the call that may have been updated. The QS website has updated their script. Perhaps you could take a look and see what it would take to get this one working again? I’d really love to see intraday data!

Reply

5 Dustyn Roberts August 20, 2013 at 9:20 am

The QS website is probably the best place to check – the script I used was from them, and I’m not much of a programmer myself either. Sorry I can’t be more helpful! Good luck. And if it does work, feel free to post back here so others can follow your process!

Reply

Leave a Comment