-
Notifications
You must be signed in to change notification settings - Fork 98
Description
Dear MNE_BIDS Team,
Thank you for writing great software to easily handle data standardization! 😊 Everything works fine but our research group is struggling with one annoying bug that is hard to deal with:
Describe the bug
We save the montage for our raw data like this:
montage = mne.channels.make_dig_montage(ch_pos=dict(zip(ch_names, elec)),
coord_frame='mni_tal')
raw.set_montage(montage, on_missing='warn')
mne_bids.write_raw_bids(raw=raw, bids_path=bids_path, overwrite=True)
However, when we load the data, process it, and save it again, we get an error:
bids_path_load = BIDSPath(subject="003", session="EphysMedOn01", task="Rest", acquisition="StimOff", run="01",
processing=None, recording=None, space=None, split=None, root="../../rawdata",
suffix="ieeg", extension=None, datatype="ieeg", check=True)
raw = read_raw_bids(bids_path_load, verbose=False)
raw.resample(128)
bids_path_save = bids_path_load.copy().update(root="../../derivatives", processing="downsample")
write_raw_bids(raw, bids_path_save, allow_preload=True, format="BrainVision")
Expected results
Actual results
Saving does not work and yields an error message:

The reason this does not work is that the coordinate system is set to "head" even though we saved it as "mni_tal". If we set it to "mni_tal" again, it now works:
montage = raw.get_montage()
new_montage = mne.channels.make_dig_montage(ch_pos=montage.get_positions()["ch_pos"], coord_frame='mni_tal')
raw.set_montage(new_montage)
write_raw_bids(raw, bids_path_save, allow_preload=True, format="BrainVision")
How can we make sure we save the data correctly and avoid this reset of the montage?
Our coordinate system .json file looks like this:
sub-003_ses-EphysMedOn01_space-MNI152NLin2009bAsym_coordsystem.json:
{
"IntendedFor": "n/a",
"iEEGCoordinateProcessingDescription": "Co-registration, normalization and electrode localization done with Lead-DBS",
"iEEGCoordinateProcessingReference": "Horn, A., Li, N., Dembek, T. A., Kappel, A., Boulay, C., Ewert, S., et al. (2018). Lead-DBS v2: Towards a comprehensive pipeline for deep brain stimulation imaging. NeuroImage.",
"iEEGCoordinateSystem": "Other",
"iEEGCoordinateSystemDescription": "MNI152 2009b NLIN asymmetric T2 template",
"iEEGCoordinateUnits": "mm"
}
We would be really thankful if you could have a look at that! 👌🙂
Additional information
Platform: macOS-11.6.3-x86_64-i386-64bit
Python: 3.10.2 | packaged by conda-forge | (main, Feb 1 2022, 19:30:18) [Clang 11.1.0 ]
Executable: /opt/anaconda3/envs/bids_neu/bin/python
CPU: i386: 8 cores
Memory: Unavailable (requires "psutil" package)
mne: 0.24.1
numpy: 1.22.2 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy: 1.8.0
matplotlib: 3.5.1 {backend=module://matplotlib_inline.backend_inline}
sklearn: Not found
numba: Not found
nibabel: 3.2.2
nilearn: Not found
dipy: Not found
cupy: Not found
pandas: 1.4.1
mayavi: Not found
pyvista: Not found
pyvistaqt: Not found
ipyvtklink: Not found
vtk: Not found
PyQt5: Not found
ipympl: Not found
mne_qt_browser: Not found
pooch: v1.6.0
mne_bids: 0.9
