Real-time brain-computer interfaces and neurofeedback loops on edge hardware like the Raspberry Pi often force developers to choose between heavy scientific stacks (scipy, mne, numba, openblas) or fragile hand-written DSP code. pifeat solves that trade-off in a single ~1.1 MB native wheel built in Rust with PyO3.
With zero runtime dependencies, pifeat installs cleanly via pip install pifeat and works directly with Python's built-in array.array, memoryview, bytearray, or numpy.ndarray through the CPython Buffer Protocol.
100x to 173x Faster Than SciPy + NumPy
Across 16 channels (500 samples at 250 Hz), pifeat extracts all 22 features per channel in ~146 microseconds with the GIL released and zero steady-state heap allocations on the real-time hot path.
- 22 Canonical Features per Channel: Time-domain (
rms,variance,line_length,zero_crossing_rate,hjorth_activity,hjorth_mobility,hjorth_complexity), Welch PSD band powers (delta,theta,alpha,beta,gamma,total_power, relative band powers,theta_beta_ratio,alpha_beta_ratio,spectral_entropy), and nonlinearpermutation_entropy. - Scientific Equivalence: Matches
scipy.signal.welch(periodic Hann window, constant detrending, density scaling) to< 10^-12relative error, using compensated two-pass variance to handle large uncalibrated ADC DC offsets. - Continuous Streaming Engine:
StreamingFeatureEnginemaintains per-channel circular buffers, tracks sequence numbers and timestamps, detects dropped upstream packets, and caches overlapping Welch segment periodograms so each hop only computes newly completed segment FFTs. - Pure Rust Support: Embed
pifeatdirectly in Rust firmware, Tauri apps, or native daemons without Python (default-features = false).
Precompiled Wheels for Raspberry Pi, Linux, and Windows
Automated releases ship prebuilt wheels for Linux (x86_64, aarch64 for Raspberry Pi 4/5 64-bit, armv7 for Raspberry Pi OS 32-bit) and Windows (x64) across Python 3.10 through 3.13. It pairs naturally with PiEEG-8, PiEEG-16, BrainFlow, LSL, MNE, or any raw SPI/ADC stream.
- GitHub Repository: github.com/pieeg-club/pifeat
- Install:
pip install pifeat



