mne.io.read_raw_fil
crashes if bad channels are specified prior to import
#12594
Labels
mne.io.read_raw_fil
crashes if bad channels are specified prior to import
#12594
Description of the problem
The format used for the FIL OPM system uses a tsv file to specify channel names and statuses, so functionality to check for bad channels from the
*channels.tsv
metadata was implemented to automatically assign the bad channels on import without user intervention. Its taken me over a year to discover this part ofread_raw_fil
never worked. Sorry!Steps to reproduce
Link to data
No response
Expected results
An instance of
raw
should be created with the bad channels listed in the edited*_channels.tsv
(this caseG2-17-TAN
) being populated inraw.info['bads']
.Actual results
Instance of
raw
not created, the following traceback belowRefining sensor orientations...
[done]
File "c:\users\george o'neill\documents\python\bad_channel_bug_test.py", line 35, in
raw = mne.io.read_raw_fil(opm_temp_data_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 12, in read_raw_fil
File "C:\Users\goneill\miniconda3\envs\mne\Lib\site-packages\mne\io\fil\fil.py", line 51, in read_raw_fil
return RawFIL(binfile, precision=precision, preload=preload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\goneill\miniconda3\envs\mne\Lib\site-packages\mne\io\fil\fil.py", line 120, in init
info = _compose_meas_info(meg, chans)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\goneill\miniconda3\envs\mne\Lib\site-packages\mne\io\fil\fil.py", line 274, in _compose_meas_info
info["bads"] = _read_bad_channels(chans)
~~~~^^^^^^^^
File "C:\Users\goneill\miniconda3\envs\mne\Lib\site-packages\mne_fiff\meas_info.py", line 1579, in setitem
val = self._attributes[key](
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\goneill\miniconda3\envs\mne\Lib\site-packages\mne_fiff\meas_info.py", line 992, in _check_bads
return MNEBadsList(bads=bads, info=info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\goneill\miniconda3\envs\mne\Lib\site-packages\mne_fiff\meas_info.py", line 966, in init
_check_bads_info_compat(bads, info)
File "C:\Users\goneill\miniconda3\envs\mne\Lib\site-packages\mne_fiff\meas_info.py", line 959, in _check_bads_info_compat
raise ValueError(f"bad channel(s) {missing} marked do not exist in info")
Additional information
It appears to be due to the fact the check for bad channels is specified before the
ch_names
has been populated. This probably can be fixed by callinginfo._update_redundant()
before_check_bads
is called.The text was updated successfully, but these errors were encountered: