Skip to content

Conversation

@marsipu
Copy link
Member

@marsipu marsipu commented Jan 30, 2022

Description

This is work in progress for epochs support.

  • adapt pyqtgraph-backend to IO for Epochs from mpl-backend
  • handle visualization
  • handle epochs-specific interaction (selecting bad epochs, etc.)
  • let pyqtgraph-backend pass mne.viz.tests.test_epochs.py

This PR depends on a correspondent PR in mne-python.

Code I currently use for testing
import mne
import os
import numpy as np

from mne.viz import use_browser_backend

# Load Raw
sample_data_folder = mne.datasets.sample.data_path()
raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
                        'sample_audvis_raw.fif')
raw = mne.io.read_raw(raw_file)

# Load Events
events_path = os.path.join(sample_data_folder, 'MEG', 'sample',
                           'sample_audvis_raw-eve.fif')
events = mne.read_events(events_path)

# Add test-annotations
onsets = np.arange(2, 8, 2) + raw.first_time
durations = np.repeat(1, len(onsets))
descriptions = ['Test1', 'Test2', 'Test3']
for onset, duration, description in zip(onsets, durations, descriptions):
    raw.annotations.append(onset, duration, description)

epo = mne.Epochs(raw, events)

epoch_col1 = np.asarray(['b'] * len(epo.ch_names))
epoch_col1[::2] = 'r'
epoch_col2 = np.asarray(['r'] * len(epo.ch_names))
epoch_col2[::2] = 'b'
epoch_col3 = np.asarray(['g'] * len(epo.ch_names))
epoch_col3[::2] = 'b'
epoch_colors = np.asarray([['b'] * len(epo.ch_names) for _ in
                           range(len(epo.events))])
epoch_colors[::3] = epoch_col1
epoch_colors[1::3] = epoch_col2
epoch_colors[2::3] = epoch_col3
epoch_colors = epoch_colors.tolist()

with use_browser_backend('pyqtgraph'):
    epo.plot(block=True, n_epochs=10, events=events, epoch_colors=epoch_colors,
             precompute=False)

REMINDER: CI testing with the PR branch from mne-tools/mne-python#10297 has to be reverted before merging!

@marsipu marsipu added enhancement New feature or request wip Work in Progress labels Jan 30, 2022
@marsipu marsipu marked this pull request as draft January 31, 2022 11:23
@marsipu marsipu marked this pull request as ready for review February 8, 2022 17:16
@marsipu marsipu force-pushed the epochs_support branch 2 times, most recently from 572f122 to acd6cc3 Compare February 8, 2022 20:57
@marsipu
Copy link
Member Author

marsipu commented Feb 8, 2022

Locally all tests are green now for me 😊
The CIs are not green yet, because this PR is codependent with mne-tools/mne-python#10297.
@larsoner This one should probably be merged first, right?

@marsipu
Copy link
Member Author

marsipu commented Feb 9, 2022

Everything seems to pass except test_epochs.py::test_plot_epochs_ctf for macos.

@marsipu
Copy link
Member Author

marsipu commented Feb 13, 2022

@larsoner I think this one would be good to go now:

pg_epochs.mp4

@marsipu
Copy link
Member Author

marsipu commented Feb 13, 2022

The only issue remaining is #53.
I don't think I can find a solution for this until the release 1.0 of mne-python. It seems to be very obscure and I even don't know if it's a problem with mne-qt-browser or generally PyQt5 with MacOS.
Do you think it would be bearable to set use_opengl=True by default for epochs.plot() or only for MacOS?

@marsipu
Copy link
Member Author

marsipu commented Feb 13, 2022

@larsoner When you are fine I think we can merge this one

@marsipu
Copy link
Member Author

marsipu commented Feb 13, 2022

The last CIs are bound to fail, because mne-tools/mne-python#10297 is not merged yet. But probably merging on mne-python's side first is preferable

@marsipu marsipu changed the title [WIP, ENH]: Epochs support ENH: Epochs support Feb 13, 2022
@larsoner
Copy link
Member

I just merged, so maybe CIs just need to be restarted?

@marsipu
Copy link
Member Author

marsipu commented Feb 14, 2022

maint/0.24 fails are expected, I will merge this one now

@marsipu marsipu merged commit 3e2bf12 into mne-tools:main Feb 14, 2022
@marsipu marsipu deleted the epochs_support branch February 16, 2022 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request wip Work in Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants