Skip to main content

MRpro

Python License Coverage Bagde

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.from_kdata(kdata)
img = reconstruction(kdata)

Full example: https://github.com/PTB-MR/mrpro/blob/main/examples/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 = MSEDataDiscrepancy(idata_multi_ti.data.abs())
functional = mse @ model
[...]
# Run optimization
params_result = adam(functional, [m0_start, t1_start], max_iter=max_iter, lr=lr)

Full example: https://github.com/PTB-MR/mrpro/blob/main/examples/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/pulseq_2d_radial_golden_angle.py

Contributing

Installation for developers

  1. Clone the MRpro repository
  2. Create/select a python environment
  3. Install "MRpro" in editable mode including test dependencies: pip install -e ".[test]"
  4. Setup pre-commit hook: pre-commit install

Recommended IDE and Extensions

We recommend to use Microsoft Visual Studio Code. A list of recommended extensions for VSCode is given in the .vscode/extensions.json

Style

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

Metadata

Release files for mrpro 0.241011

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mrpro 0.241011
File Size Uploaded
mrpro-0.241011.tar.gz 110.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mrpro 0.241011
File Interpreter ABI Platform
mrpro-0.241011-py3-none-any.whl Python 3 none any Details

Total release size: 254.9 kB

Release files / mrpro-0.241011.tar.gz

Download URL mrpro-0.241011.tar.gz
Size 110.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a09d89eb1494a0230c24b0e95feb6cb8f0513bd97aaaa15e5fe4a1b48c66b2c6
BLAKE2b-256 checksum
How to use checksums
024775fce790ce4d518f8b568e4dfb133f936341eaa48a2f99c2c9b6d3718f0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / mrpro-0.241011-py3-none-any.whl

Download URL mrpro-0.241011-py3-none-any.whl
Size 144.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80a1692827f882b6fa1a2b4f6ab27e686870d1d23d02f2c6ed1468ffef90823a
BLAKE2b-256 checksum
How to use checksums
752db8dc74e42fc6e0d6b679ea3445c116d372f3350b639efd260061e1f7f0d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.241011 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page