-
Notifications
You must be signed in to change notification settings - Fork 99
Description
The dataset mentioned in https://mne.discourse.group/t/mne-bids-pipeline-critical-error-digitisation-points/5376 is a BrainVision dataset with a [Coordinates] section in the vhdr file, specifying the electrode positions. The dataset doesn't come with an _electrodes.tsv to specify the electrode positions in a BIDS-specific way, though.
When the dataset was loaded with MNE-BIDS and visualized, a topomap could correctly be created because channel positions were taken from [Coordinates].
However, I think this is a mistake, as electrode positions must go into _electrodes.tsv.
The following not-so-short MWE demonstrates this problem:
- We load EEG data
- we set a montage
- we convert one EEG channel to
magto make MNE-BIDS believe it's an MEG dataset, so we an write this thing to a FIFF file. Here we abuse a bug (?) in MNE-BIDS: when writing M/EEG data, it doesn't create an_electrodes.tsvsidecar. - We load the data again.
- Even though there was no
_electrodes.tsv, the montage can be plotted – because the positions were taken from theinfostructure of the FIFF file.
# %%
from pathlib import Path
import mne
import mne_bids
# Load data & set a montage
ssvep_folder = mne.datasets.ssvep.data_path()
ssvep_data_raw_path = (ssvep_folder / 'sub-02' / 'ses-01' / 'eeg' /
'sub-02_ses-01_task-ssvep_eeg.vhdr')
ssvep_raw = mne.io.read_raw_brainvision(ssvep_data_raw_path, verbose=False)
ssvep_raw.set_montage('easycap-M1')
# Add a single MEG channel so we can save the data as a FIFF file in BIDS
ssvep_raw.set_channel_types({'PO10': 'mag'})
fname = Path('/tmp/sub-02_ses-01_task-ssvep_meg.fif')
ssvep_raw.save(fname, overwrite=True)
del ssvep_raw
# Create a BIDS dataset
raw = mne.io.read_raw(fname)
root = Path('/tmp/bids-test')
bp = mne_bids.BIDSPath(
subject='02',
session='01',
task='ssvep',
suffix='meg',
extension='.fif',
datatype='meg',
root=root
)
mne_bids.write_raw_bids(
raw=raw,
bids_path=bp,
overwrite=True,
)
# Load the data again
raw_loaded = mne_bids.read_raw_bids(bp)
# We do have a montage
raw_loaded.get_montage().plot()My proposal is to call raw.set_montage(None) upon loading data. If we have electrode positions in BIDS metadata, we can subsequently add them; but if we don't have any, we should get rid of the positions stored in the original data without a representation in the metadata.