You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
I would call parameter threshold not thr. Why do you need notch? what
is t_min? if onset of raw why not pass
a cropped raw? We should aim for the simplest API that does the job.
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.
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.
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.
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.
Activity
agramfort commentedon Feb 27, 2020
AdoNunes commentedon Feb 27, 2020
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.
drammock commentedon Feb 28, 2020
@AdoNunes can you mock up the API exactly as you envision it? Something like
and if there are variable outputs, give additional examples, like
AdoNunes commentedon Feb 28, 2020
Actually I did a PR #7096 with this function that at the end got shortened to
annotate_movement.The API looks like this:
Returns annotations and a 1xn_samples vector with the averaged z-scores at each sample.
agramfort commentedon Feb 28, 2020
larsoner commentedon Feb 28, 2020
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.
AdoNunes commentedon Feb 28, 2020
OK.
Then the API should look like this:
Can you suggest me a dataset reach in muscle artifacts for the example and tests?
agramfort commentedon Feb 28, 2020
AdoNunes commentedon Mar 2, 2020
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.
What do you think?
larsoner commentedon Mar 2, 2020
Sounds reasonable to me
drammock commentedon Mar 2, 2020
Is
annotate_muscleis the right name for the function (compared to, say,find_muscle_artifactsorannotate_muscle_artifactsor 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.drammock commentedon Mar 2, 2020
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.AdoNunes commentedon Mar 2, 2020
@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.