{"id":2935,"date":"2017-05-16T20:33:15","date_gmt":"2017-05-16T20:33:15","guid":{"rendered":"http:\/\/www.richardmudhar.com\/blog\/?p=2935"},"modified":"2020-04-22T11:17:48","modified_gmt":"2020-04-22T11:17:48","slug":"eeg-open-source-hardware-and-software-search","status":"publish","type":"post","link":"https:\/\/www.richardmudhar.com\/blog\/2017\/05\/eeg-open-source-hardware-and-software-search\/","title":{"rendered":"EEG Open Source hardware and software search"},"content":{"rendered":"<blockquote><p>A couple of months in the laboratory can frequently save a couple of hours in the library.<\/p>\n<p style=\"text-align: right;\"><a href=\"https:\/\/en.wikiquote.org\/wiki\/Frank_Westheimer\">Frank Westheimer<\/a><\/p>\n<\/blockquote>\n<p>And now we have Google \ud83d\ude09 In an attempt to avoid some of that time in the lab <a href=\"http:\/\/www.richardmudhar.com\/blog\/2017\/05\/building-the-mind-mirror-filter-bank\/\">lining up a load of analogue filters<\/a> I was tempted to go DSP, but I lack the DSP smarts to do this in hardware, so I turned to the Big G again. Turns out I didn&#8217;t spend enough time in the library.<\/p>\n<p>An EEG has two technical challenges, the hardware of the signal-conditioning amplifiers, and then the display mechanism, which was an analogue filter bank and LEDs in the original Mind mirror, and a computer display afterwards. This is software, and in modern practice this hardware\/software division is clear. There has been a lot of open source activity in this field, although as it happens I am still drawn to the retro.<\/p>\n<h2>Hardware<\/h2>\n<p>There are two big open source\/hardware projects for EEG hardware that I can find. <a href=\"http:\/\/openbci.com\/\">OpenBCI<\/a> seems to be in the lead with a multichannel board that digitises 16 channels of EEG and sends this via Bluetooth to a computer. There is another one, OpenEEG, which seems to be at least 15 years old. Anybody who still <a href=\"http:\/\/openeeg.sourceforge.net\/doc\/wb2004.html\">keeps their introductory material in Adobe Flash<\/a> has clearly not kept up with the times.<sup id=\"fnref-2935-1\"><a href=\"#fn-2935-1\" class=\"jetpack-footnote\">1<\/a><\/sup><\/p>\n<p>The obvious one to favour is OpenBCI, but there&#8217;s one small problem. It&#8217;s <a href=\"https:\/\/shop.openbci.com\/collections\/frontpage\">shockingly expensive<\/a>. A Cyton + Daisy RF module gives me an impressive 16 channels <a href=\"https:\/\/shop.openbci.com\/collections\/frontpage\/products\/cyton-daisy-biosensing-boards-16-channel?variant=38959256526\">for about a thousand dollars<\/a>. In comparison, the <a href=\"http:\/\/www.biofeedbackshop.biz\/digital-sampling-units\/21-vilistus-4.html\">Vilistus 4 interface<\/a> is \u00a3650 (\u00a3850 with Bluetooth).<\/p>\n<figure id=\"attachment_2936\" aria-describedby=\"caption-attachment-2936\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2017\/05\/1705_mind-mirror-self-training-edition-1.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-2936\" src=\"https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2017\/05\/1705_mind-mirror-self-training-edition-1-550x550.jpg?resize=550%2C550\" alt=\"\" width=\"550\" height=\"550\" srcset=\"https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2017\/05\/1705_mind-mirror-self-training-edition-1.jpg?resize=550%2C550&amp;ssl=1 550w, https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2017\/05\/1705_mind-mirror-self-training-edition-1.jpg?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2017\/05\/1705_mind-mirror-self-training-edition-1.jpg?resize=50%2C50&amp;ssl=1 50w, https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2017\/05\/1705_mind-mirror-self-training-edition-1.jpg?w=600&amp;ssl=1 600w\" sizes=\"auto, (max-width: 550px) 85vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-2936\" class=\"wp-caption-text\">\u00a3540? You have to be kidding, right?<\/figcaption><\/figure>\n<p>Unfortunately in the latter case one has to buy a 1984 DOS looking piece of software for \u00a3540, which is apparently <em>the most advanced Mind Mirror program yet<\/em>. Even if I were a billionaire it would pain me to hand over \u00a3540 for something that looks like an old program I wrote for a BBC Micro in the late 1980s tracking galvanic skin resistance. But compared to OpenBCI their hardware is pretty good value.<\/p>\n<p>OpenEEG has the problem of being 10-15 years old. The <a href=\"http:\/\/openeeg.sourceforge.net\/doc\/modeeg\/modEEGamp-v1.0.png\">schematic is from 2003<\/a>, but pretty much how I would have done it. It doesn&#8217;t base it all on a proprietary chip, if I blow the input up the INA114P can be changed out for about \u00a37. <a href=\"https:\/\/www.olimex.com\/Products\/EEG\/OpenEEG\/\">It&#8217;s available<\/a> for ~\u00a375 assembled, which is sort of within the groove. I&#8217;m kind of up to \u00a3200 interested in this, not much more. It&#8217;s only two channel. I could get the digital interface for another \u00a350.<\/p>\n<p>So although it&#8217;s old, OpenEEG matches my budget and requirements better. There&#8217;s not much point in me trying to wrangle the analogue front-end myself, unless I use active electrodes, in which case I can lose the INA114P and I may as well make the analogue back-end LPF of OpenEEG on veroboard<\/p>\n<h2>Software<\/h2>\n<p>Looks like I am late to the party and <a href=\"http:\/\/uazu.net\/eegmir\/\">EEGMIR from Jim Peters on the openEEG project<\/a> had largely solved this for me more than 10 years ago. Now I just said a lot of rude things about Vilnius&#8217;s<em> most advanced MM software<\/em> looking fugly, and EEGMIR isn&#8217;t a thing of beauty either<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2017\/05\/1705_eegmir2.gif\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2937\" src=\"https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2017\/05\/1705_eegmir2.gif?resize=400%2C300\" alt=\"\" width=\"400\" height=\"300\" \/><\/a>but you can&#8217;t grouse about the price, if it works \ud83d\ude09 Instant win. Since it runs on Linux it will be Raspberry Pi friendly, in theory, though I have no idea of how much Linux has changed in the intervening 14 years. The nice thing about the Pi is all those GPIO pins &#8211; so I can hate on this display all I like, but if I want it to be on LEDs I can do it. And Jim Peters seems to be using IIR filters from the filter description language. I would need to purchase the \u00a350 <a href=\"https:\/\/www.olimex.com\/Products\/EEG\/OpenEEG\/\">EEG Digital board<\/a> or hack a PIC or an Arduino to output the openEEG type 2 serial data format. A 16F88 would probably cope a treat on two channels. <!--more--><\/p>\n<p><a href=\"http:\/\/www.shifz.org\/brainbay\/manuals\/brainbay_developer_manual.pdf\">BrainBay&#8217;s developer manual<\/a> describes the openEEG data format thusly:<\/p>\n<p>The P2 Firmware Protocol was the initial transmission protocol of the OpenEEG<br \/>\nproject, used by ModularEEG.<br \/>\nP2 uses 17 data bytes to transmit 6 channels of EEG data:<br \/>\n1: sync0; \/\/ synchronisation byte 1 = 0xa5<br \/>\n2: sync1; \/\/ synchronisation byte 2 = 0x5a<br \/>\n3: version; \/\/ version number = 2<br \/>\n4: count; \/\/ packet counter. Increases by 1 each packet.<br \/>\n5: Chn1low \/\/ channel 1 low byte<br \/>\n6: Chn1high \/\/ channel 2 high byte<br \/>\n7: Chn2low \/\/ channel 2 low byte<br \/>\n8: Chn2high \/\/ &#8230;<br \/>\n9: Chn3low<br \/>\n10: Chn3high<br \/>\n11: Chn4low<br \/>\n12: Chn4high<br \/>\n13: Chn5low<br \/>\n14: Chn5high<br \/>\n15: Chn6low<br \/>\n16: Chn6high \/\/ channel 6 high byte<br \/>\n17: switches; \/\/ State of PD5 to PD2, in bits 3 to 0.<\/p>\n<p>To actually get timing info you have to get that from the <a href=\"http:\/\/openeeg.sourceforge.net\/doc\/modeeg\/firmware\/modeeg-p2.c\">firmware code<\/a> comment<\/p>\n<p>Packet Format Version 2<\/p>\n<p>17-byte packets are transmitted from the ModularEEG at 256Hz, using 1 start bit, 8 data bits, 1 stop bit, no parity, 57600 bits per second.<br \/>\nMinimal transmission speed is 256Hz * sizeof(modeeg_packet) * 10 = 43520 bps.<\/p>\n<p>Note that data is transmitted in big-endian format.<br \/>\nBy this measure together with the unique pattern in sync0 and sync1 it is guaranteed, that re-sync (i.e after disconnecting the data line) is always safe.<\/p>\n<p>and I believe the channels were 10-bit resolution, although the data format allows 16 bits<\/p>\n<h4>Big open source display software projects<\/h4>\n<p><a href=\"http:\/\/www.shifz.org\/brainbay\/\">BrainBay <\/a>talks the right talk in filter design and is a graphical filter graph sort of application, although mainly using FFT. Bit it runs only on Windows, and I don&#8217;t really want to lug a computer around. I could jump over using a Raspberry Pi or suchlike, but not a whole computer. Plus it&#8217;s always worrying when the <a href=\"http:\/\/www.shifz.org\/brainbay\/history.htm\">last news item<\/a> is from over five years ago&#8230;<\/p>\n<p><a href=\"http:\/\/openvibe.inria.fr\/\">OpenViBE <\/a>seems more actively developed. And it will run on Linux, so it might run on a Pi. But I get to compile it from source, which is another steep learning curve, so I may stick with the old Open EEG EEGMIR code for starters.<\/p>\n<div class=\"footnotes\">\n<hr \/>\n<ol>\n<li id=\"fn-2935-1\">\nThe sooner the company Adobe can be stamped into the ground and turned to dust for dreaming up such an evil concept as the Creative Community software rental scam the better IMO. I am glad that the Internet finally picked up the fact Adobe is an insidious protection racket holding your work to ransom and rerouted around it bringing us HTML5 audio and video. Creative Cloud is the epitome of what&#8217;s <a href=\"http:\/\/www.richardmudhar.com\/blog\/2014\/10\/10-reasons-for-getting-out-of-the-cloud\/\">wrong with the damn Cloud<\/a>. They got you by the goolies,&#160;<a href=\"#fnref-2935-1\">&#8617;<\/a>\n<\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A couple of months in the laboratory can frequently save a couple of hours in the library. Frank Westheimer And now we have Google \ud83d\ude09 In an attempt to avoid some of that time in the lab lining up a load of analogue filters I was tempted to go DSP, but I lack the DSP &hellip; <a href=\"https:\/\/www.richardmudhar.com\/blog\/2017\/05\/eeg-open-source-hardware-and-software-search\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;EEG Open Source hardware and software search&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[57,334],"tags":[332,333],"class_list":["post-2935","post","type-post","status-publish","format-standard","hentry","category-electronics","category-strange","tag-eeg","tag-mind-mirror"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5aOO7-Ll","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/posts\/2935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/comments?post=2935"}],"version-history":[{"count":9,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/posts\/2935\/revisions"}],"predecessor-version":[{"id":3880,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/posts\/2935\/revisions\/3880"}],"wp:attachment":[{"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/media?parent=2935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/categories?post=2935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/tags?post=2935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}