Signal Processing for EEG/ECG

#EEG #ECG #signal filtering #artifact removal #peak detection #time-domain analysis #noise reduction #HRV analysis #baseline correction #ICA

1. Characteristics of EEG Signals

Characteristics of EEG Signals

Electroencephalography (EEG) signals are voltage fluctuations resulting from ionic current flows within the neurons of the brain. These signals exhibit distinct characteristics in terms of amplitude, frequency, and spatial distribution, which are critical for both clinical diagnostics and research applications.

Time-Domain Characteristics

EEG signals are typically in the range of 1–100 µV when measured at the scalp, with intracranial recordings reaching up to 1–2 mV. The signals are non-stationary, meaning their statistical properties change over time due to varying neural activity. Key time-domain features include:

Frequency-Domain Characteristics

EEG signals are conventionally categorized into frequency bands, each associated with specific brain states:

$$ \begin{aligned} \delta &: 0.5–4\ \text{Hz} \quad \text{(deep sleep, pathological states)} \\ \theta &: 4–8\ \text{Hz} \quad \text{(drowsiness, meditation)} \\ \alpha &: 8–13\ \text{Hz} \quad \text{(relaxed wakefulness, eyes closed)} \\ \beta &: 13–30\ \text{Hz} \quad \text{(active thinking, focus)} \\ \gamma &: >30\ \text{Hz} \quad \text{(cognitive processing, memory)} \end{aligned} $$

Power spectral density (PSD) analysis reveals that EEG signals follow a 1/fα power law, where α typically ranges from 1 to 2.5, indicating scale-free dynamics.

Spatial and Topographic Properties

EEG signals are spatially correlated due to volume conduction through cerebrospinal fluid, skull, and scalp. The electric potential Φ at the scalp can be modeled by the Poisson equation:

$$ \nabla \cdot (\sigma \nabla \Phi) = -I_m $$

where σ is tissue conductivity and Im is the transmembrane current density. Spatial resolution is limited to 5–10 cm due to signal smearing, but high-density EEG (256+ electrodes) improves localization accuracy.

Nonlinear and Non-Gaussian Behavior

EEG signals exhibit nonlinear dynamics, evidenced by:

Higher-order statistics (e.g., bispectral analysis) reveal non-Gaussian properties, particularly during epileptic seizures or cognitive tasks.

Artifacts and Noise Sources

EEG recordings are contaminated by multiple noise sources:

Independent Component Analysis (ICA) and adaptive filtering (e.g., LMS, RLS) are commonly used for artifact suppression.

Characteristics of EEG Signals in Signal Processing for EEG/ECG
Diagram Description: The diagram would show the frequency bands of EEG signals (delta, theta, alpha, beta, gamma) with their respective Hz ranges and associated brain states, alongside a 1/f power law spectral density plot.

Characteristics of ECG Signals

Morphological Components

An electrocardiogram (ECG) signal represents the electrical activity of the heart and is characterized by distinct waveforms and intervals. The primary components include:

Temporal and Spectral Properties

ECG signals exhibit quasi-periodic behavior with a fundamental frequency determined by the heart rate (HR). The power spectral density (PSD) of an ECG signal is concentrated in two main bands:

$$ f_{\text{HR}} = \frac{\text{HR}}{60} \quad \text{(Hz)} $$

The dominant spectral components lie below 40 Hz, with over 90% of the signal energy contained within 0.05–30 Hz. High-frequency components (up to 150 Hz) may be present during the QRS complex.

Noise and Artifacts

ECG signals are susceptible to several noise sources that complicate analysis:

Signal Amplitude and Dynamic Range

The typical ECG signal amplitude ranges from 0.5–5 mV peak-to-peak, requiring amplifiers with:

$$ \text{Dynamic Range} = 20 \log_{10}\left(\frac{V_{\text{max}}}{V_{\text{min}}}\right) \geq 60 \text{ dB} $$

Modern ECG systems employ instrumentation amplifiers with high common-mode rejection ratios (CMRR > 100 dB) to maintain signal integrity.

Clinical Parameters Derived from ECG

Key diagnostic metrics include:

Digital Representation

For accurate digital processing, ECG signals require sampling at:

$$ f_s \geq 2f_{\text{max}} \quad \text{(Nyquist criterion)} $$

Clinical systems typically use 250–1000 Hz sampling rates with 12–16 bit resolution to preserve morphological details while minimizing storage requirements.

Characteristics of ECG Signals in Signal Processing for EEG/ECG
Diagram Description: The section describes complex ECG waveforms and their components, which are inherently visual and spatial.

1.3 Common Noise Sources in EEG/ECG

Physiological Noise

Physiological artifacts arise from the subject's own biological activity unrelated to the neural or cardiac signals of interest. In EEG, electromyographic (EMG) noise from facial muscles contaminates the signal above 20 Hz, while electrooculographic (EOG) artifacts from eye movements dominate below 4 Hz. ECG recordings suffer from baseline wander due to respiration (0.1–0.5 Hz) and motion artifacts from electrode-skin impedance changes. The power spectral density of these noise sources often overlaps with the signal band:

$$ S_{noise}(f) = \frac{A_{EMG}}{f^\alpha} + \frac{A_{EOG}}{1 + (f/f_c)^2} $$

where α ≈ 2 for EMG and fc ≈ 1 Hz for EOG. Adaptive filtering and independent component analysis (ICA) prove effective for separation when noise and signal subspaces are non-orthogonal.

Environmental Interference

Power line interference at 50/60 Hz and harmonics manifests as a comb spectrum with amplitudes reaching 20% of the EEG signal. The differential-mode coupling occurs through:

$$ V_{noise} = M \frac{dI_{AC}}{dt} + \frac{I_{AC}}{C_{stray}} $$

where M is mutual inductance (≈10-8 H) and Cstray is stray capacitance (≈10-12 F). Twisted-pair cabling and driven-right-leg circuits reduce common-mode noise by 40–60 dB. Notch filters should be avoided as they distort phase information; instead, adaptive cancellation using a reference channel yields better results.

Instrumentation Noise

Front-end electronics contribute thermal noise (4kTRB) and flicker noise (KfIα/fβ). For a typical EEG amplifier with Rin = 10 MΩ and B = 100 Hz:

$$ V_n = \sqrt{4kTBR + \frac{K_f}{f} \ln\left(\frac{f_H}{f_L}\right)} \approx 0.8 \mu V_{rms} $$

Capacitive non-idealities in electrode-tissue interfaces create additional noise through the 1/(jωCd) term in the impedance model. Silver-silver chloride electrodes exhibit the lowest noise floor (0.1–1 μV/√Hz) due to their reversible electrochemical properties.

Motion Artifacts

Electrode displacement generates triboelectric potentials reaching 100 mV through the double-layer capacitor mechanism:

$$ \Delta V = \frac{\Delta Q}{C_{dl}} = \frac{\zeta \epsilon_0 A \Delta x}{d^2} $$

where ζ is the zeta potential (≈100 mV for Ag/AgCl) and d is the Debye length (≈1 nm). Modern systems employ active electrodes with impedance converters (Zin > 1 TΩ) to mitigate this effect. Accelerometer-based motion tracking enables artifact subtraction when correlated with signal disturbances.

Common Noise Sources in EEG/ECG in Signal Processing for EEG/ECG
Diagram Description: The section describes overlapping noise spectra and coupling mechanisms that would benefit from a visual representation of frequency-domain relationships and interference pathways.

2. Filtering Methods (Low-pass, High-pass, Band-pass)

2.1 Filtering Methods (Low-pass, High-pass, Band-pass)

Frequency-Domain Filtering Fundamentals

Biological signals like EEG and ECG contain both physiological and non-physiological components spanning different frequency ranges. The power spectral density of typical EEG shows dominant activity below 40 Hz, while ECG contains fundamental components between 0.5-40 Hz. Filter design must account for these characteristics while preserving signal integrity.

$$ H(f) = \frac{1}{\sqrt{1 + \left(\frac{f}{f_c}\right)^{2n}}} $$

where fc is the cutoff frequency and n is the filter order. This magnitude response equation governs all basic filter types, with variations in stopband and passband definitions.

Low-Pass Filter Implementation

For EEG applications, low-pass filters typically target 30-100 Hz cutoff frequencies to remove high-frequency noise while preserving neural oscillations. A Butterworth implementation provides maximally flat passband response:

$$ H_{LP}(s) = \frac{1}{\prod_{k=1}^{n/2} \left[ s^2 - 2s\omega_c\cos\left(\frac{2k+n-1}{2n}\pi\right) + \omega_c^2 \right]} $$

where s is the complex frequency variable. In digital implementations, the bilinear transform converts this to the z-domain:

$$ s = \frac{2}{T}\frac{1-z^{-1}}{1+z^{-1}} $$

Practical implementations must account for phase distortion effects, often addressed using forward-backward filtering or minimum-phase designs.

High-Pass Filter Considerations

High-pass filters remove baseline wander in ECG (typically below 0.5 Hz) and slow cortical potentials in EEG. A first-order RC high-pass filter has the transfer function:

$$ H_{HP}(s) = \frac{s}{s + \omega_c} $$

For physiological signals, higher-order filters (4-8 poles) with steep roll-offs are preferred to avoid attenuating desired low-frequency components. Chebyshev Type II designs are particularly effective, offering equiripple stopband behavior:

$$ |H_{HP}(j\omega)| = \frac{1}{\sqrt{1 + \frac{1}{\epsilon^2T_n^2(\omega_c/\omega)}}} $$

Band-Pass Filter Optimization

EEG analysis often requires isolating specific frequency bands (delta: 0.5-4 Hz, theta: 4-8 Hz, alpha: 8-13 Hz, beta: 13-30 Hz, gamma: 30-100 Hz). A cascaded low-pass and high-pass implementation provides independent control:

$$ H_{BP}(s) = H_{LP}(s) \times H_{HP}(s) $$

For real-time applications, IIR implementations offer computational efficiency, while FIR filters provide linear phase response. The Parks-McClellan algorithm optimizes FIR band-pass designs:

$$ E(\omega) = W(\omega)[H_d(\omega) - H(\omega)] $$

where W(ω) is the weighting function and Hd(ω) is the desired response.

Practical Implementation Challenges

Filter choice impacts clinical interpretation - excessive high-pass filtering may distort ST segments in ECG, while aggressive low-pass filtering can attenuate high-frequency components in EEG spikes. Finite impulse response (FIR) filters avoid phase distortion but require higher computational resources. Infinite impulse response (IIR) filters offer efficiency but may introduce nonlinear phase effects.

Modern digital implementations often employ adaptive filtering techniques, particularly for motion artifact removal in ambulatory EEG/ECG systems. The normalized least mean squares (NLMS) algorithm provides stable adaptation:

$$ w(n+1) = w(n) + \frac{\mu}{\|x(n)\|^2 + \epsilon}e(n)x(n) $$

where μ is the step size and ε prevents division by zero.

Filtering Methods (Low-pass, High-pass, Band-pass) in Signal Processing for EEG/ECG
Diagram Description: The section covers multiple filter types with complex frequency-domain transformations and their impact on physiological signals, which are best visualized through magnitude response plots and signal flow diagrams.

2.2 Artifact Removal (ICA, PCA)

Independent Component Analysis (ICA)

ICA is a blind source separation technique that decomposes a multichannel signal into statistically independent components. Given an observed signal X with dimensions m × n (m channels, n samples), ICA models it as:

$$ \mathbf{X} = \mathbf{A}\mathbf{S} $$

where A is the mixing matrix and S contains the independent sources. The goal is to estimate the unmixing matrix W such that:

$$ \mathbf{S} = \mathbf{W}\mathbf{X} $$

Maximizing non-Gaussianity through measures like kurtosis or negentropy yields the independent components. For EEG/ECG, artifacts like eye blinks or muscle activity often manifest as isolated components that can be manually or automatically rejected.

Principal Component Analysis (PCA)

PCA performs orthogonal transformation to decorrelate components by eigenvalue decomposition of the covariance matrix C:

$$ \mathbf{C} = \frac{1}{n-1}\mathbf{X}\mathbf{X}^T $$

The eigenvectors form the principal components, ordered by descending eigenvalues (variance). Unlike ICA, PCA only guarantees decorrelation, not statistical independence. It is effective for dimensionality reduction but may mix artifact and neural sources.

Practical Implementation

Key steps for artifact removal:

For EEG, ICA typically outperforms PCA due to its ability to separate non-Gaussian sources like neural activity from artifacts. However, PCA remains computationally efficient for preliminary noise reduction.

EEG Signal Before and After Artifact Removal Raw Cleaned
Artifact Removal (ICA, PCA) in Signal Processing for EEG/ECG
Diagram Description: The diagram would physically show the transformation of raw EEG signals into independent components (ICA) or principal components (PCA), and their reconstruction after artifact removal.

2.3 Baseline Correction and Normalization

Baseline drift in EEG/ECG signals arises from low-frequency artifacts such as respiration, electrode impedance changes, or patient movement. These drifts obscure high-frequency components of interest, necessitating baseline correction before further analysis. Normalization ensures signals are scaled uniformly, facilitating comparison across datasets or subjects.

Baseline Correction Methods

The simplest approach is linear detrending, where a least-squares fit line is subtracted from the signal. For a signal x[n] of length N, the trend is modeled as:

$$ y[n] = a \cdot n + b $$

The coefficients a and b are estimated via:

$$ \min_{a,b} \sum_{n=0}^{N-1} (x[n] - (a \cdot n + b))^2 $$

More sophisticated methods employ high-pass filtering or polynomial fitting. A zero-phase high-pass Butterworth filter with cutoff frequency fc eliminates baseline drift while preserving signal morphology. The transfer function for a second-order filter is:

$$ H(z) = \frac{b_0 + b_1 z^{-1} + b_2 z^{-2}}{1 + a_1 z^{-1} + a_2 z^{-2}} $$

where coefficients are derived from the bilinear transform of the analog prototype.

Normalization Techniques

Normalization adjusts signal amplitude to a standard range. Common approaches include:

Practical Considerations

In EEG, baseline correction is typically applied per epoch to account for non-stationary drifts. For ECG, median filtering (window width ~200 ms) effectively removes baseline wander without distorting QRS complexes. Normalization is critical in machine learning pipelines to prevent feature magnitude biases.

Original Baseline
Baseline Correction and Normalization in Signal Processing for EEG/ECG
Diagram Description: The diagram would show the original EEG/ECG signal with baseline drift (blue) and the corrected baseline (red dashed line), illustrating the effect of linear detrending.

3. Peak Detection Algorithms

3.1 Peak Detection Algorithms

Peak detection in EEG/ECG signals is critical for identifying physiological events such as QRS complexes in ECG or epileptic spikes in EEG. Advanced algorithms must account for noise, baseline wander, and morphological variability. The following methods are widely used in biomedical signal processing.

Threshold-Based Peak Detection

A simple yet effective approach involves setting amplitude thresholds. For an ECG signal x[n], a peak is detected if:

$$ x[n] > x[n-1], \quad x[n] > x[n+1], \quad x[n] > \theta $$

where θ is a dynamic or fixed threshold. Adaptive thresholds improve robustness against varying signal amplitudes:

$$ \theta = \mu + k\sigma $$

Here, μ is the moving average, σ the standard deviation, and k a tunable parameter (typically 3–5).

Matched Filtering

Matched filters optimize the signal-to-noise ratio (SNR) by convolving the input signal with a template of the expected peak shape. For a template h[n] of length L, the output y[n] is:

$$ y[n] = \sum_{k=0}^{L-1} x[n-k] \cdot h[k] $$

Peaks are identified at local maxima of y[n]. This method excels in ECG for QRS detection when the template resembles a typical R-wave.

Wavelet Transform

Wavelet-based peak detection decomposes the signal into time-frequency components. The continuous wavelet transform (CWT) at scale s and translation τ is:

$$ W(s, \tau) = \frac{1}{\sqrt{s}} \int_{-\infty}^{\infty} x(t) \psi^*\left(\frac{t-\tau}{s}\right) dt $$

where ψ(t) is the mother wavelet. Peaks correspond to modulus maxima in the wavelet domain, particularly at scales matching the QRS duration (e.g., 2–40 ms).

Pan-Tompkins Algorithm

A classic real-time QRS detector combines derivative, squaring, and moving window integration:

  1. Bandpass filtering (5–15 Hz) to suppress noise.
  2. Differentiation to highlight steep slopes.
  3. Squaring to emphasize large differences.
  4. Integration over a 150-ms window to merge nearby peaks.

Peaks are detected when the integrated signal exceeds an adaptive threshold.

Hidden Markov Models (HMM)

HMMs model the signal as a sequence of states (e.g., P-wave, QRS, T-wave). The Viterbi algorithm identifies the most likely state sequence, with peaks corresponding to transitions. The observation probability is often modeled as a Gaussian mixture:

$$ b_j(o) = \sum_{m=1}^{M} c_{jm} \mathcal{N}(o; \mu_{jm}, \Sigma_{jm}) $$

where cjm are mixture weights and μjm, Σjm the mean and covariance of the m-th Gaussian in state j.

Performance Metrics

Algorithm efficacy is quantified using:

where TP, FP, and FN are true positives, false positives, and false negatives, respectively.

Peak Detection Algorithms in Signal Processing for EEG/ECG
Diagram Description: The section covers multiple signal processing methods (thresholding, matched filtering, wavelet transforms) that involve visual transformations of waveforms and time-domain behaviors.

3.2 Heart Rate Variability (HRV) Analysis

Time-Domain Analysis

Time-domain HRV metrics quantify statistical properties of RR intervals (the time between successive R-peaks in an ECG). The most common measures include:

Frequency-Domain Analysis

Power spectral density (PSD) decomposes HRV into frequency components via Fourier transform or autoregressive modeling. Key bands are:

The LF/HF ratio serves as a proxy for sympathovagal balance, though its interpretation remains debated.

Nonlinear Methods

Poincaré plots visualize RR interval dynamics by plotting each RRn against RRn+1. Ellipse fitting yields:

$$ SD1 = \frac{\sqrt{2}}{2} \times \text{RMSSD} \quad \text{(short-term variability)} $$ $$ SD2 = \sqrt{2 \times \text{SDNN}^2 - \frac{1}{2} \times \text{RMSSD}^2 } \quad \text{(long-term variability)} $$

Multiscale entropy (MSE) and detrended fluctuation analysis (DFA) assess complexity and fractal-like properties.

Practical Considerations

ECG-derived HRV requires:

Poincaré Plot of RR Intervals RRn (ms) RRn+1 (ms)
Heart Rate Variability (HRV) Analysis in Signal Processing for EEG/ECG
Diagram Description: The Poincaré plot and ellipse fitting for SD1/SD2 are inherently spatial concepts that require visualization to understand the relationship between successive RR intervals.

3.3 Event-Related Potentials (ERPs) in EEG

Definition and Neurophysiological Basis

Event-Related Potentials (ERPs) are voltage fluctuations in the EEG signal elicited by specific sensory, cognitive, or motor events. These potentials are time-locked to the onset of a stimulus and reflect neural activity associated with information processing. ERPs are typically in the range of 1–20 µV, making them orders of magnitude smaller than background EEG activity, which necessitates specialized signal processing techniques for extraction.

The neurophysiological origin of ERPs lies in synchronized postsynaptic potentials (PSPs) from large populations of pyramidal neurons in the cortex. When these neurons fire in a coordinated manner, their dipolar fields summate, producing measurable scalp potentials. The most studied ERP components include:

Mathematical Model of ERP Extraction

ERPs are extracted by averaging multiple EEG epochs time-locked to the same event type. Let Xi(t) represent the i-th epoch of EEG data, where t is time relative to stimulus onset. The ERP Y(t) is computed as:

$$ Y(t) = \frac{1}{N} \sum_{i=1}^{N} X_i(t) $$

where N is the number of epochs. This averaging suppresses uncorrelated noise (e.g., muscle artifacts, background EEG) by a factor of √N, while preserving the time-locked ERP signal.

Time-Frequency Decomposition of ERPs

ERPs are non-stationary, with varying spectral properties over time. A wavelet transform provides a joint time-frequency representation:

$$ C(a,b) = \frac{1}{\sqrt{a}} \int_{-\infty}^{\infty} Y(t) \psi^* \left( \frac{t-b}{a} \right) dt $$

where ψ(t) is the mother wavelet, a is the scale parameter (inversely related to frequency), and b is the time shift. The Morlet wavelet is commonly used for its balance between time and frequency resolution.

Spatial Filtering and Source Localization

To enhance ERP components and localize their neural generators, spatial filtering techniques are applied:

The forward model for source localization is given by:

$$ \Phi = \mathbf{L} \cdot \mathbf{J} + \epsilon $$

where Φ is the scalp potential, L is the lead field matrix, J is the current dipole density, and ϵ is noise. Solving this inverse problem requires regularization techniques like L2-minimum norm estimation.

Applications in Cognitive Neuroscience

ERPs are widely used to study:

Recent advances include single-trial ERP detection using machine learning, enabling real-time brain-computer interfaces (BCIs).

ERP Extraction via Epoch Averaging Diagram illustrating the extraction of Event-Related Potentials (ERPs) from EEG data via epoch averaging, showing noise reduction and highlighted ERP components (P300/N170). ERP Extraction via Epoch Averaging Raw EEG Epochs (Aligned to Stimulus Onset) Stimulus Onset Noise (√N reduction) Averaged ERP Waveform P300 N170 μV -200ms 0ms +500ms
Diagram Description: The diagram would show the ERP extraction process via averaging multiple EEG epochs, illustrating how noise cancels out while the time-locked signal remains.

4. Fourier Transform and Power Spectral Density

Fourier Transform and Power Spectral Density

Fourier Transform in EEG/ECG Analysis

The Fourier Transform (FT) decomposes a time-domain signal into its constituent frequency components. For a continuous signal x(t), the FT is defined as:

$$ X(f) = \int_{-\infty}^{\infty} x(t) e^{-j2\pi ft} dt $$

In EEG/ECG processing, we typically work with discrete signals sampled at frequency fs. The Discrete Fourier Transform (DFT) for N samples becomes:

$$ X[k] = \sum_{n=0}^{N-1} x[n] e^{-j2\pi kn/N} \quad k = 0,1,...,N-1 $$

The Fast Fourier Transform (FFT) provides an efficient O(N log N) algorithm to compute the DFT. When analyzing EEG signals, the frequency resolution Δf depends on the acquisition duration T:

$$ \Delta f = \frac{1}{T} = \frac{f_s}{N} $$

Power Spectral Density Estimation

The Power Spectral Density (PSD) describes how signal power distributes across frequencies. For EEG/ECG, we commonly use:

Periodogram Method:
$$ S_{xx}(f) = \frac{1}{N} \left| \sum_{n=0}^{N-1} x[n]e^{-j2\pi fn} \right|^2 $$
Welch's Method improves estimation by averaging modified periodograms of windowed segments:
  1. Divide signal into K overlapping segments
  2. Apply window function (e.g., Hamming) to each segment
  3. Compute periodogram for each segment
  4. Average the periodograms

Practical Considerations in Biosignal Analysis

For EEG signals (typically 0.5-100 Hz), we must account for:

Example: Alpha Rhythm Detection

To detect the alpha rhythm (8-13 Hz) in EEG:

  1. Preprocess with 0.5-100 Hz bandpass filter
  2. Compute PSD using Welch's method (2s windows, 50% overlap)
  3. Integrate power in 8-13 Hz band
  4. Normalize by total power (1-40 Hz) to compute relative alpha power
$$ P_{\alpha} = \frac{\int_{8Hz}^{13Hz} S_{xx}(f) df}{\int_{1Hz}^{40Hz} S_{xx}(f) df} $$

Multitaper Spectral Estimation

For improved spectral estimation in EEG, the multitaper method uses orthogonal tapers (Slepian sequences) to reduce variance:

$$ S_{xx}^{MT}(f) = \frac{1}{K} \sum_{k=1}^{K} \left| \sum_{n=0}^{N-1} x[n] w_k[n] e^{-j2\pi fn} \right|^2 $$

where wk[n] are the K orthogonal tapers. This approach provides better statistical properties for detecting weak oscillatory components in noisy EEG signals.

Fourier Transform and Power Spectral Density in Signal Processing for EEG/ECG
Diagram Description: The section involves complex transformations between time and frequency domains, and a visual comparison of raw EEG/ECG vs. its Fourier transform and PSD would clarify the relationships.

4.2 Wavelet Transform for Time-Frequency Analysis

Mathematical Foundations of Wavelet Transform

The wavelet transform decomposes a signal into a set of basis functions called wavelets, which are localized in both time and frequency. Unlike the Fourier transform, which uses infinite sine and cosine waves, wavelets are finite-duration functions with zero mean. The continuous wavelet transform (CWT) of a signal x(t) is defined as:

$$ CWT(a, b) = \frac{1}{\sqrt{|a|}} \int_{-\infty}^{\infty} x(t) \psi^* \left( \frac{t - b}{a} \right) dt $$

where:

Discrete Wavelet Transform (DWT) for EEG/ECG

The DWT is computationally efficient and implemented using filter banks. It decomposes a signal into approximation (low-frequency) and detail (high-frequency) coefficients through successive high-pass and low-pass filtering:

$$ y_{\text{low}}[n] = \sum_{k} x[k] \cdot g[2n - k] $$ $$ y_{\text{high}}[n] = \sum_{k} x[k] \cdot h[2n - k] $$

where g[n] and h[n] are the low-pass and high-pass filters, respectively, derived from the wavelet function. For EEG/ECG signals, common wavelets include:

Time-Frequency Localization Trade-offs

Wavelets provide a trade-off between time and frequency resolution:

This property is advantageous for EEG/ECG analysis, where high-frequency components (e.g., spikes in epilepsy) require precise time localization, while low-frequency components (e.g., alpha waves) benefit from frequency resolution.

Applications in EEG/ECG Signal Processing

Wavelet transforms are used for:

For example, in ECG analysis, the DWT can isolate the QRS complex by thresholding coefficients at scales corresponding to 10–25 Hz, while suppressing baseline wander (near 0.5 Hz).

Comparison with Short-Time Fourier Transform (STFT)

Unlike STFT, which uses a fixed window size, wavelets adapt their time-frequency resolution:

This makes wavelets superior for analyzing non-stationary signals like EEG/ECG, where frequency components evolve over time.

Practical Implementation Considerations

When applying wavelet transforms to EEG/ECG:

Wavelet Transform for Time-Frequency Analysis in Signal Processing for EEG/ECG
Diagram Description: The diagram would show the time-frequency localization trade-offs of wavelet transforms, comparing narrow vs. wide windows at different scales.

EEG Frequency Bands and Their Clinical Significance

Electroencephalography (EEG) signals are categorized into distinct frequency bands, each associated with specific neural activities and clinical implications. These bands are extracted using spectral analysis techniques such as Fourier transforms or wavelet decomposition. The primary frequency bands, their physiological correlates, and diagnostic relevance are as follows:

Delta Band (0.5–4 Hz)

The delta band dominates during deep sleep (stage N3) and is characterized by high-amplitude, slow oscillations. Its power spectral density (PSD) is computed as:

$$ P_{\delta}(f) = \int_{0.5}^{4} S_{xx}(f) \, df $$

where Sxx(f) is the power spectral density of the EEG signal. Elevated delta activity in awake adults may indicate pathological conditions such as traumatic brain injury or encephalopathy. Conversely, suppressed delta waves are observed in sleep disorders like insomnia.

Theta Band (4–8 Hz)

Theta oscillations are prominent during light sleep (stages N1-N2), meditation, and memory consolidation. The instantaneous theta power can be extracted using a Hilbert transform:

$$ A_{\theta}(t) = |\mathcal{H}\{x_{\theta}(t)\}|^2 $$

where xθ(t) is the bandpass-filtered signal. Excessive frontal theta in awake states correlates with attention deficits in ADHD, while hippocampal theta bursts are biomarkers for epilepsy.

Alpha Band (8–13 Hz)

Alpha waves exhibit maximal amplitude over occipital regions during eyes-closed resting states. The alpha peak frequency (APF) is a key metric:

$$ f_{\alpha} = \underset{f \in [8,13]}{\arg\max} \, S_{xx}(f) $$

APF below 8.5 Hz may indicate neurodegenerative diseases like Alzheimer's. Event-related desynchronization (ERD) of alpha waves during cognitive tasks reflects cortical activation patterns.

Beta Band (13–30 Hz)

Beta activity is associated with active thinking, focus, and sensorimotor processing. Its modulation is quantified using beta rebound:

$$ \beta_{\text{rebound}} = \frac{P_{\beta}^{\text{post}}-P_{\beta}^{\text{pre}}}{P_{\beta}^{\text{pre}}} $$

Abnormally high beta power occurs in Parkinson's disease patients under dopaminergic treatment, while suppressed beta indicates stroke-induced motor impairment.

Gamma Band (30–100 Hz)

Gamma oscillations underlie perceptual binding and cognitive processing. Their short-term power is often analyzed using Morlet wavelets:

$$ W_{\gamma}(t,f) = \int x(\tau)\psi^{*}_{t,f}(\tau) \, d\tau $$

where ψt,f is the complex wavelet. Reduced gamma synchrony is observed in schizophrenia, while excessive gamma coherence occurs during epileptic seizures.

Cross-Frequency Coupling

Phase-amplitude coupling (PAC) between bands reveals functional network interactions. The modulation index quantifies theta-gamma coupling:

$$ MI = \frac{H(P_{A|\phi_{\theta}) - \langle H(P_{A|\phi_{\theta}) \rangle_{\text{surrogate}}}{H(P_A)} $$

where H denotes entropy. Altered PAC profiles are biomarkers for depression and autism spectrum disorders.

EEG Frequency Bands and Their Clinical Significance in Signal Processing for EEG/ECG
Diagram Description: A diagram would visually show the distinct EEG frequency bands (delta to gamma) with their respective Hz ranges and associated brain states or pathologies, which is inherently spatial and comparative.

5. Machine Learning for Feature Extraction

5.1 Machine Learning for Feature Extraction

Dimensionality Reduction via Principal Component Analysis (PCA)

Principal Component Analysis (PCA) is a linear transformation technique that projects high-dimensional EEG/ECG data into a lower-dimensional subspace while preserving maximal variance. Given a dataset X with n samples and m features, PCA computes the covariance matrix:

$$ \Sigma = \frac{1}{n} \sum_{i=1}^{n} (X_i - \mu)(X_i - \mu)^T $$

where μ is the mean vector. Eigenvalue decomposition of Σ yields eigenvectors (principal components) and eigenvalues (explained variance). The transformed data Z is obtained by:

$$ Z = XW $$

where W is the matrix of top-k eigenvectors. PCA is particularly effective for removing redundant noise in multichannel EEG.

Time-Frequency Feature Extraction with Wavelets

Discrete Wavelet Transform (DWT) decomposes signals into approximation (low-frequency) and detail (high-frequency) coefficients. For an EEG signal x(t), the DWT is:

$$ \psi_{j,k}(t) = \frac{1}{\sqrt{2^j}} \psi\left(\frac{t - 2^j k}{2^j}\right) $$

where ψ is the mother wavelet (e.g., Daubechies, Morlet), and j, k are scale and translation parameters. Energy and entropy of wavelet coefficients serve as discriminative features for seizure detection or arrhythmia classification.

Convolutional Neural Networks (CNNs) for Spatial Features

CNNs automatically extract spatially invariant features from raw EEG/ECG through hierarchical convolution-pooling operations. A 1D convolution layer applies filters w to input x:

$$ (x * w)(t) = \sum_{\tau=-\infty}^{\infty} x(\tau) w(t - \tau) $$

Max-pooling downsamples activations to reduce computational complexity. CNNs outperform manual feature engineering in tasks like sleep stage classification, achieving >90% accuracy on benchmark datasets.

Recurrent Networks for Temporal Dynamics

Long Short-Term Memory (LSTM) networks model sequential dependencies in EEG/ECG via gated mechanisms. The cell state c_t and hidden state h_t update as:

$$ f_t = \sigma(W_f \cdot [h_{t-1}, x_t] + b_f) $$ $$ i_t = \sigma(W_i \cdot [h_{t-1}, x_t] + b_i) $$ $$ \tilde{c}_t = \tanh(W_c \cdot [h_{t-1}, x_t] + b_c) $$ $$ c_t = f_t \circ c_{t-1} + i_t \circ \tilde{c}_t $$ $$ o_t = \sigma(W_o \cdot [h_{t-1}, x_t] + b_o) $$ $$ h_t = o_t \circ \tanh(c_t) $$

where σ is the sigmoid function, and denotes element-wise multiplication. Bidirectional LSTMs capture past-future context for improved R-peak detection in ECG.

Attention Mechanisms for Interpretability

Self-attention layers compute weighted sums of input features, enabling model interpretability. The attention score α between queries Q and keys K is:

$$ \alpha = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right) $$

where d_k is the key dimension. Transformer-based architectures localize clinically relevant EEG waveforms (e.g., epileptic spikes) without manual segmentation.

Case Study: MI-EEG Classification

On the BCI Competition IV 2a dataset, a hybrid CNN-LSTM model with attention achieves 78.4% accuracy in motor imagery classification, outperforming traditional Common Spatial Patterns (CSP) by 12%. Key features include:

Machine Learning for Feature Extraction in Signal Processing for EEG/ECG
Diagram Description: The section covers multiple complex transformations (PCA, Wavelets, CNNs, LSTMs) where visual representations of data flow and mathematical operations would clarify the processes.

5.2 Deep Learning Approaches in EEG/ECG Classification

Deep learning has revolutionized biomedical signal processing by automating feature extraction and improving classification accuracy. Unlike traditional machine learning, which relies on handcrafted features, deep neural networks learn hierarchical representations directly from raw or preprocessed EEG/ECG signals.

Architectures for EEG/ECG Classification

Three primary deep learning architectures dominate EEG/ECG classification:

Mathematical Foundations

The core operation in CNNs for 1D signals is the discrete convolution:

$$ (x * w)[n] = \sum_{m=-\infty}^{\infty} x[m] \cdot w[n - m] $$

where \(x\) is the input signal and \(w\) represents the learnable kernel weights. For EEG signals sampled at 256Hz with 30ms temporal context, a kernel size of 8 samples provides optimal receptive fields.

LSTMs mitigate vanishing gradients through gating mechanisms:

$$ f_t = \sigma(W_f \cdot [h_{t-1}, x_t] + b_f) $$ $$ i_t = \sigma(W_i \cdot [h_{t-1}, x_t] + b_i) $$ $$ \tilde{C}_t = \tanh(W_C \cdot [h_{t-1}, x_t] + b_C) $$ $$ C_t = f_t \circ C_{t-1} + i_t \circ \tilde{C}_t $$ $$ o_t = \sigma(W_o \cdot [h_{t-1}, x_t] + b_o) $$ $$ h_t = o_t \circ \tanh(C_t) $$

Data Preprocessing Pipeline

Effective deep learning requires specialized preprocessing:

Performance Metrics

Evaluation requires domain-specific metrics beyond accuracy:

$$ \text{Sensitivity} = \frac{TP}{TP + FN} $$ $$ \text{Specificity} = \frac{TN}{TN + FP} $$ $$ \text{F1-score} = 2 \cdot \frac{Precision \cdot Recall}{Precision + Recall} $$

For imbalanced datasets (e.g., rare arrhythmias), the geometric mean of sensitivity and specificity provides more robust assessment.

Implementation Challenges

Key practical considerations include:

State-of-the-art models achieve >95% accuracy on benchmark datasets like MIT-BIH Arrhythmia Database and BCI Competition IV, surpassing traditional signal processing methods by 15-20% margin.

Deep Learning Approaches in EEG/ECG Classification in Signal Processing for EEG/ECG
Diagram Description: The section describes CNN and RNN architectures processing EEG/ECG signals, which inherently involve spatial/temporal relationships and mathematical operations that are better visualized.

5.3 Real-time Processing Challenges and Solutions

Latency Constraints in Real-Time Systems

Real-time EEG/ECG processing imposes strict latency requirements, typically demanding end-to-end delays of <100 ms for clinical applications. The total latency (L) comprises:

$$ L = T_{\text{acq}} + T_{\text{proc}} + T_{\text{trans}}} $$

where Tacq is sensor sampling time, Tproc includes filtering/feature extraction, and Ttrans covers data transmission. For implantable devices, L must often be <10 ms to enable closed-loop neuromodulation.

Computational Complexity vs. Resource Limitations

Multichannel biosignals (e.g., 256-channel EEG) require processing at sampling rates of 1–10 kHz. A 10-channel ECG with 16-bit resolution at 1 kHz generates:

$$ \text{Data rate} = 10 \times 16 \times 1000 = 160 \text{ kbps} $$

Common operations like discrete wavelet transforms (DWT) have complexity O(N) per level, while adaptive filters (e.g., LMS) scale as O(N2). This conflicts with embedded processors' power budgets (often <1 mW/channel).

Optimization Strategies

Artifact Rejection in Real-Time

Motion artifacts in EEG exhibit amplitudes 10–100× larger than neural signals (0.5–100 µV). A typical artifact rejection pipeline involves:

$$ y[n] = x[n] - \sum_{k=1}^{M} w_k \cdot r_k[n] $$

where rk[n] are reference signals (e.g., accelerometer data) and wk are weights updated via recursive least squares (RLS). RLS achieves convergence in ~50 ms vs. LMS’s 200+ ms, at the cost of higher computational load (O(M2)).

Hardware-Software Co-Design Solutions

Modern systems leverage heterogeneous architectures:

ARM Cortex-M4F FPGA (DWT) BLE 5.2

Example partitioning: The MCU handles IIR filtering (5 µs latency), FPGA performs 5-level DWT (12 µs), and wireless transmits only QRS complexes (reducing data by 92%).

Case Study: Closed-Loop Epilepsy Detection

The NeuroPace RNS System processes 4 channels of 250 Hz EEG with 5 ms latency using:

$$ E = \sum_{i=1}^{4} \int_{80}^{120 \text{Hz}}} |X_i(f)|^2 df $$

High-γ power is computed via Goertzel’s algorithm (reducing FFT overhead by 70%). Detection thresholds adapt every 10 minutes using exponentially weighted moving averages.

Emerging Approaches

Real-time Processing Challenges and Solutions in Signal Processing for EEG/ECG
Diagram Description: The hardware-software co-design section describes a heterogeneous architecture with multiple components (ARM Cortex, FPGA, BLE) and their interactions, which is inherently spatial.

6. Key Research Papers in EEG/ECG Signal Processing

6.1 Key Research Papers in EEG/ECG Signal Processing

6.2 Recommended Textbooks and Online Resources

6.3 Open-source Tools and Datasets