Tag: sleep

More sleep with Fitbits

After a bit less than 2 hours, jepsfitbitapp retrieved my sleep data from Fitbit for the whole 2013 (read previous post for the why (*)). Since this dataset covers the period I didn’t have a tracking device and, more broadly, I always slept at least a little bit at night, I removed all data point where it indicates I didn’t sleep.

hours alseep with FitbitSo I slept 5 hours and 37 minutes on average in 2013 with one very short night of 92 minutes and one very nice night of 12 hours and 44 minutes. Fitbits devices do not detect when you go to sleep and when you wake up: you have to tell tem (for instance by tapping 5 times on the Flex) that you go to sleep or you wake up (by the way this is a very clever way to use the Flex that has no button). Once told you are in bed the Flex manages to determine the number of minutes to fall asleep, after wakeup, asleep, awake, … The duration mentioned here is the real duration the Fitbit device considers I sleep (variable minutesAsleep).

Visually it looks like there is a tendency to sleep more as 2013 passes. But, although the best linear fit shows an angle, the difference between sleep in March and sleep in December is not significant.

R allows to study the data in many different ways (of course!). When plotting the distribution of durations asleep it seems this may be distributed like a normal (Gaussian) distribution (see the graph below). But the Shapiro-wilk normality test shows that the data doesn’t belong to a normal distribution.

Histogram of hours asleep in 2013Hours asleep in 2013 - Normal?As mentioned above, Fitbit devices are tracking other sleep parameters. Among them there is the number of awakenings and the sleep efficiency.

Awakenings in 2013

The simple plot of the number of awakenings over time shows the same non-significant trend as the sleep duration (above). The histogram of these awakenings shows a more skewed distribution to the left (to a low number of awakenings) (than the sleep duration). This however shows there is a relation between the two variables: the more I sleep the more the Flex detects awakenings (see second graph below).

Number of awakenings in 2013 (histogram)Relation between sleep duration and awakenings with Fitbit FlexSleep efficiency is the ratio between the total time asleep by the total time in bed from the moment I fell asleep. This is therefore not something related to the different sleep stages. However it may indicate an issue worth investigating with a real doctor. In my case, although I woke up 9 time per night on average in 2013, my sleep efficiency is very high (93.7% on average) …

Sleep efficiency in 2013… or very low. There are indeed some nights where my sleep efficiency is below 10% (see the 4 points at the bottom of the chart). These correspond with nights when I didn’t sleep a lot and also with very little awakenings (since these are related).

There is no mood tracking with Fitbit (except one additional tracker that you can define by yourself and must enter a value manually): everything tracked has to be a numerical value either automatically tracked or manually entered. It would be interesting to couple these tracked variables with the level of fatigue at wake-up time or the mood you feel during the subsequent day. I guess there are apps for that too …

The code is updated on Github (this post is in the sleep.R file).

(*) Note: I just discovered that there is in fact a specific call in the API for time series … This is for a next post!

Getting some sleep out of Fitbits

After previous posts playing with Fitbit API (part 1, part 2) I stumbled upon something a bit harder for sleep …

Previous data belong to the “activities” category. In this category it is easy to get data about a specific activity over several days in one request. All parameters related to sleep are not in the same category and I couldn’t find a way to get all the sleep durations (for instance) in one query (*). So I updated the code to requests all sleep parameters for each and every day of 2013 … and I hit the limit of 150 requests per hours.

Hours asleep (March-April 2013)This graph is what I achieved so far. I didn’t sleep much in March-April 2013: on average 4.9 hours per night. The interesting thing is that I can understand why by going back to my agenda at that time (work, study, family …). As soon as I can get additional data it would be interesting to see if sleep durations will increase later on.

(*) If you know how to get all sleep durations for 2013 in one query, let me know!

Idea shared #1 – measure your sleep

I don’t consider having more or better ideas than others. But I gradually realized I have less and less time for some activities like programming, electronics etc. Maybe that’s how we realize we are getting older now adults. So I decided to share these ideas rather than fueling the illusory idea that I will implement them one day.

So idea 1 is about measuring sleep. I recorded animals’sleep during my Ph.D. – but it was thanks to an EEG device. I think that if you want to understand or improve something you have to first measure it in a way or another. So I started to try to measure my own sleep with an app (Sleep Cycle). But despite its good reviews it doesn’t work, at least for me.

For instance the chart below is supposed to represent my sleep cycle for the night of the September 14th, 2012. I was certainly not in deep sleep at 1.30AM (baby did not want me to sleep immediately). I also woke up around 4AM (baby was again the reason). And I woke up at 6.45 (with a backup clock – had to wake up for work)?

My Sleep Graph with Sleep Cycle app for September 14th, 2012 night

The last version of the Sleep Cycle app improves things a bit by providing more statistics (so at last you can rely on the approximate time slept and compare your “sleep” across days etc.), more beautiful gaphs and the ability to download raw data. Don’t be fooled however, “raw data” means only start time, end time, sleep quality (how is it measured?), time in bed, number of wake ups and sleep notes. You unfortunately won’t be able to reproduce anything like the graph above.

Hardware devices like the Wakemate or the Zeo might give better results because part of the solution is using a real accelerometer. But the Up story shows that not everything is obvious in this world.

For me the fundamental flaw is to rely only on body movements to detect, quantify and even score sleep. Of course there is an abundant scientific literature about how muscle tone (of different muscles) is related to sleep stages (see here and here for introductory texts). But this is often measured by electrodes glued on your body.

So I think it could be very easy to develop a simple, cheap “sleep T-shirt” with light electrodes that will just stick to your body when you sleep (and you put enough of them so at any time at least some of them are connected). In fact it might happen that the Rest SleepShirt would already do the job – it’s a pity they don’t elaborate more on how they measure and collect data (but I understand they will want to sell the product later on ;-)). In my idea light wires would then go to a small pouch where they would be connected to something like a LilyPad Arduino (because it is flexible and can be sewed to a T-shirt – there may be other devices available). The LilyPad would serve as data collector or as data transmitter to a computer / a smartphone / a specific receiver (coupled to a real clock, like the Zeo). The advantage would be to remain sole owner of your sleep data – but of course the business plan should include some “social” features 😉

In the end it should look a bit like this:

Idea shared #1 - measure your sleep with sleep T-shirtThe other advantage would be that in such way you may also measure electrical activity through the body.

Will it work? I’m sure of it. Will it be enough to sleep correctly? I don’t think so: it’s not because you measure something that it improves. But at least you will have some clue on what is going on. Some other advices may be interesting. And for the moment nothing replaces a visit to a real doctor / sleep specialist!

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Baby movements during sleep

After a while, here is why I got a TV tuner for my Linux laptop, took screen captures and wrote a script to add a timestamp on pictures … I wanted to know how my (then 5-month-old) son was sleeping (his mom can be reassured: I was not planning to put electrodes on his scalp 😉 ).

Get the Flash Player to see this player.

var s1 = new SWFObject(“../videos/player.swf”,”ply”,”360″,”240″,”9″,”#FFFFFF”);
s1.addParam(“allowfullscreen”,”false”);
s1.addParam(“allowscriptaccess”,”sameDomain”);
s1.addParam(“flashvars”,”file=../videos/081129-night.flv&image=../videos/081129-night.jpg”);
s1.write(“container”);

Following this, I had interesting discussions with my dad about sleep patterns in babies. It could also be interesting to hybridize what we did for Gemvid and this simple solution in order to be able to quantify human/baby movements during sleep. My little knowledge of OpenCV can then come in handy for the motion and pattern detection …

Some additional technical details : Video was made from 321 TV screen captures (1 every 2 minutes) and played back at 1 frame per second. It was converted with FFmpeg (LGPL) and the Flash player is JW FLV Media Player (CC by-nc-sa). Ok: Flash is not free.

A seventh scientific paper from the Poirrier-Falisse!

Finally, a seventh scientific paper is published by the Poirrier-Falisse. After a huge batch of articles from Nandini, here is my second paper:

Poirrier J.E., Guillonneau F., Renaut J., Sergeant K., Luxen A., Maquet P. and Leprince P.: “Proteomic changes in rat hippocampus and adrenals following short-term sleep deprivation” Proteome Science, 2008, 6(1):14
doi: 10.1186/1477-5956-6-14

Very briefly, in this study we show the influence of 4 hours of prolonged wakefulness in rats hippocampus and adrenals proteome. As usual, this paper is published in an Open Access journal. Here is my updated BibTeX file (and I also updated Nandini’s BibTeX file).

Since the publication of two papers in peer-reviewed journals is a requirement, I will now be able to finish and defend my Ph.D. thesis …