Initialize NeuroAnalyzer
using NeuroAnalyzer
eeg = load("files/eeg.hdf")
e10 = epoch(eeg; ep_len = 10)using NeuroAnalyzer
eeg = load("files/eeg.hdf")
e10 = epoch(eeg; ep_len = 10)Removing bad channels and bad epochs is a critical step in EEG preprocessing. Bad channels/epochs can introduce artifacts, noise, or biases, affecting the accuracy of analyses (e.g., ERP extraction, power spectral density, source localization).
Why Remove Bad Channels/Epochs?
| Reason | Description |
|---|---|
| Improve Signal Quality | Removing noisy channels/epochs enhances the signal-to-noise ratio (SNR). |
| Avoid Artifacts | Bad channels/epochs can introduce spikes, drifts, or muscle artifacts. |
| Ensure Reliable Analysis | Analyses like ERP, connectivity, or source localization require clean data. |
| Automate Preprocessing | Automated detection reduces manual effort and subjectivity. |
NeuroAnalyzer provides automated methods to detect bad channels and epochs based on:
:flat: channels with a large proportion of flat windows:rmse: channels whose RMSE vs the median reference is outside the 95 % CI:rmsd: same as :rmse using RMSD:euclid: same using Euclidean distance:var: channels with IQR-outlier variance:p2p: channels with excessive peak-to-peak variation:tkeo: channels where z-scored TKEO diverges from z-scored signal:kurt: channels with z-scored kurtosis exceeding z:z: channels with a large proportion of samples above the z-score threshold:ransac: channels poorly correlated with their nearest spatial neighbor:amp: channels exceeding ± amplitude rejection thresholdDetecting bad channels:
bad_chs = channel_reject(e10;
ch = "all",
method = [:flat, :p2p, :var])Output: bad_chs vector of bad channels.
Header of each NEURO object contains a field for marking channels as bad (obj.header.recording[:bad_channel]). To modify this vector in-place, use the mutator variant:
channel_reject!(e10;
ch = "all",
method = [:flat, :p2p, :var])Tip: Bad channels are drawn in less intense color. You may also manually mark channels as bad when using plot() by right-clicking on the channel label.
Tip: Channels marked as bad will be be automatically excluded from analysis if exclude_bads preference is set to true.
Similarly, epoch can be rejected using the same methods:
bad_eps = epoch_reject(e10;
ch = "all",
method = [:flat, :p2p, :var])