A community-oriented file format for tractography
Actively maintained. Last release 2 months ago, commits in 14 of the last 26 weeks. A safe choice.
pip install trx-pythontrx-python
A Python implementation of the TRX file format for tractography data.
For details, please visit the documentation.
Installation
From PyPI
pip install trx-python
From Source
git clone https://github.com/tee-ar-ex/trx-python.git
cd trx-python
pip install .
Quick Start
Loading and Saving Tractograms
from trx.io import load, save
# Load a tractogram (supports .trx, .trk, .tck, .vtk, .fib, .dpy)
trx = load("tractogram.trx")
# Save to a different format
save(trx, "output.trk")
Command-Line Interface
TRX-Python provides a unified CLI (trx) for common operations:
# Show all available commands
trx --help
# Display TRX file information (header, groups, data keys, archive contents)
trx info data.trx
# Convert between formats
trx convert input.trk output.trx
# Concatenate tractograms
trx concatenate tract1.trx tract2.trx merged.trx
# Validate a TRX file
trx validate data.trx
Individual commands are also available for backward compatibility:
trx_info data.trx
trx_convert_tractogram input.trk output.trx
trx_concatenate_tractograms tract1.trx tract2.trx merged.trx
trx_validate data.trx
Development
We use spin for development workflow.
First-Time Setup
# Clone the repository (or your fork)
git clone https://github.com/tee-ar-ex/trx-python.git
cd trx-python
# Install with all dependencies
pip install -e ".[all]"
# Set up development environment (fetches upstream tags)
spin setup