Skip to content

ICA plot_components on provided axes fails #11653

@mscheltienne

Description

@mscheltienne

Description of the problem

from matplotlib import pyplot as plt
from mne.datasets import sample
from mne.io import read_raw_fif
from mne.preprocessing import ICA


# create a toy dataset
fname = sample.data_path() / "MEG" / "sample" / "sample_audvis_raw.fif"
raw = read_raw_fif(fname, preload=False)
raw.pick_types(eeg=True)
raw.crop(0, 10)
raw.load_data()
raw.filter(1.0, 40.0)
ica = ICA(n_components=5, method="picard")
ica.fit(raw)

# create figure
f, ax = plt.subplots(2, 2)
ica.plot_components(inst=raw, picks=[1, 2, 3, 4], axes=ax)

The code snippet above raises:

AttributeError: 'numpy.ndarray' object has no attribute 'set_title'

If you flatten the provided ax, it fails with:

UnboundLocalError: local variable 'fig' referenced before assignment

Working on it atm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions