Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement MNE-Realtime with MNEQt-Browser or mne.io.plot() ? #39

Open
vsltech opened this issue Apr 27, 2022 · 4 comments
Open

Comments

@vsltech
Copy link

vsltech commented Apr 27, 2022

import os.path as op
import subprocess
import mne
from mne.viz import plot_events
from mne.utils import running_subprocess
from mne_realtime import FieldTripClient, RtEpochs

info = mne.io.read_info('<myEEGFileInEDFFormat')
event_id, tmin, tmax = 1, -0.2, 0.5

with FieldTripClient(host='localhost', port=1972,tmax=40, wait_max=5, info=info) as rt_client:
    rt_epochs = RtEpochs(rt_client, event_id, tmin, tmax, proj=None)
    rt_epochs.start()
    for ev in rt_epochs.iter_evoked():
        epoch_data = ev.data
        #mne.io.raw.plot(show=True,block=True,show_options=False,theme='dark',title=None,proj=False)
        print(epoch_data)

    rt_epochs.stop()

I don't want to plot using matplotlib, any snippet on plot using PyQtGraph(MNEQtBrowser) ?

@jasmainak
Copy link
Member

I think this could be a fun project ;-) @larsoner do you think it's possible by refactoring the existing browser? I wanted to potentially use it also for the OPM-MEG system at Martinos

@larsoner
Copy link
Member

Looks like there is already a reply over at mne-tools/mne-qt-browser#117

@vsltech
Copy link
Author

vsltech commented Apr 27, 2022

Really appreciate the prompt response!
Above mentioned issue: mne-tools/mne-qt-browser#117

Loads data from mne.raw.io & plot()
I am looking forward to implement using mne-realtime using FieldTripClient, if any code snippet or way to plot the buffer data received over RtClient

Please advise further @larsoner

@larsoner
Copy link
Member

I can't think of a clean way to do it. A quick way I would try would be to create a mne.io.RawArray, call .plot with precompute=False, overview_mode='hidden', modify the raw._data as each new buffer comes in, and somehow force the MNEQtBrowser to redraw (even though the time interval has changed). There is probably some private function you can call in MNEBrowseFigure (what gets returned by raw.plot) that will do this last part for you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants