Only if no alternative diagnostic test is available and the potential benefit to the patient clearly outweighs the potential risks
If performed, the pacemaker/ICD should be interrogated before and after the procedure
Registry of non-MRI conditional pacemakers in NEJM article with nonthoracic<unk>  at field strength of 1.5 teslas suggested that lead or device failure does not occur
1000 cases of pacemakers and 500 cases of ICD in study
No deaths, lead failures, losses of capture, or ventricular arrhythmias occurred during<unk> 
Industry funded study, with strict criteria for inclusion
Risks:
Pacemaker/ICD dysfunction
Pacemaker/ICD damage
Arrhythmia
Death
1000 cases of pacemakers and 500 cases of ICD in study
No deaths, lead failures, losses of capture, or ventricular arrhythmias occurred during<unk> 
Industry funded study, with strict criteria for inclusion
Pacemaker/ICD dysfunction
Pacemaker/ICD damage
Arrhythmia
Death
Pregnancy: Unknown (if any, probably low)
Gadolinium-based contrast not recommended unless benefit justifies risk (crosses the placenta)
Claustrophobia
Agitated
Very Obese (depending on system)
Gadolinium-based contrast not recommended unless benefit justifies risk (crosses the placenta)
MRI contraindications
Oncologic emergencies
Shoulder and upper arm diagnoses
Deep brain stimulator complications
Peripheral nerve syndromes
Unstable spine fractures
Epidural compression syndromes
Gastric pacemaker complications