Repository: mne-tools/mne-python

Issue:
Document that we allow for rejection based on EMG PTP
Request from the forum:
https://mne.discourse.group/t/reject-epochs-based-on-peak-to-peak-signal-amplitude-ptp-of-emg


Discussion:
@hoechenberger I had a look at this as I thought this would be an easy first contribution to MNE. Isn't this already implemented?
I tested this loading a -raw file with 2 AUX channels, an EOG, and an ECG. I changed the type/name of the ECG to EMG to test.

```
import mne
import numpy as np

fname = r'path to -raw.fif'
raw = mne.io.read_raw(fname, preload=True)

mne.rename_channels(raw.info, {'AUX7': 'EOG', 'AUX8': 'EMG'}) 
raw.set_channel_types(mapping={'EMG':'emg', 'EOG':'eog'}) 

raw.set_eeg_reference(ref_channels='average', ch_type='eeg', projection=False)
raw.notch_filter(np.arange(50, 101, 50), picks=['eeg', 'emg', 'eog'], filter_length='auto', phase='zero')
mne.io.Raw.filter(raw, l_freq=1., h_freq=40., picks=['eeg'], method='iir',
                  iir_params=dict(order=4, ftype='butter', output='sos'))

events = mne.find_events(raw, stim_channel='TRIGGER')
reject = dict(eeg=80e-6,      # unit: V (EEG channels)
              emg=250e-6      # unit: V
              )

epochs = mne.Epochs(raw, events, event_id=4,
                    picks=['eeg', 'eog', 'emg'],
                    tmin=-0.2, tmax=0.8, reject=reject,
                    proj=True, baseline=(None, 0), preload=True)
```

And I do get a long verbose feedback in the console, with:

```
    Rejecting  epoch based on EMG : ['EMG']
    Rejecting  epoch based on EMG : ['EMG']
    Rejecting  epoch based on EEG : ['Fp2', 'F8', 'AF7', 'AF8']
    Rejecting  epoch based on EMG : ['EMG']
    Rejecting  epoch based on EMG : ['EMG']
    Rejecting  epoch based on EEG : ['Fp1', 'Fpz', 'Fp2', 'AF7', 'AF8']
    Rejecting  epoch based on EMG : ['EMG']
    Rejecting  epoch based on EMG : ['EMG']
```

`BaseEpochs._reject_setup` handles properly PTP rejection from any type of data as long as it is present in `self.info`, i.e. as long as it is present in the `picks` argument of `mne.Epochs`.

Did I oversee anything or is this actually already implemented?
it seems it's already working :)

>

I have run a test on another dataset. Yes, Mathiue @mscheltienne you are right. PTP rejection works for  EMG data when creating epochs. In this case, I suggest updating the documentation of mne. In the following link https://mne.tools/stable/generated/mne.Epochs.html#, it is stated that valid keys are: 'grad', 'mag', 'eeg', 'eog', and 'ecg' for the **reject** parameter.
Thanks for checking, @GanshengT. Would you like to do a PR? Such feedback and improvements from users are always highly welcome.
The documentation is traced back to 
```
%(reject_epochs)s
```
in mne.Epochs., class Epochs(BaseEpochs)
Would you mind explaining what is the **%()s** structure and how is it related to the docstrings？
see here:

https://github.com/mne-tools/mne-python/blob/main/mne/utils/docs.py#L2301

to avoid duplicating all docstrings there is common dictionary and %()s is used to replace the key

Resolving patch:
diff --git a/mne/utils/docs.py b/mne/utils/docs.py
--- a/mne/utils/docs.py
+++ b/mne/utils/docs.py
@@ -2295,7 +2295,7 @@
     respective epoch will be dropped.
 
     The dictionary keys correspond to the different channel types; valid
-    keys are: ``'grad'``, ``'mag'``, ``'eeg'``, ``'eog'``, and ``'ecg'``.
+    **keys** can be any channel type present in the object.
 
     Example::
 
@@ -2326,8 +2326,8 @@
 """
 flat_common = """
     Reject epochs based on **minimum** peak-to-peak signal amplitude (PTP).
-    Valid **keys** are ``'grad'``, ``'mag'``, ``'eeg'``, ``'eog'``, ``'ecg'``.
-    The **values** are floats that set the minimum acceptable PTP. If the PTP
+    Valid **keys** can be any channel type present in the object. The
+    **values** are floats that set the minimum acceptable PTP. If the PTP
     is smaller than this threshold, the epoch will be dropped. If ``None``
     then no rejection is performed based on flatness of the signal."""
 docdict['flat'] = f"""


Test patch: