[Mac] Simple EEG extraction from raw data (newbie question)


#1

Hi all !

First of all, thanks for this headset, looks promising :slight_smile:

I’m getting started, and managed to launch muse-io to get the data on port udp:5000 on my macbook pro (muse-io --preset 14 --device Muse --osc osc.udp://localhost:5000) No I want to make sure that I can browse through the real-time data to extract info (e.g. EEG).

I’ve tried the following :
1 - here https://sites.google.com/a/interaxon…useio/tutorial you mention an “osc-dump” command that isn’t found in my terminal
2 - I tried to connect with MuseLab (worked fined), and launch a “Recording”, but then I get a hudge file with strange encoding, not containing any eeg info (which according to https://sites.google.com/a/interaxon…paths—v3-6-0 should be contained under “muse/eeg” elements)
3 - I tried muse-player --input-osc-port udp:5000 -F output.muse but then got a cryptic error “server error 9904: cannot find free port”

What is the most elegant/efficient way to get the flux in real-time and extract data from it ? muse-player did seem to be the best candidate for this.

What I want to achieve is quite simple, I’d like a stand-alone Java main, an Android app or an iOS app to be able to get specific kind of signals (eg. raw EEG data) from a paired Muse headset and do some stuff according to the values. Is there somewhere an example of API use to get the signal and treat it (in java for instance) ?

Thanks for your time,
Alex


#2

Managed to make muse-player work by publishing data on other port than default port (muse-io --preset 14 --device Muse --osc osc.udp://localhost:5001) and then launching muse-player -l udp:5001

I read that Android & iOS SDK are still under development, yet I still wonder if there is a recommended way to get the data in a java main? Would there be a piece of example somewhere ?
Thanks a lot,
Alex


#3

Hi there,

  1. With the latest SDK with the standalone installer, liblo is no longer globally installed on your machine, and so you don’t have oscdump. However, you can use MusePlayer to achieve the same thing, e.g.:
muse-player -l 5000 -D
  1. MuseLab records data in the .muse format, which is a binary format that uses Google protocol buffers. Sere here for more info: https://sites.google.com/a/interaxon.ca/muse-developer-site/data-files You can convert it to other formats using MusePlayer.

  2. If you tried to run MusePlayer while another program (say, MuseLab) was also listening on port 5000, then you’ll get that error. Two processes cannot listen on the same port. If you want to have them both running and receiving the same data, you must specify two different ports for MuseIO to send to, and have one receiver listening to one port, and one to the other. To do this with MuseIO:

muse-io --osc osc.udp://localhost:5000,osc.udp://localhost:5001

Server error 9904: cannot find free port
#4

Hi again ! Thanks a lot for you answer.
1 : ok, what should I do then to have the oscdump command available ?
2 : ok but I’d really like to have a standalone program parsing the Muse EEG, not having to use external tools
3 : ok this one was obvious, silly me :slight_smile:

3 follow ups, then :
1 - Generating Muse messsages parser in Java with Protocol Buffer

[EDIT] Actually this was due to the fact that I used protocol buffer 3.0, and Muse’s proto file is not ready for it yet
I leave the comments below so that users facing the same issue know how to fix this :
=> Check that you downloaded the correct version of protocol buffer (which is 2.X)
=> use configure, make and make install to install it and make the protoc command available
=> check that protoc --version returns the expected version
=> then as explained here generate the java code use protoc https://sites.google.com/a/interaxon…ite/data-files
=> to make the generated java java class compile, of course you’ll need the protoc jar, if you do not have maven installed and hence can’t build it yourself I’ve found these URLS https://repo1.maven.org/maven2/com/g…protobuf-java/

  • I tried to generate the Protocol Buffer parser as explained here https://sites.google.com/a/interaxon…ite/data-files
    But I first got a warning [libprotobuf WARNING google/protobuf/compiler/parser.cc:471] No syntax specified for the proto file. Please use ‘syntax = “proto2”;’ or ‘syntax = “proto3”;’ to specify a syntax version. (Defaulted to proto2 syntax.)

And then many errors like this one :
Muse_v2.proto:186:18: Message extensions cannot have required fields.

I modified the .proto file to specify a syntax version (did try with proto2 and proto3), which got me rid of the warning but no of the errors.

So as this guy http://forum.choosemuse.com/forum/de…2-6-0-required I modified all “required” occurence to “optional” and the code got generated. Hope this is ok ?

2 - Now that my parser is compiling, how can I get my muse files without using MuseLab ?

When I launch the muse-player without any output parameter, it prints me the EEG messages on screen without any issue. But if I specifiy an output muse file with the -F parameter it fails with the following errors :

> muse-player -l udp:5001 -F eeg_neutral.muse
Muse Player 1.6.0
Input:
udp:5001
* OSC port: udp:5001 (Hit Control-C to stop)
Output:
* Muse file: com.irealite.muse/inputs/binary/eeg_neutral.muse
Playback Time: 0.6s : Sending Data Exception in thread Thread-2:
Traceback (most recent call last):
File "/Users/XXXX/MusePlayer-MacOS-1.6.x/workspace/build/muse-player/out00-PYZ.pyz/threading", line 810, in __bootstrap_inner
File "/Users/XXXX/MusePlayer-MacOS-1.6.x/workspace/build/muse-player/out00-PYZ.pyz/threading", line 763, in run
File "/Users/XXXX/MusePlayer-MacOS-1.6.x/workspace/build/muse-player/out00-PYZ.pyz/output_handler", line 76, in start
File "/Users/XXXX/MusePlayer-MacOS-1.6.x/workspace/build/muse-player/out00-PYZ.pyz/output_handler", line 38, in broadcast_message
File "/Users/XXXX/MusePlayer-MacOS-1.6.x/workspace/build/muse-player/out00-PYZ.pyz/output_handler", line 598, in receive_msg
KeyError: u'EEG_MICROVOLTS'

Am I doing something silly here ?

3 - Let’s say I’ve got my muse file, how can I get my parser to work

Ok so as long as 2/ is not fixed I’ll use MuseLab to get my Muse files. I’ve recording a simple EEG using MuseLab, and then wrote the following java code to parse this file :

// Step 1: get muse file as byte array
byte[] museFileContent = getBytesFromFile("inputs/muselab_recorded_eeg.muse");
// Step 2: use generated parser to parse from EEG
EEG eeg = MuseDataSerializer.EEG.parseFrom(museFileContent);

I get the following exception (same as http://forum.choosemuse.com/forum/de…alid-wire-type actually) :

com.google.protobuf.InvalidProtocolBufferException : Protocol message tag had invalid wire type.
at com.google.protobuf.InvalidProtocolBufferException .invalidWireType(InvalidProtocolBufferException.ja va:99)
at com.google.protobuf.UnknownFieldSet$Builder.mergeF ieldFrom(UnknownFieldSet.java:498)
at com.google.protobuf.GeneratedMessage.parseUnknownF ield(GeneratedMessage.java:193)
at com.ix.basis.muse.MuseDataSerializer$EEG.<init>(Mu seDataSerializer.java:2637)
at com.ix.basis.muse.MuseDataSerializer$EEG.<init>(Mu seDataSerializer.java:2620)
at com.ix.basis.muse.MuseDataSerializer$EEG$1.parsePa rtialFrom(MuseDataSerializer.java:2707)
at com.ix.basis.muse.MuseDataSerializer$EEG$1.parsePa rtialFrom(MuseDataSerializer.java:1)
at com.google.protobuf.AbstractParser.parsePartialFro m(AbstractParser.java:141)
at com.google.protobuf.AbstractParser.parseFrom(Abstr actParser.java:176)
at com.google.protobuf.AbstractParser.parseFrom(Abstr actParser.java:188)
at com.google.protobuf.AbstractParser.parseFrom(Abstr actParser.java:193)
at com.google.protobuf.AbstractParser.parseFrom(Abstr actParser.java:49)
at com.ix.basis.muse.MuseDataSerializer$EEG.parseFrom (MuseDataSerializer.java:2846)

Thanks a lot,
Alex


#5

Please let me know if I should post this in the Developper forum.
In the meantime, I can live with redirecting the screen logs of museplayer and use an ad-hoc parser, but I’d really like to see these questions answered before choosing Muse as the headset we’ll use for our app.

Regards,
Alex


#6

Hi Alex -
Thanks for pointing this out, we updated the protobuf file to work with protobuf 2.6 and proto3. You can get the new file here:

  • Paul