Repository: mne-tools/mne-python

Issue:
pick() got an unexpected keyword argument ‘meg’
### Description of the problem

I get a Type Error when I use annotate_muscle_zscore() method. I think its a bug.

### Steps to reproduce

```Python
import numpy as np
import mne
from   copy       import deepcopy as dpcpy
from mne.preprocessing import annotate_muscle_zscore

np.random.seed(10)

data = np.random.rand(24,1024)
data1 = np.random.rand(24,251)

data_ = np.concatenate((data, data1),axis=1)

ch_names = ["Fp1", "Fp2", "F3", "F4", "C3", "C4", "P3", "P4", "O1", "O2", "F7", "F8", "T7", "T8", "P7", "P8", "Fz", "Cz", "Pz", "M1", "M2", "AFz", "CPz", "POz"]

montage = mne.channels.make_standard_montage('standard_1020')
info = mne.create_info(ch_names=ch_names, sfreq=1000, ch_types='eeg').set_montage(montage, match_case=False)

raw = mne.io.RawArray(data_,info, copy='data', verbose=False)
raw.set_eeg_reference(projection=True)

raw.notch_filter([60, 120])

threshold_muscle = 5

annot_muscle, scores_muscle = annotate_muscle_zscore(
    raw,
    ch_type="eeg",
    threshold=threshold_muscle,
    min_length_good=0.2,
    filter_freq=[110, 140],
)
```


### Link to data

_No response_

### Expected results

To get the annotations for segments that likely contain muscle artifacts. 

### Actual results

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[31], line 3
      1 threshold_muscle = 5
----> 3 annot_muscle, scores_muscle = annotate_muscle_zscore(raw)

File <decorator-gen-396>:12, in annotate_muscle_zscore(raw, threshold, ch_type, min_length_good, filter_freq, n_jobs, verbose)

File c:\Users\Starboy\AppData\Local\Programs\Python\Python312\Lib\site-packages\mne\preprocessing\artifact_detection.py:106, in annotate_muscle_zscore(raw, threshold, ch_type, min_length_good, filter_freq, n_jobs, verbose)
    104 else:
    105     ch_type = {"meg": False, ch_type: True}
--> 106     raw_copy.pick(**ch_type)
    108 raw_copy.filter(
    109     filter_freq[0],
    110     filter_freq[1],
   (...)
    113     n_jobs=n_jobs,
    114 )
    115 raw_copy.apply_hilbert(envelope=True, n_jobs=n_jobs)

TypeError: pick() got an unexpected keyword argument 'meg'

### Additional information

Platform             Windows-10-10.0.22631-SP0
Python               3.9.18 (main, Sep 11 2023, 14:09:26) [MSC v.1916 64 bit (AMD64)]
Executable           C:\Users\Starboy\.envBMindMNE\python.exe
CPU                  AMD64 Family 25 Model 68 Stepping 1, AuthenticAMD (16 cores)
Memory               15.2 GB

Core
├☒ mne               1.6.0 (outdated, release 1.6.1 is available!)
├☑ numpy             1.22.4 (MKL 2023.2-Product with 8 threads)
├☑ scipy             1.11.1
├☑ matplotlib        3.5.3 (backend=QtAgg)
├☑ pooch             1.7.0
└☑ jinja2            3.1.2

Numerical (optional)
├☑ sklearn           1.3.0
├☑ numba             0.57.1
├☑ nibabel           5.1.0
├☑ nilearn           0.10.1
├☑ dipy              1.7.0
├☑ openmeeg          2.5.6
├☑ pandas            2.1.0
└☐ unavailable       cupy

Visualization (optional)
├☑ pyvista           0.42.1 (OpenGL 4.6.0 Compatibility Profile Context 24.1.1.240110 via AMD Radeon(TM) Graphics)
├☑ pyvistaqt         0.0.0
├☑ vtk               9.2.6
├☑ qtpy              2.4.0 (PyQt5=5.15.4)
├☑ ipympl            0.9.3
├☑ pyqtgraph         0.13.3
├☑ mne-qt-browser    0.5.2
├☑ ipywidgets        7.7.2
├☑ trame_client      2.15.0
├☑ trame_server      2.15.0
├☑ trame_vtk         2.7.1
└☑ trame_vuetify     2.4.2


Discussion:
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴


Resolving patch:
diff --git a/mne/preprocessing/artifact_detection.py b/mne/preprocessing/artifact_detection.py
--- a/mne/preprocessing/artifact_detection.py
+++ b/mne/preprocessing/artifact_detection.py
@@ -25,7 +25,14 @@
     apply_trans,
     quat_to_rot,
 )
-from ..utils import _mask_to_onsets_offsets, _pl, _validate_type, logger, verbose
+from ..utils import (
+    _check_option,
+    _mask_to_onsets_offsets,
+    _pl,
+    _validate_type,
+    logger,
+    verbose,
+)
 
 
 @verbose
@@ -94,16 +101,13 @@ def annotate_muscle_zscore(
             ch_type = "eeg"
         else:
             raise ValueError(
-                "No M/EEG channel types found, please specify a"
-                " ch_type or provide M/EEG sensor data"
+                "No M/EEG channel types found, please specify a 'ch_type' or provide "
+                "M/EEG sensor data."
             )
-        logger.info("Using %s sensors for muscle artifact detection" % (ch_type))
-
-    if ch_type in ("mag", "grad"):
-        raw_copy.pick(ch_type)
+        logger.info("Using %s sensors for muscle artifact detection", ch_type)
     else:
-        ch_type = {"meg": False, ch_type: True}
-        raw_copy.pick(**ch_type)
+        _check_option("ch_type", ch_type, ["mag", "grad", "eeg"])
+    raw_copy.pick(ch_type)
 
     raw_copy.filter(
         filter_freq[0],


Test patch: