An active implantable medical device for one of cardiac stimulation, resynchronization, and defibrillation is shown and described. The device includes means for placing an electronic circuit in a safekeeping operating mode in response to detecting a first magnetic field associated with a permanent magnet and detecting a second magnetic field associated with an MRI imager.