Quantum mechanical simulation of magnetic resonance imaging