Skip to content

Automatic detection of the bad EEG channels inspired by the PREP pipeline #7049

Closed

Description

@AamnaLawrence

Describe the problem

Finding bad channels is a crucial step in EEG pre-processing for making the data amenable for analysis. Detecting bad channels also has implications in re-referencing the EEG data further down in the pre-processing pipeline. Currently, MNE does not have the functionality for detecting bad channels using a single function. Also, manually rejecting bad channels by visual inspection could be cumbersome and subjective.

Describe your solution

The criteria used by the PREP pipeline is quite powerful for detecting the noisy channels and is shown to be more sensitive than the EEGLAB’s pop_rejchan function. Bad channels are detected by testing for Nan values, DC values, robust standard deviation, finding correlations among 50 Hz low-pass filtered signals, finding correlations between channels using random sampling consensus prediction, high-frequency noise, and low signal-to-noise ratio.
I would like to incorporate this functionality in MNE.

Additional context

Automagic in MATLAB posses this functionality by implementing the PREP pipeline.

Activity

  1. drammock commented on Nov 11, 2019

    @drammock
    Member

    How does PREP compare to autoreject?

  2. AamnaLawrence commented on Nov 11, 2019

    @AamnaLawrence
    Author

    @drammock PREP in itself is an EEG preprocessing pipeline concerned with filtering, bad channel detection and re-referencing. They follow an exhaustive list for detecting bad channels which includes rejection based on the RANSAC method, high-frequency noise, and SNR, to name a few.

  3. drammock commented on Nov 12, 2019

    @drammock
    Member

    What I mean is, autoreject also detects and repairs bad channels (and includes an implementation of RANSAC). Can you say a little more about what (specifically) you want to add that isn't already covered by autoreject?

  4. AamnaLawrence commented on Nov 13, 2019

    @AamnaLawrence
    Author

    @agramfort Agreed that autoreject can detect bad channels are trials based on deviation and correlation, however, in PREP, bad channels are also detected by having HF noise where the signal is 50Hz low pass filtered and the ratio of the median absolute deviation of the high and low-frequency components is used to compute the robust z-score.

  5. agramfort commented on Nov 13, 2019

    @agramfort
    SponsorMember
  6. jasmainak commented on Nov 13, 2019

    @jasmainak
    Member

    in practice though, it's RANSAC which PREP mostly relies on. It's what I've observed. The bad channels detected by the other methods are a subset of this.

  7. AamnaLawrence commented on Nov 13, 2019

    @AamnaLawrence
    Author

    @jasmainak not necessarily since RANSAC relies only on corrrelation.

  8. drammock commented on Nov 13, 2019

    @drammock
    Member

    cc @sappelhoff, and crossref to #7048 and #7053. Here are some possible ways forward:

    1. all of PREP gets implemented in MNE-Python (presumably led by @AamnaLawrence, @Nick3151, @adam2392, and others, who seem to be doing this as coursework? cf http://neurodatadesign.io/)
    2. all of PREP gets implemented in a companion module that uses MNE-Python data structures (https://github.com/sappelhoff/pyprep seems like a natural starting point, but https://autoreject.github.io/ is maybe another possibility?)
    3. some (but not all) parts of PREP get incorporated into MNE-Python
    4. some (but not all) parts of PREP get incorporated into one or more companion modules

    Once we decide that, we can start discussing API / implementation details.

    @sappelhoff @agramfort @jasmainak @larsoner @cbrnr any strong opinions?

  9. agramfort commented on Nov 13, 2019

    @agramfort
    SponsorMember
  10. adam2392 commented on Nov 13, 2019

    @adam2392
    Member

    @drammock @agramfort Would you say autoreject, or pyprep is a better place to start? It seems like they are doing very similar things, but autoreject having more functionality?

    We can start by making separate issues, and consolidating PRs to address each of these separate funcs including but not limited to:

    1. Feature enhancement by adding filtering, line noise removal, robust PCA, and robust referencing (via Ransac).
    2. Integrating all the steps into one function and pipeline
  11. drammock commented on Nov 14, 2019

    @drammock
    Member

    I think it's probably up to @jasmainak and @sappelhoff whether these additions go into autoreject or pyprep. Based on sappelhoff/pyprep#2 I'm guessing Stefan is fine with pyprep as the home for this; @jasmainak is that OK with you?

  12. jasmainak commented on Nov 14, 2019

    @jasmainak
    Member

    Either is fine by me since we're all a happy family :) While a separate package is nice for speedy development, it duplicates efforts and fractures the ecosystem a bit. Ultimately, we want to give researchers better tools to look and process their data. Currently, we have some preprocessing code in MNE-sandbox, then a separate repository for autoreject, a separate repo for PREP now. I think there are also some separate scripts for preprocessing CTF data that are floating around. It would be helpful to consolidate all these in a single place.

    That being said, I think it's fine to proceed with @sappelhoff 's repository for now and think about consolidation plans in the future.

  13. sappelhoff commented on Nov 14, 2019

    @sappelhoff
    Member

    I think that autoreject is better off remaining an "autoreject-only" repository: It keeps the codebase clean and there is a tight connection between the scientific publication and the codebase.

    I also agree with Alex that it's better to keep these rather large preprocessing pipelines (PREP, autoreject, ...) as minimal repositories, separate from MNE-Python ... so that they can be more flexibly developed ... and installed on a use base.

    Same reason as with autoreject, I think that the pyprep repo would be a good home for the Python implementation of PREP.

    Currently, there is also some part of the FASTER pipeline in the pyprep repo, based on @wmvanvliet's code

    ... I am happy to get rid of FASTER (transferring to another repo), and also API changes etc. are no problem.

  14. wmvanvliet commented on Nov 14, 2019

    @wmvanvliet
    Contributor

    Great to see people picking up this kind of work! The pyprep repo seems like a good place for it. Not sure about the current API of the Noisy class though. I would personally go with either plain functions or a scikit-learn type fit()/apply() API.

  15. cbrnr commented on Nov 14, 2019

    @cbrnr
    Contributor

    👍 for implementing all/part of PREP in pyprep.

  16. agramfort commented on Nov 14, 2019

    @agramfort
    SponsorMember
  17. larsoner commented on Nov 14, 2019

    @larsoner
    Member

    On it

  18. drammock commented on Nov 14, 2019

    @drammock
    Member
  19. larsoner commented on Nov 14, 2019

    @larsoner
    Member

    Hah! Missed that. I'll add a couple of things

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions