NN Module (stx.nn)
PyTorch neural network layers for signal processing and neuroscience applications.
Quick Reference
import scitex as stx
import torch
# Bandpass filtering as a differentiable layer
bpf = stx.nn.BandPassFilter(
bands=[[4, 8], [8, 13], [13, 30]], # theta, alpha, beta
fs=256, seq_len=1024
)
filtered = bpf(signal) # (batch, channels, 3, 1024)
# Power spectral density
psd = stx.nn.PSD(sample_rate=256)
power, freqs = psd(signal)
# Phase-amplitude coupling
pac = stx.nn.PAC(seq_len=1024, fs=256)
coupling = pac(signal)
Signal Processing Layers
Filtering (all differentiable):
BandPassFilter(bands, fs, seq_len)– Multi-band frequency filteringBandStopFilter(bands, fs, seq_len)– Reject frequency bandsLowPassFilter(cutoffs_hz, fs, seq_len)– Anti-aliasing / smoothingHighPassFilter(cutoffs_hz, fs, seq_len)– High-frequency emphasisGaussianFilter(sigma)– Gaussian kernel smoothingDifferentiableBandPassFilter(...)– Learnable bandpass parameters
Spectral Analysis:
Spectrogram(sampling_rate, n_fft)– STFT-based magnitude spectrogramPSD(sample_rate, prob)– FFT-based power spectral densityWavelet(samp_rate, freq_scale)– Continuous wavelet transform
Phase & Coupling:
Hilbert(seq_len)– Analytic signal (phase + amplitude)ModulationIndex(n_bins)– Phase-amplitude coupling metricPAC(seq_len, fs, ...)– Complete PAC analysis pipeline
Channel Manipulation
SwapChannels()– Random channel permutation (training augmentation)DropoutChannels(dropout)– Drop entire channelsChannelGainChanger(n_chs)– Learnable per-channel scalingFreqGainChanger(n_bands, fs)– Learnable per-band scaling
Attention & Shape
SpatialAttention(n_chs_in)– Adaptive channel weightingTransposeLayer(axis1, axis2)– Dimension permutationAxiswiseDropout(dropout_prob, dim)– Drop entire axis
Architectures
ResNet1D(n_chs, n_out, n_blks)– 1D residual networkBNet/BNet_Res– Multi-head EEG classifierMNet1000– 2D CNN feature extractor
API Reference
See scitex.nn API Reference for the auto-generated Python API.