An algorithm for correcting the distortions that occur in diffusion-weighted echo-planar images due to the strong diffusion-sensitizing gradients is presented. The dominant distortions may be considered to be only changes of scale coupled with a shear and linear translation in the phase-encoding direction. It is then possible to correct for them by using an algorithm in which each line of the image in the phase-encoding direction is considered in turn, with only one parameter (the scale) to be found by searching.