eelbrain.ChannelModel.find_bad_windows
- ChannelModel.find_bad_windows(data, threshold=5e-05, max_exclude=0.25, window=1.0, hop=0.5, min_duration=0.1, merge_gap=None)[source]
Find the time windows in which each sensor is bad.
Like
score(), but time-resolved: instead of flagging a channel for a whole epoch, the channel is scored within sliding time windows so that a bad channel is only flagged over the interval in which it is actually bad.- Parameters:
data (NDVar | str | list) – EEG data with the same sensors used for fitting; typically a
list(orDatalist) of long, variable-length epochs (eachsensor x time). A single continuous NDVar (sensor x time) or epoched NDVar (case x sensor x time) is also accepted.threshold (float) – A channel is bad in a window when its error exceeds this absolute value (default 50 µV; see
score()).max_exclude (float) – Maximum number of channels to exclude per window (see
score()).window (float) – Length of the sliding scoring window in seconds (default 1.0).
hop (float) – Step between successive windows in seconds (default 0.5).
min_duration (float) – Discard bad windows shorter than this many seconds (default 0.1).
merge_gap (float | None) – Merge two bad windows of the same channel separated by less than this many seconds (default:
window).
- Returns:
windows – One list of
BadChannelWindowper epoch (per case for an epoched NDVar; a single list for a continuous NDVar).- Return type:
Notes
The data are scanned with a window of length
windowseconds, stepped byhopseconds. Within each window the step-down scoring ofscore()is applied, so every channel gets an error and hence a good/bad classification (bad when the error exceedsthreshold) for that window, with at mostmax_excludechannels flagged per window. A time point is then considered bad for a channel if it is covered by any window in which that channel was classified bad; since each window’s verdict applies to the window’s full width and successive windows overlap (whenhop<window), the bad time points form contiguous runs. Each run is returned as aBadChannelWindow, after discarding runs shorter thanmin_durationand merging runs of the same channel separated by less thanmerge_gap.Because a window’s verdict spans its whole width, a localized artifact is bracketed by up to roughly one
windowlength of margin on each side.windowtherefore effectively sets the amount of padding around detected artifacts, whilehopcontrols how precisely the window edges are placed.