trx-rs#
A Rust library for reading, writing, and manipulating TRX brain tractography files, plus format-conversion helpers for common streamline formats.
TRX is a binary file format for storing streamline tractography data using memory-mapped arrays. It supports multiple coordinate precisions (f16, f32, f64), per-vertex data (DPV), per-streamline data (DPS), named groups, and data-per-group (DPG) arrays — all backed by zero-copy memory mapping for efficient access to large datasets.
Features#
Zero-copy memory mapping via
memmap2for efficient access to multi-gigabyte tractography filesMultiple precision support — f16, f32, and f64 positions with runtime dtype detection
Full read/write support for both directory-based and ZIP archive (
.trx) formatsFormat conversion helpers for
.tck,.tck.gz,.vtk, and.tt.gz -> .trxStreaming construction — build TRX files incrementally with
TrxStreamAncillary data access — DPS (per-streamline), DPV (per-vertex), group membership arrays, and DPG metadata
Set operations — intersection, union, and difference on streamline sets
Connectivity matrices — compute group-to-group connectivity (count or weighted)
Subset and merge — extract streamlines by index or concatenate multiple files
Supported data types#
Type |
Positions |
DPS/DPV |
|---|---|---|
|
Yes |
Yes |
|
Yes |
Yes |
|
Yes |
Yes |
|
- |
Yes |
|
- |
Yes |
License#
BSD 2-Clause.