Mind Monitor Python OSC Samples are now available in a new repository in my GitHub here: https://github.com/Enigma644/MindMonitorPython
Mind Monitor OSC Streaming Python Samples
These code samples are to demonstrate streaming live OSC brainwave data from Mind Monitor (connected to a Muse device), to a computer, which can then process and work with the brainwave data.
OSC Receiver Audio Feedback.py - https://github.com/Enigma644/MindMonito ... eedback.py
* Calculates and graphs the relative waves.
* Plays a sound file if Alpha relative reaches a pre-set threshold.
* Displays if the headband is correctly fitted in the console.
OSC Receiver Simple.py - https://github.com/Enigma644/MindMonito ... 0Simple.py
* Displays RAW EEG.
OSC Receiver.py - https://github.com/Enigma644/MindMonito ... eceiver.py
* Records RAW EEG to a CSV file.
* Marker #1 starts recording. Marker #2 stops recording.
Mind Monitor Python OSC Examples
- Peter Gamma
- Posts: 180
- Joined: Sat Jun 29, 2019 11:02 am
- Location: Switzerland
- Contact:
Re: Mind Monitor Python OSC Examples
Thanks, James, for these great examples. I am currently evaluating an easy way for non-programmers to stream EEG sensor data to a research grade application. I found that the Home Assisant software could be helpful. It allows to install an MQTT broker, it has InfluxDB and Grafana plugins, and it allows to integrate Python scripts that are exposed as services in Home Assistant:
https://www.home-assistant.io/integrati ... on_script/
Home Assistant is open source and well documented, and there are many helpful YouTube videos available. Developers welcome to integrate the Mind Monitor Python OSC Examples into Home Assistant.
https://www.home-assistant.io/integrati ... on_script/
Home Assistant is open source and well documented, and there are many helpful YouTube videos available. Developers welcome to integrate the Mind Monitor Python OSC Examples into Home Assistant.
-
- Posts: 5
- Joined: Thu Jul 15, 2021 11:49 am
Re: Mind Monitor Python OSC Examples
Hello
I'd like to thanks James for the python example. I feel like I'm closer to get the data I need into my computer to process it.
But I got stuck with the error on the terminal while I'm trying to run OSC Receiver Simple.py
Well, before I run your code, I did change the name because there is a space between the title. Is that what causes the issue?
So here's what the error says:
File "OSC-Receiver-Simple.py", line 13
def eeg_handler(address: str,*args):
^
SyntaxError: invalid syntax
I had installed pip install python-osc already.
I'd like to thanks James for the python example. I feel like I'm closer to get the data I need into my computer to process it.
But I got stuck with the error on the terminal while I'm trying to run OSC Receiver Simple.py
Well, before I run your code, I did change the name because there is a space between the title. Is that what causes the issue?
So here's what the error says:
File "OSC-Receiver-Simple.py", line 13
def eeg_handler(address: str,*args):
^
SyntaxError: invalid syntax
I had installed pip install python-osc already.
Re: Mind Monitor Python OSC Examples
The filename doesn't matter. I'm not sure why you're getting that issue, sorry. Defining functions with "def" is pretty basic stuff, so I don't know why you're getting an error with that. Possibly a CRLF (end of line characters) thing with your OS version if you're not using Windows.
Or there could be something messed up in your python install? Can you run your own code ok with functions?
I would ask the question on a Python specific forum.
Or there could be something messed up in your python install? Can you run your own code ok with functions?
I would ask the question on a Python specific forum.
-
- Posts: 5
- Joined: Thu Jul 15, 2021 11:49 am
Re: Mind Monitor Python OSC Examples
Thanks for the quick reply. I'm sorry the ^ was not at the def it was at the first : on that line.
It looks like this
When first the file name had space, it could not run. That's why I had to ad - [dash] between words.
In the file, I change the ip "0.0.0.0" to my IP address. Is this what I suppose to do or should I leave them 0?
Thanks for the suggestion. I'll head to some python forum and ask people over there.
It looks like this
Code: Select all
File "OSC-Receiver-Simple.py", line 13
def eeg_handler(address: str,*args):
^
SyntaxError: invalid syntax
In the file, I change the ip "0.0.0.0" to my IP address. Is this what I suppose to do or should I leave them 0?
Thanks for the suggestion. I'll head to some python forum and ask people over there.
Re: Mind Monitor Python OSC Examples
0.0.0.0 means listen on all IPs.
You don't need to change anything at all in the file and it should also run with spaces in the file name.
You don't need to change anything at all in the file and it should also run with spaces in the file name.
-
- Posts: 5
- Joined: Thu Jul 15, 2021 11:49 am
Re: Mind Monitor Python OSC Examples
hmm.. it obviously is an issue with the space in the file's name here on my computer. I tested with print 'hello world' in the file name hello.py vs hello 2.py, for example, and my mac terminal can't run the second one [hello 2.py].
so the name is the problem here. but anyway, I have changed the ip back to 0.0.0.0 as your advice.
However, I still can't solve why colon ":" is the error. I'll figure that out.
so the name is the problem here. but anyway, I have changed the ip back to 0.0.0.0 as your advice.
However, I still can't solve why colon ":" is the error. I'll figure that out.
Re: Mind Monitor Python OSC Examples
When you want to run a file with spaces in the name, you need to surround the name with quotation marks.
-
- Posts: 5
- Joined: Thu Jul 15, 2021 11:49 am
Re: Mind Monitor Python OSC Examples
Okay, thank you for this
And for the update, I finally am able to run the code without an error. ( I guess?)
It needs to be run by python3.
My mac could not run python3 at first because the Xcode is out of date. If anyone runs on Mac Catalina and has not updated the Xcode for the terminal work + python3, according to what I found on the internet, this might cause the problem. Also, pip and pip3 need to be upgraded as well for python-OSC.
Could you please tell me if this data is looking like what it suppose to be as raw data?
I just was not sure what the file should look like without any visual graphic.
At first, it shows this:
until I interupt it with my keyboard pressed
so I got this list:
[ the url likes for those images are here: https://ibb.co/1Ghbf0q
https://ibb.co/rpnZffg ]
-----
Oh and for the same visual plotted graph that we see from your example, which is from the file "OSC Receiver Audio Feedback.py", is that mean to be run on Windows?
I'm guessing this from how the UI of that example looks like. I am running into a problem with my Mac here.
The new error/ warning says: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
So my guess, and according to a quick google search, it seems like this is what Mac will face with its Xcode thing again. Is this true?
If it's not, do you have any advice on this issue?
Re: Mind Monitor Python OSC Examples
The MatPlotLib library is not thread safe. It works fine on Windows, but not on linux/mac, so there's a bug in there they need to fix.
https://matplotlib.org/stable/faq/howto ... th-threads
This is only used in the plotting audio feedback example.
If you're getting threading errors with the simple examples, then I'm not sure what's wrong sorry. I'd do a new clean install of the latest version of python.
I don't have linux/mac, so I'm not sure what you mean by xcode being an issue. I don't think xcode should affect pyton, but like I said, I don't run a mac, so I'm not sure, sorry.
The data in the second screenshot is good. You've got the date/time followed by RAW EEG values from TP9, AF7, AF8, TP10 and AUXR.
https://matplotlib.org/stable/faq/howto ... th-threads
This is only used in the plotting audio feedback example.
If you're getting threading errors with the simple examples, then I'm not sure what's wrong sorry. I'd do a new clean install of the latest version of python.
I don't have linux/mac, so I'm not sure what you mean by xcode being an issue. I don't think xcode should affect pyton, but like I said, I don't run a mac, so I'm not sure, sorry.
The data in the second screenshot is good. You've got the date/time followed by RAW EEG values from TP9, AF7, AF8, TP10 and AUXR.