PyGIRF — gradient impulse response function tools for MRI systems
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygirf-0.2.1.tar.gz.
File metadata
- Download URL: pygirf-0.2.1.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
629efe209e065afe7187ff573a4dfabd1f196f514485d3c4dbc6776a7e5b13af
|
|
| MD5 |
60d364020fbc1de339110a46ff938578
|
|
| BLAKE2b-256 |
f83f91545b841fda5892c14254333345546b9606da8c2894736e31787fe9f8d0
|
Provenance
The following attestation bundles were made for pygirf-0.2.1.tar.gz:
Publisher:
publish-pypi.yml on LeoMcBills/PyGIRF
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygirf-0.2.1.tar.gz -
Subject digest:
629efe209e065afe7187ff573a4dfabd1f196f514485d3c4dbc6776a7e5b13af - Sigstore transparency entry: 1221702480
- Sigstore integration time:
-
Permalink:
LeoMcBills/PyGIRF@5363d5a23c82fa46e74caeb58054d4943d0e9076 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/LeoMcBills
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5363d5a23c82fa46e74caeb58054d4943d0e9076 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pygirf-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pygirf-0.2.1-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
378c6d2a2a5337592c4c12d0d8db53bdeb34301c1857b56d70db842cfa137fb2
|
|
| MD5 |
5e33ee2f3d7a0caaa2599fb6f36c37c0
|
|
| BLAKE2b-256 |
9f211c58d4ec6729567ff19e4023fe8503d556f4b037c5e5f13a40f52f425b8e
|
Provenance
The following attestation bundles were made for pygirf-0.2.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on LeoMcBills/PyGIRF
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygirf-0.2.1-py3-none-any.whl -
Subject digest:
378c6d2a2a5337592c4c12d0d8db53bdeb34301c1857b56d70db842cfa137fb2 - Sigstore transparency entry: 1221702515
- Sigstore integration time:
-
Permalink:
LeoMcBills/PyGIRF@5363d5a23c82fa46e74caeb58054d4943d0e9076 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/LeoMcBills
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5363d5a23c82fa46e74caeb58054d4943d0e9076 -
Trigger Event:
push
-
Statement type: