High-performance TPX3 pixel detector data processing for neutron imaging
Project description
rustpix
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
- User Guide: ornlneutronimaging.github.io/rustpix
- Rust API: docs.rs/rustpix-core
- Design Docs: docs/ directory
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.18496371}
}
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rustpix-1.1.0.tar.gz.
File metadata
- Download URL: rustpix-1.1.0.tar.gz
- Upload date:
- Size: 132.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea5e322258d0f10d6ff2c2ec2914b85d42197e5739b721b19baeffa0384e08b6
|
|
| MD5 |
9d94f27295ba71ca5a37db9c669b487a
|
|
| BLAKE2b-256 |
74193fcd698a00e3788c110f794c7af58e9e9b930332ad62f509a128436e54bc
|
Provenance
The following attestation bundles were made for rustpix-1.1.0.tar.gz:
Publisher:
release.yml on ornlneutronimaging/rustpix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpix-1.1.0.tar.gz -
Subject digest:
ea5e322258d0f10d6ff2c2ec2914b85d42197e5739b721b19baeffa0384e08b6 - Sigstore transparency entry: 1000183249
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/rustpix@60e0eb72e9796be808899a62d5e9996968435c10 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@60e0eb72e9796be808899a62d5e9996968435c10 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustpix-1.1.0-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: rustpix-1.1.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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0f3af63baed550b125db981197a7a762186bd50d7dbbf0daa3b9513d734c60a
|
|
| MD5 |
04d5f4aeffb7d123424da123ce50a69a
|
|
| BLAKE2b-256 |
5e337e6cd6c036b7502fa0ed1f27bc9d8644d03e734bcdf5bafe89cb6fda9c92
|
Provenance
The following attestation bundles were made for rustpix-1.1.0-cp311-abi3-win_amd64.whl:
Publisher:
release.yml on ornlneutronimaging/rustpix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpix-1.1.0-cp311-abi3-win_amd64.whl -
Subject digest:
a0f3af63baed550b125db981197a7a762186bd50d7dbbf0daa3b9513d734c60a - Sigstore transparency entry: 1000183487
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/rustpix@60e0eb72e9796be808899a62d5e9996968435c10 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@60e0eb72e9796be808899a62d5e9996968435c10 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustpix-1.1.0-cp311-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rustpix-1.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13622899db6ada91ef71eb181f155f6c125d3fe665454ef978cf9cd2e01b1c0e
|
|
| MD5 |
f3a54fa52e6256ecf26fcde0861bfee7
|
|
| BLAKE2b-256 |
1d52d8fd6c643d9fd3df08c23a1e789f0e96688cbbd800c0921fd94c30752143
|
Provenance
The following attestation bundles were made for rustpix-1.1.0-cp311-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on ornlneutronimaging/rustpix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpix-1.1.0-cp311-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
13622899db6ada91ef71eb181f155f6c125d3fe665454ef978cf9cd2e01b1c0e - Sigstore transparency entry: 1000183435
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/rustpix@60e0eb72e9796be808899a62d5e9996968435c10 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@60e0eb72e9796be808899a62d5e9996968435c10 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustpix-1.1.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustpix-1.1.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c8d8442040ea99e844e621ae1cfa3e133051103e3db796ab1f6c0957118beab
|
|
| MD5 |
246653dc259cae4408e790774a5cdf35
|
|
| BLAKE2b-256 |
e4d5bf101b5f77c91d3a6a4a225e6de646b5ac05aa9d1bfb30f9218f4da2bd00
|
Provenance
The following attestation bundles were made for rustpix-1.1.0-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on ornlneutronimaging/rustpix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpix-1.1.0-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
2c8d8442040ea99e844e621ae1cfa3e133051103e3db796ab1f6c0957118beab - Sigstore transparency entry: 1000183316
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/rustpix@60e0eb72e9796be808899a62d5e9996968435c10 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@60e0eb72e9796be808899a62d5e9996968435c10 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustpix-1.1.0-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rustpix-1.1.0-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b13fe96e9f5764edcf514cd1e233bcb0513b2943424f8b0e1d2d3b7d877b4e83
|
|
| MD5 |
9fc8afbeba038004b6151e1665574699
|
|
| BLAKE2b-256 |
9bd10d589d884dbb7f43994cd7b07ecaaffe7455548f4ba9258bee343319384e
|
Provenance
The following attestation bundles were made for rustpix-1.1.0-cp311-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on ornlneutronimaging/rustpix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpix-1.1.0-cp311-abi3-macosx_10_12_x86_64.whl -
Subject digest:
b13fe96e9f5764edcf514cd1e233bcb0513b2943424f8b0e1d2d3b7d877b4e83 - Sigstore transparency entry: 1000183378
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/rustpix@60e0eb72e9796be808899a62d5e9996968435c10 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@60e0eb72e9796be808899a62d5e9996968435c10 -
Trigger Event:
push
-
Statement type: