Bluetooth Connectivity on Linux


#1

Background:
I have a 2014 version of the Muse headband. For various reasons (the most fundamental one being I’m not using an x86 architecture machine) I’m unable to use muse-io and MuseLab from the research tools, so I’ve been writing my own application to gather the raw EEG data.

I’m able to successfully pair my headset, mark it trusted and connect it as an rfcomm serial device (I can provide specific details of how I’ve done this if necessary). My application is opening the serial port at 115200,8n1 with a 1 second timeout on reads (though obviously I never get close to that once data starts flowing). I developed it based on packet specification at http://developer.choosemuse.com/protocols/bluetooth-packet-structure so I can identify which packets are coming in and how I should process them.

Currently my application is only handling uncompressed EEG packets, I haven’t written the code to process compressed EEG messages.

I have verified that I can read back the settings I’ve applied (preset, notch filter, error count, etc.) using the status serial command.

Now to my question.

When running with the default preset (10) I’m only finding about seven samples per second of the uncompressed EEG packets. If I load the AB or AD presets I’m getting about 150, but at no point do I get anywhere near the 220 and 500 Hz sample rate I would have expected based on http://developer.choosemuse.com/hardware-firmware/headband-configuration-presets Additionally there appears to be considerable noise the the signals.

Does anyone have any advice on what to check or whether these numbers I’m seeing are more-or-less expected and, in that case, how I should interpret them?


#2

If you search the forum way back in to the dark ages of 2014, you’ll find a bunch of us were cracking the code of the bluetooth protocol. It is a bit of a nightmare with all the big-endian little-endian changes. I myself just about got Muse directly connected to an Arduino, but never got around to decrypting the the compressed EEG packets. Then they released the SDK and the open source projects to connect dried up.

If you’re looking for a good place to start your own however, check out this c#.net code., specifically this file for all the bit shifting fun! There are also some good links in this post.

After reading all that, if you want to take the easy route, you can use my Muse Monitor app for Android or iOS and stream the data as OSC directly to your computer :wink:


#3

The data rates of 220Hz and 500Hz are accurate. You should be able to verify this with muse-io and MuseLab on a separate machine.

Whenever you are receiving data from the headband in any application, try to offload expensive operations like writing to a file or updating the UI to a separate thread as this can impact the rate at which the packets are received.