Repository navigation
Closed
Labels
Description
Description of the problem
I have data where the channel names contain :. While MNE is able to successfully write this data, it throws a weird error when reading. While I can fix the channel names, I think the error (if at all) should be raised when writing the data, not reading.
Steps to reproduce
import mne
root = mne.datasets.sample.data_path() / 'MEG' / 'sample'
evk_file = root / 'sample_audvis-ave.fif'
evoked = mne.read_evokeds(evk_file, baseline=(None, 0), proj=True,
verbose=False)[0]
# comment out the following line to see now error
evoked.rename_channels(lambda x: x.replace(' ', ':'))
evoked.info['bads'] = [evoked.info['ch_names'][0]]
mne.write_evokeds('test_ave.fif', evoked, overwrite=True)
evoked2 = mne.read_evokeds('test_ave.fif')[0]Link to data
No response
Expected results
No error
Actual results
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File /autofs/space/meghnn_001/users/mjas/github_repos/mne-opm/mne_bug.py:14
11 evoked.info['bads'] = [evoked.info['ch_names'][0]]
12 mne.write_evokeds('test_ave.fif', evoked, overwrite=True)
---> 14 evoked2 = mne.read_evokeds('test_ave.fif')[0]
File <decorator-gen-255>:12, in read_evokeds(fname, condition, baseline, kind, proj, allow_maxshield, verbose)
File /autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/evoked.py:1186, in read_evokeds(fname, condition, baseline, kind, proj, allow_maxshield, verbose)
1184 return_list = True
1185 if condition is None:
-> 1186 evoked_node = _get_evoked_node(fname)
1187 condition = range(len(evoked_node))
1188 elif not isinstance(condition, list):
File /autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/evoked.py:1005, in _get_evoked_node(fname)
1003 f, tree, _ = fiff_open(fname)
1004 with f as fid:
-> 1005 _, meas = read_meas_info(fid, tree, verbose=False)
1006 evoked_node = dir_tree_find(meas, FIFF.FIFFB_EVOKED)
1007 return evoked_node
File <decorator-gen-35>:10, in read_meas_info(fid, tree, clean_bads, verbose)
File /autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/io/meas_info.py:1552, in read_meas_info(fid, tree, clean_bads, verbose)
1549 acq_stim = tag.data
1551 # Load the SSP data
-> 1552 projs = _read_proj(
1553 fid, meas_info, ch_names_mapping=ch_names_mapping)
1555 # Load the CTF compensation data
1556 comps = _read_ctf_comp(
1557 fid, meas_info, chs, ch_names_mapping=ch_names_mapping)
File <decorator-gen-15>:12, in _read_proj(fid, node, ch_names_mapping, verbose)
File /autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/io/proj.py:528, in _read_proj(fid, node, ch_names_mapping, verbose)
525 data = data.T
527 if data.shape[1] != len(names):
--> 528 raise ValueError('Number of channel names does not match the '
529 'size of data matrix')
531 # just always use this, we used to have bugs with writing the
532 # number correctly...
533 nchan = len(names)
ValueError: Number of channel names does not match the size of data matrixAdditional information
Platform: Linux-3.10.0-1160.76.1.el7.x86_64-x86_64-with-glibc2.10
Python: 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05) [GCC 7.5.0]
Executable: /autofs/space/meghnn_001/users/mjas/anaconda3/envs/mne/bin/python3.8
CPU: x86_64: 64 cores
Memory: 125.4 GB
Exception ignored on calling ctypes callback function: <function _ThreadpoolInfo._find_modules_with_dl_iterate_phdr.<locals>.match_module_callback at 0x7f921e1c2790>
Traceback (most recent call last):
File "/autofs/space/meghnn_001/users/mjas/anaconda3/envs/mne/lib/python3.8/site-packages/threadpoolctl.py", line 400, in match_module_callback
self._make_module_from_path(filepath)
File "/autofs/space/meghnn_001/users/mjas/anaconda3/envs/mne/lib/python3.8/site-packages/threadpoolctl.py", line 515, in _make_module_from_path
module = module_class(filepath, prefix, user_api, internal_api)
File "/autofs/space/meghnn_001/users/mjas/anaconda3/envs/mne/lib/python3.8/site-packages/threadpoolctl.py", line 606, in __init__
self.version = self.get_version()
File "/autofs/space/meghnn_001/users/mjas/anaconda3/envs/mne/lib/python3.8/site-packages/threadpoolctl.py", line 646, in get_version
config = get_config().split()
AttributeError: 'NoneType' object has no attribute 'split'
mne: 1.4.dev0
numpy: 1.23.0 {unknown linalg bindings}
scipy: 1.5.3
matplotlib: 3.3.3 {backend=Qt5Agg}
sklearn: 0.23.2
numba: Not found
nibabel: 3.2.1
nilearn: 0.7.0
dipy: 1.3.0
openmeeg: Not found
cupy: Not found
pandas: 1.1.5
pyvista: 0.36.1 {OpenGL 4.5.0 NVIDIA 455.45.01 via Quadro P5000/PCIe/SSE2}
pyvistaqt: 0.9.0
ipyvtklink: Not found
vtk: 9.0.1
qtpy: 2.0.1 {PyQt5=5.12.9}
ipympl: Not found
/autofs/space/meghnn_001/users/mjas/anaconda3/envs/mne/lib/python3.8/site-packages/pyqtgraph/colors/palette.py:1: RuntimeWarning: PyQtGraph supports Qt version >= 5.15, but 5.12.9 detected.
from ..Qt import QtGui
pyqtgraph: 0.13.1
pooch: v1.5.2
mne_bids: Not found
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: 0.4.0
mne_connectivity: Not found
mne_icalabel: Not found
Activity