Errors in python program execution while reading data from MUSE


Hi all,
Please help me to debug the error. While i try to execute the sample python program given in Documentation (from MUSE website), am getting the error like “python.exe has stopped working”. I am sending the code below. Please check this out and help me out to know whats the error actually.

from liblo import *

import sys

import time

class MuseServer(ServerThread):

#listen for messages on port 5000

def __init__(self):

    ServerThread.__init__(self, 5000)

#receive accelrometer data

@make_method('/muse/acc', 'fff')

def acc_callback(self, path, args):

    acc_x, acc_y, acc_z = args

    print "%s %f %f %f" % (path, acc_x, acc_y, acc_z)

#receive EEG data

@make_method('/muse/eeg', 'ffff')

def eeg_callback(self, path, args):

    l_ear, l_forehead, r_forehead, r_ear = args

    print "%s %f %f %f %f" % (path, l_ear, l_forehead, r_forehead, r_ear)

#handle unexpected messages

@make_method(None, None)

def fallback(self, path, args, types, src):

    print "Unknown message 
 Source: '%s' 
 Address: '%s' 
 Types: '%s ' 
 Payload: '%s'"  % (src.url, path, types, args)


server = MuseServer()

except ServerError, err:

print str(err)



if name == “main”:

while 1:



Here is the snapshot of the error i have got

and below it is another snapshot of the crash dump file showing no access permission.


The 7th line in my code is actually causing the error i have mentioned about. i.e.,

ServerThread.init(self, 5000)

please anyone help to debug


I’m not certain if this is your issue, but it is important that you make sure no other program is receiving at that port. With ports you can only have one receiver but unlimited senders.

You can check the status of your ports using the following cmd line command:
netstat -a | find “LISTENING” Hope that helps



I haven’t been able to exactly replicate your error yet (that specific message sounds related to memory allocation to me), but I can confirm that on a Windows machine here, using the example’s default port 5001 does not seem to work. I arbitrarily changed it to 5551 and it seems to run OK.

So, basically, I’d agree with Farough that the first course of action is to try a different port, e.g.



Hi Farough and Tom, Now am able to connect muse to my laptop and get eeg readings from above code. changing port through command line helped. Thanks a lot.
Below is the part of sample code to get eeg data:

#receive EEG data

@make_method(’/muse/eeg’, ‘ffff’)

def eeg_callback(self, path, args):

l_ear, l_forehead, r_forehead, r_ear = args

print “%s %f %f %f %f” % (path, l_ear, l_forehead, r_forehead, r_ear)

in the above code, am replacing ‘/muse/eeg’ to ‘/muse/elements/alpha_absolute’ to get only alpha values.
please acknowledge me with further changes to be made in that code. (i don’t know which call_back function to be used, please specify it)


[B]eeg_output_frequency_hz: int, e.g. 500[/B]
The speed of EEG data being sent from Muse in Hz.

I would like to change the speed of EEG data being sent from Muse to 50Hz.
Where should i use the above command?



In reply to your first question, yes, that should work to get the alpha_absolute values. You can just create a new callback function or rename that one, assuming you don’t want it to receive EEG data. The callback function names are up to you.

You cannot change the sampling rate of Muse. If you want to downsample the data once it is sent out from MuseIO, you can do that.

However, why do you want to downsample the EEG data to 50hz?


I am getting exception error if i use my own callback function i.e, “alpha_absolute_callback (self,path,args):” . please send me code to get alpha absolute values.

and i want to downsample eeg to 50hz because i am not able to see all the EEG data in the output prompt.(its scrolling very fast.)
plz tell me where should i execute that downsample command? ( i mean in command prompt or in my python program?? if possible please send me one example of command to downsample EEG data to 50hz)



Can you share the exception with us here? It’s much easier to debug a problem when we can look at the error messages.

The downsampling is not a command. It is something you would have to implement yourself by only considering a subset (e.g. every fourth) of the samples. But I don’t think you need to downsample in your case. Maybe just print the values less frequently, since that’s what you want to do.

That Python example is only meant to demonstrate how to get Muse data into a Python program. Trying to look at the raw data values as strings printed to the terminal is not really very useful. If you want to look at the data to get a sense of it, please try using MuseLab, which will graph the signals for you in an easy-to-understand way.


Here is the output i am getting. am not getting the Alpha values.




Those are not exceptions, that’s the “fallback” function firing. It gets called for all OSC messages that do not have callbacks defined for them. If you don’t want the “Unknown message” stuff to be printed, simply remove the print statement from the fallback function.

The example as it is on the site has three OSC callbacks: one for raw EEG, one for raw accelerometer data, and one for everything else called “fallback”. If you want to only ever print something when alpha_absolute values are received, then you should just have one callback function for that, and either remove the print statements from the others or remove the functions entirely.


Thanks a lot tom, :slight_smile: am able to get only alpha values now.


hi Tom, am getting exception when i try to get attention values. Here is the code am trying to run. please tell me what changes have to be done.

@make_method(’/muse/elements/experimental/concentration’, ‘f’)

def concn_callback(self, path, args):

l_ear, l_forehead, r_forehead, r_ear = args

print “%s %f %f %f %f” % (path, l_ear, l_forehead, r_forehead, r_ear)

am uploading the snapshot of the error.



Hi Suhas,

Concentration is only one value. You’re assigning four values to your one value array. That’s the error you’re seeing.

l_ear, l_forehead, r_forehead, r_ear = args (args is just one number)

Feel free to google these Python errors. You’ll see posts about this error message very easily. The forums are here to help you as you develop, but for these smaller errors I’m sure you’ll find yourself progressing much faster if you try to find answers through Google rather than wait for one of us to reply.

Hope that helps though and if you’re really stuck we’re always willing to help you along.


I am not able to get the value of variable ‘P’ in my another function called ‘[B]display()[/B]’. am getting server bind error.
Please help me out on how to get the values of readings when i call [B]server.start()[/B] from another function.
below here is the part of my code am trying to run:

class MuseServer(ServerThread):

#listen for messages on port 5551

def init(self):

ServerThread.init(self, 5551)

@make_method(’/muse/elements/alpha_absolute’, ‘ffff’)

def alpha_callback(self,path, args):
l_ear, l_forehead, r_forehead, r_ear = args
return l_ear

def display(int):
global p
server = MuseServer()
” % p)