A method of ion imaging is disclosed that includes automatically sampling a plurality of different locations on a sample using a front device which is arranged and adapted to generate aerosol, smoke or vapour from the sample. Mass spectral data and/or ion mobility data corresponding to each location is obtained and the obtained mass spectral data and/or ion mobility data is used to construct, train or improved a sample classification model.