Spin-echo attenuation by diffusion in nonuniform field gradients