Skip to main content

rustneuro for Python

Fast, validated signal processing for neuroscience and physiology — EEG/MEG/iEEG/LFP, ECG/HRV, PPG, respiration, EDA, EMG, fNIRS, spikes and calcium imaging — as a NumPy-friendly Python package powered by the rustneuro Rust library.

  • Validated. Every module is tested against the reference outputs of SciPy, MNE-Python, mne-connectivity, antropy, NeuroKit2 and tensorpac — the same golden fixtures that validate the Rust crate.
  • Fast on multi-channel data. Functions act along the last axis and process channels in parallel with the GIL released.
  • One dependency. Only NumPy at runtime; wheels ship compiled code, so no Rust toolchain is needed.
pip install rustneuro

Quick start

import numpy as np
import rustneuro as rn

sfreq = 250.0
eeg = np.random.default_rng(0).standard_normal((32, 60 * 250))   # (channels, times)

# MNE-style FIR band-pass and line-noise removal, all channels in parallel
x = rn.filter.filter_data(eeg, sfreq, l_freq=1.0, h_freq=40.0)
x = rn.filter.notch_filter(x, sfreq, [50.0])

# Spectra and features
freqs, psd = rn.spectral.welch(x, sfreq, nperseg=500)              # psd: (32, 251)
alpha = rn.spectral.band_power(freqs, psd, 8.0, 13.0)              # (32,)
fit = rn.spectral.fit_aperiodic(freqs, psd, 2.0, 40.0)             # 1/f offset and exponent

# Complexity, one value per channel
sampen = rn.complexity.sample_entropy(x[:, :2000])                 # (32,)

# Connectivity across epochs (mne-connectivity's estimators)
epochs = x[:, : 58 * 250].reshape(32, 29, 500).transpose(1, 0, 2)  # (epochs, channels, times)
wpli = rn.connectivity.spectral_connectivity(epochs, sfreq, "wpli", fmin=8.0, fmax=13.0, faverage=True)
matrix = wpli.dense()[..., 0]                                      # (32, 32)

Heart-rate variability from a raw ECG:

clean = rn.physio.ecg_clean(ecg, sfreq=500.0)
peaks = rn.physio.ecg_peaks(clean, sfreq=500.0)
hrv = rn.physio.hrv(peaks, sfreq=500.0)        # {"MeanNN": ..., "RMSSD": ..., "LF": ..., "SD1": ...}

What's inside

Module Highlights Validated against
rn.filter filter_data, notch_filter (MNE conventions); iirfilter/butter, sosfiltfilt, filtfilt, firwin, resample_poly, resample, decimate, savgol_filter, medfilt MNE-Python, SciPy
rn.signal hilbert, envelope, instantaneous phase/frequency, detrend, find_peaks, peak_prominences, get_window SciPy
rn.spectral welch, periodogram, psd_multitaper, csd, coherence, spectrogram, tfr_morlet, tfr_power_itc, lomb_scargle, dpss; band power, peak/mean/edge frequency, spectral entropy, fit_aperiodic SciPy, MNE-Python, fooof
rn.connectivity spectral_connectivity (coh, imcoh, plv, ciplv, ppc, pli, pli2_unbiased, dpli, wpli, wpli2_debiased), envelope_correlation, pac with surrogates mne-connectivity, tensorpac
rn.complexity Hjorth, permutation/spectral/SVD/approximate/sample entropy, Lempel–Ziv, Petrosian/Katz/Higuchi fractal dimension, DFA antropy, NeuroKit2
rn.physio ECG, PPG, respiration, EDA and EMG cleaning and peaks; time, frequency and non-linear HRV NeuroKit2
rn.spikes detect_spikes, extract_waveforms, ISI, CV/CV2/LV, Fano factor, refractory violations, correlograms, spike-triggered average — (formula tests)
rn.calcium delta_f_over_f, oasis_ar1 deconvolution NumPy, NNLS
rn.fnirs optical_density, beer_lambert, tddr motion correction MNE-Python

Every function has a docstring naming the reference it reproduces, and the public API is fully typed (py.typed).

Conventions

  • Time is the last axis. Signal functions accept any shape (..., n_times) and return arrays of matching leading shape; reductions (entropies, band power, ...) return a NumPy scalar for 1-D input and an array of the leading shape otherwise.
  • SciPy and MNE names and defaults wherever an equivalent exists, with sampling frequencies in Hz (fs/sfreq). Differences are documented in each docstring (for example, find_peaks returns only the indices).
  • Errors become ValueError (invalid arguments), RuntimeError (numerical failures) or OSError.

Performance

64 channels × 60 s at 1 kHz on a 10-core Apple Silicon laptop (best of 5):

Operation rustneuro SciPy
sosfiltfilt, 4th-order band-pass 28 ms 124 ms
welch, nperseg=2048 8 ms 59 ms
resample_poly, 1/4 13 ms 65 ms
hilbert 34 ms 69 ms
savgol_filter, window 51 20 ms 45 ms
medfilt, one channel, kernel 101 11 ms 2 ms

Most of the gain comes from processing channels in parallel; single-channel work runs at roughly SciPy's speed, and large-kernel median filtering is currently slower.

Building from source

Requires Rust ≥ 1.89 and maturin:

cd rustneuro-py
pip install maturin
maturin develop --release
pip install pytest scipy && pytest

License

MIT. Contact: Yusuf Berdan Guzel (y.guzel@unimelb.edu.au).

Metadata

Release files for rustneuro 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rustneuro 0.3.0
File Size Uploaded Provenance Actions
rustneuro-0.3.0.tar.gz 255.0 kB Without provenance Details for rustneuro-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rustneuro 0.3.0
File Actions
rustneuro-0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for rustneuro-0.3.0-cp310-abi3-win_amd64.whl
rustneuro-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for rustneuro-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
rustneuro-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for rustneuro-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
rustneuro-0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for rustneuro-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
rustneuro-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for rustneuro-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 6.4 MB

Release files / rustneuro-0.3.0.tar.gz

Download URL rustneuro-0.3.0.tar.gz
Size 255.0 kB
Tags Source
SHA-256 checksum
How to use checksums
49d1e41596ea24b980715699094f16e57fd77cdd38a5968411db618eac3e81ec
BLAKE2b-256 checksum
How to use checksums
57a9ca86d8a2e9eed5c6084f05b4d4c1bea8c7b3c9dbd8d308baede0fab194cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / rustneuro-0.3.0-cp310-abi3-win_amd64.whl

Download URL rustneuro-0.3.0-cp310-abi3-win_amd64.whl
Size 1.3 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
25f6e94af6c51d4ede37b364d3ece8f7800bae045fbda665fc2056514d8f2b50
BLAKE2b-256 checksum
How to use checksums
37c1449fe43a7da0fd09d338d57c5c6ed14c642f34ad3f5e4d78681566f9cc74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / rustneuro-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL rustneuro-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
80e3ead6e3ad5d59b70187d8f6d11995fe821276cec39bc511595812ea2f3e7f
BLAKE2b-256 checksum
How to use checksums
edcfa1581378baedcbaa715d0b44a4abbbe62b1d5c4c16fbdee54c1fe56e5ed4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / rustneuro-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL rustneuro-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
12651ecbbe5c447f135420051dce9ea32a335ffc6b5e3095d9ae1cb32b320947
BLAKE2b-256 checksum
How to use checksums
7a9dd2fd6fc3ce8a267f4b6d3ec3af483a2650edea18838dad2a05f89ced9722
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / rustneuro-0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL rustneuro-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e2bc2a211d77cf9c9fb24ce6b0138eb01e5c31f8b83340969276ce794a9ed7cb
BLAKE2b-256 checksum
How to use checksums
43be18d7bb5a38d6940473a8f2ff76ffd4a0d3e6e6e8f7df3c2aba351bf3551f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / rustneuro-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL rustneuro-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
23985fc5a02620cb715fbfcbaedbfdcd99db85af7b443b592745935eac3d2a1a
BLAKE2b-256 checksum
How to use checksums
aa735ae4856e9288d6d27e8e5dca10e3d4006effa720cef29053019a002519a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for rustneuro 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

6 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page