osl_dynamics.meeg.preproc.detect_flat_segments#

osl_dynamics.meeg.preproc.detect_flat_segments(raw, picks='meg', min_duration=0.1, pad=1.0, ref_meg='auto')#

Mark segments where every channel is constant as bad.

Finds stretches where all the picked channels hold their value from one sample to the next, for example output that MaxFilter set to zero (it zeroes a whole tSSS buffer when too many channels are bad in it) or an acquisition drop-out. detect_bad_segments() only catches short stretches like these: it marks at most maximum_fraction of the data, and many flat windows lower the mean and standard deviation it compares each window with.

Run this before filtering: a filter turns the flat stretches into small values that are no longer constant. The segments are annotated as bad_segment_flat, so detect_bad_segments() run afterwards leaves them out.

Parameters:
rawmne.io.Raw

MNE Raw object.

picksstr, optional

Channel type to pick: ‘meg’, ‘mag’, ‘grad’ or ‘eeg’.

min_durationfloat, optional

Shortest flat stretch to mark, in seconds.

padfloat, optional

Seconds to also mark on either side of each flat stretch, for the response of later filtering to the step into and out of it.

ref_megstr, optional

ref_meg argument to pass to mne.pick_types.

Returns:
rawmne.io.Raw

MNE Raw object.