In a method to operate an image-generating medical modality in order to avoid harm to a patient caused by an electromagnetic field, an adjustment process is implemented in which the electromagnetic field is radiated by the modality and preliminary image data are acquired using the electromagnetic field and a clearance between the patient and a wall of the modality is determined from the image. The determined clearance forms the basis of a check process to determine an adaptation of the electromagnetic field for a diagnostic examination of the patient that follows. During the diagnostic examination, that also includes radiation of the electromagnetic field, movement monitoring of the patient takes place and the adjustment process is restarted as soon as a movement of the patient is registered.