{"id":24737,"library":"trx-python","title":"TRX Python","description":"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.","status":"active","version":"0.4.0","language":"python","source_language":"en","source_url":"https://github.com/tee-ar-ex/trx-python","tags":["tractography","neuroscience","file-format","streamlines","diffusion-mri"],"install":[{"cmd":"pip install trx-python","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Core dependency for array operations","package":"numpy","optional":false},{"reason":"Optional for integration with DIPY tractography workflows","package":"dipy","optional":true}],"imports":[{"wrong":"from trx.file import TRXFile","symbol":"TRXFile","correct":"from trx import TRXFile"}],"quickstart":{"code":"# Create a simple TRX file with two streamlines\nimport numpy as np\nfrom trx.file import TRXFile\n\n# Create two streamlines as arrays of 3D points\nstreamlines = [\n    np.array([[0,0,0], [1,0,0], [2,0,0]], dtype=np.float32),\n    np.array([[0,1,0], [1,1,0], [2,1,0]], dtype=np.float32)\n]\n\n# Write to file\nwith TRXFile('example.trx', mode='wb') as trx:\n    trx.write_streamlines(streamlines)\n\n# Read back\nwith TRXFile('example.trx', mode='rb') as trx:\n    loaded = list(trx.read_streamlines())\n    print(f'Loaded {len(loaded)} streamlines')","lang":"python","description":"Minimal example: create a TRX file with two streamlines and read them back."},"warnings":[{"fix":"Always specify mode='wb' for writing or mode='rb' for reading.","message":"TRXFile now requires explicit binary mode ('wb' or 'rb') when opening. Omitting mode will raise a ValueError in version 0.4.0.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Convert data to numpy.float32 before writing: np.array(streamline, dtype=np.float32).","message":"Streamline data must be float32 numpy arrays. Passing float64 or other dtypes may cause silent truncation or errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace read_trx/write_trx calls with 'with TRXFile(...) as trx: trx.read/write_streamlines(...)'.","message":"The function 'read_trx' and 'write_trx' from version 0.2 are deprecated and will be removed. Use TRXFile context manager instead.","severity":"deprecated","affected_versions":">=0.3.0"}],"env_vars":null,"search_vec":"'0.4.0':28 '3.11':31 'activ':34 'cadenc':36 'communiti':5 'community-ori':4 'current':26 'data':25 'design':18 'develop':35 'diffus':46 'diffusion-mri':45 'effici':20 'file':16,42 'file-format':41 'format':17,43 'github':38 'librari':8 'mri':47 'neurosci':40 'orient':6 'python':2,7,30 'read':10 'requir':29 'storag':21 'streamlin':23,44 'tractographi':15,24,39 'trx':1,14 'version':27 'write':12","created_at":"2026-05-01T08:14:40.039569+00:00","updated_at":"2026-05-01T08:14:40.039569+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'TRXFile' from 'trx' (/tmp/tmpwlsmj06a/venv/lib/python3.12/site-packages/trx/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.4.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/tee-ar-ex/trx-python","docs":"https://tee-ar-ex.github.io/trx-python/","changelog":null,"pypi":"https://pypi.org/project/trx-python/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}