Muse Data File creation with Protocol Buffers


I’ve got the Muse_v2.proto from and got it in my android project ok with protobuf-java-2.5.0.jar
I think I understand how to use MuseDataSerializer to read data, but what I want to do is create my own recordings for playback in the Muse Player.

Is this possible and if so could we have a quick example of creating a couple of data points to file?


This java code works to create a file… but playback crashes muse-player, so I’ve no idea what the minimum data set is.
Can someone shed a little light on this for me please?

EEG eegData = EEG.newBuilder()

MuseData museData = MuseData.newBuilder()
        .setExtension(EEG.museData, eegData)

MuseDataCollection museDataCollection = MuseDataCollection.newBuilder()


Playing it back dies:

\Muse\muse-player.exe -f test.muse -D
Muse Player 1.8.4
  * Muse file(s): ['test.muse']

  * Screen output mode
Exception in thread Thread-1:
Traceback (most recent call last):
  File "D:\Jenkins\workspace\MusePlayer-Win32-1.8.x\build\muse-player\out00-PYZ.pyz	hreading", line 810, in __bootstrap_inner
  File "D:\Jenkins\workspace\MusePlayer-Win32-1.8.x\build\muse-player\out00-PYZ.pyz	hreading", line 763, in run
  File "D:\Jenkins\workspace\MusePlayer-Win32-1.8.x\build\muse-player\out00-PYZ.pyz\input_handler", line 120, in parse_files
  File "D:\Jenkins\workspace\MusePlayer-Win32-1.8.x\build\muse-player\out00-PYZ.pyz\input_handler", line 149, in __parse_head
IndexError: list index out of range


HI Enigma,

What you’re trying to do should definitely work, however what you’re missing here is that you didn’t give a protocol buffer version to your file.

Muse player is crashing because it’s failing to find a protocol version. I will make sure that the next release gives a better error to indicate the cause.

Each DataCollection should contain the protocol version. The newest version is protocol version 2.

On a side note, each DataCollection may contain more than one sample before writing it. In your code above it appears that you’re writing each sample to the file one at a time which means a significant amount of overhead for each sample.

Hope that helps.


Thanks Farough. I managed to figure it out while the forum was offline :wink: For others struggling they key is to make sure the datalength and version are little endian!

            byte[] dataLengthBytes = ByteBuffer
            byte[] versionBytes = ByteBuffer
            dataFileOutputStream.write(dataLengthBytes);//Data Length