- MNE version: 1.1.1
- operating system: Windows 10
- Python version: 3.7.13
Hello, I was following the tutorial about Group Analysis of ERP Data (Group Analysis of ERP Data — Data Science for Psychology and Neuroscience — in Python) with my own data.
Everything works perfectly, except when I arrive to the “Scalp topographic map” part. I try to do a topomap plot of my evoked object (gA of a difference between my 2 conditions), exactly like the tutorial, but a weird error is occurring. It looks like mne.viz.plot_evoked_topomap() is bugged.
My code (without data dir and the other parts of the tutorial which work fine) :
# Load data files
evokeds = {}
conditions = ['congruent', 'incongruent']
for idx, c in enumerate(conditions):
evokeds[c] = [mne.read_evokeds(d)[idx] for d in data_files]
roi = ['Pz']
# Differences
diff_waves = []
for i in range(len(data_files)):
diff_waves.append(mne.combine_evoked([evokeds['congruent'][i], evokeds['incongruent'][i]],
weights=[1, -1]
)
contrast = 'Congruent-Incongruent'
# Scalp topographic map
mne.viz.plot_evoked_topomap(mne.grand_average(diff_waves),
times=0.300, average=0.100,
title=contrast,
size=3
)
plt.show()
The error :
Traceback (most recent call last):
File "C:\Users\remil\AppData\Local\Temp\ipykernel_13276\2413048152.py", line 4, in <module>
size=3
File "C:\Users\remil\anaconda3\envs\py37\lib\site-packages\mne\viz\topomap.py", line 1815, in plot_evoked_topomap
mask=mask_[:, average_idx] if mask is not None else None, **kwargs)
File "C:\Users\remil\anaconda3\envs\py37\lib\site-packages\mne\viz\topomap.py", line 996, in _plot_topomap
pos, res, image_interp, extrapolate, outlines, border)
File "C:\Users\remil\anaconda3\envs\py37\lib\site-packages\mne\viz\topomap.py", line 845, in _setup_interp
clip_origin, clip_radius, border)
File "C:\Users\remil\anaconda3\envs\py37\lib\site-packages\mne\viz\topomap.py", line 628, in __init__
pos, extrapolate, origin, radii)
File "C:\Users\remil\anaconda3\envs\py37\lib\site-packages\mne\viz\topomap.py", line 509, in _get_extra_points
colinear = ((slopes == slopes[0]).all() or np.isinf(slopes).all())
IndexError: index 0 is out of bounds for axis 0 with size 0
I tried to add (extrapolate = ‘local’ or ‘box’) in the function but didnt work, although ‘box’ gave another error message but originating from the same code line in _get_extra_points.
The same error happens if I use plot_topomap() rather than mne.viz.plot_evoked_topomap() :
ga_evoked = mne.grand_average(diff_waves)
ga_evoked.plot_topomap(times=0.300, average=0.100,
title=contrast,
size=3
)
plt.show()
Any idea ?