question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

find_bad_channels_maxwell breaks if during some chunk all channels are flat

See original GitHub issue

Hello 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:

image

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:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
larsonercommented, Jul 6, 2021

mne=0.22.0

I tried running it, but it is strange that flat segments are not fully detected:

I cannot reproduce on 0.22.0:

import mne
raw = mne.io.read_raw_fif('sub-1011_ses-20190430_task-vid2_meg.fif').load_data()
annot, bads = mne.preprocessing.annotate_flat(raw, picks='meg', bad_percent=100, verbose=True)
raw.set_annotations(annot)
raw.plot()

outputs:

Marking 8.85% of time points (5 segments) and 0/306 channels bad

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:

Screenshot from 2021-07-06 14-36-31

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.

1reaction
larsonercommented, Jun 16, 2021

Looks like there are likely bugs with annotate_flat and find_bad_channels_maxwell, I’ll look into it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building Big In A Bigger World // The Spawn Chunks - YouTube
Joel and Jonny take a look at bug fixes and parity changes in the latest Bedrock Beta before answering email about in -game...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found