Skip to content

ENH: what to do with muscle artifacts #7359

Closed

Description

@AdoNunes

If I am not mistaken, currently, to remove muscle artifacts it is only possible by manually annotating bad segments or write custom code to detect them.

Muscle artifacts are an issue if data is not low band passed, i.e. if studying gamma activity.

If you think that a function for estimating segments of data with muscle artifacts would be a good addition, let me know and I will make a PR.

Activity

  1. agramfort commented on Feb 27, 2020

    @agramfort
    SponsorMember
  2. AdoNunes commented on Feb 27, 2020

    @AdoNunes
    ContributorAuthor

    I was thinking to be similar to the head motion detection. Basically, the input is the raw data and the output the annotation of segments with muscle artifacts.

    The function would be very similar to how Fieldtrip does it. The data is band passed filtered between 110-140Hz, z-scored, low-passed to reduce spikes, z-score averaged across channels, and whatever is above the z-score threshold get annotated.

  3. drammock commented on Feb 28, 2020

    @drammock
    Member

    @AdoNunes can you mock up the API exactly as you envision it? Something like

    name_of_output = mne.preprocessing.name_of_new_function(arg1, arg2)

    and if there are variable outputs, give additional examples, like

    (output1, output2) = mne.preprocessing.new_function(arg1, arg2, return_extra_output=True)
  4. AdoNunes commented on Feb 28, 2020

    @AdoNunes
    ContributorAuthor

    Actually I did a PR #7096 with this function that at the end got shortened to annotate_movement.
    The API looks like this:

    annotation_muscle, scores_muscle = mne.preprocessing.annotate_muscle(raw, thr=threshold_muscle, t_min=0,
                                                     notch=None)
    

    Returns annotations and a 1xn_samples vector with the averaged z-scores at each sample.

  5. agramfort commented on Feb 28, 2020

    @agramfort
    SponsorMember
  6. larsoner commented on Feb 28, 2020

    @larsoner
    Member

    For example if notch filtering is optional (e.g., to remove line frequencies), users should do it before calling the function and we can tell them to in the notes section.

  7. AdoNunes commented on Feb 28, 2020

    @AdoNunes
    ContributorAuthor

    OK.
    Then the API should look like this:

    annotation_muscle, scores_muscle = mne.preprocessing.annotate_muscle(raw, threshold =threshold_muscle)
    

    Can you suggest me a dataset reach in muscle artifacts for the example and tests?

  8. agramfort commented on Feb 28, 2020

    @agramfort
    SponsorMember
  9. AdoNunes commented on Mar 2, 2020

    @AdoNunes
    ContributorAuthor

    It might be necessary to add the pick types (or channels) and also set a minimum segment length of good segments, i.e. mark as bad a segment between two annotations shorted than, for example, .2 seconds.

    annotation_muscle, scores_muscle = mne.preprocessing.annotate_muscle(raw, threshold,
    picks, min_length_good)
    

    What do you think?

  10. larsoner commented on Mar 2, 2020

    @larsoner
    Member

    Sounds reasonable to me

  11. drammock commented on Mar 2, 2020

    @drammock
    Member

    Is annotate_muscle is the right name for the function (compared to, say, find_muscle_artifacts or annotate_muscle_artifacts or something else)? I don't have strong instincts about what is best here, just want to ask the question now, before it becomes an API change question.

  12. drammock commented on Mar 2, 2020

    @drammock
    Member

    also wondering whether this function catches all kinds of muscle artifacts (swallowing, chewing, facial/scalp muscle, tongue/jaw/speech, etc). If not, that might suggest a more narrow naming choice like e.g. annotate_swallowing_artifact.

  13. AdoNunes commented on Mar 2, 2020

    @AdoNunes
    ContributorAuthor

    @drammock I named to be consistent with annotate_movement. Yes, it caches all types of muscles around the head as long as they are strong enough.

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