Platform Windows-11-10.0.22631-SP0
Python 3.12.3
ββ mne 1.7.1 (latest release)
ββ mne-connectivity 0.7.0
Hello, i have trouble with plotting connectivity with plot_sensors_connectivity. Error is the same regardless of change od the data and parameters. After calling plot_sensors_connectivity dark window pops up (where the plot should be), but its unresponsive, sometimes even lags my laptop, it is hard to close it (i have to use task manager to do so). I have read posts in community about similar error, and:
- my data i pass to plot function is not empty
- after calling get_montage() i have info that i have 19 electrodes
- i tried reinstalling mne
I also found that there is open bug similar to my error plot_sensors_connectivity fails when strongest conns are spatially close Β· Issue #148 Β· mne-tools/mne-connectivity Β· GitHub, but its not resolved, so that is why im asking here.
My code snippet:
sfreq = 500
tminanal = 0
tmaxanal = 4
baseline = (0, -0.1)
bl1epo = []
for fn2 in [bl1]:
os.chdir(fn2)
files2 = [fl for fl in os.listdir() if fl.endswith('.set')]
for m in tqdm(files2):
epochs_wid = mne.read_epochs_eeglab(m, verbose=False)
epochs_wid = epochs_wid.pick_channels(epochs_wid.ch_names)
epochs_wid.crop(tminanal, tmaxanal)
bl1epo.append(epochs_wid)
bl1epoall = mne.concatenate_epochs(bl1epo)
event_counts = bl1epoall.event_id #to group all events together because they have different names
all_events_id = {key: 1 for key in event_counts.keys()}
bl1epoall.event_id = all_events_id
cona = spectral_connectivity_epochs(
bl1epoall, method='pli', mode='multitaper', fmin=8, fmax=12, tmin=0, tmax=1,
faverage=True, sfreq=sfreq, mt_adaptive=False, n_jobs=1
)
bl1c = cona.get_data('dense')[:, :, 0]
plot_sensors_connectivity(bl1epoall.info, bl1c, cbar_label='Alpha frequency band, time range 0-1s')
My error:
computing cross-spectral density for epoch 1050
assembling connectivity matrix
[Connectivity computation done]
Backend tkagg is interactive backend. Turning interactive mode on.
Using notebook 3d backend.
Traceback (most recent call last):
File "C:\Users\Monika\PycharmProjects\EEG_analysis\.venv\Lib\site-packages\IPython\core\interactiveshell.py", line 3577, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-38f9b76ec237>", line 54, in <module>
plot_sensors_connectivity(bl1epoall.info, bl1c, cbar_label='Alpha frequency band, time range 0-1s')
File "C:\Users\Monika\PycharmProjects\EEG_analysis\.venv\Lib\site-packages\mne_connectivity\viz\_3d.py", line 95, in plot_sensors_connectivity
vmax = np.max(con_val)
^^^^^^^^^^^^^^^
File "C:\Users\Monika\PycharmProjects\EEG_analysis\.venv\Lib\site-packages\numpy\_core\fromnumeric.py", line 2899, in max
return _wrapreduction(a, np.maximum, 'max', axis, None, out,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Monika\PycharmProjects\EEG_analysis\.venv\Lib\site-packages\numpy\_core\fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: zero-size array to reduction operation maximum which has no identity
I will appreciate any help.
Best regards,
Monika