Skip to main content

odx — Python bindings for the ODX format

Python bindings for odx-rs, a TRX-style mmap-friendly container for orientation density functions (ODFs), peaks, and spherical-harmonic coefficients from diffusion MRI.

Install

pip install odx           # core package (numpy + nibabel)
pip install odx[dipy]     # with the dipy adapter for PeaksAndMetrics interop

Quickstart

Compute CSD in dipy, dump to a peaked ODX in one call:

import odx
from dipy.reconst.csdeconv import ConstrainedSphericalDeconvModel
from dipy.direction.peaks import peaks_from_model

# ... fit a model, get csd_fit.shm_coeff (X, Y, Z, K)

peaked = odx.from_sh_coefficients(
    csd_fit.shm_coeff, mask=mask, affine=affine,
    basis="descoteaux07", sh_order=8, legacy=True,
)
peaked.save("csd.odx")              # native, mmap-friendly
peaked.save_fz("autotrack.fz")      # → DSI Studio fz
peaked.save_mrtrix("mrtrix_out/")   # → MRtrix mif (auto-converts basis)

# Round-trip back to dipy if you want
pam = odx.to_peaks_and_metrics(peaked)

Features

  • Native ODX I/O — read/write .odx archives or directories, mmap-backed for zero-copy NumPy views. odx.load(path, skip_odf=True, skip_sh=True) (and skip_odf= on from_fibgz / from_fz) never reads dense arrays you don't need.

  • Peak finder — sphere-mesh local-maxima detection with MRtrix-style Gauss-Newton sub-vertex refinement on the SH series itself.

  • Foreign format converters — load and save DSI Studio (.fz, .fib.gz), MRtrix (fixel directories + .mif), Tortoise MAP-MRI, pyAFQ asymmetric ODFs.

  • nibabel adapter — DPVs to/from Nifti1Image; nibabel is a required dependency so NIfTI orientation and affines are always handled the same way.

  • dipy adapter (optional) — bidirectional conversion between odx.Odx and dipy's PeaksAndMetrics. Lazy-imported so dipy isn't required for the core package.

  • Coherence QC — ds.coherence() gives current DSI Studio's fib-QC coherence index (or "fixel" mode's per-fixel summaries); check_btable=True scores all 24 gradient-table permutations/flips without refitting.

  • SH basis conversion — descoteaux07 ↔ tournier07 round-trips via amplitudes, including legacy/modern variants.

  • Gradient-nonlinearity correction — odx.apply_graddev (or Odx.apply_graddev) reorients SH/FODs, dense ODFs and fixels with a per-voxel deviation field, as the odx graddev CLI does:

    img = nib.load("sub-01_space-ACPC_graddev.nii.gz")
    corrected, report = ds.apply_graddev(img)          # brings its own affine
    # also accepted: a path, or an (X,Y,Z,9) array with affine=
    

    Never reorient the field first (e.g. nib.as_closest_canonical): its components live in its own voxel axes.

    The field holds row-major T per voxel with g_eff = Tᵀ g (qsiprep / TORTOISE, identity="included"; HCP/FSL grad_dev stores T − I, identity="absent"; "auto" decides). This is a post-hoc correction of fitted data: it fixes orientation, not the per-voxel b-value change. On a Prisma-class whole-body coil the orientation effect is a fraction of a degree.

License

The bulk of odx-rs (and the Python bindings) is dual-licensed under the MIT and Apache 2.0 licenses, the typical Rust ecosystem dual-license. Pick whichever you prefer.

Two source files in the underlying Rust crate (src/peak_finder.rs and src/mrtrix_sh.rs) port code from MRtrix3 and remain governed by the Mozilla Public License v. 2.0. That's a file-scoped (weak) copyleft — modifications to those specific files must remain MPL and source-available, but the license has no effect on projects that simply use odx as a dependency.

SPDX summary: (MIT OR Apache-2.0) AND MPL-2.0.

Metadata

Release files for odx 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for odx 0.2.0
File Size Uploaded
odx-0.2.0.tar.gz 431.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for odx 0.2.0
File
odx-0.2.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
odx-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
odx-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details
odx-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
odx-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details
odx-0.2.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
odx-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 22.1 MB

Release files / odx-0.2.0.tar.gz

Download URL odx-0.2.0.tar.gz
Size 431.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5a8ccff8fbd24be922648a5a8af8b014b411710ce4926162e1798951d77e27a7
BLAKE2b-256 checksum
How to use checksums
78a501eeb8026406bfaaac6a9ce3e87a53adab1544887c10f58961cc8f130077
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / odx-0.2.0-cp39-abi3-win_amd64.whl

Download URL odx-0.2.0-cp39-abi3-win_amd64.whl
Size 4.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
44708aca03e3f61ccabdd19cf235009a20d912105eab40fa19edc55e5095b896
BLAKE2b-256 checksum
How to use checksums
f5787131d56c29e5588b4b2953a162152c4c3ed33075af1c64fa34e68b8f79f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / odx-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL odx-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 3.3 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
09e306f55dd25023d72b91d5ee957159f042b177c6a1e44e2ca507fcc20e676b
BLAKE2b-256 checksum
How to use checksums
7126fbca99f21d0fd18e13c00761e6c36dc9c598bcc5b18880049ca7f2a30da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / odx-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL odx-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 3.1 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
15233ffd6d1d138588306486e5664fabd558ba26f93d777ef28cf7756f8a12cc
BLAKE2b-256 checksum
How to use checksums
3a70e8751f2c734cb44e481820cfab89b37dc104afe15feffa6ad3965073e4f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / odx-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL odx-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 3.1 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
9ff5c3f94ffc3f99576448003b7eea1558656e5058211dffe5be6bb3cc0250f0
BLAKE2b-256 checksum
How to use checksums
4c019fb76e2cd11dbaba9778e3478c72152a9c79ec74f0d0e285603dfa1f1964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / odx-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL odx-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 2.8 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
0ddc89ee0a389fab2174bc95c82e0669026e553a135b29b74d884e926f0247c7
BLAKE2b-256 checksum
How to use checksums
fbf59b797645e090f46d84eb133470b4e5cf7dc7f039d5f2ef666a01a40d1251
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / odx-0.2.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL odx-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
34e74b633d29e015b546ba604ad974b6ac1682f87e19591d073b7271e889e6c0
BLAKE2b-256 checksum
How to use checksums
7b039a0bb5c093f0bdae4f6f325169a91d72c907b7c18b0dfce711da7826b639
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / odx-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL odx-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 2.6 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
93b97de1c76c1ed25d4111803ad1923aaed1ebb1b11df5f86f2d8346af4bee55
BLAKE2b-256 checksum
How to use checksums
ce07d13e70c4b7367054edaf8b6ad937adbe4605200f7aa8ad16f6728d411af1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

8 release files

This release

0.2.0 This release

8 release files

0.1.3

8 release files

0.1.1

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page