Skip to main content

AI-powered T1w to T2 TSE MRI translation using flow matching

Project description

MRecover

AI-powered T1w to T2 TSE MRI translation using autoregressive flow matching.

MRecover synthesizes T2-weighted turbo spin echo (TSE) images from T1-weighted (MPRAGE) brain MRI, enabling recovery of T2 TSE contrast without re-scanning.

Installation from github

git clone https://github.com/jinghangli98/MRecover.git
cd MRecover
pip install -e .

Installation from PyPI

pip install mrecover

Model

The models are hosted at https://huggingface.co/jil202/MRcover. You will need to agree to share your contact information to access the models. The model will be automatically downloaded from HuggingFace on first use. You will need to authenticate:

huggingface-cli login

Quick Start

CLI

# Force anisotropic TSE-like spacing (0.375 × 1.5 × 0.375 mm)
mrecover -i T1.nii.gz -o T2tse.nii.gz --tse-through-plane 1.5

# Input already registered to TSE space (skip resampling)
mrecover -i T1_registered.nii.gz -o T2tse.nii.gz --tse-registered

# Higher quality with more ODE steps
mrecover -i T1.nii.gz -o T2tse.nii.gz --steps 10

Python API

import mrecover

# Simple translation
mrecover.translate("T1.nii.gz", "T2tse.nii.gz")

# With options
mrecover.translate(
    "T1.nii.gz",
    "T2tse.nii.gz",
    steps=10,
    tse_through_plane=1.5,   # resample through-plane to 1.5 mm
    tse_inplane=0.375,        # target in-plane resolution
)

# Returns the generated volume as a numpy array
volume = mrecover.translate("T1.nii.gz", "T2tse.nii.gz")
print(volume.shape)  # (X, Y, Z)

CLI Reference

Argument Default Description
-i, --input required Input T1w NIfTI or DICOM directory
-o, --output required Output file path
--steps 1 ODE integration steps (more = higher quality, slower)
--device cuda Device: cuda or cpu
--rk4 off Use RK4 instead of Euler ODE solver
--no-fp16 off Disable half precision
--no-auto off Disable autoregressive slice context
--tse-inplane 0.375 In-plane resampling target (mm)
--tse-through-plane None Through-plane resampling target (mm)
--tse-registered off Skip resampling (input already in TSE space)
--model None Path to custom model checkpoint
--seed 42 Random seed

Input / Output

Input: T1w MPRAGE NIfTI (.nii / .nii.gz) at any isotropic resolution (e.g. 0.55–1 mm), or a DICOM series directory.

Output: Synthetic T2 TSE NIfTI or DICOM. By default the output is resampled to 0.375 mm in-plane with the through-plane spacing preserved from the input.

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

mrecover-0.1.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

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

mrecover-0.1.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file mrecover-0.1.0.tar.gz.

File metadata

  • Download URL: mrecover-0.1.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for mrecover-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c4be3c39444293f86d888183bbcfc97f6e6cde1ca5fb8b3b326e4443b0ae929
MD5 b6e7afdddbc2e164a4b5cfb76119de9d
BLAKE2b-256 60c97d9055e736f0b1c3932989890d78b5661d9b0558452ba37d23054e73527b

See more details on using hashes here.

File details

Details for the file mrecover-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mrecover-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for mrecover-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 475bb382f5b33919be4593fb7a4a9d150af95b54cfd9309b45a9e149a6b02503
MD5 6d666016843639ca73bc64b0dfee7d88
BLAKE2b-256 ca88be9b9d663a681fb837fe5c61f304a122307bb566c92227c5f905b3dbe18b

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