Files
rustytorch/crates/specialized/rtx-neuro-python
Omar Sobh 16161bb9df deps: align all 56 per-crate Cargo.toml files to thiserror v2
The workspace root was upgraded to thiserror = "2" in an earlier commit,
but 56 per-crate Cargo.toml files still independently declared "1.0".
These crates do not use workspace.dependencies inheritance for thiserror.
All updated to thiserror = "2" for complete fleet alignment.

Includes: rtx-backend, rtx-tensor, rtx-losses, rtx-backend-cuda/rocm/metal,
all training crates (rtx-auto, rtx-rl, rtx-distributed, rtx-federated, etc.),
specialized crates (rtx-science, rtx-platform, rtx-nmf, rtx-neuro-*),
production crates (rtx-streaming, rtx-serving-api), and all demo crates.

cargo check --workspace: PASSES.
2026-04-26 11:45:14 -07:00
..
2026-03-04 00:08:42 +00:00
2026-03-04 00:08:42 +00:00
2026-03-04 00:08:42 +00:00
2026-03-04 00:08:42 +00:00

RTX-Neuro Python

High-performance MEG/EEG analysis library with Python bindings.

RTX-Neuro provides Rust-powered neuroimaging analysis with a Python-friendly API, offering significant performance improvements over pure Python implementations.

Installation

From PyPI (when published)

pip install rtx-neuro

From Source

cd crates/specialized/rtx-neuro-python

# Development build (editable)
maturin develop

# Release build
maturin build --release
pip install target/wheels/rtx_neuro-*.whl

Quick Start

import rtx_neuro as rtx
import numpy as np

# Read MEG/EEG data
raw = rtx.io.read_raw_edf("recording.edf")
print(f"Channels: {raw.n_channels}, Sample rate: {raw.sfreq} Hz")

# Get data as numpy array
data = raw.get_data(tmin=0.0, tmax=10.0)

# Statistical analysis
t_stat, p_value = rtx.stats.ttest_1samp(data[0], popmean=0.0)

# Multiple comparison correction
p_values = np.array([0.01, 0.04, 0.03, 0.20, 0.001])
rejected, corrected = rtx.stats.fdr_correction(p_values, alpha=0.05)

Supported File Formats

Format Function Description
EDF/EDF+ read_raw_edf() European Data Format
FIF read_raw_fif() Elekta/Neuromag MEG
CTF read_raw_ctf() CTF MEG (.ds directories)
BTi read_raw_bti() 4D-Neuroimaging/BTi MEG
KIT read_raw_kit() Yokogawa/KIT/Ricoh MEG
EGI read_raw_egi() EGI (.raw, .mff)

Statistical Functions

Parametric Tests

  • ttest_1samp(data, popmean) - One-sample t-test
  • ttest_ind(a, b) - Independent samples t-test (Welch's)
  • ttest_rel(a, b) - Paired samples t-test

Non-parametric Tests

  • permutation_t_test(a, b, n_permutations, seed) - Permutation test

Multiple Comparison Correction

  • fdr_correction(p_values, alpha) - Benjamini-Hochberg FDR
  • bonferroni_correction(p_values, alpha) - Bonferroni correction

Examples

See the examples/ directory for complete tutorials:

  • quickstart.py - Getting started guide
  • reading_data.py - Reading various file formats
  • statistical_tests.py - Statistical analysis workflows

Performance

RTX-Neuro leverages Rust's performance advantages:

  • Native compiled code (10-100x faster than pure Python)
  • Parallel processing with Rayon
  • Memory-efficient data structures
  • Zero-copy numpy array transfers where possible

API Reference

RawData Object

Properties:

  • sfreq - Sampling frequency (Hz)
  • n_channels - Number of channels
  • n_samples - Number of samples
  • duration - Recording duration (seconds)
  • ch_names - List of channel names
  • path - File path

Methods:

  • get_data(tmin=None, tmax=None) - Get data as numpy array
  • pick_channels(ch_names) - Get indices for channel names

Requirements

  • Python >= 3.8
  • NumPy >= 1.20

Building from Source

Requirements:

  • Rust >= 1.70
  • maturin >= 1.0
  • Python development headers
# Install maturin
pip install maturin

# Build and install
cd crates/specialized/rtx-neuro-python
maturin develop  # Development mode
# or
maturin build --release  # Release wheel

License

MIT OR Apache-2.0