{"id":686,"date":"2017-07-30T19:34:02","date_gmt":"2017-07-30T17:34:02","guid":{"rendered":"http:\/\/jmladeno.net\/?p=686"},"modified":"2018-11-28T17:30:46","modified_gmt":"2018-11-28T16:30:46","slug":"openbci-ganglion-and-openvibe-for-dummies","status":"publish","type":"post","link":"https:\/\/jmladeno.net\/index.php\/2017\/07\/30\/openbci-ganglion-and-openvibe-for-dummies\/","title":{"rendered":"Connect OpenBCI Ganglion with OpenVibe for Dummies"},"content":{"rendered":"<p>Thanks to the community OpenBCI and <a href=\"http:\/\/phd.jfrey.info\/\">Jeremy Frey<\/a> for your python codes accessible <a href=\"https:\/\/github.com\/OpenBCI\/OpenBCI_Python\">on github<\/a><\/p>\n<p>Connect Ganglion to Ubuntu 16.04 or other versions, via BLE bluetooth, then via LSL to OpenVibe and then via OSC to MAX\/MSP or PureData!<br \/>\nCHECK:<br \/>\n<a href=\"https:\/\/shop.openbci.com\/products\/pre-order-ganglion-board?variant=13461804483\">The Ganglion<\/a><br \/>\n<a href=\"http:\/\/docs.openbci.com\/Tutorials\/02-Ganglion_Getting%20Started_Guide\">a tutorial for using ganglion<\/a><br \/>\n<a href=\"http:\/\/openvibe.inria.fr\/\">OpenVibe<\/a><br \/>\n<a href=\"https:\/\/github.com\/OpenBCI\/OpenBCI_Python\">JFREY&#8217;s Github<\/a><br \/>\n<a href=\"https:\/\/cycling74.com\/products\/max\/\">MAX\/MSP<\/a> or<br \/>\n<a href=\"https:\/\/puredata.info\/\">PureData<\/a> &#8211; open source<\/p>\n<p>Instructions for Dummies, non experts in typing terminal commands!!<\/p>\n<p>For this tutorial, Ubuntu 16.4 was used!!<\/p>\n<p>BEFORE STARTING:<br \/>\nInstall dependencies necessary for this to work!!<br \/>\nYou can copy line by line each of these terminal commands presented here in <strong>bold<\/strong>!!!<br \/>\nCopy here with Ctr-C, and paste in terminal with Ctr-Shift-V!!!<br \/>\nA hint for linux terminals, click on keyboard -arrowUp- to see all the previous commands you typed before and reuse them again with modifications!!!<\/p>\n<p>So, type or just copy\/paste in terminal:<br \/>\n<strong>sudo apt install git python-pip bluez-tools build-essential<\/strong><br \/>\n(you will be asked to type in your password and to confirm the installations)<\/p>\n<p>*explanation:<br \/>\n1. git is needed so that you can download all the files from github of OpenBCI, with git clone<br \/>\n2. python-pip (pip is to install python libraries as we use python code to connect with ganglion)<br \/>\n3. bluez-tools (utilities for bluez &#8211; permits access to BLE bluetooth)<br \/>\n4. build-essential (to compile stuff &#8211; probably already exists in your system)<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>Download files from openBCI<br \/>\n(think about where you want to download it), once you are there then type, copy\/paste in terminal:<br \/>\n<strong>git clone &#8211;recursive https:\/\/github.com\/OpenBCI\/OpenBCI_Python.git<\/strong><\/p>\n<p>Go to the directory you downloaded, called OpenBCI_Python! To do so type or copy\/paste line by line (until &#8211;, so do not copy my explanations on the right) in terminal:<\/p>\n<p><strong>cd OpenBCI_Python\/bluepy\/bluepy<\/strong> &#8212; enter into bluepy<br \/>\n<strong>make <\/strong> &#8212; compile everything needed<br \/>\n<strong>cd ..\/.. <\/strong> &#8212; go back in the OpenBCI_Python folder and type:<\/p>\n<p><strong>pip install -r requirements.txt<\/strong> (maybe sudo required, if so then type again:<br \/>\n<strong>sudo pip install -r requirements.txt<\/strong><\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n*reduce the latencies, EACH TIME YOU TURN ON COMPUTER* remember to copy\/paste this in terminal:<\/p>\n<p><strong>sudo bash -c &#8220;echo 6 &gt; \/sys\/kernel\/debug\/bluetooth\/hci0\/conn_min_interval&#8221;<\/strong><br \/>\n*one line after the other, min before max!!*<br \/>\n<strong>sudo bash -c &#8220;echo 6 &gt; \/sys\/kernel\/debug\/bluetooth\/hci0\/conn_max_interval&#8221;<\/strong><\/p>\n<p>these last 2 commands are necessary because you will lose too many packets from the board OpenBCI ganglion, as the latency of linux is much higher than the one required!! so you need to manually reduce it each time you turn on your computer as linux sets it by default back again! if 6 is too low for your computer type another &#8211; higher- value.<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>if your system can&#8217;t automatically detect ganglion via Bluetooth devices than you need to type a command line to find the ganglion BLUETOOTH MAC address with:<\/p>\n<p><strong>sudo hcitool lescan<\/strong><\/p>\n<p>it will give you an address, so select to copy (with mouse) the one indicated as ganglion, and just ***copy it by clicking <strong>Ctr-Shift-C<\/strong>**** on keyboard!<br \/>\nonce you copied the address of ganglion, then press:<br \/>\n<strong>Ctr-C <\/strong> &#8212; to exit hcitool lescan!<\/p>\n<p>CONNECT TO GANGLION via BLE:<br \/>\nTYPE THIS, don\u2019t copy this line below, because you will loose the address you just copied earlier:<\/p>\n<p><strong>python user.py &#8211;board ganglion -p<\/strong> *** here you will paste the address of ganglion you copied above with <strong>Ctr-Shift-V<\/strong>***<\/p>\n<p>***You do not need to retype each time the same command, just click on the UpArrow on your keyboard! (the MAC address is already typed once, so you don\u2019t need to type it again, so you can copy the next commands in this text below)<\/p>\n<p><strong>python user.py &#8211;help<\/strong> &#8212; here you see what you need to type to connect to openBCI boards!<\/p>\n<p>COMMAND TO SEND LSL TO OPENVIBE:<br \/>\n(-Uparrow- on the keyboard, and just add -a streamer_lsl) giving:<\/p>\n<p><strong>python user.py &#8211;board ganglion -p<\/strong> *ganglion address* <strong>-a streamer_lsl<\/strong><\/p>\n<p>*if we use multiple LSL at the same time* need to name each lsl as:<br \/>\npython user.py -a streamer_lsl ganglion2_eeg ganglion2_id<\/p>\n<p>NB *** If you use WIFI at the same time as bluetooth, it can create a bit of interference!<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>To stream data from ganglion, type:<\/p>\n<p><strong>\/start<\/strong> &#8212; you will see nothing happening for a while, but it is working!! then it will lose some packets, drop packet, which is normal!<\/p>\n<p>if you wish to stop streaming type:<br \/>\n<strong>\/stop <\/strong> &#8211;keep typing even if you dont see what you are typing as the packets keep coming at she same time!<br \/>\nTo take off some electrodes you do not wish to measure, just type<br \/>\n<strong>2<br \/>\n3<br \/>\n4<\/strong><br \/>\ntake off each channel you do not use! one by one!<br \/>\nIn this example we use only channel 1 for recording!<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nNEW TERMINAL FOR OPENVIBE ACQUISITION SERVER:<\/p>\n<p>To use openvibe acquisition server, you need another terminal, find where you installed openvibe and type:<br \/>\n<strong>cd openvibe-<\/strong>1.3.0-src, or the version you have, then go to dist<br \/>\n<strong>cd dist<\/strong><br \/>\n<strong>.\/openvibe-acquisition-server.sh<\/strong> &#8212; RUN IT!!<\/p>\n<p>*** an advice, these names are very long, and to help you with this, type only a few first letters, and then click on Tab key to autocomplete the name of the files!!! here eg, openvibe- acq Tab and it will fill the rest \ud83d\ude42<\/p>\n<p>Once you are in<br \/>\n<strong>acquisition server<\/strong><br \/>\n&#8211; change the Driver into <strong>LabStreamLayer (LSL)<\/strong><br \/>\n&#8211; go to driver properties (<strong>signal stream &#8212; EEG_id (lsl)<\/strong>)<br \/>\n&#8211; go to preferences (<strong>augment drift tolerance &#8212; 100<\/strong>? if not using ERPs which need a smaller value)<br \/>\n&#8211; change <strong>sample count per sent block &#8212; 4 <\/strong>&#8211; if computer is strong! default is 32 &#8212; sends 32 chunks to the designer, if we put 4 chunks, it sends more frequently&#8230; it also needs to be synced with the sampling rate of BLE ganglion (200Hz), so 4 is good!!!<\/p>\n<p>**if multiple ganglions on one PC, need to change connection port (use 2 openvibe acquisition servers)<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nNEW TERMINAL FOR OPENVIBE DESIGNER:<\/p>\n<p>To use openvibe designer, you need to use another terminal, and type:<br \/>\n<strong>cd openvibe-1.3.0-src<\/strong> , or another version you have installed.<br \/>\n<strong>cd dist<br \/>\n.\/openvibe-d Tab<\/strong>, it will auto-fill the rest giving<br \/>\n<strong>.\/openvibe-designer.sh<\/strong> &#8212; RUN IT<br \/>\nOnce you are in the<br \/>\n<strong>designer:<\/strong><br \/>\nopen a file and you will automatically be in scenarios, which give many examples and tutorials!!<br \/>\nScenario Neurofeedback, or scenarios for Motor Imagery or for P300!!<\/p>\n<p>In openvibe designer, there is an OSC controller box, you should add if you want to send data to a sound editing program such as MAX\/MSP, or PureData!<br \/>\nDouble click this box and specify the Ip address you send the data to &#8211; if the receiver is another computer like a Mac or windows which has MAX.<br \/>\nIn the receiving party, there is no need to specify the ip address of the sender!! Only the port specified in the OSC box! however if you are using the sound design on your own computer there is no need to specify any address, it is set by default.<\/p>\n<p>** command linux to find IP address: ifconfig<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Clear STEPS to connect the OpenBCI Ganglion board to a Ubuntu 16.04 linux, via BLE bluetooth! And then via LSL to OpenVibe!!<br \/>\nFor those who really don&#8217;t know anything about terminal commands.<\/p>\n","protected":false},"author":2,"featured_media":691,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-686","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/posts\/686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/comments?post=686"}],"version-history":[{"count":24,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/posts\/686\/revisions"}],"predecessor-version":[{"id":1195,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/posts\/686\/revisions\/1195"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/media\/691"}],"wp:attachment":[{"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/media?parent=686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/categories?post=686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/tags?post=686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}