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

When displaying ERP/ERF image in Epochs plot, a superfluous empty matplotlib figure opens in the background #92

Open
hoechenberger opened this issue Apr 5, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@hoechenberger
Copy link
Member

hoechenberger commented Apr 5, 2022

MWE:

# %%
from pathlib import Path
import mne


sample_dir = Path(mne.datasets.sample.data_path())
sample_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'

raw = mne.io.read_raw_fif(sample_fname)
raw.crop(tmax=60)

events = mne.find_events(raw, stim_channel='STI 014')
event_id = {'auditory/left': 1, 'auditory/right': 2, 'visual/left': 3,
            'visual/right': 4, 'face': 5, 'buttonpress': 32}

epochs = mne.Epochs(raw, events=events, event_id=event_id,
                    tmin=-0.2, tmax=0.5, baseline=(None, 0),
                    preload=True)

epochs.plot()
Screen.Recording.2022-04-05.at.11.31.14.mov

This problem does not occur with Raw data when opening the channel location window via a right-click on the channel name.

@hoechenberger hoechenberger changed the title When displaying channel location, a superfluous empty matplotlib figure opens in the background When displaying channel location in Epochs plot, a superfluous empty matplotlib figure opens in the background Apr 5, 2022
@hoechenberger hoechenberger changed the title When displaying channel location in Epochs plot, a superfluous empty matplotlib figure opens in the background When displaying ERP/ERF image in Epochs plot, a superfluous empty matplotlib figure opens in the background Apr 5, 2022
@hoechenberger
Copy link
Member Author

hoechenberger commented Apr 5, 2022

I've tracked this down to happen in the following line that creates the colorbar in the upstream plotting code:

https://github.com/mne-tools/mne-python/blob/93dc7dc9022ed861ddb2afda73143efbbaf6bf4a/mne/viz/epochs.py#L552

The matplotlib code internally calls gcf(), which opens an empty figure.

@agramfort
Copy link
Member

agramfort commented Apr 5, 2022 via email

@hoechenberger
Copy link
Member Author

you see how to fix?

Not yet.
I think we'd need to fix this in MNE. I need to check whether the same is present with the MPL backend too.

@marsipu marsipu added the bug Something isn't working label May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants