Diffraction gratings are one of the most used elements in optics and even in other fields of science. They are used also like part of measurement devices in scientific and industrial applications. As it is well known, self-imaging effect appears when a diffraction grating is illuminated with a coherent beam, such as a plane wave. This effect has been analyzed in depth and its behavior is well known under ideal grating and illumination conditions. Usually, the illumination beam is not perfectly collimated but presents a certain degree of aberration. The motivation of this work is to try to explain the behavior of the self-images of an ideal amplitude grating when it is illuminated by a non-perfect beam, that is, an aberrated beam. The known of this effect can help to understand how much the aberration of the light beam affects to the diffraction pattern, and more in depth, to the self-imaging phenomenon. The results presented in this work can be very useful in metrology applications, since sometimes the contrast obtained experimentally does not correspond to the theoretical predictions, usually due to aberrations in the light beam. For this, we have used a formalism based in the Rayleigh-Sommerfeld approach. We have modeled the aberrations by using the Zernike polynomials. On the other hand, we have considered all kinds of aberrations, spherical, coma, tilt, astigmatism, etc. As it is expected the contrast of the self-images decrease when the order of them increases and also when the aberration degree increase. In some cases, contrast inversion is also produced for high aberrations.