Muse 2016: Reading Data From Muse UDP Port Using Python

musedeveloper

#1

Hi experts,

I am currently trying to develop a python script that is able to retrieve data from the UDP port (127.0.0.1:7000) that Muse Direct is giving out data to. I have gotten the connection from python to the UDP port to work, however nothing is appearing out.

Am I missing some parts anywhere? i got the codes from the developer section on the Muse website.

Code

import argparse
import math

from pythonosc import dispatcher
from pythonosc import osc_server


def eeg_handler(unused_addr, args, ch1, ch2, ch3, ch4):
    print("EEG (uV) per channel: ", ch1, ch2, ch3, ch4)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="127.0.0.1",
                        help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=7000,
                        help="The port to listen on")
    args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/debug", print)
    dispatcher.map("/muse/eeg", eeg_handler, "EEG")

    server = osc_server.ThreadingOSCUDPServer(
        (args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()

Results

Thanks!


#2

In the above post you stated you’re sending to UDP 7000, but listening on UDP 5000.


#3

ops sorry let me correct my question. thank you for mentioning.


#4

Hi again, has anyone managed to done what I am trying to do successfully, its been almost a week already and i am still facing the errors listed above. and yes, both ports (Muse Direct and python) are locahost:7000.


#5

hi, i’m having the same problem as you had, did you make any progress?
thank you


#6

Have you tried temporarily disabling your firewall?


#7

hi did you manage to solve it? just run into the same problem …


#8

Same for me. I am able to receive messages in C++ (using library called oscpack), but not in Python. I have ver. 2016 and using Muse Direct on Windows 10 for streaming data. Actually, with this setup, one shall replace osc path, for instance, “/muse/eeg”, with “Person0/eeg”. But event that did not help in Python. Curious what could be wrong here…


#9

Solved it by creating custom OSC output target in Muse Direct.