I wanted to compare actual accelerometer data to the sleep report from my Fitbit Flex, so for the past several weeks I’ve been sleeping with both the flex and the data logger on my left hand. I chose a night where I felt like I had slept very well the next morning, and recorded the following screenshot from the FitBit app:
I then compiled data from the logger, which was tedious because I was sampling at 25Hz with a max file size of 90,000 samples. So, I had to combine many files in excel to produce a single data set for the accelerometer output which had 885,265 data points (Raw Data)… In retrospect, this was a little overkill, as there is nothing in the body that is happening so fast that you need to sample 25 times a second! Once this data was imported into Matlab, I was able to plot it versus time, where time was given in seconds since the beginning of the recording period. I wanted to plot the data versus the hour of the day however, and it took me a while to figure out the ultimately trivial commands. I first used the command ttime= datestr(t/86400+datenum(2013,10,14,22,54,14)) to create a date string which would combine the seconds elapsed with the start time to produce absolute rather than relative time measurements. I then converted that string back into numbers using the command tdate = datenum(ttime), and plotted all the data versus this new time variable. Finally, I changed the formatting of time ticks to just show the hour of the day using the datetick(‘x’,’HH PM’) command. I also created a vector based on the FitBit sleep data, which I had to manually grab from the app by sliding my finger around the plot and noting the start and stop times of “restlessness”. This was then overlaid ontop of the accelerometer data (as shown below), with an arbitrary magnitude.
Needless to say, I was very surprised by this data. First, there was much more movement than I had anticipated given the relatively stable reading from the Fitbit. Second, I was surprised at the low correlation between the data from the Fitbit and the logger. Without doing any quantitative analysis, it is easy to see that Restless Period (RP) 1 is due to a flurry of motion, which most likely represents me trying to fall asleep. RP2 seems to correlate with the spike in logger data which occurs just after it, and the discrepancy in timing could be due to the fact that FitBit quantizes data into 1 minute intervals, as well as differences in timing between the two devices. RP3 corresponds nicely with a large spike in the Y Axis, however the subsequent movements between 3am and 7am do not trigger any “restlessness” events, and there does not appear to be a clear trigger for restlessness based on either magnitude or duration of movement, which is somewhat perplexing. Perhaps FitBit’s algorithm is more nuanced, and takes into account the predicted sleep cycle. For example, the extended period of stillness from about 1230am to 130am might have registered as the first REM cycle, such that motion which occurred 4 hours latter in the next cycle was ignored because the algorithm predicted that I would be in REM sleep once again. It should also be noted that I was not sleeping alone during this data collection cycle, but as the data shows, there was nothing going on but sleeping because there are no high frequency, sinusoidal movements…. Giggity.