Fitbit Lab

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:

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

http://dev.fitbit.com/:

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

 

 

7 Replies to “Fitbit Lab”

  1. 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. 😉

    1. 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.

  2. 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

  3. 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!

    1. 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!

Leave a Reply to Dustyn Roberts Cancel reply

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