|
| 1 | +Methods and implementation |
| 2 | +========================== |
| 3 | +*SDCFlows* defines a clear :abbr:`API (application programming interface)` that divides |
| 4 | +the problem of susceptibility distortions (SD) into two stages: |
| 5 | + |
| 6 | +#. **Estimation**: |
| 7 | + the MRI acquisitions in the protocol for :abbr:`SD (susceptibility distortions)` are |
| 8 | + discovered and preprocessed to estimate a map of B\ :sub:`0` non-uniformity in Hz (:math:`\Delta B_0`). |
| 9 | + The theory behind these distortions is well described in the literature ([Jezzard1995]_, [Hutton2002]_), |
| 10 | + and further discussed below (see a summary in :numref:`fig-1`). |
| 11 | + *SDCFlows* builds on freely-available software to implement three major strategies for estimating |
| 12 | + :math:`\Delta B_0` (Eq. :math:`\eqref{eq:fieldmap-1}`). |
| 13 | + These strategies are described below, and implemented within :py:mod:`sdcflows.workflows.fit`\ . |
| 14 | + |
| 15 | +#. **Application**: |
| 16 | + the B-Spline basis coefficients used to represent the estimated :math:`\Delta B_0` map mapped into the |
| 17 | + target :abbr:`EPI (echo-planar imaging)` scan to be corrected, and a displacement field in NIfTI |
| 18 | + format that is compatible with ANTs is interpolated from the B-Spline basis. |
| 19 | + The voxel location error along the :abbr:`PE (phase-encoding)` will be proportional to :math:`\Delta B_0 \cdot T_\text{ro}`, |
| 20 | + where :math:`T_\text{ro}` is the *total readout time* of the target :abbr:`EPI (echo-planar imaging)` (:numref:`fig-1`). |
| 21 | + The implementation of these workflows is found in the submodule :py:mod:`sdcflows.workflows.apply`\ . |
| 22 | + |
| 23 | +.. _fig-1: |
| 24 | + |
| 25 | +.. figure:: _static/sdcflows-OHBM21-fig1.png |
| 26 | + :width: 100% |
| 27 | + :align: center |
| 28 | + |
| 29 | + Susceptibility distortions in a nutshell |
| 30 | + |
| 31 | +.. admonition:: BIDS Specification |
| 32 | + |
| 33 | + See the section `Echo-planar imaging and *B0* mapping |
| 34 | + <https://bids-specification.readthedocs.io/en/latest/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#echo-planar-imaging-and-b0-mapping>`__. |
| 35 | + |
| 36 | +Fieldmap estimation: theory and methods |
| 37 | +--------------------------------------- |
| 38 | +The displacement suffered by every voxel along the :abbr:`PE (phase-encoding)` direction |
| 39 | +can be derived from Eq. (2) of [Hutton2002]_: |
| 40 | + |
| 41 | +.. math:: |
| 42 | +
|
| 43 | + \Delta_\text{PE} (i, j, k) = \gamma \cdot \Delta B_0 (i, j, k) \cdot T_\text{ro}, |
| 44 | + \label{eq:fieldmap-1}\tag{1} |
| 45 | +
|
| 46 | +where |
| 47 | +:math:`\Delta_\text{PE} (i, j, k)` is the *voxel-shift map* (VSM) along the :abbr:`PE (phase-encoding)` direction, |
| 48 | +:math:`\gamma` is the gyromagnetic ratio of the H proton in Hz/T |
| 49 | +(:math:`\gamma = 42.576 \cdot 10^6 \, \text{Hz} \cdot \text{T}^\text{-1}`), |
| 50 | +:math:`\Delta B_0 (i, j, k)` is the *fieldmap variation* in T (Tesla), and |
| 51 | +:math:`T_\text{ro}` is the readout time of one slice of the :abbr:`EPI (echo-planar imaging)` dataset |
| 52 | +we want to correct for distortions. |
| 53 | + |
| 54 | +Let :math:`V` represent the *fieldmap* in Hz (or equivalently, |
| 55 | +*voxel-shift-velocity map*, as Hz are equivalent to voxels/s), with |
| 56 | +:math:`V(i,j,k) = \gamma \cdot \Delta B_0 (i, j, k)`, then, introducing |
| 57 | +the voxel zoom along the phase-encoding direction, :math:`s_\text{PE}`, |
| 58 | +we obtain the nonzero component of the associated displacements field |
| 59 | +:math:`\Delta D_\text{PE} (i, j, k)` that unwarps the target :abbr:`EPI (echo-planar imaging)` dataset: |
| 60 | + |
| 61 | +.. math:: |
| 62 | +
|
| 63 | + \Delta D_\text{PE} (i, j, k) = V(i, j, k) \cdot T_\text{ro} \cdot s_\text{PE}. |
| 64 | + \label{eq:fieldmap-2}\tag{2} |
| 65 | +
|
| 66 | +.. _sdc_direct_b0 : |
| 67 | + |
| 68 | +Direct B0 mapping sequences |
| 69 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 70 | +.. admonition:: BIDS Specification |
| 71 | + |
| 72 | + See the section `Types of fieldmaps - Case 3: Direct field mapping |
| 73 | + <https://bids-specification.readthedocs.io/en/latest/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#case-3-direct-field-mapping>`__ |
| 74 | + in the BIDS specification. |
| 75 | + |
| 76 | +Some MR schemes such as :abbr:`SEI (spiral-echo imaging)` can directly |
| 77 | +reconstruct an estimate of *the fieldmap in Hz*, :math:`V(i,j,k)`. |
| 78 | +These *fieldmaps* are described with more detail `here |
| 79 | +<https://cni.stanford.edu/wiki/GE_Processing#Fieldmaps>`__. |
| 80 | + |
| 81 | +.. _sdc_phasediff : |
| 82 | + |
| 83 | +Phase-difference B0 estimation |
| 84 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 85 | +.. admonition:: BIDS Specification |
| 86 | + |
| 87 | + See the section `Types of fieldmaps - Case 2: Two phase maps and two magnitude images |
| 88 | + <https://bids-specification.readthedocs.io/en/latest/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#case-2-two-phase-maps-and-two-magnitude-images>`__ |
| 89 | + in the BIDS specification. |
| 90 | + |
| 91 | + Some scanners produce one ``phasediff`` map, where the drift between the two echos has |
| 92 | + already been calculated, see the section |
| 93 | + `Types of fieldmaps - Case 1: Phase-difference map and at least one magnitude image |
| 94 | + <https://bids-specification.readthedocs.io/en/latest/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#case-1-phase-difference-map-and-at-least-one-magnitude-image>`__. |
| 95 | + |
| 96 | +The fieldmap variation in T, :math:`\Delta B_0 (i, j, k)`, that is necessary to obtain |
| 97 | +:math:`\Delta_\text{PE} (i, j, k)` in Eq. :math:`\eqref{eq:fieldmap-1}` can be |
| 98 | +calculated from two subsequent :abbr:`GRE (Gradient-Recalled Echo)` echoes, |
| 99 | +via Eq. (1) of [Hutton2002]_: |
| 100 | + |
| 101 | +.. math:: |
| 102 | +
|
| 103 | + \Delta B_0 (i, j, k) = \frac{\Delta \Theta (i, j, k)}{2\pi \cdot \gamma \, \Delta\text{TE}}, |
| 104 | + \label{eq:fieldmap-3}\tag{3} |
| 105 | +
|
| 106 | +where |
| 107 | +:math:`\Delta \Theta (i, j, k)` is the phase-difference map in radians, |
| 108 | +and :math:`\Delta\text{TE}` is the elapsed time between the two GRE echoes. |
| 109 | + |
| 110 | +For simplicity, the «*voxel-shift-velocity map*» :math:`V(i,j,k)`, which we |
| 111 | +can introduce in Eq. :math:`\eqref{eq:fieldmap-2}` to directly obtain |
| 112 | +the displacements field, can be obtained as: |
| 113 | + |
| 114 | +.. math:: |
| 115 | +
|
| 116 | + V(i, j, k) = \frac{\Delta \Theta (i, j, k)}{2\pi \cdot \Delta\text{TE}}. |
| 117 | + \label{eq:fieldmap-4}\tag{4} |
| 118 | +
|
| 119 | +This calculation is further complicated by the fact that :math:`\Theta_i` |
| 120 | +(and therefore, :math:`\Delta \Theta`) are clipped (or *wrapped*) within |
| 121 | +the range :math:`[0 \dotsb 2\pi )`. |
| 122 | +It is necessary to find the integer number of offsets that make a region |
| 123 | +continuously smooth with its neighbors (*phase-unwrapping*, [Jenkinson2003]_). |
| 124 | + |
| 125 | +.. _sdc_pepolar : |
| 126 | + |
| 127 | +:abbr:`PEPOLAR (Phase Encoding POLARity)` techniques |
| 128 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 129 | +.. admonition:: BIDS Specification |
| 130 | + |
| 131 | + See the section `Types of fieldmaps - Case 4: Multiple phase encoded directions ("pepolar") |
| 132 | + <https://bids-specification.readthedocs.io/en/latest/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#case-4-multiple-phase-encoded-directions-pepolar>`__. |
| 133 | + |
| 134 | +Alternatively, it is possible to estimate the field by exploiting the symmetry of the |
| 135 | +distortion when the :abbr:`PE (phase-encoding)` polarity is reversed. |
| 136 | +*SDCFlows* integrates two implementations based on FSL ``topup`` [Andersson2003]_, |
| 137 | +and AFNI ``3dQwarp`` [Cox1997]_. |
| 138 | +By default, FSL ``topup`` will be used. |
| 139 | + |
| 140 | +.. _sdc_fieldmapless : |
| 141 | + |
| 142 | +Fieldmap-less approaches |
| 143 | +~~~~~~~~~~~~~~~~~~~~~~~~ |
| 144 | +Many studies acquired (especially with legacy MRI protocols) do not have any |
| 145 | +information to estimate susceptibility-derived distortions. |
| 146 | +In the absence of data with the specific purpose of estimating the :math:`B_0` |
| 147 | +inhomogeneity map, researchers resort to nonlinear registration to an |
| 148 | +«*anatomically correct*» map of the same individual (normally acquired with |
| 149 | +:abbr:`T1w (T1-weighted)`, or :abbr:`T2w (T2-weighted)` sequences). |
| 150 | +One of the most prominent proposals of this approach is found in [Studholme2000]_. |
| 151 | + |
| 152 | +*SDCFlows* includes an (experimental) procedure, based on nonlinear image registration |
| 153 | +with ANTs' symmetric normalization (SyN) technique. |
| 154 | +This workflow takes a skull-stripped :abbr:`T1w (T1-weighted)` image and |
| 155 | +a reference :abbr:`EPI (Echo-Planar Imaging)` image, and estimates a field of nonlinear |
| 156 | +displacements that accounts for susceptibility-derived distortions. |
| 157 | +To more accurately estimate the warping on typically distorted regions, this |
| 158 | +implementation uses an average :math:`B_0` mapping described in [Treiber2016]_. |
| 159 | +The implementation is a variation on those developed in [Huntenburg2014]_ and |
| 160 | +[Wang2017]_. |
| 161 | + |
| 162 | +The process is divided in two steps. |
| 163 | +First, the two images to be aligned (anatomical and one or more :abbr:`EPI (echo-planar imaging)` sources) are prepared for |
| 164 | +registration, including a linear pre-alignment of both, calculation of a 3D :abbr:`EPI (echo-planar imaging)` *reference* map, |
| 165 | +intensity/histogram enhancement, and *deobliquing* (meaning, for images where the physical |
| 166 | +coordinates axes and the data array axes are not aligned, the physical coordinates are |
| 167 | +rotated to align with the data array). |
| 168 | +Such a preprocessing is implemented in |
| 169 | +:py:func:`~sdcflows.workflows.fit.syn.init_syn_preprocessing_wf`. |
| 170 | +Second, the outputs of the preprocessing workflow are fed into |
| 171 | +:py:func:`~sdcflows.workflows.fit.syn.init_syn_sdc_wf`, |
| 172 | +which executes the nonlinear, SyN registration. |
| 173 | +To aid the *Mattes* mutual information cost function, the registration scheme is set up |
| 174 | +in *multi-channel* mode, and laplacian-filtered derivatives of both anatomical and :abbr:`EPI (echo-planar imaging)` |
| 175 | +reference are introduced as a second registration channel. |
| 176 | +The optimization gradients of the registration process are weighted, so that deformations |
| 177 | +effectively possible only along the :abbr:`PE (phase-encoding)` axis. |
| 178 | +Given that ANTs' registration framework performs on physical coordinates, it is necessary |
| 179 | +that input images are not *oblique*. |
| 180 | +The anatomical image is used as *fixed image*, and therefore, the registration process |
| 181 | +estimates the transformation function from *unwarped* (anatomically *correct*) coordinates |
| 182 | +to *distorted* coordinates. |
| 183 | +If fed into ``antsApplyTransforms``, the resulting transform will effectively *unwarp* a distorted |
| 184 | +:abbr:`EPI (echo-planar imaging)` given as input into its *unwarped* mapping. |
| 185 | +The estimated transform is then converted into a :math:`B_0` fieldmap in Hz, which can be |
| 186 | +stored within the derivatives folder. |
| 187 | + |
| 188 | +.. danger :: |
| 189 | +
|
| 190 | + This procedure is experimental, and the outcomes should be scrutinized one-by-one |
| 191 | + and used with caution. |
| 192 | + Feedback will be enthusiastically received. |
| 193 | +
|
| 194 | +Other (unsupported) approaches |
| 195 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 196 | +There exist some alternative options to estimate the fieldmap, such as mapping the |
| 197 | +point-spread-function [Zaitsev2004]_, or by means of nonlinear registration of brain |
| 198 | +surfaces onto the distorted :abbr:`EPI (echo-planar imaging)` data [Esteban2016]_. |
| 199 | + |
| 200 | +Estimation tooling |
| 201 | +~~~~~~~~~~~~~~~~~~ |
| 202 | +The workflows provided by :py:mod:`sdcflows.workflows.fit` make use of several utilities. |
| 203 | +The cornerstone of these tools is the fieldmap representation with B-Splines |
| 204 | +(:py:mod:`sdcflows.interfaces.bspline`). |
| 205 | +B-Splines are well-suited to plausibly smooth the fieldmap and provide a compact |
| 206 | +representation of the field with fewer parameters. |
| 207 | +This representation is also more accurate in the case the images that were used for estimation |
| 208 | +are not aligned with the target images to be corrected because the fieldmap is not directly |
| 209 | +interpolated in the projection, but rather, the position of the coefficients in space is |
| 210 | +updated and then the fieldmap reconstructed. |
| 211 | + |
| 212 | +Unwarping the distorted data |
| 213 | +---------------------------- |
| 214 | +:py:mod:`sdcflows.workflows.apply` contains workflows to project fieldmaps represented by B-Spline |
| 215 | +basis into the space of the target :abbr:`EPI (echo-planar imaging)` data. |
| 216 | + |
| 217 | +Discovering fieldmaps in a BIDS dataset |
| 218 | +--------------------------------------- |
| 219 | +To ease the implementation of higher-level pipelines integrating :abbr:`SDC (susceptibility distortion correction)`, |
| 220 | +*SDCFlows* provides :py:func:`sdcflows.utils.wrangler.find_estimators`. |
| 221 | + |
| 222 | +Explicit specification with ``B0FieldIdentifier`` |
| 223 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 224 | +.. admonition:: BIDS Specification |
| 225 | + |
| 226 | + See the section `Expressing the MR protocol intent for fieldmaps - Using *B0FieldIdentifier* metadata |
| 227 | + <https://bids-specification.readthedocs.io/en/latest/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#using-b0fieldidentifier-metadata>`__. |
| 228 | + |
| 229 | +If one or more ``B0FieldIdentifier``\ (s) are set within the input metadata (following BIDS' specifications), |
| 230 | +then corresponding estimators will be built from the available input data. |
| 231 | + |
| 232 | +Implicit specification with ``IntendedFor`` |
| 233 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 234 | +.. admonition:: BIDS Specification |
| 235 | + |
| 236 | + See the section `Expressing the MR protocol intent for fieldmaps - Using *IntendedFor* metadata |
| 237 | + <https://bids-specification.readthedocs.io/en/latest/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#using-intendedfor-metadata>`__. |
| 238 | + |
| 239 | +In the case no ``B0FieldIdentifier``\ (s) are defined, then *SDCFlows* will try to identify as many fieldmap |
| 240 | +estimators as possible within the dataset following a set of heuristics. |
| 241 | +Then, those estimators may be linked to target :abbr:`EPI (echo-planar imaging)` data by interpreting the |
| 242 | +``IntendedFor`` field if available. |
| 243 | + |
| 244 | +Fieldmap-less by registration to a T1-weighted image |
| 245 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 246 | +If none of the two previous options yielded any workable estimation strategy, and provided that |
| 247 | +the argument ``fmapless`` is set to ``True``, then :py:func:`~sdcflows.utils.wrangler.find_estimators` |
| 248 | +will attempt to find :abbr:`BOLD (blood-oxygen level-dependent)` or :abbr:`DWI (diffusion-weighted imaging)` |
| 249 | +instances within single sessions that are consistent in :abbr:`PE (phase-encoding)` direction and |
| 250 | +*total readout time*, assuming they have been acquired with the same shimming settings. |
| 251 | + |
| 252 | +If one or more anatomical images are found, and if the search for candidate |
| 253 | +:abbr:`BOLD (blood-oxygen level-dependent)` or :abbr:`DWI (diffusion-weighted imaging)` data |
| 254 | +yields results, then corresponding fieldmap-less estimators are set up. |
| 255 | + |
| 256 | +It is possible to force the fieldmap-less estimation by passing ``force_fmapless=True`` to the |
| 257 | +:py:func:`~sdcflows.utils.wrangler.find_estimators` utility. |
| 258 | + |
| 259 | +References |
| 260 | +---------- |
| 261 | +.. [Jezzard1995] Jezzard, P. & Balaban, R. S. (1995) Correction for geometric distortion in |
| 262 | + echo planar images from B0 field variations. Magn. Reson. Med. 34:65–73. |
| 263 | + doi:`10.1002/mrm.1910340111 <https://doi.org/10.1002/mrm.1910340111>`__. |
| 264 | +.. [Hutton2002] Hutton et al., (2002) Image Distortion Correction in fMRI: A Quantitative |
| 265 | + Evaluation, NeuroImage 16(1):217-240. doi:`10.1006/nimg.2001.1054 |
| 266 | + <https://doi.org/10.1006/nimg.2001.1054>`__. |
| 267 | +.. [Jenkinson2003] Jenkinson, M. (2003) Fast, automated, N-dimensional phase-unwrapping |
| 268 | + algorithm. MRM 49(1):193-197. doi:`10.1002/mrm.10354 |
| 269 | + <https://doi.org/10.1002/mrm.10354>`__. |
| 270 | +.. [Andersson2003] Andersson, J. (2003) How to correct susceptibility distortions in spin-echo |
| 271 | + echo-planar images: application to diffusion tensor imaging. NeuroImage 20:870–888. |
| 272 | + doi:`10.1016/s1053-8119(03)00336-7 <https://doi.org/10.1016/s1053-8119(03)00336-7>`__. |
| 273 | +.. [Cox1997] Cox, R. (1997) Software tools for analysis and visualization of fMRI data. NMR Biomed. |
| 274 | + 10:171–178, doi:`10.1002/(sici)1099-1492(199706/08)10:4/5%3C171::aid-nbm453%3E3.0.co;2-l |
| 275 | + <https://doi.org/10.1002/(sici)1099-1492(199706/08)10:4/5%3C171::aid-nbm453%3E3.0.co;2-l>`__. |
| 276 | +.. [Studholme2000] Studholme et al. (2000) Accurate alignment of functional EPI data to |
| 277 | + anatomical MRI using a physics-based distortion model, |
| 278 | + IEEE Trans Med Imag 19(11):1115-1127, 2000, doi: `10.1109/42.896788 |
| 279 | + <https://doi.org/10.1109/42.896788>`__. |
| 280 | +.. [Treiber2016] Treiber, J. M. et al. (2016) Characterization and Correction |
| 281 | + of Geometric Distortions in 814 Diffusion Weighted Images, |
| 282 | + PLoS ONE 11(3): e0152472. doi:`10.1371/journal.pone.0152472 |
| 283 | + <https://doi.org/10.1371/journal.pone.0152472>`_. |
| 284 | +.. [Wang2017] Wang S, et al. (2017) Evaluation of Field Map and Nonlinear |
| 285 | + Registration Methods for Correction of Susceptibility Artifacts |
| 286 | + in Diffusion MRI. Front. Neuroinform. 11:17. |
| 287 | + doi:`10.3389/fninf.2017.00017 |
| 288 | + <https://doi.org/10.3389/fninf.2017.00017>`_. |
| 289 | +.. [Huntenburg2014] Huntenburg, J. M. (2014) `Evaluating Nonlinear |
| 290 | + Coregistration of BOLD EPI and T1w Images |
| 291 | + <http://pubman.mpdl.mpg.de/pubman/item/escidoc:2327525:5/component/escidoc:2327523/master_thesis_huntenburg_4686947.pdf>`__, |
| 292 | + Berlin: Master Thesis, Freie Universität. |
| 293 | +.. [Zaitsev2004] Zaitsev, M. (2004) Point spread function mapping with parallel imaging techniques and |
| 294 | + high acceleration factors: Fast, robust, and flexible method for echo-planar imaging distortion correction, |
| 295 | + MRM 52(5):1156-1166. doi:`10.1002/mrm.20261 <https://doi.org/10.1002/mrm.20261>`__. |
| 296 | +.. [Esteban2016] Esteban, O. (2016) Surface-driven registration method for the structure-informed segmentation |
| 297 | + of diffusion MR images. NeuroImage 139:450-461. |
| 298 | + doi:`10.1016/j.neuroimage.2016.05.011 <https://doi.org/10.1016/j.neuroimage.2016.05.011>`__. |
0 commit comments