Skip to main content

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)

Use an API token from https://pypi.org/manage/account/token/ (not TestPyPI). 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/*

Confirm on https://pypi.org/project/pygirf/. Bump version in pyproject.toml before each new release; you cannot reuse the same version.

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 GirfProvider and GirfApplier work, 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

  1. On GitHub, open the repository → SettingsPages.
  2. Under Build and deployment, set Source to GitHub Actions (not “Deploy from a branch”).
  3. Push to main or master (or run the workflow manually under ActionsDeploy documentationRun 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygirf-0.1.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygirf-0.1.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file pygirf-0.1.0.tar.gz.

File metadata

  • Download URL: pygirf-0.1.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pygirf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe2848430c36cec5206a86cb17165a59e92823ccc696f04f89407ac8000f1ee8
MD5 d7b84e8a9f97df610b935a8c459ea874
BLAKE2b-256 31bd93b47e0ef4261810becbebe11ac8f1b73c518c3dc549ce31b34fe9f991f8

See more details on using hashes here.

File details

Details for the file pygirf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pygirf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pygirf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 925dd5f5109c9b835ff5ebb7a92cfc73dd88ec7f47cf1a1ac5ed65f5bea8c1d1
MD5 32ab62274d0f43048e4845e4a02a7407
BLAKE2b-256 8f16d61b27758bb0e0b89f1380000dbbcb86dbdcd6fd5d765f476dc4208e9bec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page