Getting data out of the Muse2016 EEG headband

The Muse headband is an EEG headband which can relay information from 4 electrodes on your forehead. Pretty dope. The headband comes in two flavors, the 2014 and the 2016 version. The 2014 version is pretty well supported with tools such as muse-io which creates an OSC server from the headband data. The 2016, however, isn’t nearly as well supported.

There is currently an API for Windows and Android. Furthermore there is a tool by a non-muse affiliated developer available on android (muse monitor) for $10. Since this is ResearchOnABudget, we need a way to get to the data and save that money (#lilDicky).

This is a Windows-native app I made by extending one of the examples in the libMuse6.0 SDK. The app connects to the muse, and whenever it receives a packet, it transmits it on local UDP port 777 (127.0.0.1:777).

You can download the app here: [app download link]

This is still a work in progress, so if you have any suggestions, I can try to incorporate them.

How to Use:

  • You’ll need a Muse2016 headband and an appropriate BLE dongle.
  • Pair the Muse2016 with your Windows PC
  • Install the app by unzipping the folder and double clicking on the .appxbundle file
  • Run the app!
  • Hit the refresh button to see the Muse’s you can try to connect to (lists the ones paired)
  • Hit connect. The light on the Muse2016 will bounce back and forth, the app will say connecting
  • Wait a little bit, and the light on the Muse2016 will turn solid, then the app will say “CONNECTED”
  • Signals are now being transmitted at 127.0.0.1:777
  • Change the signal you want to listen to using the drop-down

gettingdataudpscreenshot

Here’s an example of getting the data into matlab via UDP:

Accelerometer Data:

matlab_screenshot_accel

EEG Data:

matlab_screenshot


%%
data = {''};
u1 = udp('127.0.0.1',765,'LocalPort',777);

u1.InputBufferSize = 1024;

u1.DatagramTerminateMode = 'on';

%u1.DatagramReceivedFcn = {'udpcallback'};

fopen(u1);

%%
buf = 400;
dataVec = zeros(buf,7);
refresh = .02;
tic;
startTime = toc;
lastTime = startTime;
go = 1;

while(go)

str = fscanf(u1);
parts = strsplit(str,',');
newVec = zeros(1,7);
if(length(parts)==7)
 for jj = 1:7
 if(length(str2num(parts{jj}))==0)
 newVec(jj)=0;
 else
 newVec(jj) = str2num(parts{jj});
 end
 end
end

dataVec(1:end-1,:) = dataVec(2:end,:);
dataVec(end,:) = newVec;

if((toc-lastTime)>refresh)
 figure(1)
 plot(dataVec(:,1:6))
 title(num2str(mean(diff(dataVec(:,7)))))
 drawnow;
 lastTime = toc;
end

if(toc > 10)
 go = 0;
end

end

%%
fclose(u1); delete(u1)

Advertisements

21 thoughts on “Getting data out of the Muse2016 EEG headband

    1. thanks, that’s interesting. Does the app say the muse is “connected” and does the light on the muse turn solid white? Also, is the muse plugged in when you did it? For me, I tried all my tests with the muse not plugged in. Im curious to help!

      Like

      1. yes, i’m using 2016 version and muse’s led turn solid white when program says “connected”. my computer(laptop) using bluetooth 4.0.
        i think reason is i’m in college and there’s couple of bluetooth devices and muse headbands when i connect with my muse headband, so i think that made trouble with my connection. or Bluetooth Low Energy is problem maybe… uses too many energy because sending gyrosensor or accelerometer, eec, etc data… just my guess.

        also i’m korean, so i’m not very good at english. i’m apologize…

        Like

      2. OK, this is very interesting. When the muse connects and the LED is solid white, how long until it says “disconnected”? What happens when you leave the muse on the table (not moving at all)? Also, what happens when you try changing the drop-down from ACCEL to EEG?

        Also, I was in Seoul in August, very beautiful place!

        Like

  1. I am having problems installing. I am trying to install via powershell since double clicking the .appxbundle is nto doing anything

    C:\muse\GettingData_1.0.2.0_Test> Add-AppxPackage .\GettingData_1.0.2.0_x86_x64.appxbundle

    Add-AppxPackage : Deployment failed with HRESULT: 0x80073CFD, A Prerequisite for an install could not be satisfied.
    Unspecified error
    NOTE: For additional information, look for [ActivityId] 7076b116-87ca-0000-f338-7970ca87d201 in the Event Log or use
    the command line Get-AppxLog -ActivityID 7076b116-87ca-0000-f338-7970ca87d201
    At line:1 char:1
    + Add-AppxPackage .\GettingData_1.0.2.0_x86_x64.appxbundle
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (C:\muse\Getting…_x64.appxbundle:String) [Add-AppxPackage], Exception
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

    Like

    1. Hey,

      I’m not sure what’s going on. I’m assuming you’re using Windows 10 right? Googling the error didn’t work either. Worst case scenario, I think I’m going to redo the app to be a command line thing (so that it doesn’t have to be an appx package).

      Like

    1. Hi,

      In the next version I do I’ll make it so you can control the port number. In the meantime, can you try transmitting something from matlab or another program on port 777 to see if it works (via UDP)? That way we can figure out if it’s your firewall or something else

      Like

  2. Hi,
    Great approach! However, it doesn’t seem that the current version is actually dumping anything on udp (any ports). Would it be possible to dump som debug information in the app on which port data is transmitted to?

    Like

      1. Sorry, I didn’t see your reply. Yeah, data is showing up in the 6 fields, but it doesn’t seem to be dumped anywhere

        Like

  3. So this requires MatLab to run is that correct? And MatLab isn’t a free app but an expensive or subscription package?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s