PyGIRF
Gradient impulse response function (GIRF) tools in Python for MRI gradient systems. This code was ported from MATLAB which was initially written by jvannjo. The original MATLAB project is MRI-gradient/GIRF.
Installation
python3 -m pip install -e .
Installs the pygirf package from src/pygirf/.
After publishing to PyPI, install with:
pip install pygirf
Publish to PyPI (production)
Option A — GitHub Actions (recommended)
The workflow .github/workflows/publish-pypi.yml builds and uploads to PyPI using trusted publishing (OIDC). You do not store a long-lived PyPI token in GitHub secrets.
One-time setup
- On PyPI, open your project → Publishing → Add a new pending publisher (or manage existing).
- Choose GitHub as the publisher type and enter:
- Owner: your GitHub user or organization
- Repository name:
PyGIRF(or whatever the repo is called) - Workflow name:
publish-pypi.yml - Environment name: leave blank unless you add a matching GitHub Environment later.
- Save. PyPI will trust that workflow to upload
pygirf.
Each release
-
Bump
versioninpyproject.toml(PyPI rejects duplicate versions). -
Commit, then create and push a tag whose name starts with
vand matches the release, e.g.:git tag v0.2.0 git push origin v0.2.0
-
Watch Actions → Publish to PyPI on GitHub. Confirm on https://pypi.org/project/pygirf/.
Option B — Manual upload (token)
Use an API token from https://pypi.org/manage/account/token/. Username for uploads is always __token__; the password is the token string.
pip install build twine
rm -rf dist && python -m build
twine check dist/*
TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-your-token-here twine upload dist/*
Quick start
Run the demo workflow:
uv run demo_pygirf.py
Or:
python3 demo_pygirf.py
That demo builds synthetic calibration data (band-limited “measured” outputs + noise), fits a GIRF, predicts the response to the same nominal gradients, and prints relative RMSE and correlation vs the synthetic ground truth (strong correlation on the dominant Z-like term shows the forward model matches the data you trained on).
Use in Python:
from pygirf import GirfProvider, GirfApplier
Documentation
- Concepts and algorithm — how the package models the gradient system, how
GirfProviderandGirfApplierwork, array shapes, and the end-to-end flow.
Zensical site (browse locally)
Install Zensical and from the repository root run:
pip install zensical
zensical serve
Open http://localhost:8000 for a live preview. Build static HTML with zensical build (output in site/).
GitHub Pages (hosted documentation)
The workflow .github/workflows/deploy-docs.yml builds the Zensical site and deploys it with the official GitHub Pages Actions.
One-time setup
- On GitHub, open the repository → Settings → Pages.
- Under Build and deployment, set Source to GitHub Actions (not “Deploy from a branch”).
- Push to
mainormaster(or run the workflow manually under Actions → Deploy documentation → Run workflow).
After a successful run, the site is available at:
https://<your-github-username>.github.io/<repository-name>/
For example, if the repo is github.com/octocat/PyGIRF, the docs URL is https://octocat.github.io/PyGIRF/.
The workflow sets site_url automatically for that URL so links, search, and sitemap stay correct. For local zensical serve, keep site_url in zensical.toml pointed at http://127.0.0.1:8000 (or your dev URL).
If you use this code package for your research, please cite at least one of the following papers (depending on the use case):
Gradient system characterization
Vannesjo, S.J., Haeberlin, M., Kasper, L., Pavan, M., Wilm, B.J., Barmet, C., Pruessmann, K.P., 2013. Gradient system characterization by impulse response measurements with a dynamic field camera. Magn Reson Med 69, 583–593. https://doi.org/10.1002/mrm.24263
Image reconstruction based on the GIRF characterization
Vannesjo, S.J., Graedel, N.N., Kasper, L., Gross, S., Busch, J., Haeberlin, M., Barmet, C., Pruessmann, K.P., 2016. Image reconstruction using a gradient impulse response model for trajectory prediction. Magn Reson Med 76, 45–58. https://doi.org/10.1002/mrm.25841
GIRF-based spiral fMRI
Graedel, N.N., Kasper, L., Engel, M., Nussbaum, J., Wilm, B.J., Pruessmann, K.P., Vannesjo, S.J., 2019. Feasibility of spiral fMRI based on an LTI gradient model. bioRxiv 805580. https://doi.org/10.1101/805580
GIRF-based pre-emphasis of gradient or shim channels
Vannesjo, S.J., Duerst, Y., Vionnet, L., Dietrich, B.E., Pavan, M., Gross, S., Barmet, C., Pruessmann, K.P., 2017. Gradient and shim pre-emphasis by inversion of a linear time-invariant system model. Magn Reson Med 78, 1607–1622. https://doi.org/10.1002/mrm.26531
Metadata
Release files for pygirf 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pygirf-0.2.1.tar.gz | 16.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygirf-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.9 kB
Release files / pygirf-0.2.1.tar.gz
| Download URL | pygirf-0.2.1.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
629efe209e065afe7187ff573a4dfabd1f196f514485d3c4dbc6776a7e5b13af
|
|
BLAKE2b-256 checksum How to use checksums |
f83f91545b841fda5892c14254333345546b9606da8c2894736e31787fe9f8d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Apr 3, 2026.
Transparency logRelease files / pygirf-0.2.1-py3-none-any.whl
| Download URL | pygirf-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
378c6d2a2a5337592c4c12d0d8db53bdeb34301c1857b56d70db842cfa137fb2
|
|
BLAKE2b-256 checksum How to use checksums |
9f211c58d4ec6729567ff19e4023fe8503d556f4b037c5e5f13a40f52f425b8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Apr 3, 2026.
Transparency logSecurity for pygirf 0.2.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pygirf-0.2.1.tar.gz
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 Apr 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.