Annotate raw data based on peak-to-peak amplitude. Creates annotations ``BAD_peak`` or ``BAD_flat`` for spans of data where consecutive samples exceed the threshold in ``peak`` or fall below the threshold in ``flat`` for more than ``min_duration``. Channels where more than ``bad_per
(
raw,
peak=None,
flat=None,
bad_percent=5,
min_duration=0.005,
picks=None,
*,
verbose=None,
)
| 17 | |
| 18 | @verbose |
| 19 | def annotate_amplitude( |
| 20 | raw, |
| 21 | peak=None, |
| 22 | flat=None, |
| 23 | bad_percent=5, |
| 24 | min_duration=0.005, |
| 25 | picks=None, |
| 26 | *, |
| 27 | verbose=None, |
| 28 | ): |
| 29 | """Annotate raw data based on peak-to-peak amplitude. |
| 30 | |
| 31 | Creates annotations ``BAD_peak`` or ``BAD_flat`` for spans of data where |
| 32 | consecutive samples exceed the threshold in ``peak`` or fall below the |
| 33 | threshold in ``flat`` for more than ``min_duration``. |
| 34 | Channels where more than ``bad_percent`` of the total recording length |
| 35 | should be annotated with either ``BAD_peak`` or ``BAD_flat`` are returned |
| 36 | in ``bads`` instead. |
| 37 | Note that the annotations and the bads are not automatically added to the |
| 38 | :class:`~mne.io.Raw` object; use :meth:`~mne.io.Raw.set_annotations` and |
| 39 | :class:`info['bads'] <mne.Info>` to do so. |
| 40 | |
| 41 | Parameters |
| 42 | ---------- |
| 43 | raw : instance of Raw |
| 44 | The raw data. |
| 45 | peak : float | dict | None |
| 46 | Annotate segments based on **maximum** peak-to-peak signal amplitude |
| 47 | (PTP). Valid **keys** can be any channel type present in the object. |
| 48 | The **values** are floats that set the maximum acceptable PTP. If the |
| 49 | PTP is larger than this threshold, the segment will be annotated. |
| 50 | If float, the minimum acceptable PTP is applied to all channels. |
| 51 | flat : float | dict | None |
| 52 | Annotate segments based on **minimum** peak-to-peak signal amplitude |
| 53 | (PTP). Valid **keys** can be any channel type present in the object. |
| 54 | The **values** are floats that set the minimum acceptable PTP. If the |
| 55 | PTP is smaller than this threshold, the segment will be annotated. |
| 56 | If float, the minimum acceptable PTP is applied to all channels. |
| 57 | bad_percent : float |
| 58 | The percentage of the time a channel can be above or below thresholds. |
| 59 | Below this percentage, :class:`~mne.Annotations` are created. |
| 60 | Above this percentage, the channel involved is return in ``bads``. Note |
| 61 | the returned ``bads`` are not automatically added to |
| 62 | :class:`info['bads'] <mne.Info>`. |
| 63 | Defaults to ``5``, i.e. 5%%. |
| 64 | min_duration : float |
| 65 | The minimum duration (s) required by consecutives samples to be above |
| 66 | ``peak`` or below ``flat`` thresholds to be considered. |
| 67 | to consider as above or below threshold. |
| 68 | For some systems, adjacent time samples with exactly the same value are |
| 69 | not totally uncommon. Defaults to ``0.005`` (5 ms). |
| 70 | %(picks_good_data)s |
| 71 | %(verbose)s |
| 72 | |
| 73 | Returns |
| 74 | ------- |
| 75 | annotations : instance of Annotations |
| 76 | The annotated bad segments. |