Registry / serialization / trx-python

trx-python

JSON →
library0.4.0pypypiunverified

A community-oriented Python library for reading and writing the TRX (Tractography) file format, designed for efficient storage of streamline tractography data. Current version 0.4.0, requires Python >=3.11, with an active development cadence on GitHub.

pip install trx-python
INSTALL
IMPORT
SIG · TRX-PYTHON
T
trx-python
serializationpythonv0.4.0
Install
5.8s avg
Import
—
Disk
114MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 106.5MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 5.8s · import 0.000s · 102MB
114MB installed
● package 114MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TRXFile
✓ from trx import TRXFile
✗ from trx.file import TRXFile

Minimal example: create a TRX file with two streamlines and read them back.

# Create a simple TRX file with two streamlines import numpy as np from trx.file import TRXFile # Create two streamlines as arrays of 3D points streamlines = [ np.array([[0,0,0], [1,0,0], [2,0,0]], dtype=np.float32), np.array([[0,1,0], [1,1,0], [2,1,0]], dtype=np.float32) ] # Write to file with TRXFile('example.trx', mode='wb') as trx: trx.write_streamlines(streamlines) # Read back with TRXFile('example.trx', mode='rb') as trx: loaded = list(trx.read_streamlines()) print(f'Loaded {len(loaded)} streamlines')
Debug
Known issues
breakingTRXFile now requires explicit binary mode ('wb' or 'rb') when opening. Omitting mode will raise a ValueError in version 0.4.0.
fix
Always specify mode='wb' for writing or mode='rb' for reading.
affects: >=0.4.0
gotchaStreamline data must be float32 numpy arrays. Passing float64 or other dtypes may cause silent truncation or errors.
fix
Convert data to numpy.float32 before writing: np.array(streamline, dtype=np.float32).
affects: all
deprecatedThe function 'read_trx' and 'write_trx' from version 0.2 are deprecated and will be removed. Use TRXFile context manager instead.
fix
Replace read_trx/write_trx calls with 'with TRXFile(...) as trx: trx.read/write_streamlines(...)'.
affects: >=0.3.0
Upgrade
Version history
0.4.0latest on PyPI · released Mar 5, 2026
Audit
Dependencies
numpyrequiredCore dependency for array operations
dipyoptionalOptional for integration with DIPY tractography workflows
Agent activity
35 hits · last 30 days
node
28
Bingbot
1
OpenAI (training)
1
Resources
trx-python — pip install trx-python · libregistry