Skip to contents

Replaces data in bad channels by interpolating from remaining good channels using either spherical spline interpolation (Perrin et al., 1989) or nearest-neighbor weighted averaging.

Usage

eegInterpolate(
  x,
  bad_channels,
  method = c("spline", "nearest"),
  assay_name = NULL,
  output_assay = "interpolated"
)

Arguments

x

A PhysioExperiment object.

bad_channels

Character vector of channel labels to interpolate.

method

Interpolation method: "spline" for spherical spline (default) or "nearest" for inverse-distance weighted nearest neighbors.

assay_name

Name of the assay to interpolate. If NULL, uses defaultAssay(x).

output_assay

Name of the output assay (default: "interpolated").

Value

A PhysioExperiment object with interpolated channels in the specified output assay.

Details

Requires electrode positions (pos_x, pos_y, pos_z) in colData. Apply eegMontage first if positions are not set.

Examples

pe <- make_eeg(n_time = 5000, n_channels = 19, sr = 500)
pe <- eegMontage(pe, system = "10-20")
# interpolate two named channels from their neighbours
pe_clean <- eegInterpolate(pe, bad_channels = c("C3", "C4"))
pe_clean
#> class: PhysioExperiment
#> dim: 5000 x 19 
#> assays(2): raw, interpolated
#> samplingRate: 500 Hz
#> channels(19): Fp1, Fp2, F7, F3, Fz ...
#> colData names(5): label, type, pos_x, pos_y, pos_z