Brainwaves for Hackers 3.0
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Klostermann, Andreas
Andreas Klostermann - Brainwaves for Hackers 3.0 This talk is about using our **Python** skills to explore the **secrets of our brains**. Using the Neurosky Mindwave as a bluetooth connected EEG device, I'll talk about new experiments I have performed inside the Jupyter notebook, for example "Evoked Response Potentials" and more about "Neuro Feedback" training. - Electroencephalography **(EEG)** measures potential waves originating within the brain. Billions of brain cells fire inside your brain, each sending out a minuscule wave. The summed potential waves can be measured, even with quite cheap and **portable devices**. Being the third major version of this talk, I'll talk briefly about the Neurosky Mindwave and the Muse headset. I have also developed more interactive Jupyter experiments, which I'll demonstrate in the talk. For example **Evoked Response Potentials (ERP)** can be demonstrated with relatively simple means. Also I'll talk some more about experiments with **Neuro Feedback**.
 Hello, my name is Andreas Klostermann and this talk is called brainwaves for hackers. It's about using our Python tools to understand our brain a little closer. It's also in the sense of hackers as people who build stuff and not as hackers who try to hack your brain or something. Well, please don't take anything of this as medical advice or this is just mainly a hobby project for me. It's no academic endeavor or something. I've given two talks previously like this. If you have seen them, you probably don't. If you have seen them, I'll still show you something new, but if you haven't, you probably can follow quite nicely without it. First of all, what are brainwaves? Brainwaves are created by your brain cells. You probably know your brain is composed of billions of brain cells and these communicate with each other via electrical signals. And these signals travel outwards through your skull and through your skin. And if you have a sensitive sensor, you can measure the waves at these locations. As this also already implies, these signals are very weak and they are very noisy. And you can only measure the summation of billions of cells at once so you can't listen in on a specific brain cell or specific group of brain cells. And that makes the signal analysis very challenging and it limits what we can get in terms of information. So what can we do with brainwave technology at all, especially as hobbyists? We can do neurofeedback training and I think that it's a very big and very good area for devices, for consumer-grade devices. It is about training your brain to attain certain mental states. The way it works is that we use brainwave data to assess, for example, how concentrated a user is. And then on the screen or via headphones, you give him a feedback about this mental state and he tries to increase it. And by trying to increase it, he learns how to consciously control this brain state and this kind of training has been proven quite successful in, for example, ADHD and epilepsy. But if you need, if you want to use new feedback in a medical indication, please consult a doctor. Now, the second thing you can do are simple neurologic experiments. I've done some correlation things and tried to figure out how, especially the news brain band works, but there is another thing that I got to work with the newest guy, which is auditory evoked response potential. But since I didn't get it to work here without some serious yuck-shaving, I tried to, I didn't bring it today and I won't even explain what it is. Then there is this area of brain-computer interfaces, these BCI types of applications. They are a bit like the new feedback thing, but there the goal is actually to control the computer or to control a robot or something just with your brain, but it's very difficult and it's not really my main interest because it doesn't really work very reliably. You have to find a way to have some kind of button, for example, a button that you can press when you want to press it and not press it when you don't want to press it. And that's kind of hard, especially with the devices I have. Some researchers had more success with implanting electrodes under the skull, not necessarily for this reason, but rather for epilepsy, and then they did BCI experiments and it worked very nicely, but please don't do that at home. Theoretically, you could use EEG devices like this for diagnostic purposes, but I would not believe that it is legal to do this with these devices and probably they aren't really suited for this. Now the device I presented in my last few talks was the Neurosky MindFive headset. It's a Bluetooth connected device and it has one sensor in the front. I have this device here and it has a sensor and you can wear it like this and it has a reference electrode and one channel. Inside this headset is a technology called an ASIC, an application-specific integrated circuit and this can be used in other devices too. For example, there are board games where you can control the ball moving up and down through your brain waves and there's also a headset that has cat ears mounted on servos and then these ears move according to how relaxed or concentrated you are. Well, and there's also another headset which is a bit more expensive but is more comfortable to wear. And it uses the same, always the same protocol and the same characteristics. The second device is the Interaxon Muse. The Interaxon Muse is a bit more expensive, about 300 Euros and it has four channels. It has a very good app for Android and iOS, also connected through Bluetooth and it teaches you to meditate and gives you feedback on how calm you are and how you progress over time. And it uses lots of gamification and I think this app is really very well designed. Overall, I'd say the Muse is also a lot more comfortable so it's just this headband and it's a bit flexible so you can adjust it to your head. In the direct comparison, the Muse has four channels and the mind wave has one channel. So in theory, the Muse will give you better quality data. The Muse also has an accelerometer channel, two accelerometer channels. So this measures how the head is moving and that's quite useful because if you know that the head is moving, you can already say the brain waves are probably not very useful but you will probably have artifacts in there. They have different sample rates so the mind wave uses 512 samples per second because of bit reasons so it's two times 256. And the Muse has a little trouble with the P-sets so you can't really change the options directly but you have to set certain presets and then there are consumer presets and research presets. And what the documentation didn't say is that the firmware that was distributed with the Android app does not give you the research presets and then you only have 200 hertz. Also, the protocol is somehow a bit compressed so they have a bit length scheme to encode their packets and the consumer things and then this year they switched to a newer firmware in the Envoid app and then I got the research presets to work and that did work nicely. But the newer versions of the headset so after 2014-1 and probably the 2016-1 doesn't do research it only has these 200 hertz so very important is that both these devices have dry sensors so you don't need to put any gel or fluid on there to make it work like the medical devices. The mind wave also has pre-computed measures I'd say so there's a value from 0 to 100 for attention and for meditation what they are calling it and this is already completely analyzed from the brain wave data and the only thing you have to do is to react to this one byte and this means that for example an Arduino or a micro-bit would be able to pass this protocol and do something useful with it. With the MUSE it's not possible because it only gives you raw data and you have to process this raw data and that takes more processing power. But on the other hand the MUSE data is less processed so you can have more control over how to actually process it. So that's why I say the hackability of the mind wave is excellent and from the MUSE it's only good. The MUSE still has documentation I found it a bit confusing or even wrong but it still has this documentation it's accessible over Bluetooth but the mind wave really is a bit easier to work with and the data you get from it also the raw data is easier to process. But these devices are also very different in price so the mind wave costs about 130 Euros and MUSE costs about 300 Euros. Last time I checked a bit more I think. So the third kind of device which I don't own however is the OpenBCI. They have two versions one for $100 and one for $400 or $500 I don't know quite correctly but anyway the one has four channels the other has eight channels which is more than the MUSE even. And well the advantage of this OpenBCI technology is that it is extremely flexible so you can even program the firmware yourself if you want and you can even reprogram the amplifier so you can even measure heart signals or other electrical heart signals or electrical muscle signals. The big disadvantage of this device is that it's very do-it-yourself. It doesn't even have an enclosure and you have to attach your own electrodes and these electrodes probably have to be wet and in all in all it takes a lot more effort to get this set up. But anyway it probably produces very good data and probably is very useful for custom mods and it's as the name OpenBCI implies it's probably mainly geared towards brain control interfaces, brain computer interfaces. Now what I've done with this stuff is I've built a little library called Bideology and it's geared towards real-time analysis of physiological time series and physiological time series are different stuff like brain waves for example but also ECG so heart waves if you want to call it that or even muscle movements or even breathing rates or anything else you can think of and they are transmitted at different frequencies of course and I'm using the PANAS time series functionality to make this a little less painless. First of all it currently supports mind wave and muse. I'm also working on a bitalino driver but that doesn't really work that well. If you know what a bitalino is but it's also something for ECG and stuff. It supports especially multiple and irregular time series so you don't really know when the data is coming and maybe it has a varying rate or whatever and PANAS really supports this really well. Our main feature is integration into the Jupiter notebook and I try to make this relatively painless. Now I can try to show you how this works. I have to adjust the headband to my head. Now it's streaming but it's not quite right yet. So this device is a bit more finicky. That looks a bit more easier than it should but in any case the problem with this kind of brain wave is this kind of electrophysiological measurement is that virtually anything in your face or in your head will have a higher or louder signal than your brain. And for example I can move my eyes. I can clench my teeth. And this time the, sorry I'm displaying here two channels. The blue one is the left one and the right one is the red one is the right one and I can just try to move my left face. It doesn't really work currently. So now I can move my left face and my right face. And as you can see the strength of the signal is slightly different because it's a different distance. So the architecture of how this works is that there's an async IO server that is a different process and I did that to isolate all this Bluetooth handling stuff from the notebook and it communicates with the Bluetooth headset to get the data and then it can send it onwards to the IPython kernel. So inside the IPython kernel I have some codes that manages an experiment. It can record the data and it can then update for example a book a time series or something. So inside the notebook there's also some, on the browser side there's also some software currently I'm not using any custom JavaScript earlier I had to but Booker now has this push notebook and that also works very nicely. But it's important to know that the browser is sort of a different network endpoints and the actual server or the kernel and these are different moving paths. So what Pyseology is mainly about is doing experiments and experiments can be anything like mostly some recordings and maybe you do some feedback or some sound experiments or whatever. I have an experiment class so these are declared like this and in this case I would be declaring two devices, the MUSE and the MindWave to have these different MAC addresses and then the server is contacted and tries to reach these devices and stream their data. This is a more practical example with only one device. In the second cell there's first of all HTML widget from the IPyWidgets library and this is later updated to contain some information and I instantiate the experiment class with a file name where all the data is stored. Now the experiment class instance is used as a decorator on a handler function and this handler function is called every time some new data arrives and it checks if the experiment already has data on the AF7 time series which is one of the channels and then there's display values thing which updates the HTML dynamically. In this case just with how long the time series currently is. So that's the problem, it jumped to 30 seconds because it has data in the queue and I still have some problems with timing and synchronization and stuff. It could be a bit smoother but it works quite nicely. So with relatively simple means I can already have some kind of feedback. Well synchronization. These experiment classes contain time series as I said and for example in this case from the MUSE the AF7 and this shows the first few samples, every sample has a time. As a time stamp, this time stamp isn't really the real time stamp but rather I try to figure out inside the server at which point this was measured by some simple heuristics. Probably MUSE nor the MindWave contain any logic to tell you when they sample something. Now to analyze it we need to often we need to window this data. So it's a particular sample of brain wave is relatively useless. What is more useful is for example different frequencies that you are seeing or different signal strength over a certain time period. So for example you would window the data like with a window with three seconds and a step size of one second that means that the first window is at zero seconds to three seconds and one to four, two to five and so on. And this is turned into an iterator and then we can do more processing on it. So the analysis class then can, so here on the button I pass this processing function over the windows and then into a data frame and this processing function generates several features for every window especially important is the standard deviation because this is a nice way to find if there is noise in the system or any artifacts or bigger artifacts. On the bottom here I try to or I do calculate some frequency measurements not really important to understand it right now but there are several frequency bands so when you have alpha waves you should be more relaxed and better waves mean more concentration and that's, so that's important to know. Of course this data frame now is just a standard pandas data frame with columns and now that we have this data frame information we can actually do normal data science stuff for example correlations. Now as I said the MUSE has four channels and two of these are on the front of the head and these are AF7 and AF8 and I'm plotting these here together. The first the alpha strength on the left the alpha strength correlates very nicely just as a better one strength and this also means that even if you have more channels than one it's still relatively similar information but you can also imagine that having two channels will measure more or less the same thing is more reliable or more precise. Now the second thing I tried is to correlate MUSE and mind wave so I did what I showed earlier I put two devices into an experiment I recorded it I had to wear these devices at the same time which I want to know because it looks silly but it doesn't really work as well. It could mean that I did some other I didn't put much work in it and the signal could be horrible that could be a reason why this is not such a good correlation. It could also mean that they have very different latencies but well. So that's basically everything I have to tell today. I'm trying to do more experiments but most of the work I have done so far is integrating these devices and trying to make them work and well so I haven't really progressed into doing much experimentation. But anyway the code is also on GitHub I have to publish it later because I have to clean something up and the slides will also be on GitHub. This whole notebook presentation and some supporting code will be there and I will treat it later. Now I'd like to talk about some other stuff I've been up to. I've been working on pocket Python which is a library I created to deal with Oxford Nanopore data which is a sequence DNA sequence so the Oxford Nanopore Minion is a DNA sequence which is about the size of a computer mouse and it can sequence DNA and it has a particular data format and I try to work with that and maybe next year I'll present genome sequencing for hackers. I'm also working on a workshop called presenting with Jupiter which contains several tricks that I'm also using here so you probably noticed that I don't have the help thing and the x processing and various other ugly artifacts and I changed the transition styles and adjusted the size a bit. That's all nice to know and it's not so common knowledge. A lot of presenters had problems here with the screen resolutions. Anyway I also did something called Jupiter flight gear which is an afternoon hack so I used flight simulation software and I managed to stream data from the flight gear directly into the Jupiter notebook and have some graphics or something. In theory you could do your own autopilot but I just want to mention it here because I have to, it's sort of cool but I have to abandon it because of time. Now I'd like to thank you for your attention. My Twitter handle is Bayesian horse. I have a GitHub account with Pyzeology especially. It doesn't have the news code yet but it will today. Another project I've been working on is Table Cleaner which can do, which cleans up data frame like data to enter into the errors into data itself and where the notebook assets stuff is all that I should have deleted it. So we now have time for questions and I'd like to start with that. One question. We should have a microphone but we don't even have a chair. Yes, it depends if there is, sorry, let's repeat the question. He's talking about headphones, which name? They have from Kickstarter, they have EEG sensor somehow and maybe it's an interesting device to address that. Yes, I'll try. I'll see if you want to pull requests or if you need help, I can certainly help you. Can you please repeat this with ability? You mean the data quality? So the question was which has a better data quality and I'd say the news clearly has more data and you probably can get more information out of it. It depends for the kind of application you want. I mean the MindWave, the newest guy stuff does very much signal processing already inside the device that can have advantages and disadvantages. I'd say the news produces certainly more data and probably more information, especially of different parts of the brain. Hardly. He can tell some thing about the mental state but even that isn't very useful without knowing it. So without knowing, I have to repeat the question. The question was if you have the recording, can you tell what the person was doing? So the question was can you tell what someone is doing just from the brain wave data? No, you can't really because it very much depends on the person and it's very vague information and you can maybe tell if he is very concentrated or very relaxed but even that depends on how his brain waves usually are distributed and there are interpersonal differences. Yes, it's possible to recognize feelings if you set up the experiments right. I guess you could do that. The question is that I only showed two channels and you asked about... Yes, if I can analyze different kind of wave bands inside the brain waves. So the data analysis works like you can do a Fourier transform analysis and then you can detect the strengths of different frequencies and of course you can calculate that. In my example, I only calculated alpha and beta 1 and I could of course calculate everything else and it should be more precise with the user and with the mind wave. Okay so there's no further questions and I'd like to thank you again and have a nice day. Thank you.
 Hello, my name is Andreas Klostermann and this talk is called brainwaves for hackers.  It's about using our Python tools to understand our brain a little closer.  It's also in the sense of hackers as people who build stuff and not as hackers who try  to hack your brain or something.  Well, please don't take anything of this as medical advice or this is just mainly a hobby  project for me.  It's no academic endeavor or something.  I've given two talks previously like this.  If you have seen them, you probably don't.  If you have seen them, I'll still show you something new, but if you haven't, you probably  can follow quite nicely without it.  First of all, what are brainwaves?  Brainwaves are created by your brain cells.  You probably know your brain is composed of billions of brain cells and these communicate  with each other via electrical signals.  And these signals travel outwards through your skull and through your skin.  And if you have a sensitive sensor, you can measure the waves at these locations.  As this also already implies, these signals are very weak and they are very noisy.  And you can only measure the summation of billions of cells at once so you can't listen  in on a specific brain cell or specific group of brain cells.  And that makes the signal analysis very challenging and it limits what we can get in terms of  information.  So what can we do with brainwave technology at all, especially as hobbyists?  We can do neurofeedback training and I think that it's a very big and very good area for  devices, for consumer-grade devices.  It is about training your brain to attain certain mental states.  The way it works is that we use brainwave data to assess, for example, how concentrated  a user is.  And then on the screen or via headphones, you give him a feedback about this mental state  and he tries to increase it.  And by trying to increase it, he learns how to consciously control this brain state and  this kind of training has been proven quite successful in, for example, ADHD and epilepsy.  But if you need, if you want to use new feedback in a medical indication, please consult a  doctor.  Now, the second thing you can do are simple neurologic experiments.  I've done some correlation things and tried to figure out how, especially the news brain  band works, but there is another thing that I got to work with the newest guy, which is  auditory evoked response potential.  But since I didn't get it to work here without some serious yuck-shaving, I tried to, I didn't  bring it today and I won't even explain what it is.  Then there is this area of brain-computer interfaces, these BCI types of applications.  They are a bit like the new feedback thing, but there the goal is actually to control  the computer or to control a robot or something just with your brain, but it's very difficult  and it's not really my main interest because it doesn't really work very reliably.  You have to find a way to have some kind of button, for example, a button that you can  press when you want to press it and not press it when you don't want to press it.  And that's kind of hard, especially with the devices I have.  Some researchers had more success with implanting electrodes under the skull, not necessarily  for this reason, but rather for epilepsy, and then they did BCI experiments and it worked  very nicely, but please don't do that at home.  Theoretically, you could use EEG devices like this for diagnostic purposes, but I would  not believe that it is legal to do this with these devices and probably they aren't really  suited for this.  Now the device I presented in my last few talks was the Neurosky MindFive headset.  It's a Bluetooth connected device and it has one sensor in the front.  I have this device here and it has a sensor and you can wear it like this and it has a  reference electrode and one channel.  Inside this headset is a technology called an ASIC, an application-specific integrated  circuit and this can be used in other devices too.  For example, there are board games where you can control the ball moving up and down through  your brain waves and there's also a headset that has cat ears mounted on servos and then  these ears move according to how relaxed or concentrated you are.  Well, and there's also another headset which is a bit more expensive but is more comfortable  to wear.  And it uses the same, always the same protocol and the same characteristics.  The second device is the Interaxon Muse.  The Interaxon Muse is a bit more expensive, about 300 Euros and it has four channels.  It has a very good app for Android and iOS, also connected through Bluetooth and it teaches  you to meditate and gives you feedback on how calm you are and how you progress over  time.  And it uses lots of gamification and I think this app is really very well designed.  Overall, I'd say the Muse is also a lot more comfortable so it's just this headband and  it's a bit flexible so you can adjust it to your head.  In the direct comparison, the Muse has four channels and the mind wave has one channel.  So in theory, the Muse will give you better quality data.  The Muse also has an accelerometer channel, two accelerometer channels.  So this measures how the head is moving and that's quite useful because if you know that  the head is moving, you can already say the brain waves are probably not very useful but  you will probably have artifacts in there.  They have different sample rates so the mind wave uses 512 samples per second because of  bit reasons so it's two times 256.  And the Muse has a little trouble with the P-sets so you can't really change the options  directly but you have to set certain presets and then there are consumer presets and research  presets.  And what the documentation didn't say is that the firmware that was distributed with the  Android app does not give you the research presets and then you only have 200 hertz.  Also, the protocol is somehow a bit compressed so they have a bit length scheme to encode  their packets and the consumer things and then this year they switched to a newer firmware  in the Envoid app and then I got the research presets to work and that did work nicely.  But the newer versions of the headset so after 2014-1 and probably the 2016-1 doesn't do  research it only has these 200 hertz so very important is that both these devices have  dry sensors so you don't need to put any gel or fluid on there to make it work like the  medical devices.  The mind wave also has pre-computed measures I'd say so there's a value from 0 to 100 for  attention and for meditation what they are calling it and this is already completely  analyzed from the brain wave data and the only thing you have to do is to react to this  one byte and this means that for example an Arduino or a micro-bit would be able to pass  this protocol and do something useful with it.  With the MUSE it's not possible because it only gives you raw data and you have to process  this raw data and that takes more processing power.  But on the other hand the MUSE data is less processed so you can have more control over  how to actually process it.  So that's why I say the hackability of the mind wave is excellent and from the MUSE it's  only good.  The MUSE still has documentation I found it a bit confusing or even wrong but it still  has this documentation it's accessible over Bluetooth but the mind wave really is a bit  easier to work with and the data you get from it also the raw data is easier to process.  But these devices are also very different in price so the mind wave costs about 130  Euros and MUSE costs about 300 Euros.  Last time I checked a bit more I think.  So the third kind of device which I don't own however is the OpenBCI.  They have two versions one for $100 and one for $400 or $500 I don't know quite correctly  but anyway the one has four channels the other has eight channels which is more than the  MUSE even.  And well the advantage of this OpenBCI technology is that it is extremely flexible so you can  even program the firmware yourself if you want and you can even reprogram the amplifier  so you can even measure heart signals or other electrical heart signals or electrical  muscle signals.  The big disadvantage of this device is that it's very do-it-yourself.  It doesn't even have an enclosure and you have to attach your own electrodes and these  electrodes probably have to be wet and in all in all it takes a lot more effort to get  this set up.  But anyway it probably produces very good data and probably is very useful for custom  mods and it's as the name OpenBCI implies it's probably mainly geared towards brain  control interfaces, brain computer interfaces.  Now what I've done with this stuff is I've built a little library called Bideology and  it's geared towards real-time analysis of physiological time series and physiological  time series are different stuff like brain waves for example but also ECG so heart waves  if you want to call it that or even muscle movements or even breathing rates or anything  else you can think of and they are transmitted at different frequencies of course and I'm  using the PANAS time series functionality to make this a little less painless.  First of all it currently supports mind wave and muse.  I'm also working on a bitalino driver but that doesn't really work that well.  If you know what a bitalino is but it's also something for ECG and stuff.  It supports especially multiple and irregular time series so you don't really know when  the data is coming and maybe it has a varying rate or whatever and PANAS really supports  this really well.  Our main feature is integration into the Jupiter notebook and I try to make this relatively  painless.  Now I can try to show you how this works.  I have to adjust the headband to my head.  Now it's streaming but it's not quite right yet.  So this device is a bit more finicky.  That looks a bit more easier than it should but in any case the problem with this kind  of brain wave is this kind of electrophysiological measurement is that virtually anything in your  face or in your head will have a higher or louder signal than your brain.  And for example I can move my eyes.  I can clench my teeth.  And this time the, sorry I'm displaying here two channels.  The blue one is the left one and the right one is the red one is the right one and I  can just try to move my left face.  It doesn't really work currently.  So now I can move my left face and my right face.  And as you can see the strength of the signal is slightly different because it's a different  distance.  So the architecture of how this works is that there's an async IO server that is a different  process and I did that to isolate all this Bluetooth handling stuff from the notebook  and it communicates with the Bluetooth headset to get the data and then it can send it onwards  to the IPython kernel.  So inside the IPython kernel I have some codes that manages an experiment.  It can record the data and it can then update for example a book a time series or something.  So inside the notebook there's also some, on the browser side there's also some software  currently I'm not using any custom JavaScript earlier I had to but Booker now has this push  notebook and that also works very nicely.  But it's important to know that the browser is sort of a different network endpoints  and the actual server or the kernel and these are different moving paths.  So what Pyseology is mainly about is doing experiments and experiments can be anything  like mostly some recordings and maybe you do some feedback or some sound experiments  or whatever.  I have an experiment class so these are declared like this and in this case I would be declaring  two devices, the MUSE and the MindWave to have these different MAC addresses and then  the server is contacted and tries to reach these devices and stream their data.  This is a more practical example with only one device.  In the second cell there's first of all HTML widget from the IPyWidgets library and this  is later updated to contain some information and I instantiate the experiment class with  a file name where all the data is stored.  Now the experiment class instance is used as a decorator on a handler function and this  handler function is called every time some new data arrives and it checks if the experiment  already has data on the AF7 time series which is one of the channels and then there's display  values thing which updates the HTML dynamically.  In this case just with how long the time series currently is.  So that's the problem, it jumped to 30 seconds because it has data in the queue and I still  have some problems with timing and synchronization and stuff.  It could be a bit smoother but it works quite nicely.  So with relatively simple means I can already have some kind of feedback.  Well synchronization.  These experiment classes contain time series as I said and for example in this case from  the MUSE the AF7 and this shows the first few samples, every sample has a time.  As a time stamp, this time stamp isn't really the real time stamp but rather I try to figure  out inside the server at which point this was measured by some simple heuristics.  Probably MUSE nor the MindWave contain any logic to tell you when they sample something.  Now to analyze it we need to often we need to window this data.  So it's a particular sample of brain wave is relatively useless.  What is more useful is for example different frequencies that you are seeing or different  signal strength over a certain time period.  So for example you would window the data like with a window with three seconds and a step  size of one second that means that the first window is at zero seconds to three seconds  and one to four, two to five and so on.  And this is turned into an iterator and then we can do more processing on it.  So the analysis class then can, so here on the button I pass this processing function  over the windows and then into a data frame and this processing function generates several  features for every window especially important is the standard deviation because this is a  nice way to find if there is noise in the system or any artifacts or bigger artifacts.  On the bottom here I try to or I do calculate some frequency measurements not really important  to understand it right now but there are several frequency bands so when you have alpha waves  you should be more relaxed and better waves mean more concentration and that's, so that's  important to know.  Of course this data frame now is just a standard pandas data frame with columns and now that  we have this data frame information we can actually do normal data science stuff for  example correlations.  Now as I said the MUSE has four channels and two of these are on the front of the head  and these are AF7 and AF8 and I'm plotting these here together.  The first the alpha strength on the left the alpha strength correlates very nicely just  as a better one strength and this also means that even if you have more channels than one  it's still relatively similar information but you can also imagine that having two channels  will measure more or less the same thing is more reliable or more precise.  Now the second thing I tried is to correlate MUSE and mind wave so I did what I showed  earlier I put two devices into an experiment I recorded it I had to wear these devices  at the same time which I want to know because it looks silly but it doesn't really work  as well.  It could mean that I did some other I didn't put much work in it and the signal could be  horrible that could be a reason why this is not such a good correlation.  It could also mean that they have very different latencies but well.  So that's basically everything I have to tell today.  I'm trying to do more experiments but most of the work I have done so far is integrating  these devices and trying to make them work and well so I haven't really progressed into  doing much experimentation.  But anyway the code is also on GitHub I have to publish it later because I have to clean  something up and the slides will also be on GitHub.  This whole notebook presentation and some supporting code will be there and I will treat  it later.  Now I'd like to talk about some other stuff I've been up to.  I've been working on pocket Python which is a library I created to deal with Oxford  Nanopore data which is a sequence DNA sequence so the Oxford Nanopore Minion is a DNA sequence  which is about the size of a computer mouse and it can sequence DNA and it has a particular  data format and I try to work with that and maybe next year I'll present genome sequencing  for hackers.  I'm also working on a workshop called presenting with Jupiter which contains several tricks  that I'm also using here so you probably noticed that I don't have the help thing and the x  processing and various other ugly artifacts and I changed the transition styles and adjusted  the size a bit.  That's all nice to know and it's not so common knowledge.  A lot of presenters had problems here with the screen resolutions.  Anyway I also did something called Jupiter flight gear which is an afternoon hack so I  used flight simulation software and I managed to stream data from the flight gear directly  into the Jupiter notebook and have some graphics or something.  In theory you could do your own autopilot but I just want to mention it here because  I have to, it's sort of cool but I have to abandon it because of time.  Now I'd like to thank you for your attention.  My Twitter handle is Bayesian horse.  I have a GitHub account with Pyzeology especially.  It doesn't have the news code yet but it will today.  Another project I've been working on is Table Cleaner which can do, which cleans up data  frame like data to enter into the errors into data itself and where the notebook assets  stuff is all that I should have deleted it.  So we now have time for questions and I'd like to start with that.  One question.  We should have a microphone but we don't even have a chair.  Yes, it depends if there is, sorry, let's repeat the question.  He's talking about headphones, which name?  They have from Kickstarter, they have EEG sensor somehow and maybe it's an interesting  device to address that.  Yes, I'll try.  I'll see if you want to pull requests or if you need help, I can certainly help you.  Can you please repeat this with ability?  You mean the data quality?  So the question was which has a better data quality and I'd say the news clearly has more  data and you probably can get more information out of it.  It depends for the kind of application you want.  I mean the MindWave, the newest guy stuff does very much signal processing already inside  the device that can have advantages and disadvantages.  I'd say the news produces certainly more data and probably more information, especially  of different parts of the brain.  Hardly.  He can tell some thing about the mental state but even that isn't very useful without knowing  it.  So without knowing, I have to repeat the question.  The question was if you have the recording, can you tell what the person was doing?  So the question was can you tell what someone is doing just from the brain wave data?  No, you can't really because it very much depends on the person and it's very vague information  and you can maybe tell if he is very concentrated or very relaxed but even that depends on how  his brain waves usually are distributed and there are interpersonal differences.  Yes, it's possible to recognize feelings if you set up the experiments right.  I guess you could do that.  The  question is that I only showed two channels and you asked about...  Yes, if I can analyze different kind of wave bands inside the brain waves.  So the data analysis works like you can do a Fourier transform analysis and then you  can detect the strengths of different frequencies and of course you can calculate that.  In my example, I only calculated alpha and beta 1 and I could of course calculate everything  else and it should be more precise with the user and with the mind wave.  Okay so there's no further questions and I'd like to thank you again and have a nice day.  Thank you.
Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_0_215.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_216_4115.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_4116_4367.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_4368_6155.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_6156_6287.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_6288_7043.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_7044_11747.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_11748_11831.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_11832_11951.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_11952_12395.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_12396_12719.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_12720_13223.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_13224_13331.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_13332_14111.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_14112_15647.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_15648_16535.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_16536_18083.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_18084_19847.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_19848_20111.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_20112_20195.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_20196_22019.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_22020_22691.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_22692_22811.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_22812_23507.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_23508_25463.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_25464_25559.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_25560_26279.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_26280_26819.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_26820_33347.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_33348_34067.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_34068_34151.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_34152_34559.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_34560_34799.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_34800_34967.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_34968_37019.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_37020_43463.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_43464_43775.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_43776_43847.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_43848_43919.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_43920_45935.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_45936_48407.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_48408_48587.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_48588_52247.png Andreas_Klostermann_-_Brainwaves_for_Hackers_3_0_52248_53081.png