Welcome to shimming-toolbox!

Releases GitHub Actions CI Coverage Status Documentation Status Twitter Follow License

shimming-toolbox is an open-source Python software package enabling a variety of MRI shimming (magnetic field homogenization) techniques such as static and real-time shimming for use with standard manufacturer-supplied gradient/shim coils or with custom "multi-coil" arrays. The toolbox provides useful set of command line tools as well as a fsleyes plugin dedicated to make shimming more accessible and more reproducible.

For more details, see: D'Astous A, Cereza G, Papp D, Gilbert KM, Stockmann JP, Alonso-Ortiz E, Cohen-Adad J. Shimming toolbox: An open-source software toolbox for B0 and B1 shimming in MRI. Magn Reson Med. 2022; 1-17. doi:10.1002/mrm.29528



  • Built-in DICOM to NIfTI conversion

  • Masking tools for the brain and spinal cord

  • Create and use a variety of B0 shimming coil profiles: Spherical harmonics, shim-only arrays, "AC-DC" multi-coil, etc.

  • Supports different B0 shimming scenarios: dynamic (slicewise), realtime (shim modulation with respiration), gradient z-shimming, two-region shimming (e.g., fat and brain)

  • RF shimming for parallel transmit systems (a.k.a. B1+ shimming)

  • Powered by freely available software tools: dcm2niix, dcm2bids, FSL-prelude, SCT, FSLeyes.


See the Installing shimming-toolbox page.


1. Graphical User Interface (FSLeyes)

shimming-toolbox features a graphical user interface (GUI) via a FSLeyes plugin.


2. Command Line

shimming-toolbox can be used on the the command line. For example:

$ st_prepare_fieldmap -h

Usage: st_prepare_fieldmap [OPTIONS] PHASE...

Creates fieldmap (in Hz) from phase images.

This function accommodates multiple echoes (2 or more) and phase difference.
This function also accommodates 4D phase inputs, where the 4th dimension
represents the time, in case multiple field maps are acquired across time
for the purpose of real-time shimming experiments. For non Siemens phase
data, see --autoscale-phase option.

PHASE: Input path of phase nifti file(s), in ascending order: echo1, echo2,

--mag PATH                     Input path of mag nifti file  [required]
--unwrapper [prelude|skimage]  Algorithm for unwrapping. skimage is
                               installed by default, prelude requires FSL to
                               be installed.  [default: prelude]
-o, --output PATH              Output filename for the fieldmap, supported
                               types : '.nii', '.nii.gz'  [default:
--autoscale-phase BOOLEAN      Tells whether to auto rescale phase inputs
                               according to manufacturer standards. If you
                               have non standard data, it would be
                               preferable to set this option to False and
                               input your phase data from -pi to pi to avoid
                               unwanted rescaling  [default: True]
--mask PATH                    Input path for a mask. Mask must be the same
                               shape as the array of each PHASE input.
--threshold FLOAT              Threshold for masking if no mask is provided.
                               Allowed range: [0, 1] where all scaled values
                               lower than the threshold are set to 0.
                               [default: 0.05]
--savemask PATH                Filename of the mask calculated by the
--gaussian-filter BOOLEAN      Gaussian filter for B0 map
--sigma FLOAT                  Standard deviation of gaussian filter. Used
                               for: gaussian_filter
-v, --verbose [info|debug]     Be more verbose
-h, --help                     Show this message and exit.


To facilitate reproducibility, commands can be chained together in a pipeline using multiple Shimming Toolbox commands. An example script is provided.

The different commands of Shimming Toolbox can be found in the Command Line Tools page.