The present disclosure relates to a medical apparatus including a magnetic resonance imaging (MRI) system for acquiring magnetic resonance (MR) data from an imaging volume. In one implementation, the MRI system may include a particle beam apparatus having a particle beam line for producing, directing and managing a particle beam of charged particles, a magnetic correction device for applying a magnetic correction to a magnetic field perturbation within the imaging volume, and a controller for controlling the magnetic correction device. The controller may be configured to provide a spatially optimized magnetic correction within a restricted volume of the imaging volume during a spatially optimized magnetic correction period posterior to an excitation period during which a selected slice from the imaging volume is excited.