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.
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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 106.5MB
glibcpy 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.
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')
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.