mne.preprocessing.annotate_muscle_zscore#

mne.preprocessing.annotate_muscle_zscore(raw, threshold=4, ch_type=None, min_length_good=0.1, filter_freq=(110, 140), n_jobs=None, verbose=None)[source]#

Create annotations for segments that likely contain muscle artifacts.

Detects data segments containing activity in the frequency range given by filter_freq whose envelope magnitude exceeds the specified z-score threshold, when summed across channels and divided by sqrt(n_channels). False-positive transient peaks are prevented by low-pass filtering the resulting z-score time series at 4 Hz. Only operates on a single channel type, if ch_type is None it will select the first type in the list mag, grad, eeg. See [1] for background on choosing filter_freq and threshold.

Parameters:
rawinstance of Raw

Data to estimate segments with muscle artifacts.

thresholdfloat

The threshold in z-scores for marking segments as containing muscle activity artifacts.

ch_type‘mag’ | ‘grad’ | ‘eeg’ | None

The type of sensors to use. If None it will take the first type in mag, grad, eeg.

min_length_goodfloat | None

The shortest allowed duration of “good data” (in seconds) between adjacent annotations; shorter segments will be incorporated into the surrounding annotations.``None`` is equivalent to 0. Default is 0.1.

filter_freqarray_like, shape (2,)

The lower and upper frequencies of the band-pass filter. Default is (110, 140).

n_jobsint | str

Number of jobs to run in parallel. Can be 'cuda' if cupy is installed properly.

Changed in version 1.13: Added support for CUDA.

verbosebool | str | int | None

Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

Returns:
annotmne.Annotations

Periods with muscle artifacts annotated as BAD_muscle.

scores_musclearray

Z-score values averaged across channels for each sample.

Notes

Because the z-scores are summed across channels and divided by sqrt(n_channels), an artifact present on only a few channels is diluted: one channel with a z-score of 10 among 270 channels contributes only 10 / sqrt(270), about 0.6, to the score. To detect focal muscle activity, such as temporal muscle seen on a few temporal sensors, pass a copy restricted to those channels, e.g. annotate_muscle_zscore(raw.copy().pick(ch_names)).

Each channel is z-scored against its own mean and standard deviation over the whole recording (excluding segments annotated as bad). If a channel shows muscle activity during a large part of the recording, that activity inflates its mean and standard deviation, so the artifact no longer stands out and may not be annotated. In that case, consider marking the channel as bad rather than annotating time spans.

References

Examples using mne.preprocessing.annotate_muscle_zscore#

Annotate muscle artifacts

Annotate muscle artifacts