Skip to main content

MR data handling and image reconstruction.

Project description

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

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

mrtwo-0.260503.tar.gz (272.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mrtwo-0.260503-py3-none-any.whl (366.3 kB view details)

Uploaded Python 3

File details

Details for the file mrtwo-0.260503.tar.gz.

File metadata

  • Download URL: mrtwo-0.260503.tar.gz
  • Upload date:
  • Size: 272.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mrtwo-0.260503.tar.gz
Algorithm Hash digest
SHA256 82019f6ee753b947256bc17358f1a854827cd9ff3ffc595b728d875e45984550
MD5 3ec2b6d3007a5cac2797b9c21bc22569
BLAKE2b-256 c168f84e1ce5ed82a999631957594f52a084c7a2402b0c154c742e037acceb26

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrtwo-0.260503.tar.gz:

Publisher: deployment.yml on fzimmermann89/mr2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mrtwo-0.260503-py3-none-any.whl.

File metadata

  • Download URL: mrtwo-0.260503-py3-none-any.whl
  • Upload date:
  • Size: 366.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mrtwo-0.260503-py3-none-any.whl
Algorithm Hash digest
SHA256 b723408e550c6170d583ef3aa1e6c72edabd1310644a22febec5d0ce95f63180
MD5 96a4a0665309f3ad20d1df3a65f47dfc
BLAKE2b-256 b8d19f1833843ef651b5d36efe2de3c63947c4f6c1778be157b31df7426c5d2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrtwo-0.260503-py3-none-any.whl:

Publisher: deployment.yml on fzimmermann89/mr2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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