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.6 The easiest way to install erwin and its dependencies is through PyPi and pip:
python3 -m pip install erwin
If this fails, you may need to
- adjust the
python3
executable to match your local installation - upgrade
pip
(python3 -m pip install --upgrade pip
, especially on Debian ≤ 10 and Ubuntu ≤ 18.04) - install Cython
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
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.