Introduction

This project begun with the idea of a smart home, regulating environment variables according to the sleep stages you are in. But there is no reliable way of measuring that! EEG or MRI are the only accurate ways for telling the quality of a sleep. But guess what, those machines are expensive. They don't have to be. EEG is a better approach since it does not involves you to be in a hazardous magnetic field to tell whether you are asleep or thinking in the woman of your dreams. Its non intrusive, and if well designed its portable and comfortable.


Problematic

Imagine you are in a kilometer long park. This park is filled with people talking, and your buddy is at the other extreme calling out your name. Yes, it is in fact that hard to listen to an EEG signal. Static and other signals in our bodies lie around 120mV while EEG signals are in the range of 1-160uV (yes Micro Volts). But hey, technology is amazing and it is completely possible to do so at a low effort expense. My goal is to do that. And yes, it is uncomfortable, having 32 to 124 wires on your head to get a complete EEG scan? current approaches look like this:

They use that to check on your sleep. Yeah, imagine sleeping with that! The leading opensource alternative OpenBCI looks like this:

Please, i dare you to wear that to switch tabs. Ok, i am not gonna lie, its open source and it works pretty good. The alternatives above are fare more tedious to setup. But still, OpenBCI offers only a 16 channel board for almost 1000$ the cheapest of 4 Channels costs 200$ + 250$ Headset (for printed yourself option! Even though its opensource, they provide cables, electrodes and whatnot). You cant do much with 4 channels in research. But i get it, electrodes, instrumentation op-amps, and filters are expensive. But here is where my brilliant idea comes!

Solution(s) - Proposal

None, i don't have ideas.... (juust kidding)

For electrodes i found out recently some guys are making 3D printed electrodes! And this company has an interesting approach of flexible electrodes. Mix those to and i bet you have cheap, comfortable DIY electrodes. Put those comfy electrodes in a cap like the first ones and you have an ultimate massag... i mean ultimate wearable EEG cap.

For the amplification, i found a novel design from 1994 which eliminates instrumentation amplifiers, coupling filters and other amplifiers, replacing them with 3 op amps to do all of that. And there is this other paper that implements differential amplifiers in a different way relying on ICA algorithm to eliminate the use of expensive instrumentation amplifiers. See where i am going? Yes, less components, more Machine Learning! Woho!

About filtering. Come on, its 2017, everything is digital. But i will thank to ICA to Better remove particular noises such as 60Hz rather than a careless notch filter. Thanks to the last paper cited above.

For Computing. Thank God for Raspberry Pi and DSPs like Teensy (i know its not a DSP, but who cares. It does deliver and with an awesome community). I like the idea of OpenBCI to have a small board built into the helmet or cap... Lets cross our fingers that the RPi Zero Wireless would be able to handle the ML or better yet, use a ESP8266 as a serial transparent bridge between teensy or whatever ADC or DSP we put in, and a local server that can also be a Raspberry (i have serious issues about Raspberry, i'ts true love. Don't judge me!)

Modularity. About ModularEEG and CHIP... They were right on spot on modularity. I am thinking of building 3 modules.

    1. Main Board: This will handle signal multiplexing, ADC acquisition, and serial transmission.
    2. Digital Board: This board will contain one ADC with some signal multiplexers and a anti-aliasing filter. This board will be the intermediate between the main DSP and the Analog boards. The Digital boards can be stacked up creating a bus communication using something like I2C or SPI with the Main Board.
    3. Analog Board: This board will contain Op-Amps capable of reading 4 to 8 channels. Theese boards can be stacked one above the other up to 4 boards connected to a single Digital Board

    Processing Software. I am intending to use python as the core (Raspberries everywhere). Ok not only because of raspberry but because it is a robust language and offers better compatibility and its more lightweight than Mat lab or Octave. I heard of R, but i thing python offers a wider community and libraries on Machine Learning. Plus, i have never used or seen R. If some one believes python is not the best, let me know!

    Machine Learning. A recent article came out on IEEE spectrum magazine, it showed how neural networks were used for hearing aids. Remember the example of the park? well, we could train our network to detect known brainwaves (Alpha, Beta, Gamma, etc) so that it can separate them and even output a live percentage of the presence of it on the signal and on what part of the scalp.

    Digital Noise Filtering. Independent Component Analysis is a really powerful algorithm. Ever heard of the 'Cocktail Party' problem? Well ICA addresses the subject fairly well. The goal with ICA would be to separate the so annoying Common Mode (CM) Noise Improving this way a great deal of CMRR (CM Rejection Ratio). This is the key for allowing us to use cheaper components and avoiding the expensive instrumentation amplifiers.


Design

This is meant to be a PLATFORM that is easily reproducible, affordable and powerful. It will meet both safety and quality standards such as IEC 60101-1 and IFCN. I will write an extensive wiki on understanding signal acquisition systems, machine learning algorithms, 3d printing, Internet of Things, brain waves and sleep disorders.

Here i will break down the project Blocks.


Field of Study - Sleep

Growing up, my major problem was sleep! I went tired, lacking sleep every single day of my school years. Imagine daydreaming almost all the time triggered by the tiredness of my body. Well its not so dramatic, but for me was a key point. I decided to build a IOT automated home to regulate temperature, light, sound around my room to improve my sleep. While searching for a way of accurately measuring my sleep stages i founded that there were none reliable commercial devices to do so. The only way is to get to a sleep clinic for a couple of days, but they put so much stuff in your body that i doubt that you could get a good sleep, therefore i doubt you could get accurate data. The study is too intrusive! (they stick a tube down your throat through your nose) With more than 100 cables attached to your body.

So this platform can be build to become as powerful as 100+ lead system and as simple as 4 leads with the capability of building into a completely automated IOT room.

To complex for a good night sleep? it is not just that. This is about creating habits, fixing sleep disorders. In general, improving your life quality. There are thousands of studies that show how sleep important and how it affects you, don't get me started. But there is an issue. There aren't the right tools.

Github Repo: https://github.com/R0dri/DIY-BAS/