mne.preprocessing.annotate_break#

mne.preprocessing.annotate_break(raw, events=None, min_break_duration=15.0, t_start_after_previous=5.0, t_stop_before_next=5.0, ignore=('bad', 'edge'), *, verbose=None)[source]#

Create Annotations for breaks in an ongoing recording.

This function first searches for segments in the data that are not annotated or do not contain any events and are at least min_break_duration seconds long, and then proceeds to creating annotations for those break periods.

Parameters:
rawinstance of Raw

The continuous data to analyze.

eventsNone | array, shape (n_events, 3)

If None (default), operate based solely on the annotations present in raw. If an events array, ignore any annotations in the raw data, and operate based on these events only.

min_break_durationfloat

The minimum time span in seconds between the offset of one and the onset of the subsequent annotation (if events is None) or between two consecutive events (if events is an array) to consider this period a “break”. Defaults to 15 seconds.

Note

This value defines the minimum duration of a break period in the data, not the minimum duration of the generated annotations! See also t_start_after_previous and t_stop_before_next for details.

t_start_after_previous, t_stop_before_nextfloat

Specifies how far the to-be-created “break” annotation extends towards the two annotations or events spanning the break. This can be used to ensure e.g. that the break annotation doesn’t start and end immediately with a stimulation event. If, for example, your data contains a break of 30 seconds between two stimuli, and t_start_after_previous is set to 5 and t_stop_before_next is set to 3, the break annotation will start 5 seconds after the first stimulus, and end 3 seconds before the second stimulus, yielding an annotated break of 30 - 5 - 3 = 22 seconds. Both default to 5 seconds.

Note

The beginning and the end of the recording will be annotated as breaks, too, if the period from recording start until the first annotation or event (or from last annotation or event until recording end) is at least min_break_duration seconds long.

ignoreiterable of str

Annotation descriptions starting with these strings will be ignored by the break-finding algorithm. The string comparison is case-insensitive, i.e., ('bad',) and ('BAD',) are equivalent. By default, all annotation descriptions starting with “bad” and annotations indicating “edges” (produced by data concatenation) will be ignored. Pass an empty list or tuple to take all existing annotations into account. If events is passed, this parameter has no effect.

verbosebool | str | int | None

Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

Returns:
break_annotationsinstance of Annotations

The break annotations, each with the description 'BAD_break'. If no breaks could be found given the provided function parameters, an empty Annotations object will be returned.

Notes

New in version 0.24.

Examples using mne.preprocessing.annotate_break#

Rejecting bad data spans and breaks

Rejecting bad data spans and breaks

Rejecting bad data spans and breaks