Skip to content

tee-ar-ex/trx-cpp

Repository files navigation

TRX-cpp

Documentation codecov

A C++17 library for reading, writing, and memory-mapping the TRX tractography format — efficient storage for large-scale tractography data.

Features

  • Zero-copy memory mapping — positions, DPV, and DPS arrays are exposed as Eigen::Map views directly over memory-mapped files; no unnecessary copies for large tractograms
  • Streaming writesTrxStream appends streamlines one at a time and finalizes to a standard TRX archive or directory, suitable when the total count is unknown at the start
  • Spatial queries — build per-streamline axis-aligned bounding boxes (AABBs) and efficiently extract spatial subsets; designed for interactive slice-view workflows
  • Typed and type-erased APIsTrxFile<DT> gives compile-time type safety; AnyTrxFile dispatches at runtime when the dtype is read from disk
  • ZIP and directory storage — read and write .trx zip archives and plain on-disk directories with the same API
  • Optional NIfTI support — read qform/sform affines from .nii / .nii.gz and embed them in the TRX header

Quick start

Dependencies: a C++17 compiler, libzip, Eigen 3.4+

# CMakeLists.txt
find_package(trx-cpp CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE trx-cpp::trx)
#include <trx/trx.h>

// Load any TRX file — dtype detected at runtime
auto trx = trx::load_any("tracks.trx");

std::cout << trx.num_streamlines() << " streamlines, "
          << trx.num_vertices()    << " vertices\n";

// Access positions as an Eigen matrix (zero-copy)
auto positions = trx.positions.as_matrix<float>(); // (NB_VERTICES, 3)

trx.close();

See Building for platform-specific dependency installation and Quick Start for a complete first program.

Documentation

Full documentation is at trx-cpp.readthedocs.io.

Third-party notices

About

C++17 library for interacting with TRX files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors