Gradient Gradient Non-linearity Correction Software Package

Author: Silvester Czanner (see also: SilvesterNotes)

  1. Overview of distortion correction code
  2. Limitations of the code
  3. Contents in distribution
  4. Setting up local environment variables for use
  5. Use instructions
  6. Support and contacts
  7. Acknowledgements

==== Overview of distortion correction code ===================

Goal: To correct for image distortions in MRI data due to non-linearity of the magnetic fields from the imaging gradient coils.

Method: Described in: Jovicich J, Czanner S, Greve D, Haley E, Kouwe A, Gollub R, Kennedy D, Schmitt F, Brown G, MacFall J, Fischl B, Dale A. Reliability in Multi-Site Structural MRI Studies: Effects of Gradient Non-linearity Correction on Phantom and Human Data. NeuroImage NeuroImage (Apr 1;30(2):436-43, 2006)

Outline of steps involved:

==== Limitations of the code =============================

- This distortion correction code has been tested on 3D structural images

- This code consists of linux bash scripts that call matlab functions - This code has been developed for linux platforms and tested on RED HAT, Fedora Core 2 - This code needs a Matlab license and an Image Toolbox license. - This code has been tested on Matlab's version 7.0 (r14) - We are working on creating a c-version of the code

==== Contents of distribution =============================

The whole distribution package contains 5 subdirectories:

===== Setting up local environment variables ==============

You need to set up the following two variables:

Setup the environment variable GRAD_UNWARP_DIR to the grad_unwarp_bash directory. For example:

Setup the variable MATLAB to the path of your matlab executable file For example:

With these environments you can define aliases to run the scripts:

And then just run the scripts by typing:

============= How to use it =====================

Script is used to convert Siemens .grad or GE .dat to .coef, which is needed to create the displacement table.

Usage: perl <filename> Examples: perl bay1-gw_coils.dat

Script create_displacement_table is used to create a displacement table (*.gwv). It has 2 parameters: vendor and table name. Supported vendor names are siemens and ge. Allowed table names are avanto, sonata, brm, crm. Meaningful combinations are siemens (avanto or sonata), ge (brm or crm)

Usage: create_displacement_table vendor table_name Example: create_displacement_table siemens sonata

Script is reading file with the 1st harmonic coefficients (*.coef) from $GRAD_UNWARP_DIR/grad_unwarp_tables and calculates the displacement table. The table is saved into $GRAD_UNWARP_DIR/grad_unwarp_tables directory.

Script grad_unwarp is used to unwarp the warped raw images produced by scanner devices. It uses several options. If you are not sure about the options, just type

alias grad_unwarp $GRAD_UNWARP_DIR/scripts/grad_unwarp grad_unwarp


grad_unwarp -help

Grad_unwarp script has been tested with avanto, sonata, brm and crm MGH phantom files and with brm dicom files (series #6). You can find the testing data files in

$GRAD_UNWARP_DIR/sample_phantom_data $GRAD_UNWARP_DIR/sample_phantom_data/dicom_BRM_ucsd

==================== H E L P =========================

grad_unwarp is an unwarping tool. It provides a full 3D unwarping for data from Siemens devices. For data from GE devices there is an assumption that these data are already in-plane dewarped.

There are four gradient-coil types supported at the moment: GE BRM, GE CRM, Siemens Sonata/Trio, Siemens Avanto, Siemens Allegra. For each of these, there is a large file somewhere that is an offsets table - for outvol voxel here, look there in invol. Interpolation in the offsets table is trilinear; interpolation in the input volume may be specified by the user with -interp foo. Default is cubic.

There are three ways to use the grad_unwarp flag -unwarp <type>.

A jacobian brightness correction is applied by default - areas of the image that spread out (increase in volume) should dim (decrease in intensity). If for some reason you wish to skip that step, use the -nojac option.

======= E X A M P L E S =================================================

grad_unwarp -i avanto.mgh -o avanto_uw.mgh -unwarp avanto

it will read data stored in avanto.mgh and produce a new dewarped data file avanto_uw.mgh The dewarping will be done based on displacement table stored in file avanto.gvw

grad_unwarp -i dicom_BRM_ucsd/001.dcm -s 6 -o brm_ucsd_uw.mgh -unwarp brm

it will read the data from DICOM file, serie #6 from directory dicom_BRM_ucsd/, dewarp it and create new data file brm_ucsd_uw.mgh in MGH format

============== FORMAT CONVERSION UTILITY ================================

mri_convert is a utility used for a conversion between different volume formats.

Usage: mri_convert [options] <in volume> <out volume>

To see all options type:

alias mri_convert $GRAD_UNWARP_DIR/bin/Linux/mri_convert mri_convert

The input and output file type can be specified in two ways. First, mri_convert will try to figure it out on its own from the format of the file name (eg, files that end in .img are assumed to be in spm analyze format). Second, the user can explicity set the type of file using --in_type and/or --out_type.

Legal values for --in_type (-it) and --out_type (-ot) are:


============== MGH data file Viewer ================================

There is a simple MGH/MGZ/DICOM data file viewer written in matlab. To use it, you have to run matlab, add new path $GRAD_UNWARP_DIR/matlab and type mgh_viewer in matlab's command window. It will create and open an User interface.

To load a MGH/MGZ/DICOM file press button LOAD VOLUME To change a view press one of the buttons SAGITAL, CORONAL and AXIAL To move through the volume by slices use slider Slice #. To change the brightmess and contrast use sliders Window and Level. To quit the Program press button Quit

==== Support and contacts ===============================================

Support is very limited but we will do our best to try to answer your questions. Please email your constructive comments to: