mne-icalabel
mne-icalabel copied to clipboard
ICLabel doesn't work with combined MEG/EEG data
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 https://github.com/mne-tools/mne-icalabel/issues/124#issuecomment-1435759721