MR data processing and image reconstruction.
This project is a faster moving continuation/fork of MRpro. Some of the additional features of MRtwo will eventually get backported to MRpro, all new features of MRpro will be included in MRtwo.
In most cases, you can replace mrpro by mr2 in you code and everything works.
- Source code: https://github.com/fzimmermann89/mr2
- Documentation: https://fzimmermann89.github.io/mr2/
- Bug reports: https://github.com/fzimmermann89/mr2/issues
- Try it out:
Main features
- Data handling Custom dataclasses for fast data subsetting, sorting, rearranging
- Neural Network Block Common blocks and networks used for ML based MRI reconstruction
- ISMRMRD support MRtwo 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 MRtwo can reconstruct data obtained with Cartesian and non-Cartesian (e.g. radial, spiral...) sapling schemes. MRtwo 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 MRtwo 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 MRtwo. 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 = mr2.data.traj_calculators.KTrajectoryIsmrmrd()
# Load in the Data from the ISMRMRD file
kdata = mr2.data.KData.from_file(data_file.name, trajectory)
# Perform the reconstruction
reconstruction = mr2.algorithms.reconstruction.DirectReconstruction(kdata)
img = reconstruction(kdata)
Full example: https://github.com/fzimmermann89/mr2/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/fzimmermann89/mr2/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/fzimmermann89/mr2/blob/main/examples/scripts/comparison_trajectory_calculators.py
Development
pip install -e ".[dev]"
MRtwo requires PyTorch 2.3.1 or newer. CI currently validates the minimum supported CPU build, PyTorch 2.3.1, and the recommended CPU build, PyTorch 2.13.0.
Docker
A notebook-capable image for the recommended environment (Python 3.13 and PyTorch 2.13) is available from GHCR:
docker pull ghcr.io/fzimmermann89/mr2_py313:latest
Citation
MRtwo is a continuation of MRpro. If you use MRtwo, please cite the MRpro framework paper:
F. F. Zimmermann, P. Schuenke, C. S. Aigner, B. A. Bernhardt, M. Guastini, J. Hammacher, H. Herthum, N. Jaitner, A. Kofler, L. Lunin, S. Martin, C. Redshaw Kranich, J. Schattenfroh, D. Schote, Y. Wu, and C. Kolbitsch (2026). MRpro: Open Framework for Model-Based, Learned, and Quantitative MR Imaging—Application to Low-Field MRI. NMR in Biomedicine, 39(11), e70405. Zimmermann and Schuenke contributed equally. doi:10.1002/nbm.70405
Metadata
Release files for mrtwo 0.261029
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mrtwo-0.261029.tar.gz | 375.3 kB | With provenance | Details for mrtwo-0.261029.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mrtwo-0.261029-py3-none-any.whl | Python 3 | none | any | Details for mrtwo-0.261029-py3-none-any.whl |
Total release size: 865.5 kB
Release files / mrtwo-0.261029.tar.gz
| Download URL | mrtwo-0.261029.tar.gz |
|---|---|
| Size | 375.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
618c3af97495aa2cb68c3b617503f059f00f9c5f69758f1123d6c1972139a8ba
|
|
BLAKE2b-256 checksum How to use checksums |
93ca3d8926776678654b94efe5ecf651c085e66d99c7a99a50a48da88be411e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / mrtwo-0.261029-py3-none-any.whl
| Download URL | mrtwo-0.261029-py3-none-any.whl |
|---|---|
| Size | 490.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3a8591ca99f5f78f4283dccb63a2103687939cf8832a265a2667b2c34ee4741
|
|
BLAKE2b-256 checksum How to use checksums |
ba77f676d7cb5125a54e8f45bfba7f5e361b89efc32102414c1911329bb5c46d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logSecurity for mrtwo 0.261029
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mrtwo-0.261029.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.