The design of an MRI (Magnetic Resonance Imaging) compatible PET (Positron Emission Tomography) detector is regarded to be a challenging task since both imaging devices are likely interacting with each other potentially leading to performance degradation. A typically expected consequence of this interaction is the distortion of the MRI system’s ${B_0}$ field homogeneity. The ${B_0}$ field gets distorted by any material with non-zero susceptibility brought into the MRI system. Typically, MRI machines have a so-called active shimming system available which allows the field optimization by using additional dedicated shim coils. However, this active shimming mechanism is limited and might not be capable to compensate localized higher order field patterns caused by e.g. a PET system. Since the high ${B_0}$ field quality is needed for an undisturbed MRI acquisition in general and especially for more advanced MR sequences (spectroscopic studies, sequences which utilizes spectral selective pre-pulses), the PET system’s hardware needs to be designed carefully. Consequently, the typical design paradigm regarding this ${B_0}$ field distortion is the careful selection of all components according to their susceptibility (as low as possible). This design paradigm certainly limits the flexibility of the system design since worse performing components might be chosen over better alternatives because of their higher susceptibility. To overcome this limitation and to retain the MRI capabilities, we propose the application of localized shimming on PET detector level, meaning that the distortion profile caused by PET modules is compensated using either additional components such as magnetic materials (passive shimming) or DC coils (active shimming) on the PET modules or by intelligently arranging the hardware components of the PET detector. We have implemented a software framework which covers three parts: firstly, it calculates the ${B_0}$ distortion of various objects (susceptibility objects, conductor configuration). Secondly, it allows the characterization of magnetic objects by fitting the implemented models to data and thirdly, it performs a ${B_0}$ field homogenization of measured distortion maps by superimposing field disturbances of additional simulated objects. We tested this software framework in a first attempt with a single PET module of the Hyperion-II $^ {\rm D}$ scanner. The measured distortion map of the single PET module shows a strong localized ${B_0}$ distortion with a volume RMS value of about $0.6~\hbox{ppm}$ . After optimization, the homogeneity of the simulated field distribution is strongly improved by a factor of 8 (volume RMS $ \approx 0.075~\hbox{ppm}$ ).