A method, using patches fixed to a surface of a body, thepatches including respective electrodes in contact with thesurface, and at least one of the patches configured to output asignal in response to a magnetic field applied to the body.Initially, the signal is processed to compute first magneticlocations and first electrical locations of the at least one ofthe patches. Subsequently, the signal is processed to computesecond magnetic locations and second electrical locations of theat least one of the patches. A first relation is computedbetween the first magnetic and the first electrical locations, asecond relation is computed between the second magnetic and thesecond electrical locations, and upon detecting a differencebetween the second and the first relations, a magnetic locationcorrection is computed and then applied to track a position of amagnetic sensor inside the body.