Electrocardiography (ECG or EKG from ) is a transthoracic (across the thorax or chest) interpretation of the electrical activity of the heart over a period of time , as detected by electrodes attached to the surface of the skin and recorded by a device external to the body.