mne-tools / mne-tools/mne-python

IndexError when clicking on trace in ICA.plot_overlay()

Open
#9,342 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

BUG VIZ
Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Description

MWE:

from pathlib import Path
import matplotlib
import mne

matplotlib.use('Qt5Agg')


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).pick_types(meg=False, eeg=True,
                                                   stim=True)

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,
                    preload=True)

ica = mne.preprocessing.ICA(n_components=0.8, method='picard', max_iter=500)
ica.fit(epochs)

ica.plot_overlay(inst=epochs.average().apply_baseline())

https://user-images.githubusercontent.com/2046265/115895458-ba078900-a45a-11eb-95ac-9e97e86c3de3.mov

Traceback:

Traceback (most recent call last):
  File "/Users/hoechenberger/miniforge3/envs/mne/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 270, in process
    func(*args, **kwargs)
  File "/Users/hoechenberger/Development/mne-python/mne/viz/evoked.py", line 52, in _butterfly_onpick
    lidx = np.where([
IndexError: index 0 is out of bounds for axis 0 with size 0
Traceback (most recent call last):
  File "/Users/hoechenberger/miniforge3/envs/mne/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 270, in process
    func(*args, **kwargs)
  File "/Users/hoechenberger/Development/mne-python/mne/viz/evoked.py", line 52, in _butterfly_onpick
    lidx = np.where([
IndexError: index 0 is out of bounds for axis 0 with size 0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducer in the issue and inspect mne/viz/evoked.py, particularly the _butterfly_onpick callback named in the traceback. Reproduce the failure by clicking a trace in ICA.plot_overlay(); done means the click no longer raises IndexError in the reported MNE and Matplotlib setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.