Optical and infrared diagnostics of SDSS galaxies in the SWIRE survey