braindecode.preprocessing.RemoveBadChannels#
- class braindecode.preprocessing.RemoveBadChannels(*, corr_threshold=0.8, noise_threshold=4.0, window_len=5, max_broken_time=0.4, subset_size=0.25, num_samples=50)[source]#
 Removes EEG channels with problematic data; variant that uses channel locations. Implemented as in [Kothe2013].
This is an automated artifact rejection function which ensures that the data contains no channels that record only noise for extended periods of time. This uses a hybrid criterion involving correlation and high-frequency noise thresholds:
if a channel has lower correlation to its robust estimate (based on other channels) than a given threshold for a minimum period of time (or percentage of the recording), it will be removed.
if a channel has more (high-frequency) noise relative relative to the (robust) population of other channels than a given threshold (in standard deviations), it will be removed.
This method requires channels to have an associated location; when a location is not known or could not be inferred (e.g., from channel labels if using a standard montage such as the 10-20 system), use the
RemoveBadChannelsNoLocspreprocessor instead.Preconditions:
One of
RemoveDriftsorbraindecode.preprocessing.Filter( configured as a highpass filter) must have been applied beforehand.3D channel locations must be available in the data (can be automatic with some file types, but may require some MNE operations with others).
Consider applying
RemoveDCOffsetbeforehand as a general precaution.
- Parameters:
 corr_threshold (float) – Correlation threshold. If a channel over a short time window is correlated at less than this value to its robust estimate (based on other channels), it is considered abnormal during that time. A good default range is 0.75-0.8 and the default is 0.8. Becomes quite aggressive at and beyond 0.8; also, consider using lower values (eg 0.7-0.75) for <32ch EEG and higher (0.8-0.85) for >128ch. This is the main tunable parameter of the method.
noise_threshold (float) – Threshold for high-frequency (>=45 Hz) noise-based bad channel detection, in robust z-scores (i.e., st. devs.). Lower is more aggressive. Default is 4.0. This is rarely tuned, but data with unusual higher-frequency activity could benefit from exploration in the 3.5-5.0 range.
window_len (float) – Length of the time windows (in seconds) for which correlation statistics are computed; ideally short enough to reasonably capture periods of global artifacts or intermittent sensor dropouts, but not shorter (for statistical reasons). Default is 5.0 sec.
subset_size (float) – Size of random channel subsets to compute robust reconstructions. This can be given as a fraction (0-1) of the total number of channels, or as an absolute number. Multiple (pseudo-)random subsets are sampled in a RANSAC-like process to obtain a robust reference estimate for each channel. Default is 0.25 (25% of channels). For higher-density EEG (e.g., 64-128ch) with potential clusters of bad channels, one can achieve somewhat better robustness by setting this to 0.15 and increasing num_samples to 200.
num_samples (int) – Number of samples generated for the robust channel reconstruction. This is the number of samples to generate in a RANSAC-like process. The larger this value, the more robust but also slower the initial identification of bad channels will be. Default is 50.
max_broken_time (float) – Maximum time (either in seconds or as fraction of the recording) during which a channel is allowed to have artifacts. If a channel exceeds this, it will be removed. Not usually tuned. Default is 0.4 (40%), max is 0.5 (breakdown point of stats). Pretty much never tuned.
References
[Kothe2013]Kothe, C.A. and Makeig, S., 2013. BCILAB: a platform for brain–computer interface development. Journal of Neural Engineering, 10(5), p.056014.
Methods