find_bad_channels_maxwell breaks if during some chunk all channels are flat
See original GitHub issueHello everyone!
I faced with a problem using mne.preprocessing.find_bad_channels_maxwell()
. At some point it returns an error:
Interval 103: 510.000 - 514.999
Flat ( 2): MEG1243 MEG1532
Interval 104: 515.000 - 519.999
Traceback (most recent call last):
File "<input>", line 172, in <module>
File "<decorator-gen-415>", line 24, in find_bad_channels_maxwell
File "E:\Egor_Levchenko\Software\Miniconda\envs\MCCA-MEG\lib\site-packages\mne\preprocessing\maxwell.py", line 2190, in find_bad_channels_maxwell
delta = chunk_raw.get_data(these_picks)
File "<decorator-gen-170>", line 22, in get_data
File "E:\Egor_Levchenko\Software\Miniconda\envs\MCCA-MEG\lib\site-packages\mne\io\base.py", line 819, in get_data
picks = _picks_to_idx(self.info, picks, 'all', exclude=())
File "E:\Egor_Levchenko\Software\Miniconda\envs\MCCA-MEG\lib\site-packages\mne\io\pick.py", line 1058, in _picks_to_idx
'(%r)' % (orig_picks,))
ValueError: No appropriate channels found for the given picks ([])
I checked the code and my data. I think the problem is that my data is corrupted a little bit and I have all flat channels for around 20 seconds. After detecting the flat channels the code takes only good_meg_picks
which are not in chunk_flats
. As a result, these_picks
appears to be empty if all channels are in chunk_flats
:
https://github.com/mne-tools/mne-python/blob/8b9616dfbc377ce468a6d52b43f7a973eac47cab/mne/preprocessing/maxwell.py#L2167-L2175 https://github.com/mne-tools/mne-python/blob/8b9616dfbc377ce468a6d52b43f7a973eac47cab/mne/preprocessing/maxwell.py#L2187
You can see a snapshot of raw data below:
I think this is more a problem of my data, but I guess it should be nice to ignore “all flat” chunks with a warning or something like that. Correct me please if I am wrong and thank you for any comments!
System properties:
OS: Windows Server 2012 R2
python=3.7.7
mne=0.22.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
I cannot reproduce on 0.22.0:
outputs:
Either way, though, I recommend updating to the latest release 0.23 as 0.22 is no longer supported. There I get the same thing:
Can you try on 0.23? If you have the same problem with the code snippet above I’ll boot into Windows to see if I can replicate there.
Looks like there are likely bugs with
annotate_flat
andfind_bad_channels_maxwell
, I’ll look into it!