trx-python
A community-oriented file format for tractography
What it is and what it does
trx-python is a Python library for working with TRX, a community-oriented file format for tractography data used in neuroimaging research. It provides both a programmatic API and a unified command-line interface for loading, saving, converting, validating, and concatenating tractography files. The library supports multiple input formats (TRX, TRK, TCK, VTK, FIB, DPY) and can export to any of these formats, making it useful for interoperability across neuroimaging pipelines.
The package depends on numpy for numerical operations, nibabel for neuroimaging file I/O, deepdiff for data comparison, and typer for CLI argument parsing. It uses memory-mapped files to handle large tractography datasets efficiently without loading entire files into RAM. The project is actively maintained, supports Python 3.11–3.13, and is licensed under the permissive BSD License.
Use it for:
- Convert brain fiber tract data between TRX and legacy formats (TRK, TCK, VTK) in neuroimaging pipelines.
- Validate TRX tractography files for data integrity before processing or sharing with collaborators.
- Merge multiple tractography datasets into a single file using the concatenate command.
- Inspect TRX file metadata, headers, groups, and archive contents via the CLI info command.
- Integrate tractography I/O into Python-based neuroimaging analysis workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Reads, writes, and manipulates TRX tractography files in Python, supporting conversion between TRX and other formats (TRK, TCK, VTK, FIB, DPY) with command-line tools for validation and concatenation.
Yes. trx-python is worth installing if you work with tractography data in neuroimaging. It has low install friction, active maintenance, no known vulnerabilities, a permissive license, and fills a clear need for TRX format support. The CLI tools are convenient for one-off conversions and validation; the Python API integrates well into larger pipelines. The Alpha status reflects the format's maturity, not instability.
Install
trx-python on PyPI
pip
pip install trx-pythonuv
uv add trx-pythonpoetry
poetry add trx-pythonInstalling trx-python
Before you install
Low friction: pure Python wheel with four runtime dependencies (deepdiff, nibabel, numpy, typer). Active maintenance with a recent commit on 2026-08-11 and a release on 2026-03-05.
License in practice
BSD License (permissive) — you can use, modify, and distribute this package freely in both open and closed projects with minimal restrictions.
Quickstart
pip install trx-python
from trx.io import load, save
trx = load("tractogram.trx")
save(trx, "output.trk")
Requires Python 3.11 or later. Large tractography files use memory-mapped temporary storage; ensure adequate disk space (several gigabytes possible) and set TRX_TMPDIR if default temp location is insufficient.
Verify before relying
- Whether nibabel and numpy versions have known compatibility constraints with the supported Python versions.
- Performance characteristics and memory overhead when processing very large tractography files.
- Completeness of format support across all advertised file types (TRK, TCK, VTK, FIB, DPY) in practice.
Package facts
| License | BSD License (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — deepdiff, nibabel, numpy, typer |
| Maintenance | actively maintained — 162 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 100,126/month — #13,000 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: trx_python-0.4.0-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
dipyDIPY is a Python library for analyzing…
permissive · top 15,000 on PyPI
pynrrdReads and writes NRRD (Nearly Raw Raster Data)…
permissive · top 15,000 on PyPI
mne-bidsMNE-BIDS reads and writes neuroimaging datasets…
permissive · top 15,000 on PyPI
hdx-python-utilitiesProvides a collection of utilities for Python…
permissive · top 15,000 on PyPI
bidsschematoolsParse, validate, and export the Brain Imaging…
permissive · top 15,000 on PyPI
meshioReads and writes mesh files in dozens of…
permissive · top 5,000 on PyPI
pyevtkExports scientific data to binary VTK files for…
permissive · top 15,000 on PyPI
segyioSegyio reads and writes SEG-Y formatted seismic…
copyleft · top 15,000 on PyPI
nibabelNiBabel reads and writes neuroimaging file…
permissive · top 5,000 on PyPI
pybidsPyBIDS provides a Python interface to query,…
permissive · top 15,000 on PyPI