Interpolating Bad Channels

Initialize NeuroAnalyzer
using NeuroAnalyzer
eeg = load("files/eeg.hdf")
e10 = epoch(eeg; ep_len = 10)

Interpolating bad channels is a common preprocessing step in neurophysiology, particularly in EEG (electroencephalography) and MEG (magnetencephalography) data analysis. Bad channels are typically those with excessive noise, flat signals, or other artifacts that cannot be corrected with standard filtering or artifact removal techniques. Interpolation replaces these bad channels with estimated values based on the surrounding good channels, allowing you to preserve as much data as possible.

Why Interpolate Bad Channels?

  • Preserve Data Integrity: Instead of discarding entire channels, interpolation allows you to retain more data.
  • Improve Signal Quality: A clean dataset is essential for accurate analysis (e.g., source localization, ERP analysis, connectivity studies).
  • Standard Practice: Many pipelines include interpolation as a standard step.

Common Interpolation Methods

Method Description Pros Cons
Spherical Spline Fits a 3D spline over the scalp based on good channels. Most accurate for EEG/MEG, handles curvature well. Computationally intensive.
Linear Interpolation Estimates bad channels using a weighted average of neighboring channels. Fast, simple. Less accurate for high-density montages.
Nearest Neighbor Replaces bad channels with the closest good channel. Very fast. Least accurate, introduces artifacts.

When to Interpolate?

  • Before epoching (if using continuous data).
  • After artifact removal and filtering.
  • Before advanced analyses (e.g., source localization, connectivity).

How to Interpolate

1. Identify Bad Channels

  • Visual inspection (plot raw data).
  • Automated methods

2. Choose Interpolation Method

  • For EEG/MEG, spherical spline is the gold standard.
  • For simplicity, linear works well for low-density arrays.

Planar Interpolation

Interpolating bad channel Fp1 in epochs 1:2 using planar interpolation:

e10pl = plinterpolate_channel(e10;
                              ch = "Fp1",
                              ep = 1:2)

Planar interpolation requires electrode locations. Interpolation must be performed one channel at a time. However, a single channel can be interpolated across multiple epochs.

This method is based on ScatteredInterpolation.interpolate() and remains under experimental validation.

Linear Regression

Interpolating bad channel C3 in epoch 25 using linear regression, using all other epochs as a reference:

e10lr = lrinterpolate_channel(e10;
                              ch = "C3",
                              ep = 25)

This method is based on GLM.lm() and remains under experimental validation.