A long time ago I was really impressed by one story I’ve read: developers around the world starts building an open source artificial pancreas in order to reduce the burden of Type 1 diabetes. Yes developers, hackers and makers can change the world.
We all have around us frictions than the digital revolution technologies can reduce or avoid. When your inner circle is impacted by an illness, some people begin by deeply learning about the illness and its treatment, and often they discover than the right tools are missing. When difficulties strikes your home’s door, some people refuse to be resigned and try to find a solution. And in all modesty, I’m one of them.
What’s the relation between mood disorders and sleep analysis ?
Researchers have found than Bipolar’s sleep architecture is deeply impacted during a depression or mania state. REM appears to be the aspect of sleep architecture most affected. Ever more important, the sleep architecture starts changing up to two weeks before clinical symptoms. In another words be able to monitor the sleep architecture, more especially the REM phases night after night could improve the therapeutic approach, react and adapt the treatment faster and at the end limit the psychiatric internment needs.
How monitor sleep phases?
The scientific approach is to use EEG, record and analyse electrical activity of the brain. They are extremely reliable but it is just impossible to wear it every nights.
The monitoring have to be done with a non intrusive sensor. An hear rate monitor is the ideal candidate because the relationship between sleep phases and heart rate has already be proven. But a medical grade heart rate monitor is also out of scope for everyday use.
With the rise of IoT we’ve seen last years many sleep monitors on the market. So the idea was simple: can we use them for record the sleep architecture with an acceptable level of reliability?
Why the Eclipse Open IoT Challenge ?
The idea had been in my head for a while, but I hadn’t found the right way to tackle it. Nevertheless, I work everyday with Open Source Software. I contribute to OSS too, on Warp10. I had everything in my hands, but I had also one fear: I’m not data scientist. The heart of this project is just data science.
In my case I am not waiting for a psychiatric internment of my child.
13th December 2016: Engage
We were starting from scratch, with only one ambition, go as far as we can in the implementation of the product, whilst taking care to make a work scientifically valid. We entered in the community of the “night hackers”, we had our regular job the day and InTheMoodForLife the night and the weekend.
The project were spitted into 3 phases. The first was taking the control of the Beddid device without this step impossible to continue. The second phase was build roots of the application, check the capabilities of the Raspberry PI for our project and building on top the application based on Eclipse Vert.x and Warp10. The last phase, the most difficult were develop the data stream processing and extract REM sleep with a good level of reliability. At the end we added the base bricks of the frontend for drive it from a smartphone.
What we have done in 75 (days) nights
First, an impressive coffee consumption for, at the end, be proud to announce that it’s not an idea anymore: it’s a product under construction. We validated not only that technically we could analyse sleep architecture with a BCG sensor but also that this product answers to a missing need. Indeed two psychiatrists will help us to validate the sleep algorithms and check than this IoT device can reach his medical goal.
We can now announce than the next step will be to install this device in the bed of one unstabilized bipolar patient in order to build the predictive model based on medical observations.
Open source from the beginning
This adventure would have never taken place without open source software and hardware. Technology integration of all the bricks has never been a problem, the diagram below of all open source software and hardware use on the project simply illustrate it. Open Source today is a complete high quality ecosystem. These software permits us to build quickly a functional application and be fully concentrated on our product.
A simple “cloc + wc” on the git repository give us a small idea of the work done since December.
Globally more than 2700 lines of code for bringing the project into life.
As developer, code is important. But when your starts an open project, communication is important too in order to get a feedback from the community. In the same spirit, we wrote 7 blogpost and try to promote them on twitter and reddit.
Vanity metrics are by design not interpretable, we can only say than the most read blogpost were about how we use Eclipse Vert.x on our project.
From a data point of view, our brave Raspberry PI have recorded approximately 130 millions of datapoints during 28 nights that represents 1.2 gigabytes stored locally.
Reuse it in on wider context? Obviously Yes
If we look beyond our project context, that the key factor ?
First: the ability of store on an ARM based computer a large amount of data. The ARM (Raspberry PI) act first as a data logger. If you look around you, sensors are everywhere (industry, automotive, healthcare…). Data produced by these devices are rarely historized. At best these objects compute aggregated data and the raw data is destroyed, discarded.
Second: Store data is the first step, but it’s being able to locally analyse the data on the device (embedded data science) that gives to the objects the capability to interact in a smarter way with the local environment.
This approach is usable on any smart object with an operating system and a Java Virtual Machine, so nothing really exotic but I’m personnally convinced than this approach will be democratized in the next years.
What we have learned since 3 month
This is the first time I had to transform an idea into product. During the last years I made many objects in a “maker style”. Playing a few weeks on a maker project is fun, I love it, but building a product is slightly different: as a developer you have learn and understand the issues surrounding your project’s context . This is a difficult but the enlightening part of the developer’s job.
I have spent more time reading psychiatry books, PhD thesis and other research papers than coding. It was mandatory in order to find the right way to implements data analysis. At the beginning of this project I had completely underestimated the time needed for this part. I had completely underestimated how important it is.
This accumulation of knowledge gives you one capability necessary for product building: having a holistic view. I’m thinking now to build other “satellites” devices, transform mood charting into IoT devices in order to accumulate data, merge it with sleep analysis or also integrates the impact of seasonality and local weather, secure upload on a cloud in order to share analyse results with patient’s psychiatrist or also personal coaching based on sensor data.
This is not end
We had a good feedback from psychiatrist and bipolar associations. We have now the expected and dreaded question When can I install your product on my bed?. We can not stop, we will go ahead, embed developers and transform this POC into an open source product with a particular goal in head: everybody should be able to easily build it at home.
From a hardware point of view, RPI3 have one structural problem, a cut in the electrical power could brick the device (is you are writing on the SDcard at the moment where power fails). We will base the final solution on the last compute module with a dedicated extension card (Wifi, Bluetooth, SDcard storage, safe shutdown + internal battery). Today building extensions for Raspberry PI compute modulse has never been so quick and easy!
So, stay tune, the Eclipse IoT Challenge is ended for this year but we will continue to work actively on this project. Moods disorders are diagnosed on average in France 10 years after the first clinical symptoms. After the first diagnose, mood stabilization takes time. If a smart device can help to reduce this time, this project will contribute to save lives, because suicide is the most significant cause of death during depression phases.
We all have to keep in mind than all mood disorder’s types represents up to 5% of the world wide population.