Skip to main content

Crate dspk_ops

Crate dspk_ops 

Source
Expand description

Signal processing for multi-channel recordings on the device (any GPU through wgpu, CUDA or HIP, or the CPU), written as CubeCL kernels: filters, spatial operators, statistics, linear algebra, peak finding, threshold crossings and resampling.

§Where things are

NeedModuleStart with
Chain preprocessing stepspipelinePipeline, PipelineStage
Filters (IIR, FIR, median, templates)filterfilter::FilterSpec, filter::DeviceFilter
Mix channels (CAR, whitening, Laplacian)spatialSpatialWhitening, SurfaceLaplacian
Noise, percentiles, element-wise mathmathmath::estimate_noise_std
Matrix products, PCA, ICAlinalgPcaModel, linalg::matmul
Peaks (find_peaks)peakspeaks::find_peak_candidates
Threshold crossings as events (onset, offset, peak)crossingscrossings::detect_crossings_on_device
Resamplingresamplerresampler::execute_resample_poly
Device buffers and shared kernelscorecore::buffer

Data is a [channels, samples] buffer, channel-major. Functions take a cubecl Client, from dspk_core::compute::ComputeTarget: ComputeTarget::from_env()?.client()? picks the runtime named by DSPK_RUNTIME, otherwise the first compiled in. See Pipeline for a complete example.

Re-exports§

pub use error::OpsError;
pub use error::OpsResult;
pub use pipeline::Pipeline;
pub use pipeline::PipelineStage;
pub use linalg::FastIcaModel;
pub use linalg::IcaContrast;
pub use linalg::PcaModel;
pub use linalg::PpcaModel;
pub use spatial::SpatialWhitening;
pub use spatial::SurfaceLaplacian;

Modules§

autotune
Tunes every autotuned operation on this device ahead of time.
core
Device-side building blocks shared by every dspk-ops algorithm.
crossings
Threshold crossings as events: where each channel goes past a level (above it, below it, or either) and where it comes back. One tool for any signal: muscle contractions on an EMG envelope (band-pass → rectify → low-pass → crossings), excursions of a raw trace past ±level, a temperature above a limit, a trigger line going high.
error
The one error type of dspk-ops.
filter
Filters for [channels, samples] signals on the device.
linalg
Linear algebra on the device: matrix products (matmul), covariance, symmetric eigendecomposition, Cholesky; and the models built on them: PcaModel, TopComponents (the leading principal components of many rows, streamed in batches), PpcaModel (probabilistic PCA), FastIcaModel (independent components), and DeviceProjection (applying a fitted projection to device buffers).
math
Element-wise operations and statistics.
peaks
Peak finding, as scipy.signal.find_peaks:
pipeline
resampler
Sample-rate conversion on the device, following scipy.signal:
spatial
Operators that mix channels: each output channel is a weighted sum of input channels.