trx-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
Common Commands
spin setup # Set up development environment
spin install # Install in editable mode
spin test # Run all tests
spin test -m memmap # Run tests matching pattern
spin lint # Run linting (ruff)
spin lint --fix # Auto-fix linting issues
spin docs # Build documentation
spin clean # Clean temporary files
Run spin without arguments to see all available commands.
Code Quality
We use ruff for linting and formatting:
# Check for issues
spin lint
# Auto-fix issues
spin lint --fix
# Format code
ruff format .
Pre-commit Hooks
# Install hooks
pre-commit install
# Run on all files
pre-commit run --all-files
Temporary Directory
The TRX file format uses memory-mapped files to limit RAM usage. When dealing with large files, several gigabytes may be required on disk.
By default, temporary files are stored in:
- Linux/macOS:
/tmp - Windows:
C:\WINDOWS\Temp
To change the directory:
# Use a specific directory (must exist)
export TRX_TMPDIR=/path/to/tmp
# Use current working directory
export TRX_TMPDIR=use_working_dir
Temporary folders are automatically cleaned, but if the code crashes unexpectedly, ensure folders are deleted manually.
Troubleshooting
If the trx command is not working as expected, run trx --debug to print diagnostic information about the Python interpreter, package location, and whether all required and optional dependencies are installed.
Documentation
Full documentation is available at https://tee-ar-ex.github.io/trx-python/
To build locally:
spin docs --open
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
BSD License - see LICENSE for details.
Metadata
Release files for trx-python 0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trx_python-0.6.tar.gz | 125.3 kB | Without provenance | Details for trx_python-0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trx_python-0.6-py3-none-any.whl | Python 3 | none | any | Details for trx_python-0.6-py3-none-any.whl |
Total release size: 189.0 kB
Release files / trx_python-0.6.tar.gz
| Download URL | trx_python-0.6.tar.gz |
|---|---|
| Size | 125.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
434d53ca9ba347680ff334124c5882668f322660c75aba480e88bdbba8de349f
|
|
BLAKE2b-256 checksum How to use checksums |
7d7017da9485112c3c333d78c28eaab5d9e4eded06420b156622ce474d5bce1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trx_python-0.6-py3-none-any.whl
| Download URL | trx_python-0.6-py3-none-any.whl |
|---|---|
| Size | 63.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf7892cb5c4c70d6e2e36bf73d96a7eea2d405b59e1c109cfc2dee8f675e54cb
|
|
BLAKE2b-256 checksum How to use checksums |
66d066f981c7edcfdc76426031ee6b53cf5bfd6acfb9565a4b1d533fef93a43e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for trx-python 0.6
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.