Spatial encoding in magnetic resonance imaging (MRI) techniques is achieved by sampling the signal as a function of time in the presence of magnetic field gradients, e.g., X, Y, and Z gradients. The gradient magnets have in the past been assumed to generate a linear gradient, and typical image reconstruction techniques have relied upon this assumption. However, to achieve high speed performance, gradient magnets often sacrifice linearity for speed. This non-linearity, in turn, results in distorted images, the distortion often being sufficiently large to compromise the usefulness of MRI images for stereotaxy or longitudinal studies, where precise volumetric information is required. The disclosure provides practical methods for correcting distorted images resulting from such non-linearity in the gradient fields, as well as distortions resulting from translational, rotational, and / or winding / design errors in the field generating devices. The methods employ spherical harmonic expansions of the gradient fields and fast Fourier transform techniques to provide well-corrected images without undue computational burdens.