I noticed that the electrode positions are offset when using plot_sensors.

  • MNE version: e.g. 1.9.0
  • operating system: e.g. Windows 11

The following is my codes:

# 假设你的数据存放路径
datadir = './Web/datas'

data = np.load(os.path.join(datadir, 'sub1.npy'))
# 读取电极名称数据
electrode_data = pd.read_excel(os.path.join(datadir, 'channel-order.xlsx'), header=None)
# 将电极名称列表转为一个列表
electrode_names = electrode_data[0].tolist()

# 数据的形状
n_blocks, n_channels, n_samples = data.shape
sfreq = 200  # 采样频率

# 创建 info 字典
ch_names = [electrode_names[i] for i in range(n_channels)]
info = create_info(ch_names=ch_names, sfreq=sfreq, ch_types='eeg')

# 将所有块的数据拼接到一起
data_combined = data.reshape(n_channels, -1)  # (n_channels, n_samples)

# 创建 RawArray
montage = mne.channels.make_standard_montage('standard_1005')
raw = RawArray(data_combined, info)
raw.set_montage(montage, match_case=False, match_alias=True)

psd = raw.compute_psd()
psd.plot_topo()

raw.plot_sensors(ch_type='eeg', show_names=True)

#绘制ICA成分地形图
ica = mne.preprocessing.ICA(n_components=12, random_state=97, max_iter=800)
ica.fit(inst=raw)
ica.plot_components()
plt.show()

My data only has 62 channels. From the forum, I learned that I can use match_case=False, match_alias=True
to match the electrode positions of standard_1005, but the generated image has an offset and is shifted upwards.
This is the plot image:

I think I have solved it!
I should add sphere="eeglab" to the line raw.plot_sensors(ch_type='eeg', show_names=True)

I don’t know if this is the correct solution.

You might want to try "biosemi64" instead of "standard_1005". The reason is that the former contains idealized locations, whereas the latter contains actual measured locations AFAIK. Otherwise, as you’ve already mentioned, you can play around with the sphere argument to set the head origin.

1 Like

I tried ‘biosemi64’ and error ocurred:

’
Traceback (most recent call last):
File “D:\Desktop\多模态脑电信号\Web\data_process.py”, line 35, in
raw.set_montage(montage, match_case=False, match_alias=True)
File “”, line 12, in set_montage
File “C:\Users\22801\AppData\Local\Programs\Python\Python312\Lib\site-packages\mne_fiff\meas_info.py”, line 422, in set_montage
_set_montage(info, montage, match_case, match_alias, on_missing)
File “C:\Users\22801\AppData\Local\Programs\Python\Python312\Lib\site-packages\mne\channels\montage.py”, line 1250, in _set_montage
_on_missing(on_missing, missing_coord_msg)
File “C:\Users\22801\AppData\Local\Programs\Python\Python312\Lib\site-packages\mne\utils\check.py”, line 1191, in _on_missing
raise error_klass(msg)
ValueError: DigMontage is only a subset of info. There are 4 channel positions not present in the DigMontage. The channels missing from the montage are:

[‘PO5’, ‘PO6’, ‘CB1’, ‘CB2’].

Consider using inst.rename_channels to match the montage nomenclature, or inst.set_channel_types if these are not EEG channels, or use the on_missing parameter if the channel positions are allowed to be unknown in your analyses.