Theory of Image Formation in Non-linear Optical Microscopy