Skip to main content

dspk_ops/
lib.rs

1//! Signal processing for multi-channel recordings on the device (any GPU through wgpu, CUDA or HIP,
2//! or the CPU), written as CubeCL kernels: filters, spatial operators, statistics, linear algebra,
3//! peak finding, threshold crossings and resampling.
4//!
5//! # Where things are
6//!
7//! | Need | Module | Start with |
8//! |---|---|---|
9//! | Chain preprocessing steps | [`pipeline`] | [`Pipeline`], [`PipelineStage`] |
10//! | Filters (IIR, FIR, median, templates) | [`filter`] | [`filter::FilterSpec`], [`filter::DeviceFilter`] |
11//! | Mix channels (CAR, whitening, Laplacian) | [`spatial`] | [`SpatialWhitening`], [`SurfaceLaplacian`] |
12//! | Noise, percentiles, element-wise math | [`math`] | [`math::estimate_noise_std`] |
13//! | Matrix products, PCA, ICA | [`linalg`] | [`PcaModel`], [`linalg::matmul`](fn@linalg::matmul) |
14//! | Peaks (`find_peaks`) | [`peaks`] | [`peaks::find_peak_candidates`] |
15//! | Threshold crossings as events (onset, offset, peak) | [`crossings`] | [`crossings::detect_crossings_on_device`] |
16//! | Resampling | [`resampler`] | [`resampler::execute_resample_poly`] |
17//! | Device buffers and shared kernels | [`core`] | [`core::buffer`] |
18//!
19//! Data is a `[channels, samples]` buffer, channel-major. Functions take a cubecl `Client`, from
20//! [`dspk_core::compute::ComputeTarget`]: `ComputeTarget::from_env()?.client()?` picks the runtime
21//! named by `DSPK_RUNTIME`, otherwise the first compiled in. See [`Pipeline`] for a complete
22//! example.
23
24#[cfg(test)]
25#[macro_use]
26mod test_support;
27
28pub mod autotune;
29pub mod error;
30pub mod core;
31pub mod filter;
32pub mod spatial;
33pub mod math;
34pub mod linalg;
35pub mod crossings;
36pub mod peaks;
37pub mod pipeline;
38pub mod resampler;
39
40pub use error::{OpsError, OpsResult};
41pub use pipeline::{Pipeline, PipelineStage};
42pub use linalg::{FastIcaModel, IcaContrast, PcaModel, PpcaModel};
43pub use spatial::{SpatialWhitening, SurfaceLaplacian};