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.

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.


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.


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.


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

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only.

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.


New in version 0.24.

Examples using mne.preprocessing.annotate_break