Optimization of NMR sequences through simulation of real samples and instrumental artifacts: application to the LAPSR sequence