Skip to main content

MRtwo logo


Python License Coverage Bagde arXiv FAIR checklist badge

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.

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]"

Metadata

Release files for mrtwo 0.260510

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

Source distribution (sdist)

Source distribution for mrtwo 0.260510
File Size Uploaded
mrtwo-0.260510.tar.gz 289.6 kB Details

Built distribution (wheel)

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

Total release size: 677.1 kB

Release files / mrtwo-0.260510.tar.gz

Download URL mrtwo-0.260510.tar.gz
Size 289.6 kB
Tags Source
SHA-256 checksum
How to use checksums
797c6cccea8f0f448a9cd56f0d450811ae9faf8f3e7ac255b848288a5473d8d5
BLAKE2b-256 checksum
How to use checksums
b30745d642f3bac9aee8f55d5c5df272f1c1764e6868c9fe95be7a32772b5917
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 10, 2026.

Transparency log

Release files / mrtwo-0.260510-py3-none-any.whl

Download URL mrtwo-0.260510-py3-none-any.whl
Size 387.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0ff2ff73058f77ce855e1f5c64a4c1aed93da6e51968a79bfaadb931967f46a
BLAKE2b-256 checksum
How to use checksums
0ba437f648cceed8aa33dab6fee298bfa9e88ce205fba697ce224cabd9d37f8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.260510 This release

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