2-D Array Error in ICALabel

Hello,
I am using MNE 17.1 and mne-icalabel 0.6.0 in R (through reticulate). I am getting the following error:

RuntimeWarning: invalid value encountered in scalar multiply
g = np.square(d) * (np.log(d) - 1) # Green’s function.
Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
ValueError: array must be at least 2-d

Here is my code.

ica ← mne$preprocessing$ICA(method=‘infomax’, fit_params=dict(extended=TRUE))
ica$fit(eeg)
clean_eeg ← mne_iclabel$label_components(eeg, ica, method=“iclabel”)

Any idea on what the problem might be?
I don’t think it has anything to do with me running MNE through R, because everything else seems to be working just fine.

Hello,

No idea what the problem could be. If you could provide a minimal working example, i.e. a python code snippet which can be run and reproduces the error, we could have a look.

Mathieu

1 Like

Here is a minimal working example:

import mne
import mne_icalabel
data_name = “GX_01_2019-09-24_15-45-53.set”
data = mne.io.read_raw_eeglab(data_name)
eeg_channels = data.ch_names[0:32]
data.pick_channels(eeg_channels)
data.crop(tmax=60)
ica = mne.preprocessing.ICA(
max_iter=“auto”,
method=“infomax”,
fit_params=dict(extended=True),
)
ica.fit(data)
clean_data = mne_icalabel.label_components(data,ica,method=‘iclabel’)

Here are the necessary files: Upload Files | Free File Upload and Transfer Up To 20 GB.
To get the .set file I just opened the .cnt file through EEGLAB and saved it to .set because MNE doesn’t work with .cnt from ANT Neuro.

I also tried a few other files I had (.edf and .bdf), They seem to work fine, so I am starting to think that either conversion from .cnt to .set created a problem or the original dataset (online dataset) has something wrong with it…

This file is failing during the computation of the topographic map. A topographic map requires a DigMontage to specify the channel location. Let’s have a look at the montage in this file:

data.get_montage().dig

Gives me:

[<DigPoint |        LPA : (-0.0, 0.0, 0.0) mm       : head frame>,
 <DigPoint |     Nasion : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |        RPA : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #1 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #2 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #3 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #4 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #5 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #6 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #7 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #8 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |     EEG #9 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #10 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #11 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #12 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #13 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #14 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #15 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #16 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #17 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #18 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #19 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #20 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #21 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #22 : (0.0, 0.0, 0.0) mm        : head frame>,
...
 <DigPoint |    EEG #28 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #29 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #30 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #31 : (0.0, 0.0, 0.0) mm        : head frame>,
 <DigPoint |    EEG #32 : (0.0, 0.0, 0.0) mm        : head frame>]

All sensors are positioned at the same point, the origin of the head coordinate frame. This montage is definitely not valid.

Mathieu

2 Likes

Hi ,

Thanks for the help!

data.set_montage(“easycap-M1”)

before running the code fixed it

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.