cannot save channels_type and motage information

Dear developers,
I am using the following system:
- MNE version: e.g. 1.5.1 or 1.7.1
- operating system: e.g. Windows 10

I read the eeg data and initiate the channel type and montage by:

raw=mne.io.read_raw_brainvision(r'G:\preference_task\test\behavior\sub-161\ses-pre\eeg\sub-161_ses-pre_task-Association_run-01_eeg.vhdr')
channel_types= {
"eog": [ "HEOGL","HEOGR"],
"ecg": ["ECG", "ECG"],
"emg": ["EMG"],
"misc": ["M1", "M2",'RES']}

for key_i, val_i in channel_types.items(): raw.set_channel_types(dict(zip(val_i, [key_i,] * len(val_i))))
montage = mne.channels.make_standard_montage('standard_1020')
raw.set_montage(montage)
raw.info
raw.get_montage()


mne.export.export_raw(r'D:\work\nap_task\output\sub-002\ses-02\eeg\a.vhdr',a,overwrite=True,fmt='brainvision')
out = mne.io.read_raw_brainvision(r'D:\work\nap_task\output\sub-002\ses-02\eeg\a.vhdr')
out.info
out.get_montage()

Before export raw, I can get the right info and montage:


However, when I read the export file, the info was wrong and montage disappeared.

I restarted the computer, switched to a different computer, tried collecting data using two different brands of devices (BP and ANT), and changed the MNE versions (1.5.1, 1.7.1), but the issue persists.

Maybe I did something wrong, and I want to ask how to save the channels’ type and montage? Thank you very much!

The mne export functionality does not guarantee a perfect round-trip of the data. Some metadata may always get lost in the process.

If you want to preserve raw, you must save it to FIF.

For more info about brainvision format montage writing, see also: Let pybv write [coordinates] section to vhdr files · Issue #44 · bids-standard/pybv · GitHub

Got it! Thank you very much!

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