Phase transitions in deterministic compressed sensing, with application to magnetic resonance spectroscopy