A method and apparatus for compensating for the presence of a magnetic field during medical imaging are disclosed. Gamma photons are acquired at a detector. An orientation of the detector (e.g., relative to the surface of the earth) corresponding to the acquisition is determined. Based on the determined detector orientation, one or more compensation value(s) are determined from a memory of a computer, e.g., based on interpolation, parametric computation, or a look-up table. Energy signal variation of a detected signal due to the detector orientation is compensated for by applying the determined compensation value.