cogpy.preprocess.interpolate

Spatial interpolation for bad / missing channels.

Two families of functions are provided:

  • Grid-based (interpolate_bads, extrapolate_bads) — assumes a regular 2D (AP, ML) grid. Fast and simple when electrodes sit on a uniform lattice.

  • Coordinate-based (interpolate_bads_coords, interpolate_bads_xarray) — takes explicit (x, y) electrode coordinates in physical units. Handles non-uniform layouts such as graphene ECoG arrays with hemispheric gaps, checkerboard 32×16 patterns, and depth probes. The geometry lives in the data (BIDS _electrodes.tsv coordinates), not in the code.

Functions

bad2nan(arr, bad)

Converts bad channel indicators in a 2D boolean array to NaN values in a corresponding 3D data array.

extrapolate_bads(x[, footprint, median, ...])

Extrapolates to fill in NaN values based on the spatial neighborhood of each bad channel in a grid.

infer_nan_mask(arr)

Creates a mask indicating the positions of NaN values in the input array.

interpolate_bads(arr, skip[, method, ...])

Interpolates and optionally extrapolates to fill in bad or missing data in a 3D array based on a 2D mask of bad channels.

interpolate_bads_1d(arr, bad[, positions])

Interpolate bad channels on a linear (1D) probe.

interpolate_bads_coords(arr, coords, bad[, ...])

Interpolate bad channels using explicit electrode coordinates.

interpolate_bads_xarray(sig, bad[, x_coord, ...])

Interpolate bad channels in an xarray DataArray using stored coordinates.