plot_evoked_topomap

Hello everyone;

I am trying to use the plot_evoked_topomap, but I am having some issues (script below)

I guess the problem is about the sensor location .

the error I get is:

ValueError: Cannot determine location of MEG/EOG/ECG channels using digitization points.

My code:

import pandas as pd
import matplotlib.pyplot as plt
import mne
import numpy as np
from mne.viz import plot_evoked_topomap

excel_file = "DATA2.xlsx" #"your_excel_file.xlsx"
df = pd.read_excel(excel_file)

time_series = df.iloc[:, 0].values 
magnetic_field_series = df.iloc[:, 1:].values.T

sfreq = 1 / np.mean(np.diff(time_series))
ch_names = [f'MEG {i:04d}' for i in range(1, magnetic_field_series.shape[0] + 1)]
ch_types = ['mag'] * magnetic_field_series.shape[0]
info = mne.create_info(ch_names=ch_names, sfreq=sfreq, ch_types=ch_types)

montage = mne.channels.make_standard_montage('standard_1005')
info.set_montage(montage)

raw = mne.io.RawArray(magnetic_field_series, info)

events = np.array([[0, 0, 1]])
event_id = dict(event=1)

epochs_data = magnetic_field_series[np.newaxis, :]
epochs = mne.EpochsArray(epochs_data, info, events=events, event_id=event_id, tmin=0)

evoked = epochs.average()

fig = epochs.plot(scalings='auto', show=False)
fig.set_size_inches(10, 6)

plot_evoked_topomap(evoked, times='auto', ch_type='mag', time_unit='s')

plt.show()
  • MNE version: 1.6.1
  • operating system: Windows 11

Hello and welcome to the forum!

You’re setting an EEG montage but you have MEG channels, so you end up with data that doesn’t contain location information for your MEG sensors. I think you may have to work with a layout here but I don’t have any experience with this. Maybe @wmvanvliet can help.

Good luck,
Richard

1 Like

Could you tell us what kind of MEG machine the data was recorded from? Since you only seem to have magnetometers I’m guessing either a CTF151 or CTF275? (But then again, why is your data in Excel format?).