An electrocardiography (ECG) is a quick, painless, noninvasive test that records the heart's electrical activity. Sticky patches (electrodes) are placed on the skin to measure electrical impulses and map them as wave patterns. Doctors use these graphs to diagnose arrhythmias and heart attacks