MR image reconstruction and processing package specifically developed for PyTorch.
Project description
MRpro
MR image reconstruction and processing package specifically developed for PyTorch.
- Source code: https://github.com/PTB-MR/mrpro
- Documentation: https://ptb-mr.github.io/mrpro/
- Bug reports: https://github.com/PTB-MR/mrpro/issues
- Try it out:
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
- Clone the MRpro repository
- Create/select a python environment
- Install "MRpro" in editable mode including test dependencies:
pip install -e ".[test]"
- 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
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
File details
Details for the file mrpro-0.241112.tar.gz
.
File metadata
- Download URL: mrpro-0.241112.tar.gz
- Upload date:
- Size: 127.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 153f66f60d18a71e41ae4f67c0f7f3d67a4192db8da345f0c56fedd082c77e23 |
|
MD5 | be1d27a3fe7b87a684428c93cf78155b |
|
BLAKE2b-256 | b071866306366b50a91211471b12db626035f76474786813ac6ad2ddee2e91e3 |
Provenance
The following attestation bundles were made for mrpro-0.241112.tar.gz
:
Publisher:
deployment.yml
on PTB-MR/mrpro
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
mrpro-0.241112.tar.gz
- Subject digest:
153f66f60d18a71e41ae4f67c0f7f3d67a4192db8da345f0c56fedd082c77e23
- Sigstore transparency entry: 148340505
- Sigstore integration time:
- Predicate type:
File details
Details for the file mrpro-0.241112-py3-none-any.whl
.
File metadata
- Download URL: mrpro-0.241112-py3-none-any.whl
- Upload date:
- Size: 170.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 917a98b5cf9fb7fa9711c0b7ead7ff437f1931157046dbd2a90615f778e0b559 |
|
MD5 | c3e68a78c92cb4c0cd105862a6350b88 |
|
BLAKE2b-256 | 59432cc33e413c81061099dfdcbee799bbcdbfb167b127ad2f85027aa6757e96 |
Provenance
The following attestation bundles were made for mrpro-0.241112-py3-none-any.whl
:
Publisher:
deployment.yml
on PTB-MR/mrpro
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
mrpro-0.241112-py3-none-any.whl
- Subject digest:
917a98b5cf9fb7fa9711c0b7ead7ff437f1931157046dbd2a90615f778e0b559
- Sigstore transparency entry: 148340507
- Sigstore integration time:
- Predicate type: