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

ICLabel doesn't work with combined MEG/EEG data #133

Open
mscheltienne opened this issue Jul 16, 2023 · 0 comments
Open

ICLabel doesn't work with combined MEG/EEG data #133

mscheltienne opened this issue Jul 16, 2023 · 0 comments

Comments

@mscheltienne
Copy link
Member

          I meant that if we have a dataset with combined channels, ICLabel should be applied only to the EEG channel-related components. And at the moment, it is indeed not working.
from mne.datasets import sample
from mne.io import read_raw_fif
from mne.preprocessing import ICA
from mne_icalabel import label_components


directory = sample.data_path() / "MEG" / "sample"
raw = read_raw_fif(directory / "sample_audvis_raw.fif", preload=False)
raw.pick_types(meg=True, eeg=True)
raw.load_data()
raw.filter(1., 100.)
ica = ICA(n_components=5, method="picard")
ica.fit(raw)

labels = label_components(raw, ica, method="iclabel")

Raises:

  Cell In[1], line 15
    labels = label_components(raw, ica, method="iclabel")

  File ~\Documents\git\mscheltienne\mne-icalabel\mne_icalabel\label_components.py:50 in label_components
    labels_pred_proba = ICALABEL_METHODS[method](inst, ica)  # type: ignore

  File ~\Documents\git\mscheltienne\mne-icalabel\mne_icalabel\iclabel\label_components.py:57 in iclabel_label_components
    features = get_iclabel_features(inst, ica)

  File ~\Documents\git\mscheltienne\mne-icalabel\mne_icalabel\iclabel\features.py:85 in get_iclabel_features
    topo = _eeg_topoplot(inst, icawinv, ica.ch_names)

  File ~\Documents\git\mscheltienne\mne-icalabel\mne_icalabel\iclabel\features.py:186 in _eeg_topoplot
    temp_topo = _topoplotFast(icawinv[:, it], rd, th)

  File ~\Documents\git\mscheltienne\mne-icalabel\mne_icalabel\iclabel\features.py:236 in _topoplotFast
    Xi, Yi, Zi = _gdatav4(x, y, values.reshape((-1, 1)), XQ, YQ)

  File ~\Documents\git\mscheltienne\mne-icalabel\mne_icalabel\iclabel\utils.py:132 in _gdatav4
    x, y, v = _mergepoints2D(x, y, v)

  File ~\Documents\git\mscheltienne\mne-icalabel\mne_icalabel\iclabel\utils.py:194 in _mergepoints2D
    v = np.reshape(v, sz, order="F")

  File <__array_function__ internals>:200 in reshape

  File ~\Documents\pyvenv\mscheltienne\mne-icalabel\lib\site-packages\numpy\core\fromnumeric.py:298 in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)

  File ~\Documents\pyvenv\mscheltienne\mne-icalabel\lib\site-packages\numpy\core\fromnumeric.py:57 in _wrapfunc
    return bound(*args, **kwds)

ValueError: cannot reshape array of size 364 into shape (59,)

But I'm not sure how MNE handles an ICA decomposition on multiple channel types.. I need to look into that first.

Originally posted by @mscheltienne in #124 (comment)

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

1 participant