MCPcopy
hub / github.com/mne-tools/mne-python / annotate_muscle_zscore

Function annotate_muscle_zscore

mne/preprocessing/artifact_detection.py:39–149  ·  view source on GitHub ↗

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)

(
    raw,
    threshold=4,
    ch_type=None,
    min_length_good=0.1,
    filter_freq=(110, 140),
    n_jobs=None,
    verbose=None,
)

Source from the content-addressed store, hash-verified

37
38@verbose
39def annotate_muscle_zscore(
40 raw,
41 threshold=4,
42 ch_type=None,
43 min_length_good=0.1,
44 filter_freq=(110, 140),
45 n_jobs=None,
46 verbose=None,
47):
48 """Create annotations for segments that likely contain muscle artifacts.
49
50 Detects data segments containing activity in the frequency range given by
51 ``filter_freq`` whose envelope magnitude exceeds the specified z-score
52 threshold, when summed across channels and divided by ``sqrt(n_channels)``.
53 False-positive transient peaks are prevented by low-pass filtering the
54 resulting z-score time series at 4 Hz. Only operates on a single channel
55 type, if ``ch_type`` is ``None`` it will select the first type in the list
56 ``mag``, ``grad``, ``eeg``.
57 See :footcite:`Muthukumaraswamy2013` for background on choosing
58 ``filter_freq`` and ``threshold``.
59
60 Parameters
61 ----------
62 raw : instance of Raw
63 Data to estimate segments with muscle artifacts.
64 threshold : float
65 The threshold in z-scores for marking segments as containing muscle
66 activity artifacts.
67 ch_type : 'mag' | 'grad' | 'eeg' | None
68 The type of sensors to use. If ``None`` it will take the first type in
69 ``mag``, ``grad``, ``eeg``.
70 min_length_good : float | None
71 The shortest allowed duration of "good data" (in seconds) between
72 adjacent annotations; shorter segments will be incorporated into the
73 surrounding annotations.``None`` is equivalent to ``0``.
74 Default is ``0.1``.
75 filter_freq : array-like, shape (2,)
76 The lower and upper frequencies of the band-pass filter.
77 Default is ``(110, 140)``.
78 %(n_jobs)s
79 %(verbose)s
80
81 Returns
82 -------
83 annot : mne.Annotations
84 Periods with muscle artifacts annotated as BAD_muscle.
85 scores_muscle : array
86 Z-score values averaged across channels for each sample.
87
88 References
89 ----------
90 .. footbibliography::
91 """
92 raw_copy = raw.copy()
93
94 if ch_type is None:
95 raw_ch_type = raw_copy.get_channel_types()
96 if "mag" in raw_ch_type:

Calls 13

_check_optionFunction · 0.85
filter_dataFunction · 0.85
_annotations_from_maskFunction · 0.85
_adjust_onset_meas_dateFunction · 0.85
get_channel_typesMethod · 0.80
infoMethod · 0.80
apply_hilbertMethod · 0.80
sqrtMethod · 0.80
copyMethod · 0.45
pickMethod · 0.45
filterMethod · 0.45
get_dataMethod · 0.45

Tested by 2

test_muscle_annotationFunction · 0.72