AV-Portal 3.23.2 (82e6d442014116effb30fa56eb6dcabdede8ee7f)

Brain Waves for Hackers

Video in TIB AV-Portal: Brain Waves for Hackers

Formal Metadata

Brain Waves for Hackers
Title of Series
Part Number
Number of Parts
CC Attribution 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 purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date
Production Place

Content Metadata

Subject Area
Andreas Klostermann - Brain Waves for Hackers Using the Neurosky Mindwave headset we can read brain waves via bluetooth. In this talk I will present ways to interface with this device and to analyze their data, mostly from the perspective of a Python hacker, and not so much from the perspective of academic research or the development of production-ready software. I will convey the basic scientific and technical background, keeping in mind the non-medical audience, and touch on several practical applications, especially Neurofeedback and its use for personal mental training and potential therapeutic uses. The Audience can expect to walk away with a basic knowledge of EEG analysis, Neurofeedback and how to start experimenting with these devices on their own. ----- A new class of cheap consumer EEG devices allows ordinary hackers and even high school students a glimpse into the human brain. This talk will present how to use the "Neurosky Mindwave" headset with python software, and lay out the basic scientific and technical background. The Mindwave Mobile is a device that can be easily talked to using bluetooth, and it talks a binary protocol which is specifically designed to be useful without much computing power in the receiving device or advanced knowledge of signal processing. In fact, an Arduino with a few lines of code is perfectly capable of parsing some of the byte stream and reacting to the mental state of the user, while fully-featured python software can do advanced analysis using PyEEG and Pandas. The same hardware module and protocol is used in the Nekomimi headset (mind-controlled cat ears for cosplay) and some Boardgames (MindFlex). A python library for interfacing with the headset is presented and will be demonstrated on stage. Mostly kivy applications will be used. Also I will present some data analysis you can perform with pandas and scipy. Neurofeedback is a type of mental exercise where a computer uses the EEG data to direct the user towards certain mental states. In the easiest configuration a program would display a bar with the "concentration" level, and the user would learn how to tilt this bar upwards. In more complicated setups a game could react favorably towards states like relaxation or concentration. Using Gamification, Neurofeedback can provide a more engaging experience for children or adults, than other techniques with similar goals, like mindfulness meditation, and the more immediate feedback should enhance the effectiveness of mental training, though that has not been investigated scientifically yet. Neurofeedback has been shown to be effective (albeit not recommended as sole treatment) in Patients with Attention Deficit Hyperactivity Disorder (ADHD), Epilepsy and Dementia. Some background about these conditions and applications of Neurofeedback to them will be given. The first use of Neurofeedback was done in Cats, during early experiments with EEG electrodes in the 60ies. Cats where conditioned to exhibit certain wave patterns, and later, due to a coincidence, the researchers noticed that the conditioned cats where more resistant to epilepsy-inducing medications. The effect has since been reproduced in humans, in cases where medications did not work sufficiently. Ample hints on not to treat any of this information as medical advice will be provided. The goal of this talk is to promote Neurofeedback as a useful mental training and to encourage development of applications around Neurofeedback and the analysis of EEG data, from the perspective of a python hacker. I gave a similar talk at PyConDe 2013 in Cologne. The new talk will be in English, show some improvements on the software, and more advanced demonstrations.
Keywords EuroPython Conference EP 2014 EuroPython 2014
Area Logical constant Dialect Observational study Cellular automaton Feedback Sound effect Cartesian coordinate system Flow separation Vector potential Programmer (hardware) Wave Electromagnetic radiation Pattern language Summierbarkeit Quicksort Hacker (term) Computer-assisted translation Amenable group Resolvent formalism
Area Default (computer science) Functional (mathematics) Game controller Multiplication sign Web browser Mereology Complete metric space Wave packet Impulse response Causality Bridging (networking) Entropie <Informationstheorie> Function (mathematics) output Quicksort Position operator
Module (mathematics) Trail Focus (optics) Concentric MIDI Rule of inference Wave packet Neuroinformatik 2 (number) Function (mathematics) Quicksort Form (programming) God
Game controller Whiteboard Mathematical analysis Digital signal Physicalism Quicksort Object (grammar) Game theory Game theory
Functional (mathematics) State of matter Transformation (genetics) Mobile Web Archaeological field survey Parsing Price index Shape (magazine) Raw image format Event horizon Public key certificate Power (physics) Revision control Frequency Root Interrupt <Informatik> Endliche Modelltheorie Communications protocol output Computer-assisted translation Loop (music) Form (programming) Feedback Connected space Orbit Particle system Frequency Error message Function (mathematics) Series (mathematics) Video game Key (cryptography) Quicksort Communications protocol Software protection dongle
Area Presentation of a group Focus (optics) Greatest element State of matter Code Graph (mathematics) Multiplication sign Interface (computing) Parsing Bit Plot (narrative) Medical imaging Different (Kate Ryan album) Function (mathematics) Video game Energy level Right angle Quicksort Electronic visual display
Dependent and independent variables Graph (mathematics) Function (mathematics) Interface (computing) Parsing Quicksort Electronic visual display Food energy Plot (narrative) Frame problem
Graph (mathematics) Electronic mailing list Parsing Computer programming Connected space Sign (mathematics) Process (computing) Exterior algebra Personal digital assistant Different (Kate Ryan album) Order (biology) Electronic visual display output
Group action State of matter Length Multiplication sign Set (mathematics) Parsing Insertion loss Data analysis Food energy Data quality Neuroinformatik Machine learning Bit rate Different (Kate Ryan album) Videoconferencing Beta function Feedback Electronic mailing list Bit Measurement Orbit Wave Frequency Vector space Right angle Alpha (investment) Asynchronous Transfer Mode Histogram Feedback Real number Shift operator 2 (number) Wave packet Number Power (physics) Frequency Data independence Thetafunktion Musical ensemble Boundary value problem output Graph (mathematics) Interface (computing) Mathematical analysis Binary file Cartesian coordinate system Error message Personal digital assistant Function (mathematics) Formal grammar Electronic visual display Routing Library (computing)
Histogram Observational study Confidence interval 2 (number) Measurement Data model Mechanism design Population density Bayesian network Videoconferencing Endliche Modelltheorie System identification Posterior probability Focus (optics) Graph (mathematics) Interface (computing) Sampling (statistics) Bit Instance (computer science) Shooting method Estimation Personal digital assistant Chain Volumenvisualisierung System identification Software testing Quicksort Game theory Object (grammar) Bayesian network Videoconferencing
Sign (mathematics) Multiplication sign Right angle Line (geometry)
Module (mathematics) Enterprise architecture Information Software developer Virtual machine Sound effect Online help Bit Solid geometry Perturbation theory Disk read-and-write head Mereology Flow separation Wave packet Bit rate Different (Kate Ryan album) Quicksort Exception handling
can my name is there still some money and I'm going to tell you a lot about brain waves and how we as Python programmers can use of skills and tools to explore online 1st it medical disclaimer i'm not ratified to give medical advice on on certain medical conditions or treatments that also whatever I say about this treatments I think it was a grain of salt and coincides with a qualified medical doctor if you need to do what I say 1st of all a a lot of brain as as well as you probably know your answers all you princes only you right so the the communicate why are connected signals among other things and the side effect of this signaling is that they send all the electromagnetic waves and it some of this this potential for more the great sense of who gets sort of Summations Secure that you can measure on the skull but as I said from every brain so that means you can't really isolated single cells you can't even all of them on top of you can't even resolve certain brain regions from that was medical devices that make it easy to that is sometimes possible but also quite restricted but there was a signal so extremely weak and noisy and virtually every facial muscle has the strongest signal on the brain it's a relatively early on in the sixties and researchers are still questions this you can actually but you can actually consciously control your brain areas and that did that some experiments on cats they trained the to exhibit strong brainwaves just want them for some constants and there able to control the patterns by just holding registers later these cats were used in experiments to read on that epileptic medication or rather the opposite so medications that a that's missing the epileptic seizures and it turned out that these kids were actually more tolerant of what is new medications than other and so there are more and more resistant to epileptic seizures over the decades and it has turned out that several studies showed In effect from neurofeedback this some of you for that's the positive small communities that are more than common but let's also has a very so the idea of severe conditions and so it's not really amenable philosophers amateur brain scientists from the more important application of your feedback is in the treatment of ADHD which is an attention deficit hyperactivity disorder
of which is characterized by a short attention span of height impulsivity among other things from the consequences are for example higher risk for depression and other
conditions no academic achievement and resources gives individual behavior I was browser but this is not a complete discussion of ADHD because I don't have the time for it and it's very complicated conditions it turns out that these that that's research around ADHD is highly relevant to general mentor training and generally training of for example mentor for causal skills training there's 1 part of the brain which is especially relevant and responsible for the default executive functions of the brain for inputs control and for all sorts of positive features and that is the prefrontal cortex bridges so right in the front as the name implies that and also as is 1 of the most the brain areas because the other animals don't really have all of that developed in prefrontal cortex and that makes us pretty human and shovels all adult country origin is intentionally long except was very good training
on there is such that it turns out that all sorts of activities have been shown to actually train the prefrontal cortex for example meditation as it is in the form of around meditation which was propagated by buddhism mainly about in psychology it often is called mindfulness training on mindfulness-based therapy and In the most basic sense you worked for example concentrated on these sensations of your reasoning and in which try to focus on them but after a few seconds especially when you're big enough you will just drift away and think of something that is also your or your mental voice really go on and your concentrations then you bring it back again as you notice that return the minutes later on so it's a very simple to describe training but very hard to do wouldn't it be nice if there was a significant halo going off track here but your your not focusing anymore and that is basically the idea of new rules feedback training so a computer could give you feedback on your own vocal stated about that but it has to have some way of telling if your focus on if you're not focus so and that is done with the EEG sensors and the big problem with these devices all of these are really expensive and not very practical to use that's
because the company college you numerous God has developed and a basic module which is sort of what was achieved and it does all the amplification
and translated into a digital signal also already with some preliminary analysis which is relatively simple but works quite nicely and it is used
in several devices about the regional sold the company famous for example this what games if you ever saw that you can't control physical objects with your brain and they never really true false barge invented several people also said that uh this is the sort of all respects the chief inside of this probably just exactly
what it what it is supposed to do the and yeah that is a very nice device it's that separates cats years and this cat is unbounded on the on the and according to focus state these models moved over sort of popular in costly and this is the mind more wine versions of these exist but 1 has a USB dongle violent C way of reducing the dominant this communicates with the headset you have more biologically rich has grouped with connected was which is actually more useful but they all tell the same protocol because they all have the same shape the the proper
called tells us about the raw signal attention and meditation values of these are all values which are computed inside the ship the 2 newest guy doesn't really tell us how they don't doing that that but I think it's about the frequency bands I going to that later and this attention and meditation values are just between 0 and 100 and so of this particle it says is designed to be extremely hackable and so therefore it is very concise and for example if you hold it up to now that we know that was able I was just reading a few bytes to tell you is that you is paying attention on on frequency bands and going into that later what they mean but they're essentially they there already was computed inside certificates have us or not we wouldn't have to do fourier transformation then there is the detection for being the events as I said earlier facial muscles all have a higher cost promising gives them some brain of our so it's nice to no sensibly going on for signal detection essentially run the device isn't on orbit to devise detects most interconnection it's nice to know and now we're moving on to the life demonstrations of a drug and the 1st thing is to make a connection why have includes and I have to excuse the survey between those before I went into this room it's had a connection and I hope that will stay that way well no connection song also my review applies really doesn't really work as well as expected the theoretical example this is a feedback loop sort of culture from which I'm going to use later to to some feedback and I have written person so that is provides a protocol and reads protocol and so it's so when the rupiah ever read something from the root to a soccer than the to the powers and then at the expected the functions to the other functions and this is the most the simplest way of it's the most simple form of the state in which I just cleaned out the last attention value is there is 1 isn't really that for but I have to remove so not wanting to know the values between 0
and 100 it is somewhat more difficult to do when you're standing up I the 1st time I give this talk I was wondering what had such as that such a bad signal but it turned out that we need the the whole time I was practicing for the talk was sitting down and then as a that the presentation has adopted worldwide and got got the most significant signal but it's really solving the problem is when I'm standing up on metaphase muscles under the stressed and the brain is is different state of mind has to stay upright and balanced and stuff so that biology sometimes confuse stuff and also uses this also means that you have in our of blue thing gunfire and I I'm not afraid of you and and if you're
life culture can also miss up code now this is a vise and images as a and controlling attention is by sort of mindfulness meditation I concentrate on my Brazilian by tried to consciously put his focus level on was about and also I concentrated on the area below my eyes and that's sort of that's that seems to work reasonably well now they the much as a what you compute imitation red you know I won't comment on this really meditation from me what works from annotation is I think of something that you would draw a door bell smiling smiling baby baby anymore and that sometimes that most now there is something about called Brain-Computer Interfacing Brain-Computer Interfacing means you would use this EEG device to control or something as by essentially it's a bit most basic level you would want to have a bottom but the problem with these also was of these values is usually not only have a right to consciously push the button
but also avoid pushing the bomb and that is much harder to
do now I'm going to show you the all
data and also in the same manner that we had a few frames which relatively good so I'm not going to show you what happens when I move my eyes and as you can see every muscle is so strong and now I'm going to change my and I can use this signal are true to some sort of Brain-Computer Interfacing but it's not really brain it's really muscles and the energy is normally a lecture my all my grand and you would use other sensor responses were also works and I do that by parsing so I'm taking biology the quarter of a
2nd because of data computes the 1st order difference takes absolute and then I mean it's so in this case I'm I'm having right but it it's not Nova process again dollar the but it's a good sign
actually because then you will need it makes a connection if you wanted to program really consumer sent that this kind of to alternatives this kind of connection because it would be high on the list to make that and so I have to
demonstrations list and don't have much time is left OK then a route to 1 which I will not try truth to detect but essentially need to write for the blue the energy to to turn to the brain anymore and now the some of the
top the computed value and I have a couple of in this in this example have also started and then I can more honest consciously or mostly consciously turn the switch on and off In more sophisticated applications you would use machine learning especially if you really want it's up to to you to EEG data not EMG data but also this is the 1 China device only 1 1 should also of of measurement and usually that Computer Interfacing requires more no more data but you can do some some of it was just 1 should I now have to call back to frequency bands in a more sophisticated analysis of EEG data from the I think I didn't explain EEG that was an actual and so follow precedent for grammar and the idea between frequency bands is said right of the brain that tells us something about what the brain is doing and how it's doing it and different frequencies with 10 different stories about the brain but it is rarely but the relationship between what the frequencies mean and show how you measure them so it's very it's very complicated someone just giving superficial from overview of all over at the boundaries of taken from the to DPRK or below 4 we have data associated with deep sleep real that then there's a 4 to 7 on the a set of waves after all as innocent 5 losses edge 15 as far as I've already are associated with relaxation and closed eyes 6 31 in this case is that of the attention is this associated with attention back from in a ditch the therapy you new feedback you tried to the number of training data for attention and don't train that are there are other modes the other ways of detecting attention but that is 1 of them From here on the court example there's a library called ploidy EEG that can compute various stuff among other things as a whole as opposed the relatively of where the power of a certain frequency bins the I have different frequency in the united different frequency boundaries and there are this vector was noted in the documentation he put prior dating that these values from about 1 2nd of data independent try from different the length of time on the 1 hand you want so once frequency computation to be accurate on the other hand you want to give immediate feedback at about after just 5 minutes of running yeah yeah destructing this vector again in 2 different values and then and displaying just a bit of a set of orbitals that are another group was acting up again and I'm not going to turn that cost because this was last demonstration center outcomes from consciously uh manipulators value but it's a bit more tricky than on the attention and mutation rate now on to my 1 of my favorite topics which is that of science I designed it and experiment no literature again I told you I recorded so 2 sessions 1 is the baseline session 1 is a training session during the baseline session I tried to choose not to pay a lot of attention which is really difficult because paying attention is a very physiologically thing and happens all the time especially unconscious so I just took 5 minutes of that data and I counted on that I was more often distracted then I approached reportage 15 seconds of mindfulness and I wrote both of these this the state up to 5 so I just took the route data and dumped it into a fight and that I can't pass it again for data analysis which means it's a bit more reproducible so if I have a back in the fossil and I had but before and then I corrected later I can reproduce my data quite easily so there is here's the data as a histogram I've taken several values of our time and so on well especially in the top we have about 2 moles I think that is the data quality problems so if I wanted to be more sophisticated about it I would have to exclude I believe this and so on the the situations where I am not sure entirely confidence in about the signal because if you move the device you move ahead and stuff this affects also the data now we have a general sense that the the the video in the bottom graph is a bit more to survive at its heart attack and we could do a t-test parts and as always Bayesian it that there is
some did that a there's toolkit on determine which stuff that was playing see us I was playing see as an Markov chain Monte
Carlo engine and if I do that I think I have coach here this is what this this sort and then I just sample tomorrow I already did that and then I can show this is the graph so that it's this I don't want to go into too much detail and is but essentially this true histograms show also the posterior belief about what the model believes where mean values from the the 95 % the highest density intervals Bayesian don't like bayesians often don't like it when you call these confidence intervals and yeah in this case they don't or whatever which is a good thing about that what the intent was is certainly a bit broader on and that is because I just had 15 seconds of recording so 1 true for other ideas the you could explore Brain Computer Interfacing somewhat as I said it's very difficult to really designed rockabilly switches that's not between sessions and between in between people and another thing you could try is watching movie videos and monitoring render when you're getting out of focus the could make actual games that that game mechanics you could say that makes a game mechanics that that character John's when you concentrate on approach make a shooting game the the objective of the gun is controlled by the tensions all the more attention to and because study of and by identification is you make basically the possibilities that you try to read that identifies a person just by their renders a I can recommend several courses but as and only it's all 1 don't explain this animal and I'd like to thank you for your attention few compared instance yes so so
1st of all thanks very much and
interested especially on his courage to actually examples making like mammals and so ph so that the everybody having a question need line there are 2 microphones from sign the sign up and ask you questions like if I wanna start doing this right now and in which during ice-age time the nearest anything where she gets or when they start I think there out several devices out there about the news that might this is probably the cheapest and from what I have seen idea I don't own this the other devices but this is really 1 of the most useful devices that has a dry sense of we don't need to to on once so you have to make it work and just eats the Triple a battery was good 50 and it's also wireless that I think mind with more was greater role that they have a more confortable headset which is about double the price and what about for example if you wanted to use it while making bothering sleeping but that would probably be be a better idea how much does that 1 I
don't know what to trouble of my head but it's at least double the enterprise so this discourse about 110 euros and the other 1 watch 1 goes for I think the next question and I should have as far as his matching resolution of and get better detail is that's happening the the fact that he would have would would assess a 2nd sense of work or anybody to want what being used by 1 and effect we had a separate sense sector except for profit had with that help all with that aim looking for is anything more than a reasonable to to get more channels with these devices I think you can't really amounts several of these devices and that would look kind of stupid I think they they offer these modules as in developed markets so you put it your heart to John hot like you might be able to book something out about that's complicated so as the fundamentalist when you say the different channels it will be different parts of the brain in looking at the end of the year would get more of spatial information but all of that is also a bit restricted thank you I have 2 questions 1st this how much data or a 2nd or minutes invites us this device produce the other thing I don't know and was the top of my head I thought about 5 or 10 kilowatts someone talking kilobytes I think years but that's mostly there already is that you don't really you you can really just got most of it is don't want to go in and have you will a lot the brain rates by shrinking your the and I have a question I would it be possible to trigger different features with different feelings and that is certainly machine learning question and I don't even know what you can develop a reliable switch in with just 1 set China and that is certainly more this requires more market really is we something of a classification and not especially not all that training on the condition that you lied to me using and an end to you have a danger there that you that you overfit on that you all current thoughts so there might be you might try to distinguish between 2 different solids and then some other sorts of the same thing and we don't know it before and it's it's really tough I think tank and the whole thing again because of the month of few