A method for guiding nanoparticles to a target location by a magnetic gradient field and/or holding them at the target location is proposed. The magnetic gradient field is generated by a magnet system with at least one magnet. A focus of the magnet system is registered with an X-ray device. At least one three-dimensional image dataset showing the target location is captured by the X-ray device. The position of the target location is determined manually and/or automatically in the image dataset or in an image dataset determined therefrom and is positioned automatically based on the registration of the focus so that the focus coincides with the position of the target location.