Skip to main content

rustpix

CI Documentation Crates.io PyPI DOI License: MIT

High-performance pixel detector data processing for neutron imaging. Supports Timepix3 (TPX3) with 96M+ hits/sec throughput. Features multiple clustering algorithms, centroid extraction, and Python bindings.

Features

  • Fast TPX3 Processing: Parallel packet parsing with memory-mapped I/O
  • Multiple Clustering Algorithms:
    • ABS (Adjacency-Based Search) - 8-connectivity clustering
    • DBSCAN - Density-based with spatial indexing
    • Graph - Union-find connected components
    • Grid - Parallel grid-based clustering
  • Streaming Architecture: Process files larger than RAM
  • Python Bindings: Thin wrappers with NumPy integration
  • CLI Tool: Command-line interface for batch processing
  • GUI Application: Interactive analysis with real-time visualization
  • Multiple Output Formats: HDF5, Arrow, CSV

Installation

Python (pip)

pip install rustpix

macOS (Homebrew)

brew tap ornlneutronimaging/rustpix
brew install --cask rustpix  # GUI app

Rust (cargo)

# CLI tool
cargo install rustpix-cli

# Library
cargo add rustpix-core rustpix-algorithms

From Source

# Using pixi (recommended)
git clone https://github.com/ornlneutronimaging/rustpix
cd rustpix
pixi install
pixi run build

# Or with cargo
cargo build --release --workspace

Quick Start

Python

import rustpix

# Process TPX3 file to neutron events
config = rustpix.ClusteringConfig(radius=5.0, temporal_window_ns=75.0)
neutrons = rustpix.process_tpx3_neutrons(
    "data.tpx3",
    clustering_config=config,
    algorithm="abs"
)

# Convert to NumPy
data = neutrons.to_numpy()
print(f"Found {len(data['x'])} neutron events")

Command Line

# Process file
rustpix process input.tpx3 -o output.h5

# Show file info
rustpix info input.tpx3

# Benchmark algorithms
rustpix benchmark input.tpx3

GUI Application

Launch the GUI for interactive analysis:

# macOS (Homebrew)
open -a Rustpix

# From source
pixi run gui
cargo run -p rustpix-gui --release

Workspace Structure

Crate Description
rustpix-core Core traits and types
rustpix-tpx TPX3 packet parser and hit types
rustpix-algorithms Clustering algorithms (ABS, DBSCAN, Graph, Grid)
rustpix-io File I/O with memory-mapped reading
rustpix-python Python bindings (PyO3)
rustpix-cli Command-line interface
rustpix-gui GUI application (egui)

Python API

Read Hits

import rustpix

# Read all hits
hits = rustpix.read_tpx3_hits("input.tpx3")
hits_np = hits.to_numpy()

# Stream hits in batches
for batch in rustpix.stream_tpx3_hits("input.tpx3"):
    process(batch.to_numpy())

Process Neutrons

# Configure clustering
clustering = rustpix.ClusteringConfig(
    radius=5.0,
    temporal_window_ns=75.0,
    min_cluster_size=1
)

# Configure centroid extraction
extraction = rustpix.ExtractionConfig(
    super_resolution_factor=8.0,
    weighted_by_tot=True,
    min_tot_threshold=10
)

# Stream processing (low memory)
for batch in rustpix.process_tpx3_neutrons(
    "input.tpx3",
    clustering_config=clustering,
    extraction_config=extraction,
    algorithm="abs"
):
    save_batch(batch.to_numpy())

# Batch processing (collect all)
neutrons = rustpix.process_tpx3_neutrons(
    "input.tpx3",
    clustering_config=clustering,
    extraction_config=extraction,
    algorithm="abs",
    collect=True
)

CLI Usage

# Process with custom parameters
rustpix process input.tpx3 -o output.csv \
    --algorithm dbscan \
    --spatial-epsilon 2.0 \
    --temporal-epsilon 500

# Show file information
rustpix info input.tpx3

# Benchmark different algorithms
rustpix benchmark input.tpx3 --iterations 5

# Convert formats
rustpix convert input.tpx3 -f hdf5 -o output.h5

Performance

  • Throughput: 96M+ hits/sec on modern hardware
  • Memory: Streaming architecture processes files larger than RAM
  • Parallel: Multi-threaded clustering with rayon
  • Optimized: SIMD-friendly data layouts (SoA)

Development

# Install dependencies with pixi
pixi install

# Run tests
pixi run test

# Format and lint
pixi run lint

# Build documentation
pixi run docs

# Run GUI in debug mode
pixi run gui-debug

Documentation

Citation

If you use rustpix in your research, please cite:

@software{rustpix2026,
  title = {rustpix: High-performance pixel detector data processing},
  author = {{ORNL Neutron Imaging Team}},
  year = {2026},
  url = {https://github.com/ornlneutronimaging/rustpix},
  doi = {10.5281/zenodo.18496370}
}

License

MIT License - see LICENSE for details.

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

Acknowledgments

Developed by the Neutron Imaging Team at Oak Ridge National Laboratory.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rustpix-1.2.0.tar.gz (140.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rustpix-1.2.0-cp311-abi3-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.11+Windows x86-64

rustpix-1.2.0-cp311-abi3-manylinux_2_28_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

rustpix-1.2.0-cp311-abi3-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustpix-1.2.0-cp311-abi3-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file rustpix-1.2.0.tar.gz.

File metadata

  • Download URL: rustpix-1.2.0.tar.gz
  • Upload date:
  • Size: 140.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for rustpix-1.2.0.tar.gz
Algorithm Hash digest
SHA256 763be10c0f96398230159cc956d1acde3aab845a1b5087972984cc7e2d3c28a6
MD5 d509fea4726f478143995475fac414c6
BLAKE2b-256 10605ec759109c8a7d9b703d32c57893b418237ebb3b4eebe2dd71a72f8c46d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustpix-1.2.0.tar.gz:

Publisher: release.yml on ornlneutronimaging/rustpix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustpix-1.2.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: rustpix-1.2.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for rustpix-1.2.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f02d105bd936d4c9dc0e372b984e99cf060e6e470ee34fe0436ff1547d28ecfc
MD5 c5939f37a1d6467a581637f189257534
BLAKE2b-256 a2848d0b593df2e8103279ec5eb95526032d609eb141876eae2d4e3f9fd9bbf1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustpix-1.2.0-cp311-abi3-win_amd64.whl:

Publisher: release.yml on ornlneutronimaging/rustpix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustpix-1.2.0-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rustpix-1.2.0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b39b9651e516e6a719d6a0ae4280d6ee7d6f675d0599e194978b9015845a5213
MD5 b5aa07611fb5d74f7e9ee062a093c3ec
BLAKE2b-256 4906dcf46bf9a7c0561d259d734922de7a048f870eb570b6ac122c1bef835845

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustpix-1.2.0-cp311-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on ornlneutronimaging/rustpix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustpix-1.2.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustpix-1.2.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 49c2c0068ecc94749fd4689e2843576bff6bc89c3289f8429d9cb6000463772a
MD5 0a8926899cd0aa67dd23c349eefbd4fd
BLAKE2b-256 14d60afb00747032653dc28ddb899389e27aaa0155c8fdfb3f6592f2fa794b06

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustpix-1.2.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on ornlneutronimaging/rustpix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustpix-1.2.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustpix-1.2.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0b08959e1b1b3daebddbcdbf2718fcd68c2bbecebbc108f0320a0d686dbc9e1a
MD5 a16eff14c509f1d1b29125c2fd211306
BLAKE2b-256 7c7b3ecbedf3f4a1a8d448cd2bf21433c067949669d55474e42b64825f6056bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustpix-1.2.0-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on ornlneutronimaging/rustpix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.2.1

5 files

This release

1.2.0 This release

5 files

1.1.3

5 files

1.1.2

5 files

1.1.1

5 files

1.1.0

5 files

1.0.5

5 files

1.0.4

5 files

1.0.3

5 files

1.0.2

5 files

1.0.1

4 files

0.1.0

2 files

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