Skip to main content

Toolbox to generate quantitative maps from MRI images

Project description

erwin — a qMRI toolbox

erwin is a Python-based toolbox dedicated to the computation of quantitative maps from MRI data. Accessible through either its Python API or its command-line interface, erwin provides a unified interface to well-known methods and toolboxes.

  • Field mapping: relative B0 and relative B1
  • Cerebral blood flow: ASL-based models (pulsed ASL, pseudo-continuous ASL)
  • Diffusion: DTI and spherical harmonics, NODDI
  • Motion correction
  • Magnetization transfer: MTR and single-point qMT
  • Magnetic susceptibility: QSM and R2*
  • T1 and T2 mapping: VFA, bSSFP, pSSFP

Since quantitative MRI requires accessing acquisition parameters, often stored in vendor-specific meta-data, erwin includes tools to access meta-data in a vendor-neutral way.

Using doit and Spire, erwin allows the definition of complex pipelines with automatic dependency handling.

Installation

erwin requires Python ≥ 3.5 The easiest way to install erwin and its dependencies is through PyPi and pip (the python3 executable may need to be adjusted to fit your local installation):

python3 -m pip install erwin

Using the following methods requires additional dependencies:

  • Diffusion tensor and spherical harmonics: MRtrix; conversion from Bruker or Siemens DICOM also requires Dicomifier
  • Motion correction: ANTs
  • NODDI: Amico
  • QSM: MEDI

Command-line usage

On the command-line, the main executable is called erwin; a list of all methods can be obtained by

erwin --list

The documentation of each individual method is accessed by appending --help to its name, e.g.

erwin b0_map.double_echo --help

Due to the large number of parameters -- input and output paths, flip angles, echo times, imaging frequencies, etc. -- each command line argument is named. Parameters corresponding to physical quantities are expressed in SI units in order to avoid discrepancies between standards: DICOM uses "usual" units, e.g. milliseconds for TR or degrees for flip angles, while BIDS uses seconds for TR, but keeps degrees for flip angles.

erwin b0_map --magnitude /path/to/magnitude.nii.gz --phase /path/to/phase.nii.gz --echo-times 0.01 0.02 --target B0_map.nii.gz

erwin includes a generic meta-data reader to facilitate the conversion to SI: from either a DICOM or a JSON file, meta-data can be queried using specific units. A flip angle can be read and converted to radians using one of the two following examples, from a DICOM file or from a BIDS sidecar file:

ALPHA=$(erwin meta_data.get -p /path/to/some_file -q FlipAngle -u deg)

The same tool can be used for array-like meta-data (erwin meta_data.get -p /path/to/file.dcm -q ImageType.0) or for nested structures, including vendor-specific elements. For example, Siemens-specific meta-data from the sequence card can be queried by

erwin meta_data.get -p /path/to/some_file -q 00291020.MrPhoenixProtocol.0.sWiPMemBlock.adFree.0

Usage in a Python program

TODO Sample B0 from program

import erwin
import nibabel

magnitude = nibabel.load("/path/to/magnitude.nii.gz")
phase = nibabel.load("/path/to/phase.nii.gz")

TODO Sample T2 pipeline

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

erwin-1.0.0rc1.tar.gz (61.3 kB view hashes)

Uploaded Source

Built Distribution

erwin-1.0.0rc1-cp39-cp39-macosx_10_14_x86_64.whl (63.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page