eegprep.clean_windows#
- eegprep.clean_windows(EEG, max_bad_channels=0.2, zthresholds=(-3.5, 5), window_len=1.0, window_overlap=0.66, max_dropout_fraction=0.1, min_clean_fraction=0.25, truncate_quant=(0.022, 0.6), step_sizes=(0.01, 0.01), shape_range=array([1.7, 1.85, 2., 2.15, 2.3, 2.45, 2.6, 2.75, 2.9, 3.05, 3.2, 3.35, 3.5]))#
Remove periods with abnormally high-power content from continuous data.
This function cuts segments from the data which contain high-power artifacts. Specifically, only windows are retained which have less than a certain fraction of bad channels, where a channel is bad in a window if its RMS power is above or below some z-threshold relative to a robust estimate of clean EEG power in that channel.
- Return type:
- Parameters:
Args#
- EEGdict
Continuous dataset using the EEGLAB dict schema. The data is expected to be high-passed appropriately (>1 Hz recommended).
- max_bad_channelsint | float
The maximum number or fraction of channels that may exceed the thresholds inside a time-window for the window to be kept. Values in (0,1) are interpreted as a fraction; otherwise as an absolute count.
- zthresholdstuple(float, float)
Lower and upper z-score limits for RMS power ([low, high]).
- window_lenfloat
Window length in seconds. Should be at least half a period of the high- pass cut-off that was used. Default is 1 s.
- window_overlapfloat
Fractional overlap between consecutive windows (0-1). Higher overlap finds more artefacts but is slower. Default is 0.66 (≈⅔ overlap).
- max_dropout_fractionfloat
Maximum fraction of windows that may have arbitrarily low amplitude (e.g. sensor unplugged). Default is 0.1.
- min_clean_fractionfloat
Minimum fraction of windows expected to be clean (essentially uncontaminated EEG). Default is 0.25.
- truncate_quanttuple(float, float)
Quantile range of the truncated Gaussian to fit (default (0.022,0.6)).
- step_sizestuple(float, float)
Grid-search step sizes in quantiles for lower/upper edge.
- shape_rangesequence(float)
Range for the beta shape parameter in the generalised Gaussian used for distribution fitting.
Returns#
- EEGdict
The passed-in structure with bad time periods excised.
- sample_masknp.ndarray[bool]
Boolean mask (length == original
pnts) indicating which samples are retained (True) or removed (False).