Analyzing a Year of My Sleep Tracking Data

Below is a chart I made showing all of my sleep tracking data for last year collected using my Basis Health Tracker. Each day shows a stacked bar consisting of each major sleep stage (Light, REM, Deep) as well as any time I woke up during the night (Interruption) or the device was unable to get readings (Unknown).

2014 Sleep Tracking Chart

Note that Basis didn’t enable their sleep tracking functionality until January 19th, which is why there is no data showing on the chart for the first few weeks.

Average Sleep by Day of Week

I wanted to dig a little deeper into the data and see if there were any obvious trends. The first thing I did was calculate my average sleep for each day of the week:

2014 Average Sleep by Day of Week

Average Sleep by Day of Week
Day Minutes Hours
Sun 442.1 7.37
Mon 428.6 7.14
Tue 406.4 6.77
Wed 388.9 6.48
Thu 401.7 6.69
Fri 389.7 6.50
Sat 395.8 6.60
Overall 408.0 6.8

For the year, I averaged 6.8 hours of sleep per night, ranging from a low of 6.48 hours on Wednesdays to a high of 7.37 hours on Saturdays (no surprise there!). I’m actually somewhat surprised that my average is so low, as I have always considered myself to be someone that got closer to a “solid 8″ hours a night.

 Average Sleep Stages by Day of Week

I then looked at how my various sleep stages compared for each day of the week:

2014 Average Sleep Stages by Day of Week

Average Sleep Stages by Day of Week
Day Light Light % REM REM % Deep Deep % Interrupt Interrupt % Unknown Unknown %
Sun 268.8 61% 99.3 22% 65.5 15% 4.9 1% 3.7 1%
Mon 261.9 61% 92.5 22% 65.8 15% 4.7 1% 3.7 1%
Tue 255.0 63% 84.7 21% 58.5 14% 4.9 1% 3.3 1%
Wed 237.2 61% 86.6 22% 58.3 15% 3.8 1% 3.0 1%
Thu 243.4 61% 91.4 23% 60.5 15% 2.9 1% 3.6 1%
Fri 243.6 63% 83.4 21% 54.7 14% 4.4 1% 3.6 1%
Sat 236.1 60% 90.9 23% 60.0 15% 3.8 1% 5.0 1%
Overall 249.7 61% 89.9 22% 60.5 15% 4.2 1% 3.7 1%

What’s interesting is that even though my total sleep time fluctuates throughout the week, my relative percentages of Light, REM, and Deep sleep remain consistent.

Sleep Time?

I wanted to then calculate the average time I fell asleep each night. Unfortunately, I ran into some problems doing this because you can’t simply use Excel’s AVERAGE() command. Let’s say you fell asleep one night at 11pm, the next night at 1am, and the third night at 3:00am – the average time you fell asleep would be 1am, right? Not according to Excel:

Average time in Excel

Excel calculates the average time as 9am! The problem is that some nights I fall asleep before midnight (23:59:59), and others I fall after (00:00:00). This is like averaging 24 and 0, which equals noon. Ugh.

Time Zones and Travel

I noticed several instances where my sleep start time looked a bit strange. This was because although Basis provides each sleep instance in UTC time format (along with offset, so you can adjust for your local time zone/daylight savings time), it doesn’t factor in traveling to other time zones. So, all of my sleep times are based on my local time zone, even if I was, say, traveling halfway around the world.

Trends?

Surprisingly, there weren’t as many sleep trends as I had expected. Overall, I seem to sleep pretty consistently. I think a more valuable use of my sleep data is to begin correlating it with other variables – i.e., if I exercise or drink alcohol, does that have a positive or adverse effect on overall sleep? Does meditation or brain entrainment result in improved REM function that evening? Does sleep quality predict Heart Rate Variability (HRV) the following day (or vice versa)?

How I Did It

Manipulating this data was a bit more laborious than I was expecting. First, I exported all of my sleep data from Basis using my export script that I have previously posted about. Here is a sample JSON response that Basis provides for one given day of sleep data. I wrote a simple Python script to dump each day’s worth of data into MongoDB (preserving the original JSON structure), then wrote a MongoDB aggregation query that would return a summary of sleep data for each day:

MongoDB aggregation for Sleep Tracking Data

This would dump the results into a temporary collection called “sleepexport” that contains each day’s aggregate sleep totals (since you may have multiple segments of sleep for any given night):

sleep-results

I could then run mongoexport on to create a .csv file that I could import into Excel and make pretty charts:

mongoexport-query

If anyone knows how to calculate average time in Excel from a series of UTC-formatted timestamps, please let me know!

Glucose Tracking Experiment – My Quantified Self Talk

I previously posted about a glucose tracking experiment I conducted over the course of 7 months to better understand the effects of diet, exercise, supplementation, stress, and travel on my fasting glucose levels. I have had the opportunity to give several talks about this experiment, including the Quantified Self Europe Conference and the New York Quantified Self Meetup. Video and slides below.

Bob Troia: Understanding My Blood Glucose from Quantified Self on Vimeo.

Quantifying Goals Using Key Performance Indicators (KPIs)

The new year is always a time for both reflection (mostly thinking about all of the things you didn’t accomplish!) and setting new goals. The problem I have with goals are that they are often too… binary. You will either succeed or fail. Perhaps your goal was to lose 15 pounds, but you only lost 10. While yes, you didn’t meet your goal, you got 66% of the way there!

My dresser during my decluttering goalMy actual dresser(s!) with piles of clothes removed, ready to sort

As an entrepreneur with a background in marketing, and a popular term I see most business-types throw around is “KPI”, which stands for Key Performance Indicator. Companies ultimately focus on the bottom line (“ROI” – return on investment), but KPIs allow different business units to establish their own set of success metrics for their activities (customer acquisition, customer satisfaction, awareness or “buzz” of a marketing campaign, etc.). The benchmarks for “success” are often arbitrary (“We need a million Facebook fans!”), given there will be little history or accepted industry benchmarks to compare to, so KPIs are usually refined over time. Why not use the same logic and apply KPIs to your goals? Having KPIs will also allow you to track progress both during and at the end of the year. And who says you can’t recalibrate a goal if you realize in 6 months that it was over- or under-ambitious, based on data you have collected? Below I’ve outlined a number of my goals for this year, broken up by category. On a binary scale, I will most like “fail” more often than succeed, but at the end of the day bettering oneself by any capacity is still a “success”!

Below I have listed several (but not all) of my goals for this year, along with some KPIs and tools that can be used. Feel free to copy or adapt them to suit your needs.*

* Yes, I realize I am posting this in late January, but that was intentional, as I didn’t want this post to get lost in all of the post-New Year’s madness : )

[Read more…]

Visualizing HR, HRV, and GSR While Watching ‘Interstellar’

Interstellar

(Note: This experiment was inspired by a Reddit user who recently posted a graph showing their heart rate while watching the movie Interstellar).

Last week I went to see Interstellar (in IMAX, for full sensory effect!) and captured some biometric data to see how I reacted during the course of this nearly 3-hour movie. I wore a Polar H7 heart rate monitor paired with the SweetBeatLife app on my iPhone, along with my wrist-worn Basis B1. I exported the raw data from SweetBeatLife using their built-in export tool, and my Basis data using my Basis data export script.

Whereas the original experimenter only tracked heart rate, I wanted to analyze:

  • Heart Rate
  • Heart Rate Variability (HRV)
  • Galvanic Skin Response (GSR)

Heart Rate

Interestingly, my heart rate trend (on the left, below) looks very similar to the original Reddit user (on the right)! Both of us are using data from our wrist-worn Basis devices – in my case, the older B1 model, and for the Reddit user the newer Basis Peak. Although the Peak is capable of capturing more samples, the data returned from Basis is always an average value for each minute.

Interstellar HR comparison

However, SweetBeatLife is recording data at a resolution of 1 sample per second via the Polar H7. The per-second pulse data is a little bit jumpy and hard to follow (in gray), so I’ll also include a 60-second moving average as well (in blue):

Interstellar Heart Rate Polar H7

It looks very similar to the data recorded by my Basis. Good!

Heart Rate Variability (HRV)

Heart Rate Variability uses a technique in which the spaces between heart beats are measured, and is a good way to measure stress via an individual’s “flight or fight” response (the higher one’s HRV, the better). There are a number of ways HRV can be calculated, and in this case we are using what’s known as rMSSD (root mean square of successive differences). You can check out Wikipedia for a pretty good overview of HRV.

Interstellar Heart Rate Variability

Galvanic Skin Response (GSR)

Galvanic skin response (also known as skin conductance) can be used as an indication of psychological or physiological arousal:

Interstellar Galvanic Skin Response

My GSR started out rather elevated, which I guess was due to a combination of anticipation for the movie to begin as well as my eyes getting adjusted to the huge IMAX screen (and my body adjusting to the temperature in the theater). I was clearly into whatever was happening on-screen between 1:50 and 2:20!

Putting It All Together…

Now, if we look at all of the visualizations together, we can easily spot key moments in the movie (no spoiler alerts here, but if you’ve seen the movie you should be able to figure out what was happening in each area!), or when I might be internalizing some deep analysis of gravity and multidimensional spacetime, or simply bored (the movie takes some time to really get going!). We can also see when my stress response kicks in or relaxes (phew!).

Interstellar HR HRV GSR

Looking back at the data, you’ll see there is often an inverse relationship between heart rate and HRV, which makes sense – if your heart starts beating faster, you are most likely encountering more stress, which increases your sympathetic response and thus lowers HRV. Galvanic skin response typically is reflective of one’s sympathetic autonomic nervous system response (will increase as HRV decreases).

I think a great experiment idea would be for a bunch of self-quantifiers to all go see the same movie so we can all share and compare our data! Shoot me an email if you’d like to get involved.

Mobile Health and Telemedicine App Test Drive

I began to virtualize the way I manage my health several years back with the launch of ZocDoc, which provides an online system to locate and schedule appointments with doctors (similar to the way we use OpenTable for restaurant reservations). Flash forward to today, and my functional medicine doctor lives almost 2000 miles away. We keep in regular contact through email and set up monthly 30 minute consults over Skype (we do meet face-to-face at least once a year). He has access to all of my lab data in addition to other QS-related data I provide (there’s a misconception that the quantified self movement is “anti-doctor”, which is not the case – the issue is finding the right doctor(s)).

But things are just getting started. A number of mobile health/telemedicine-related technologies are coming to market that will continue to disrupt healthcare – by not just saving time and money, but potentially saving lives and allowing patients to have access to the best doctors regardless of geography. Dr. Eric Topol talks about the impending democratization of health care based 8 key consumer drivers: sensors, labs, imaging, physical exams, access to medical records, transparency of costs, and digital pills.

Here are a few examples of mobile health apps I have recently used:

[Read more…]