Purpose: Average the signal using a sliding window.
Method: Sliding average using filtfilt (bidirectional filtering).
Formula:epoch_length_samples = epoch_length_seconds * Fs
b = ones(1, epoch_length_samples) / epoch_length_samples
smoothed_signal = filtfilt(b, 1, signal)
How it works:
- An averaging window of the specified length (in seconds) is created.
- The signal is filtered using a bidirectional moving average.
- The result is a smoothed signal with reduced variability.
Physiological explanation of epochs:
An epoch is averaging over a time window. This makes it possible to see general trends hidden behind rapid fluctuations.
Why averaging is needed:
- EEG signals are very “noisy” and contain many rapid oscillations.
- The processes of interest (for example, changes in alpha activity) often evolve slowly.
- Averaging smooths fast fluctuations while preserving slow trends.
Physiological meaning:
- Fast oscillations (milliseconds): individual neural events, artifacts
- Medium oscillations (seconds): brain rhythms (alpha, beta)
- Slow trends (tens of seconds): changes in state, responses to stimuli
Example:
- Without averaging: all fast oscillations are visible and the general trend is hard to see.
- With 2-second averaging: changes in alpha activity over time become visible.
- With 8-second averaging: only very slow state changes remain visible.
