Transforms#

GPU-accelerated transforms using PyTorch named tensors. Works on both CPU and GPU - tensors provide dimension awareness everywhere.

Base Classes#

Temporal / Signal Processing#

Temporal transforms for EMG feature extraction and signal processing.

SlidingWindowTransform(window_size[, ...])

Base class for sliding window transforms (GPU-accelerated).

RMS(window_size[, stride, dim])

Root Mean Square over sliding windows (GPU-accelerated).

MAV(window_size[, stride, dim])

Mean Absolute Value over sliding windows (GPU-accelerated).

VAR(window_size[, stride, dim])

Variance over sliding windows (GPU-accelerated).

Rectify([dim, name])

Full-wave rectification (absolute value).

Bandpass(low, high, fs[, order, Q, dim])

Bandpass filter using cascaded torchaudio biquads (GPU-accelerated).

Highpass(cutoff, fs[, order, Q, dim])

Highpass filter using torchaudio biquad (GPU-accelerated).

Lowpass(cutoff, fs[, order, Q, dim])

Lowpass filter using torchaudio biquad (GPU-accelerated).

Notch(freq[, width, fs, dim])

Notch filter using FFT (GPU-accelerated).

ZeroCrossings(window_size[, stride, dim])

Count zero crossings in sliding windows (GPU-accelerated).

SlopeSignChanges(window_size[, stride, dim])

Count slope sign changes in sliding windows (GPU-accelerated).

WaveformLength(window_size[, stride, dim])

Waveform length over sliding windows (GPU-accelerated).

Diff([n, dim])

Compute differences along a dimension.

Normalization#

Normalization transforms for data preprocessing.

ZScore([dim, eps, keepdim])

Z-score normalization (mean=0, std=1) along a dimension.

MinMax([dim, eps, range])

Min-max normalization to [0, 1] range along a dimension.

Normalize([p, dim, eps])

L-p normalization along a dimension.

Standardize(mean, std[, eps])

Standardize using pre-computed mean and std.

InstanceNorm([eps])

Instance normalization (normalize each sample independently).

LayerNorm(normalized_shape[, eps])

Layer normalization along specified dimensions.

BatchNorm([eps])

Batch normalization (normalize over batch dimension).

ClampRange([min_val, max_val])

Clamp values to a specified range.

Generic Operations#

Generic array operations.

Reshape(shape[, names])

Reshape tensor with new dimension names.

Index(indices[, dim])

Index/slice along a dimension.

Flatten([start_dim, end_dim])

Flatten dimensions of a tensor.

Squeeze([dim])

Remove dimensions of size 1.

Unsqueeze(dim[, name])

Add a dimension of size 1.

Transpose(dims, **kwargs)

Transpose/permute dimensions.

Mean([dim, keepdim])

Compute mean along a dimension.

Sum([dim, keepdim])

Compute sum along a dimension.

Stack(transforms[, dim])

Stack multiple tensors along a new dimension.

Concat(transforms[, dim])

Concatenate multiple tensors along an existing dimension.

Lambda(func, **kwargs)

Apply a custom function.

Identity([dim, name])

Identity transform (returns input unchanged).

Repeat(repeats[, dim])

Repeat tensor along a dimension.

Pad(padding[, dim, mode, value])

Pad tensor along a dimension.

Augmentation#

Data augmentation transforms.

GaussianNoise([std, p])

Add Gaussian noise to the signal.

MagnitudeWarp([sigma, n_knots, p, dim])

Warp magnitude using smooth random curves.

TimeWarp([sigma, n_knots, p, dim])

Warp time axis with smooth random curves.

Dropout([p, dim])

Randomly zero out elements.

ChannelShuffle([p])

Randomly shuffle channel order.

TimeShift([max_shift, p, fill])

Randomly shift signal in time.

Scale([scale_range, p])

Random amplitude scaling.

Cutout([n_holes, length, p, dim])

Randomly zero out contiguous regions.

Spatial / Grid-Aware#

Spatial transforms for electrode grid processing.

SpatialFilter([kernel, grids, dim])

Apply spatial filtering using grid layouts.

NDD([grids])

Normal Double Differential (Laplacian) filter.

LSD([grids])

Longitudinal Single Differential filter.

TSD([grids])

Transverse Single Differential filter.

IB2([grids])

Inverse Binomial 2nd order filter.