Skip to main content

MR image reconstruction and processing package specifically developed for PyTorch.

Project description

MRpro logo


Python License Coverage Bagde DOI arXiv FAIR checklist badge

MR image reconstruction and processing package specifically developed for PyTorch.

Awards

  • 2024 ISMRM QMRI Study Group Challenge, 2nd prize for Relaxometry (T2* and T1)

Main features

  • ISMRMRD support MRpro supports ismrmrd-format for MR raw data.
  • PyTorch All data containers utilize PyTorch tensors to ensure easy integration in PyTorch-based network schemes.
  • Cartesian and non-Cartesian trajectories MRpro can reconstruct data obtained with Cartesian and non-Cartesian (e.g. radial, spiral...) sapling schemes. MRpro automatically detects if FFT or nuFFT is required to reconstruct the k-space data.
  • Pulseq support If the data acquisition was carried out using a pulseq-based sequence, the seq-file can be provided to MRpro and the used trajectory is automatically calculated.
  • Signal models A range of different MR signal models are implemented (e.g. T1 recovery, WASABI).
  • Regularized image reconstruction Regularized image reconstruction algorithms including Wavelet-based compressed sensing or total variation regularized image reconstruction are available.

Examples

In the following, we show some code snippets to highlight the use of MRpro. Each code snippet only shows the main steps. A complete working notebook can be found in the provided link.

Simple reconstruction

Read the data and trajectory and reconstruct an image by applying a density compensation function and then the adjoint of the Fourier operator and the adjoint of the coil sensitivity operator.

# Read the trajectory from the ISMRMRD file
trajectory = mrpro.data.traj_calculators.KTrajectoryIsmrmrd()
# Load in the Data from the ISMRMRD file
kdata = mrpro.data.KData.from_file(data_file.name, trajectory)
# Perform the reconstruction
reconstruction = mrpro.algorithms.reconstruction.DirectReconstruction(kdata)
img = reconstruction(kdata)

Full example: https://github.com/PTB-MR/mrpro/blob/main/examples/scripts/direct_reconstruction.py

Estimate quantitative parameters

Quantitative parameter maps can be obtained by creating a functional to be minimized and calling a non-linear solver such as ADAM.

# Define signal model
model = MagnitudeOp() @ InversionRecovery(ti=idata_multi_ti.header.ti)
# Define loss function and combine with signal model
mse = MSE(idata_multi_ti.data.abs())
functional = mse @ model
[...]
# Run optimization
params_result = adam(functional, [m0_start, t1_start], n_iterations=n_iterations, learning_rate=learning_rate)

Full example: https://github.com/PTB-MR/mrpro/blob/main/examples/scripts/qmri_sg_challenge_2024_t1.py

Pulseq support

The trajectory can be calculated directly from a provided pulseq-file.

# Read raw data and calculate trajectory using KTrajectoryPulseq
kdata = KData.from_file(data_file.name, KTrajectoryPulseq(seq_path=seq_file.name))

Full example: https://github.com/PTB-MR/mrpro/blob/main/examples/scripts/comparison_trajectory_calculators.py

Contributing

We are looking forward to your contributions via "fork and pull requests". If you would like to fix a bug or add a new feature:

  1. Create your own copy of MRpro (i.e. create a fork via GitHub)
  2. Clone your forked copy of the MRpro repository
  3. Create/select a python environment (e.g. conda create -n mrpro python=3.12)
  4. Install MRpro in editable mode with developer dependencies: pip install -e ".[dev]"
  5. Setup pre-commit hook: pre-commit install
  6. Create a new branch
  7. Implement your changes to MRpro
  8. Commit and push them to GitHub
  9. Open a pull request via GitHub

You can find more information on "fork and pull requests" on the GitHub documentation

Please also look at our contributor guide for more information on the repository structure, naming conventions, and other useful information.

[!NOTE]
There are a few things which cannot be modified as "fork and pull requests" such as modifications of the docker images. If you think something needs to be changed there, please open up an issue first.

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

mrpro-0.260420.tar.gz (227.0 kB view details)

Uploaded Source

Built Distribution

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

mrpro-0.260420-py3-none-any.whl (294.7 kB view details)

Uploaded Python 3

File details

Details for the file mrpro-0.260420.tar.gz.

File metadata

  • Download URL: mrpro-0.260420.tar.gz
  • Upload date:
  • Size: 227.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mrpro-0.260420.tar.gz
Algorithm Hash digest
SHA256 75630ba0c3271b5b53e262cce87895c57d43362178ecab1e1ea1a17a2b82efe1
MD5 9d4bf235d3e08a9d38a239e3e471cbe5
BLAKE2b-256 780d58ff559e5e119782f2a618f7a8fa010104eeae8841b1b1cf7ce1d71d08f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrpro-0.260420.tar.gz:

Publisher: deployment.yml on PTB-MR/mrpro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mrpro-0.260420-py3-none-any.whl.

File metadata

  • Download URL: mrpro-0.260420-py3-none-any.whl
  • Upload date:
  • Size: 294.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mrpro-0.260420-py3-none-any.whl
Algorithm Hash digest
SHA256 bc50d29afe51a33001827ece76a77cd639c4ea2d88f190ae18847097ec62358b
MD5 c18d9f18aee410f0645bcd1f271eadaf
BLAKE2b-256 32136b6054d7bd505510e850ae14213e7bd885dc1f39b16a4bb260261103e77c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrpro-0.260420-py3-none-any.whl:

Publisher: deployment.yml on PTB-MR/mrpro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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