Skip to content

Filters

Butterworth, Chebyshev I or Bessel, as low-pass, high-pass, band-pass or band-stop.

y = dspk.ops.filter.iir(x, 30_000.0, "bandpass", (300.0, 6000.0), order=5)

Zero phase or causal. mode="forward_backward" (the default) runs the filter forward and back, as scipy.signal.sosfiltfilt, so nothing shifts in time, and the magnitude response applies twice. mode="forward" is causal, as sosfilt, and is what streaming needs.

Takes out one frequency, as scipy.signal.iirnotch. The notch is freq / q Hz wide at −3 dB.

y = dspk.ops.filter.notch(x, 30_000.0, 60.0, 30.0)

Taps you give, causal (as scipy.signal.lfilter(taps, 1, x)) or centred on each sample. Design taps with firwin.

taps = dspk.ops.filter.firwin(101, 250.0, sample_rate=30_000.0)
y = dspk.ops.filter.fir(x, taps, centered=True)

Zero phase, as scipy.ndimage.gaussian_filter1d, with the kernel cut at 4 standard deviations.

y = dspk.ops.filter.gaussian_smooth(x, 30.0) # sigma in samples

Over an odd width of at most 31 samples. With the default edge it is scipy.signal.medfilt.

y = dspk.ops.filter.median(x, 31)

x[t]**2 - x[t-1] * x[t+1]: large where the signal is both large and fast, so spikes stand out from slow waves.

energy = dspk.ops.filter.teager_kaiser(x)

Removes a known waveform at each event, such as stimulation artefacts, aligned and scaled per event. Python only: subtract_template.

Worked examples: Filtering.