PiEEG XR Live on Kickstarter
Back to News
Software

pifeat: Zero-Dependency, Sub-Millisecond EEG Feature Extraction in Rust and Python

pifeat: Zero-Dependency, Sub-Millisecond EEG Feature Extraction in Rust and Python

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 nonlinear permutation_entropy.
  • Scientific Equivalence: Matches scipy.signal.welch (periodic Hann window, constant detrending, density scaling) to < 10^-12 relative error, using compensated two-pass variance to handle large uncalibrated ADC DC offsets.
  • Continuous Streaming Engine: StreamingFeatureEngine maintains 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 pifeat directly 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.

Open SourceRustPythonSignal ProcessingRaspberry PiEdge AIBCI