A method for magnetic resonance spectroscopy (=MRS) or magnetic resonance imaging (=MRI) in which an NMR time-domain signal is created by an RF excitation pulse applied to an object in the presence of an applied magnetic field that may depend on spatial position and/or time, the time-domain signal being generated by an excited transverse nuclear magnetisation precessing about the applied magnetic field, whereby the RF excitation pulse is adapted to cover a whole range of NMR frequencies of interest present in the object, and time-domain signal acquisition takes place during, or during and after the application of the RF excitation pulse, is characterized in that spectral or image data are reconstructed by a matrix product of a reconstruction matrix and a vector of time-domain signal points, the reconstruction matrix being an inversion of an encoding matrix Anα whose elements are calculated using the formula:
wherein n is the running number of a time-domain signal point, α is the running number of a discrete image or spectral element, Pm is the m-th discrete element of the RF excitation pulse in the time-domain, and Φ(n,m,α) is the phase accrued by the transverse nuclear magnetisation related to the discrete image or spectral element a in the time between the discrete RF excitation pulse element Pm and the time-domain signal point n under the influence of the applied magnetic field. An improved method for reconstructing spectral or image data from time-domain signal acquired as describe above is thereby provided which can be used more versatilely than conventional Fourier transform.