PolyCortex / pyMuse

Python tools associated with Muse headband
http://polycortex.polymtl.ca/
MIT License
58 stars 16 forks source link

eeg_display.py calls abset class from viz.py #19

Closed osencan closed 7 years ago

osencan commented 7 years ago

eeg_display.py calls ViewerSignal, which does not exist anymore. Alternatives Viewer and RawViewer are not compatible with the call.

benjamindeleener commented 7 years ago

Hi @osencan, thanks for the feedback. We recently introduced pipelines into the framework and many of our initial scripts (such as eeg_display.py) are not compatible anymore with the current version of pyMuse.

We will work on updating the software as soon as possible. Meanwhile, you can take a look into test_ttih.py which should work for the Muse headband (not the 2016 one) as well as the OpenBCI board (tested).

Note that pyMuse is still in its early development phase and developed by students.

osencan commented 7 years ago

Thanks for the quick reply @benjamindeleener find solution by calling the function as

...
from pymuse.viz import RawViewer #instead of viewer signal
...
#label channels are also increased, length should be one per channel otherwise an empty array with 1999
# zeros will be received
signal_eeg = MultiChannelSignal(length=1,
                                    estimated_acquisition_freq=220.0,
                                    label_channels=['Front Head', 'Left ear', 'Left forehead', 'Right forehead', 'Right ear'])
viewer_eeg = RawViewer(signal=signal_eeg, refresh_freq=220.0, signal_boundaries=[600, 1200], label_channels=signal_eeg.label_channels, )

I have the new 2016 version. Too shame that Muse did not update its API. So, I use the muse monitor app to forward OSC signals to PC(Bluetooth is also problematic). Now testing the data acquisition. It is ok now I get the raw data like below cannot plot yet, it is ongoing :)

self data[[ 851.79486084] [ 848.16851807] [ 848.57141113] [ 871.13555908] [ 832.8571167 ]]

benjamindeleener commented 7 years ago

Nice that you were able to connect to Muse 2016! Make sure you start the server and viewer in your program to be able to display data. Also note that the viewer is using Matplotlib and can be very slow to display data (~5-10 Hz) so you won't be able to display it at 220 Hz as suggested into your code (refresh_freq option).

osencan commented 7 years ago

So far so good :)

However, I still struggle with the RawViewer(). In viz.py that seems the plot is fed with fake data fake_data = np.zeros(self.number_display)

And the data is in server object (MuseIO) which is gathered with a callback function(_callback_eegraw). So, the question here: how to connect server data to RawViewer in an elegant way? Am I missing something?

benjamindeleener commented 7 years ago

@osencan I've updated eeg_display.py on the branch Master to work with the current pipeline. Just pull the latest version and try the script while receiving Muse data via OSC. As you will see, the pipeline only consists of writing the data into a CSV file and displaying raw data. There is not a lot of documentation on the pipeline yet and I have not update the rest of the code. So other functions and filters will fail. I'll work on it as soon as possible. Tell me your needs so I can focus on your priorities.

osencan commented 7 years ago

Thank you @benjamindeleener for the effort. Otherwise, I will struggle with the pipeline structure :) Now, I can plot the results in 3Hz. I was hoping that I can prototype in Python. But it is too slow for the demands :/ Maybe it is because of the R/W speeds.

screenshot_17

benjamindeleener commented 7 years ago

@osencan That's nice that you were able to make it work. The pipeline is quite difficult to start with but we will try to simplify its use and expand its potential in the next few months.

The slowness is mainly due to the viewer, because Matplotlib (the library used for display graphs in pyMuse) is not good for real-time visualisation. Switching to another visualisation library would probably improve real-time visualisation. Meanwhile, note that it is only the visualisation that slows the analysis process and when removing the viewer, the speed can go much higher than 3Hz.

benjamindeleener commented 7 years ago

I'll close this issue as it has been fixed. I've opened the issue #20 to improve visualisation.