The :ref:`dwipreproc` command handles motion and distortion correction for DWI data (including eddy current distortions and optionally susceptibility-induced EPI distortions). Even though the command works seamlessly like any other MRtrix3 command, it is in fact a script that interfaces with the `FSL <http://fsl.fmrib.ox.ac.uk/>`_ package to perform most of its core functionality and algorithms. For this command to work, `FSL <http://fsl.fmrib.ox.ac.uk/>`_ (including `eddy <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy>`_) needs to be installed. Also remember to cite the relevant articles with respect to the specific algorithms (see the :ref:`dwipreproc` help page).

The simplest scenario is to (only) correct for motion and eddy current-induced distortions::

    foreach * : dwipreproc IN/dwi_denoised_unringed.mif IN/dwi_denoised_unringed_preproc.mif -rpe_none -pe_dir AP

.. WARNING:: The :code:`-pe_dir` option to :ref:`dwipreproc` is used to specify the phase encoding direction of the acquisition. The :code:`-pe_dir AP` in the example above refers to an *anterior-posterior* phase encoding direction, which is relatively commonly used for acquiring human data. For typical human data, change this to :code:`-pe_dir LR` for a *left-right* phase encoding direction or :code:`-pe_dir SI` for a *superior-inferior* phase encoding direction.

For different, more advanced, scenarios and acquisitions (e.g. the common case of correcting for susceptibility-induced EPI distortions using a pair of reverse phase-encoded b=0 images), refer to the :ref:`dwipreproc_page` section and the :ref:`dwipreproc` documentation.

