Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/dev/14418.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug with :func:`mne.preprocessing.annotate_muscle_zscore` where channels in ``raw.info["bads"]`` were included in the computation of the muscle artifact scores, by `Hamza Abdelhedi`_.
2 changes: 1 addition & 1 deletion mne/preprocessing/artifact_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def annotate_muscle_zscore(
logger.info("Using %s sensors for muscle artifact detection", ch_type)
else:
_check_option("ch_type", ch_type, ["mag", "grad", "eeg"])
raw_copy.pick(ch_type)
raw_copy.pick(ch_type, exclude="bads")

raw_copy.filter(
filter_freq[0],
Expand Down
6 changes: 6 additions & 0 deletions mne/preprocessing/tests/test_artifact_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ def test_muscle_annotation(meas_date, events):
onset = onset.astype(int)
assert_array_equal(scores[onset].astype(int), np.array([23, 10]))
assert annot_muscle.duration.size == 2
# Bad channels are excluded
raw.info["bads"] = ["MEG0111"]
_, scores_bads = annotate_muscle_zscore(raw, ch_type="mag", threshold=10)
raw_drop = raw.copy().drop_channels(raw.info["bads"])
_, scores_drop = annotate_muscle_zscore(raw_drop, ch_type="mag", threshold=10)
assert_allclose(scores_bads, scores_drop)
raw.set_annotations(annot_muscle)


Expand Down
Loading