Skip to content

ENH: mne.set_bipolar_reference should not ignore bad channels #11243

Closed

Description

@moritz-gerster

Description of the problem

When setting the bipolar reference between one good and one bad channel, the final bipolar channel is marked as good.

Bad channels are marked as bad because they contain artefacts. The bipolar reference between a bad channel and a good channel can never yield a good channel as a result. Therefore, the resulting bipolar channels should be marked as bad by mne.

Jupyter Notebook: Steps to reproduce

Steps to reproduce

A jupyter notebook to reproduce the problem is uploaded as a pdf.

Link to data

No response

Expected results

Bipolar referencing works but the bipolar channel is automatically marked as bad.

Actual results

Bipolar referencing works but the bipolar channel is marked as a good channel even though it is clearly a bad channel.

Additional information

Platform: macOS-12.6-arm64-arm-64bit
Python: 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:41:22) [Clang 13.0.1 ]
Executable: /Users/moritzgerster/anaconda3/envs/bids_neu/bin/python
CPU: arm: 10 cores
Memory: 16.0 GB

mne: 1.2.dev0
numpy: 1.23.2 {unknown linalg bindings (threadpoolctl module not found: No module named 'threadpoolctl')}
scipy: 1.9.0
matplotlib: 3.5.3 {backend=module://matplotlib_inline.backend_inline}

sklearn: Not found
numba: Not found
nibabel: 4.0.1
nilearn: Not found
dipy: Not found
openmeeg: Not found
cupy: Not found
pandas: 1.4.3
pyvista: 0.36.1 {OpenGL 4.1 Metal - 76.3 via Apple M1 Pro}
pyvistaqt: 0.9.0
ipyvtklink: Not found
vtk: 9.1.0
qtpy: 2.2.0 {None=None}
ipympl: Not found
pyqtgraph: Not found
pooch: v1.6.0

mne_bids: 0.10
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: Not found
mne_connectivity: Not found
mne_icalabel: Not found

Activity

  1. welcome commented on Oct 13, 2022

    @welcome

    Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

  2. agramfort commented on Oct 13, 2022

    @agramfort
    SponsorMember
  3. moritz-gerster commented on Oct 13, 2022

    @moritz-gerster
    ContributorAuthor

    agreed set_bipolar_reference should update the info['bads'] and maybe even maybe warn that a bipolar channel is created from bad channels?
    …
    Message ID: @.***>

    great, we currently work on a PR!

  4. hoechenberger commented on Oct 13, 2022

    @hoechenberger
    Member

    I think we should raise if a channel is bad, not just warn 🤔

  5. larsoner commented on Oct 13, 2022

    @larsoner
    Member

    Agreed. And to give an option we could have on_bad='raise' as a default, that way people can override with 'warn' or 'ignore' if they really know what they are doing

  6. moritz-gerster commented on Oct 13, 2022

    @moritz-gerster
    ContributorAuthor

    I think we should raise if a channel is bad, not just warn 🤔

    Are you sure @hoechenberger? Usually, bad channels are easily excluded from further analysis, so it wouldn't hurt to add some bad bipolar channels to the instance. It could be very cumbersome to remove the bad channels from all anodes and cathodes manually before passing them to set_bipolar_reference.

    @larsoner's suggestion seems reasonable to me if on_bad='warn' will be the default argument?

  7. moritz-gerster commented on Oct 13, 2022

    @moritz-gerster
    ContributorAuthor

    If on_bad='raise', which error should be raised? ValueError?

  8. larsoner commented on Oct 13, 2022

    @larsoner
    Member

    Use the _on_missing handler, it will take care of these conditionals and classes for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions