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
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Metadata
Release files for unpile 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| unpile-0.2.0-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details |
| unpile-0.2.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.2.0-py3-none-manylinux_2_28_x86_64.whl
| Download URL | unpile-0.2.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 |
888309fe2f3a62ab496f8a6657aed82c60146fe957f25d5bf271791d56ef91a2
|
|
BLAKE2b-256 checksum How to use checksums |
0fd3a59db140c7169d5d1307c129537625f4eb3f4dabb4cfe03cbba5670ac74f
|
| 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 14, 2026.
Transparency logRelease files / unpile-0.2.0-py3-none-macosx_11_0_arm64.whl
| Download URL | unpile-0.2.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 |
660aaf1372218a4e93f6070452ca6d3cf6315058e4bac90c0e6ae84f63ca959c
|
|
BLAKE2b-256 checksum How to use checksums |
7b6589f58889b29cdcfb2ccf190e1149859a5ec78bc692eb0387d5d32b50e926
|
| 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 14, 2026.
Transparency log