Skip to main content

unpile

Susceptibility distortion correction for EPI: diffusion b=0 volumes, single-band reference images, BOLD means. One Rust binary that writes ITK transforms, so qsiprep and ANTs can apply the result.

Documentation: https://unpile.readthedocs.io

unpile does two jobs:

  • Fieldmap refinement. A gradient-echo fieldmap from the same session is kept as a prior, and its position, a low-order shim term and a smooth residual are fitted against the EPI. A fieldmap acquired after the subject moved, or with a slightly different shim, is not applied as is.
  • Fieldmap-less correction. Without a fieldmap, the field is estimated from the EPI and an undistorted reference: a SynB0 image, or the subject's T2w with a rigid position fitted at the same time.

Pairs of opposite phase-encoding direction are supported too.

Install

pip install unpile

or build from source (rust-toolchain.toml pins the toolchain):

cargo build --release --features wgpu

Example

The sidecar values are passed as they are: PhaseEncodingDirection and TotalReadoutTime.

unpile fit --epi b0.nii.gz --reference t2w.nii.gz --mask brain.nii.gz \
    --pe-dir j- --total-readout-time 0.0557 --metric lncc --pose --lam-mm 60 --out out
antsApplyTransforms -d 3 -i b0.nii.gz -r b0.nii.gz -t out/sdc_warp.nii.gz -o b0_unwarped.nii.gz

The same from Python: unpile.fit(epi, mask, out, sidecar=..., reference=..., metric="lncc", pose=True); unpile.prepare puts the inputs on the EPI grid first.

With a fieldmap in Hz on the EPI grid, add --fieldmap gre_hz.nii.gz. With a second image of the opposite direction, use --reverse-epi instead of a reference. --device wgpu runs on a GPU; --threads N sizes the CPU thread pool.

Outputs: the field in Hz, the displacement in mm, the corrected image, the ITK warp (sdc_warp.nii.gz) and the fitted positions as ITK affines.

Development

cargo test --release --features wgpu                                  # unit tests
./target/release/unpile check --dir testdata/rpe                      # operators vs the PyTorch dumps
python scripts/make_fixtures.py phasediff rpe                         # simulated test data (TRXScan)
UNPILE_FIXTURES=$PWD/testdata/fixtures cargo test --release --features wgpu --test fixtures
scripts/fetch_testdata.sh                                             # OpenNeuro test data bundle

See docs/development.md for the rest.

License

Dual-licensed under either of

at your option.

Metadata

Release files for unpile 0.1.0

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

Built distributions (wheels)

Table of built distributions (wheels) for unpile 0.1.0
File Interpreter ABI Platform
unpile-0.1.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
unpile-0.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 47.6 MB

Release files / unpile-0.1.0-py3-none-manylinux_2_28_x86_64.whl

Download URL unpile-0.1.0-py3-none-manylinux_2_28_x86_64.whl
Size 25.4 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
ba32706e2c961592ac7a405d171d9613870b18859bced32ce752bae9f2783503
BLAKE2b-256 checksum
How to use checksums
8131c2483e93b5218f018db4e005b7228ce556fec8846868ab6220bc84cc252e
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 12, 2026.

Transparency log

Release files / unpile-0.1.0-py3-none-macosx_11_0_arm64.whl

Download URL unpile-0.1.0-py3-none-macosx_11_0_arm64.whl
Size 22.2 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c1a0005405f63fa8b2d291a408e1aaf63f4325d91c7e46e2011a6dc7bc769f67
BLAKE2b-256 checksum
How to use checksums
2a917f2e2ee1c602bd4644db4746637663b316b1257d1b6e6bbf32fc9f31fbdb
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 12, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 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