Skip to content

Referencing

At every sample, subtract the mean (CAR) or the median (CMR) over channels. The median survives a bad channel, where the mean would spread it to all the others.

y = dspk.ops.spatial.cmr(x) # or car

Each electrode minus the mean of its neighbours, on a grid. It removes what spreads across the whole array and keeps what is local: useful for HD-EMG and ECoG. Inside the grid a channel has 4 neighbours, on an edge 3, and in a corner 2. Channels are row-major: channel row * cols + col.

lap = dspk.ops.spatial.Laplacian.from_grid(8, 8)
y = lap.apply(x)

A grid of another size than the chain’s channels is refused, with the reason. Python also has a distance-weighted version from electrode positions, Laplacian.from_positions.

Decorrelates the channels, as sorters do before matching: the result has uncorrelated channels of unit variance. It is a matrix fitted on the signal.

w = dspk.ops.spatial.Whitening.fit_zca(x)
y = w.apply(x)

Python also has Whitening.fit_local_knn, which whitens each channel over its nearest channels, as Kilosort4 does.

Worked examples: Referencing, Spatial.