Skip to main content

MR image reconstruction and processing package specifically developed for PyTorch.

Project description

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

We are looking forward to your contributions via Pull-Requests.

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

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

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.241029.tar.gz (123.6 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.241029-py3-none-any.whl (164.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mrpro-0.241029.tar.gz
  • Upload date:
  • Size: 123.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mrpro-0.241029.tar.gz
Algorithm Hash digest
SHA256 bb6f22a20e4000cdacdd469af3d7ef5a1803c6af3bad2e7dda4f072074a4c3c6
MD5 2795b97b25e48c645eb66b0a6445d7e2
BLAKE2b-256 fd49a9e5f3b92563a6a789fcb20adbcd1a504109acb3d9ffbe732fdc3113f861

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mrpro-0.241029-py3-none-any.whl
  • Upload date:
  • Size: 164.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mrpro-0.241029-py3-none-any.whl
Algorithm Hash digest
SHA256 df70a5edd6292ca2d53424f774191ff7ba99f5ba796b88fc997ac0d682453723
MD5 d18c57df78ca035ffe0db8f35fa2ff47
BLAKE2b-256 cc90270a6f97dba0a03ec3f24964417b9ec19011534fe45a39c40d827d2307fb

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