pax_global_header 0000666 0000000 0000000 00000000064 15152407737 0014525 g ustar 00root root 0000000 0000000 52 comment=db56c466d69decb5f7f2311adf9e60f132f076ca tee-ar-ex-trx-python-a304ac2/ 0000775 0000000 0000000 00000000000 15152407737 0016045 5 ustar 00root root 0000000 0000000 tee-ar-ex-trx-python-a304ac2/.flake8 0000664 0000000 0000000 00000000212 15152407737 0017213 0 ustar 00root root 0000000 0000000 [flake8] max-line-length = 88 max-complexity = 10 exclude = .git, __pycache__, .tox, .eggs, *.egg, build, dist tee-ar-ex-trx-python-a304ac2/.github/ 0000775 0000000 0000000 00000000000 15152407737 0017405 5 ustar 00root root 0000000 0000000 tee-ar-ex-trx-python-a304ac2/.github/workflows/ 0000775 0000000 0000000 00000000000 15152407737 0021442 5 ustar 00root root 0000000 0000000 tee-ar-ex-trx-python-a304ac2/.github/workflows/codeformat.yml 0000664 0000000 0000000 00000000742 15152407737 0024313 0 ustar 00root root 0000000 0000000 name: Code Format on: push: branches: [master] pull_request: branches: [master] permissions: contents: read jobs: pre-commit: name: Pre-commit checks runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.12" - name: Install and run pre-commit hooks uses: pre-commit/action@v3.0.1 tee-ar-ex-trx-python-a304ac2/.github/workflows/coverage.yml 0000664 0000000 0000000 00000002064 15152407737 0023762 0 ustar 00root root 0000000 0000000 name: Coverage on: push: branches: [master] pull_request: branches: [master] permissions: contents: read jobs: coverage: name: Code Coverage runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.12" cache: pip cache-dependency-path: pyproject.toml - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install -e .[test] - name: Run tests with coverage run: | pytest trx/tests --cov=trx --cov-report=xml --cov-report=term-missing - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: files: ./coverage.xml flags: unittests name: codecov-trx fail_ci_if_error: false verbose: true env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} tee-ar-ex-trx-python-a304ac2/.github/workflows/docbuild.yml 0000664 0000000 0000000 00000010162 15152407737 0023752 0 ustar 00root root 0000000 0000000 name: Documentation build on: push: branches: [ master ] tags: - '*' pull_request: branches: [ master ] permissions: contents: write jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ["3.13"] steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Fetch all history and tags for setuptools_scm - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install run: | python -m pip install cython python -m pip install --upgrade pip pip install .[doc] - name: Build docs run: | cd docs SPHINXOPTS="-W" make html - name: Upload docs uses: actions/upload-artifact@v4 with: name: docs path: docs/_build/html deploy-dev: needs: build runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'tee-ar-ex/trx-python' steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: name: docs path: docs/_build/html - name: Publish dev docs to Github Pages uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages folder: docs/_build/html target-folder: dev deploy-release: needs: build runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') && github.repository == 'tee-ar-ex/trx-python' steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: name: docs path: docs/_build/html - name: Get version from tag id: get_version run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - name: Fetch existing switcher.json from gh-pages run: | curl -sSL https://tee-ar-ex.github.io/trx-python/switcher.json -o switcher.json || echo '[]' > switcher.json - name: Update switcher.json with new version run: python tools/update_switcher.py switcher.json --version ${{ steps.get_version.outputs.VERSION }} - name: Create root files (redirect + switcher.json) run: | mkdir -p root_files cp switcher.json root_files/ cat > root_files/index.html << 'EOF'
Python implementation of the TRX file format for tractography data.
If you are not redirected automatically, visit the stable documentation.
EOF - name: Publish root files (redirect + switcher.json) uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages folder: root_files target-folder: . clean: false - name: Publish release docs to Github Pages uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages folder: docs/_build/html target-folder: ${{ steps.get_version.outputs.VERSION }} - name: Publish stable docs to Github Pages uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages folder: docs/_build/html target-folder: stable tee-ar-ex-trx-python-a304ac2/.github/workflows/publish-to-test-pypi.yml 0000664 0000000 0000000 00000004647 15152407737 0026222 0 ustar 00root root 0000000 0000000 name: Publish to TestPyPI and PyPI on: push: branches: - master tags: - "*" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build-sdist: name: Build sdist runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - name: Build sdist run: pipx run build - uses: actions/upload-artifact@v6 with: name: source-dist path: ./dist/* test-sdist: name: Test sdist needs: [build-sdist] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v7 with: name: source-dist path: ./dist - uses: actions/setup-python@v6 with: python-version: "3.11" - name: Display Python version run: python -c "import sys; print(sys.version)" - name: Install sdist without optional dependencies run: pip install dist/*.tar.gz - run: python -c 'import trx; print(trx.__version__)' - name: Install pytest run: pip install pytest psutil pytest-console-scripts pytest-cov - name: Run tests run: pytest -v --pyargs trx pre-publish: runs-on: ubuntu-latest needs: [test-sdist] steps: - uses: actions/download-artifact@v7 with: path: dist/ pattern: '*-dist' merge-multiple: true - run: ls -lR dist/ - run: pipx run twine check dist/* test-pypi-publish: runs-on: ubuntu-latest needs: [pre-publish] steps: - uses: actions/download-artifact@v7 with: path: dist/ pattern: '*-dist' merge-multiple: true - run: ls -lR dist/ - uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ verbose: true pypi-publish: runs-on: ubuntu-latest environment: "Package deployment" needs: [pre-publish] if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') steps: - uses: actions/download-artifact@v7 with: path: dist/ pattern: '*-dist' merge-multiple: true - run: ls -lR dist/ - uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} tee-ar-ex-trx-python-a304ac2/.github/workflows/test.yml 0000664 0000000 0000000 00000001745 15152407737 0023153 0 ustar 00root root 0000000 0000000 name: Tests on: push: branches: [master] pull_request: branches: [master] permissions: contents: read jobs: test: name: Python ${{ matrix.python-version }} • ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: python-version: ["3.11", "3.12", "3.13"] os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # needed for setuptools_scm version detection - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: pip cache-dependency-path: pyproject.toml - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install -e .[dev,test] python -c "import trx; print(trx.__version__)" - name: Test run: spin test tee-ar-ex-trx-python-a304ac2/.gitignore 0000664 0000000 0000000 00000003616 15152407737 0020043 0 ustar 00root root 0000000 0000000 trx/version.py .DS_Store *_version.py # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover *.py, cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 db.sqlite3-journal # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. # Pipfile.lock # PEP 582; used by e.g. github.com/David-OConnor/pyflow __pypackages__/ # Celery stuff celerybeat-schedule celerybeat.pid # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ .vscode/ tmp/ auto_examples/ CLAUDE.md claude.md agents.md AGENTS.md sg_execution_times.rst tee-ar-ex-trx-python-a304ac2/.pre-commit-config.yaml 0000664 0000000 0000000 00000001241 15152407737 0022324 0 ustar 00root root 0000000 0000000 default_language_version: python: python3 repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.14.14 hooks: # Run the linter - id: ruff args: [ --fix ] # Run the formatter - id: ruff-format - repo: https://github.com/codespell-project/codespell rev: v2.4.1 hooks: - id: codespell args: [--skip, "pyproject.toml,docs/_build/*,*.egg-info"] additional_dependencies: - tomli - repo: https://github.com/numpy/numpydoc rev: v1.10.0 hooks: - id: numpydoc-validation name: numpydoc validate description: Run numpydoc validation across trx package tee-ar-ex-trx-python-a304ac2/.spin/ 0000775 0000000 0000000 00000000000 15152407737 0017074 5 ustar 00root root 0000000 0000000 tee-ar-ex-trx-python-a304ac2/.spin/__init__.py 0000664 0000000 0000000 00000000035 15152407737 0021203 0 ustar 00root root 0000000 0000000 """Spin commands package.""" tee-ar-ex-trx-python-a304ac2/.spin/cmds.py 0000664 0000000 0000000 00000020613 15152407737 0020376 0 ustar 00root root 0000000 0000000 """Custom spin commands for trx-python development.""" import glob import os import shutil import subprocess import sys import tempfile import click UPSTREAM_URL = "https://github.com/tee-ar-ex/trx-python.git" UPSTREAM_NAME = "upstream" def run(cmd, check=True, capture=True): """Run a shell command. Parameters ---------- cmd : list of str Command and arguments to execute. check : bool, optional If True, check the return code and report errors. capture : bool, optional If True, capture stdout and stderr. Returns ------- str or int or None Captured stdout string, return code, or None on error. """ result = subprocess.run(cmd, capture_output=capture, text=True, check=False) if check and result.returncode != 0: if capture: click.echo(f"Error: {result.stderr}", err=True) return None return result.stdout.strip() if capture else result.returncode def get_remotes(): """Get dict of remote names to URLs. Returns ------- dict Mapping of remote names to their fetch URLs. """ output = run(["git", "remote", "-v"]) if not output: return {} remotes = {} for line in output.split("\n"): if "(fetch)" in line: parts = line.split() remotes[parts[0]] = parts[1] return remotes @click.command() def setup(): """Set up development environment (fetch tags from upstream). This command configures your fork for development by: 1. Adding the upstream remote if not present 2. Fetching tags from upstream (required for correct version detection) Run this once after cloning your fork. """ click.echo("Setting up trx-python development environment...\n") # Check if in git repo if run(["git", "rev-parse", "--git-dir"], check=False) is None: click.echo("Error: Not in a git repository", err=True) sys.exit(1) # Check/add upstream remote remotes = get_remotes() upstream_remote = None for name, url in remotes.items(): if UPSTREAM_URL.rstrip(".git") in url.rstrip(".git"): upstream_remote = name click.echo(f"Found upstream remote: {name}") break if upstream_remote is None: click.echo(f"Adding upstream remote: {UPSTREAM_URL}") run(["git", "remote", "add", UPSTREAM_NAME, UPSTREAM_URL]) upstream_remote = UPSTREAM_NAME # Fetch tags click.echo(f"\nFetching tags from {upstream_remote}...") run(["git", "fetch", upstream_remote, "--tags"], capture=False) # Verify version click.echo("\nVerifying version detection...") try: from setuptools_scm import get_version version = get_version() click.echo(f"Detected version: {version}") # Check for suspicious version patterns if version.startswith("0.0"): click.echo( "\nWarning: Version starts with 0.0 - tags may not be fetched.", err=True, ) sys.exit(1) except ImportError: click.echo("Note: Install setuptools_scm to verify version detection") click.echo("\nSetup complete! You can now run:") click.echo(" spin install # Install in development mode") click.echo(" spin test # Run tests") @click.command() @click.option( "-m", "--match", "pattern", default=None, help="Only run tests matching this pattern (passed to pytest -k)", ) @click.option("-v", "--verbose", is_flag=True, default=False, help="Verbose output") @click.argument("pytest_args", nargs=-1) def test(pattern, verbose, pytest_args): """Run tests using pytest. Additional arguments are passed directly to pytest. Parameters ---------- pattern : str or None Only run tests matching this pattern (passed to pytest -k). verbose : bool If True, enable verbose output. pytest_args : tuple Additional arguments passed directly to pytest. """ cmd = ["pytest", "trx/tests"] if pattern: cmd.extend(["-k", pattern]) if verbose: cmd.append("-v") if pytest_args: cmd.extend(pytest_args) click.echo(f"Running: {' '.join(cmd)}\n") sys.exit(run(cmd, capture=False, check=False)) @click.command() @click.option( "--fix", is_flag=True, default=False, help="Automatically fix issues where possible" ) def lint(fix): """Run linting checks using ruff and codespell. Parameters ---------- fix : bool If True, automatically fix issues where possible. """ click.echo("Running ruff linter...") cmd = ["ruff", "check", "."] if fix: cmd.append("--fix") result = run(cmd, capture=False, check=False) if result != 0: click.echo("\nLinting issues found!", err=True) sys.exit(1) click.echo("\nRunning ruff formatter check...") cmd_format = ["ruff", "format", "--check", "."] result = run(cmd_format, capture=False, check=False) if result != 0: click.echo("\nFormatting issues found!", err=True) sys.exit(1) click.echo("\nRunning codespell...") cmd_spell = [ "codespell", "--skip", "*.pyc,.git,pyproject.toml,./docs/_build/*,*.egg-info,./build/*,./dist/*,./tmp/*", "trx", "docs/source", ".spin", ] result = run(cmd_spell, capture=False, check=False) if result != 0: click.echo("\nSpelling issues found!", err=True) sys.exit(1) click.echo("\nAll checks passed!") @click.command() @click.option( "--clean", is_flag=True, default=False, help="Clean build directory before building" ) @click.option( "--open", "open_browser", is_flag=True, default=False, help="Open documentation in browser after building", ) def docs(clean, open_browser): """Build documentation using Sphinx. Parameters ---------- clean : bool If True, clean build directory before building. open_browser : bool If True, open documentation in browser after building. """ import os docs_dir = "docs" if clean: click.echo("Cleaning build directory...") build_dir = os.path.join(docs_dir, "_build") if os.path.exists(build_dir): shutil.rmtree(build_dir) # Clean sphinx-gallery generated files gallery_dir = os.path.join(docs_dir, "source", "auto_examples") if os.path.exists(gallery_dir): click.echo("Cleaning sphinx-gallery generated files...") shutil.rmtree(gallery_dir) # Clean sphinx-gallery execution times file sg_times = os.path.join(docs_dir, "source", "sg_execution_times.rst") if os.path.exists(sg_times): os.remove(sg_times) click.echo("Building documentation...") cmd = ["make", "-C", docs_dir, "html"] result = run(cmd, capture=False, check=False) if result == 0: index_path = os.path.abspath( os.path.join(docs_dir, "_build", "html", "index.html") ) click.echo("\nDocs built successfully!") click.echo(f"Open: {index_path}") if open_browser: import webbrowser webbrowser.open(f"file://{index_path}") sys.exit(result) @click.command() def clean(): # noqa: C901 """Clean up temporary files and build artifacts.""" click.echo("Cleaning up temporary files...") # Clean TRX temp directory trx_tmp_dir = os.getenv("TRX_TMPDIR", tempfile.gettempdir()) if os.path.exists(trx_tmp_dir): temp_files = glob.glob(os.path.join(trx_tmp_dir, "trx_*")) for temp_dir in temp_files: if os.path.isdir(temp_dir): click.echo(f"Removing temporary directory: {temp_dir}") shutil.rmtree(temp_dir) # Clean build artifacts for build_pattern in ["build", "dist", "*.egg-info"]: for path in glob.glob(build_pattern): if os.path.isdir(path): click.echo(f"Removing build directory: {path}") shutil.rmtree(path) elif os.path.isfile(path): click.echo(f"Removing build file: {path}") os.remove(path) # Clean Python cache for cache_dir in ["**/__pycache__", "**/.pytest_cache"]: for path in glob.glob(cache_dir, recursive=True): if os.path.isdir(path): click.echo(f"Removing cache directory: {path}") shutil.rmtree(path) click.echo("Cleanup complete!") tee-ar-ex-trx-python-a304ac2/.zenodo.json 0000664 0000000 0000000 00000005335 15152407737 0020322 0 ustar 00root root 0000000 0000000 { "upload_type": "software", "title": "trx-python: A Python implementation of the TRX tractography file format", "description": "trx-python is a Python implementation of the TRX file format for brain tractography data. TRX is a community-driven tractography file format designed to facilitate dataset exchange, interoperability, and state-of-the-art analyses, acting as a replacement for the myriad of existing formats. The library uses memory-mapped files to efficiently handle large neuroimaging datasets and provides a unified I/O interface supporting TRX, TRK, TCK, FIB, VTK, and DPY formats.", "access_right": "open", "license": "bsd-3-clause", "language": "eng", "keywords": [ "tractography", "neuroimaging", "diffusion MRI", "white matter", "brain connectivity", "streamlines", "connectome", "file format", "memory-mapped", "nibabel", "dipy" ], "creators": [ { "name": "Rheault, François", "affiliation": "Université de Sherbrooke", "orcid": "0000-0002-0097-8004" } ], "contributors": [ { "name": "Rokem, Ariel", "affiliation": "University of Washington", "orcid": "0000-0003-0679-1985", "type": "ProjectMember" }, { "name": "Koudoro, Serge", "affiliation": "Indiana University Bloomington", "orcid": "0000-0002-9819-9884", "type": "ProjectMember" }, { "name": "Hayot-Sasson, Valérie", "affiliation": "ÉTS Montréal", "orcid": "0000-0002-4830-4535", "type": "ProjectMember" }, { "name": "Sólon Heinsfeld, Anibal", "affiliation": "University of Texas at Austin", "orcid": "0000-0002-2050-0614", "type": "ProjectMember" }, { "name": "Beasley, Benjamin A.", "type": "Other" }, { "name": "Mollier, Étienne", "affiliation": "Debian Project", "type": "Other" } ], "grants": [ { "id": "10.13039/100000025::1R01MH126699" } ], "related_identifiers": [ { "identifier": "https://github.com/tee-ar-ex/trx-python", "relation": "isSupplementTo", "resource_type": "software" }, { "identifier": "https://tee-ar-ex.github.io/trx-python/", "relation": "isDocumentedBy", "resource_type": "publication-other" } ], "communities": [ { "identifier": "neuroscience" } ] } tee-ar-ex-trx-python-a304ac2/LICENSE 0000664 0000000 0000000 00000002442 15152407737 0017054 0 ustar 00root root 0000000 0000000 Copyright (c) 2021 -- , Francois Rheault and others All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. tee-ar-ex-trx-python-a304ac2/README.md 0000664 0000000 0000000 00000007742 15152407737 0017336 0 ustar 00root root 0000000 0000000 # trx-python [](https://github.com/tee-ar-ex/trx-python/actions/workflows/test.yml) [](https://github.com/tee-ar-ex/trx-python/actions/workflows/codeformat.yml) [](https://codecov.io/gh/tee-ar-ex/trx-python) [](https://badge.fury.io/py/trx-python) A Python implementation of the TRX file format for tractography data. For details, please visit the [documentation](https://tee-ar-ex.github.io/trx-python/). ## Installation ### From PyPI ```bash pip install trx-python ``` ### From Source ```bash git clone https://github.com/tee-ar-ex/trx-python.git cd trx-python pip install . ``` ## Quick Start ### Loading and Saving Tractograms ```python from trx.io import load, save # Load a tractogram (supports .trx, .trk, .tck, .vtk, .fib, .dpy) trx = load("tractogram.trx") # Save to a different format save(trx, "output.trk") ``` ### Command-Line Interface TRX-Python provides a unified CLI (`trx`) for common operations: ```bash # Show all available commands trx --help # Display TRX file information (header, groups, data keys, archive contents) trx info data.trx # Convert between formats trx convert input.trk output.trx # Concatenate tractograms trx concatenate tract1.trx tract2.trx merged.trx # Validate a TRX file trx validate data.trx ``` Individual commands are also available for backward compatibility: ```bash trx_info data.trx trx_convert_tractogram input.trk output.trx trx_concatenate_tractograms tract1.trx tract2.trx merged.trx trx_validate data.trx ``` ## Development We use [spin](https://github.com/scientific-python/spin) for development workflow. ### First-Time Setup ```bash # Clone the repository (or your fork) git clone https://github.com/tee-ar-ex/trx-python.git cd trx-python # Install with all dependencies pip install -e ".[all]" # Set up development environment (fetches upstream tags) spin setup ``` ### Common Commands ```bash spin setup # Set up development environment spin install # Install in editable mode spin test # Run all tests spin test -m memmap # Run tests matching pattern spin lint # Run linting (ruff) spin lint --fix # Auto-fix linting issues spin docs # Build documentation spin clean # Clean temporary files ``` Run `spin` without arguments to see all available commands. ### Code Quality We use [ruff](https://docs.astral.sh/ruff/) for linting and formatting: ```bash # Check for issues spin lint # Auto-fix issues spin lint --fix # Format code ruff format . ``` ### Pre-commit Hooks ```bash # Install hooks pre-commit install # Run on all files pre-commit run --all-files ``` ## Temporary Directory The TRX file format uses memory-mapped files to limit RAM usage. When dealing with large files, several gigabytes may be required on disk. By default, temporary files are stored in: - Linux/macOS: `/tmp` - Windows: `C:\WINDOWS\Temp` To change the directory: ```bash # Use a specific directory (must exist) export TRX_TMPDIR=/path/to/tmp # Use current working directory export TRX_TMPDIR=use_working_dir ``` Temporary folders are automatically cleaned, but if the code crashes unexpectedly, ensure folders are deleted manually. ## Troubleshooting If the `trx` command is not working as expected, run `trx --debug` to print diagnostic information about the Python interpreter, package location, and whether all required and optional dependencies are installed. ## Documentation Full documentation is available at https://tee-ar-ex.github.io/trx-python/ To build locally: ```bash spin docs --open ``` ## Contributing We welcome contributions! Please see our [Contributing Guide](https://tee-ar-ex.github.io/trx-python/contributing.html) for details. ## License BSD License - see [LICENSE](LICENSE) for details. tee-ar-ex-trx-python-a304ac2/docs/ 0000775 0000000 0000000 00000000000 15152407737 0016775 5 ustar 00root root 0000000 0000000 tee-ar-ex-trx-python-a304ac2/docs/Makefile 0000664 0000000 0000000 00000001177 15152407737 0020443 0 ustar 00root root 0000000 0000000 # Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = source BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) tee-ar-ex-trx-python-a304ac2/docs/_static/ 0000775 0000000 0000000 00000000000 15152407737 0020423 5 ustar 00root root 0000000 0000000 tee-ar-ex-trx-python-a304ac2/docs/_static/switcher.json 0000664 0000000 0000000 00000000435 15152407737 0023150 0 ustar 00root root 0000000 0000000 [ { "name": "dev", "version": "dev", "url": "https://tee-ar-ex.github.io/trx-python/dev/" }, { "name": "stable", "version": "stable", "url": "https://tee-ar-ex.github.io/trx-python/stable/", "preferred": true } ] tee-ar-ex-trx-python-a304ac2/docs/_static/trx_logo.png 0000664 0000000 0000000 00000114036 15152407737 0022773 0 ustar 00root root 0000000 0000000 PNG IHDR ":9 IDATx]Wu/"zd˖d7`[q( 8$@ $! ixy{ !0L T7\d[Vh[9{>wdC$c)?y<9e*[w-__=~_7/B?0}@_O $D/̌ }t1%JJ @QK `N%G@_O3QVLnMQO1~˭d/[nIł[Cbn 2"+H[ 'ZCFIo'Y[/چH2H,DE1Njxj>ݐA#Ƞ @hИ$#eJȉ$+X%, "to_~)X Mj,rID;]k,ND,0;Ua9zIgtP;̄Qgfo+fXN=Y'h-&&o EMiO<:5cL=i4rUh jm8F1`0[@Fh/W(B= %&fdK :3qI&|^6:yISťBI7NSl!n n0t-3Nb`@Id Say1~]̓*29c rG}sj8N䅞:~˙@_+VXYde! P=v xQT|g CEA`S$Z2c_,E9Q(X+PDc ց/qR' ӪNLCO>eVYRX U)6[RH@F&Ke庣