Initialize NeuroAnalyzer
using DSP
using NeuroAnalyzer
using Plots
eeg = load("files/eeg.hdf")using DSP
using NeuroAnalyzer
using Plots
eeg = load("files/eeg.hdf")Below is a concise guide to common EEG preprocessing functions in NeuroAnalyzer, including normalization, DC removal, signal derivatives, and detrending. These functions are essential for preparing EEG data for analysis by reducing noise, removing artifacts, and standardizing signals.
Standardize EEG signals to have a mean of 0 and standard deviation of 1 (z-score normalization). This is useful for:
Examples
Normalize All Channels (z-score)
NeuroAnalyzer.normalize(eeg;
ch = "all",
method = :zscore)Effect: Each channel’s signal is transformed to have a mean of 0 and standard deviation of 1.
Normalize Specific Channels (min-max scaling)
NeuroAnalyzer.normalize(eeg;
ch = ["Fp1", "Fp2"],
method = :minmax)Effect: Channels Fp1 and Fp2 are scaled to the range [0, 1].
Tip: To get the list of all available methods, see normalize.
When to Use
Eliminate DC Offset: removing the mean value (DC offset) from EEG signals. DC offset can arise from:
Removing DC offset from all channel:
remove_dc(eeg; ch = "all")The derivative of an EEG signal measures the rate of change of the signal over time. It is useful for:
The symmetric difference quotient approximates the derivative of a discrete signal \(x[n]\) as:
\[ \frac{dx}{dt} \approx \frac{x[n+1] - x[n-1]}{2 \Delta t} \]
where:
\(x[n]\) is the signal value at time \(n\),
\(\Delta t\) is the sampling interval (time between samples).
This method is more accurate than the standard forward or backward difference because it centers the approximation around the point of interest.
Computing the derivative of channel Fp1:
derivative(eeg; ch = "Fp1")Detrending is a preprocessing technique used to remove slow drifts or trends from EEG signals. These drifts can arise from:
Detrending improves the quality of EEG data by ensuring that analyses (e.g., ERP extraction, power spectral density) are not biased by these slow variations.
In NeuroAnalyzer, the detrend() function performs piecewise detrending using different methods, depending on the type of trend you want to remove:
detrend(eeg;
ch = "all",
type = :constant)Tip: To get the list of all available methods, see detrend.
Some of the available methods are:
| Method | Description | When to Use |
|---|---|---|
:constant |
Removes the mean (DC offset) from the signal. | When the signal has a constant drift (e.g., baseline offset). |
:linear |
Removes a linear trend (e.g., slow upward or downward slope). | When the signal has a linear drift (e.g., due to amplifier drift over time). |
:poly |
Removes a polynomial trend of a specified order (e.g., quadratic, cubic). | When the signal has a non-linear trend (e.g., due to physiological artifacts). |