Electrocardiogram ( ecg ) . During an ecg sensors ( electrodes ) that can detect the electrical activity of your heart are attached to your chest and sometimes to your limbs . An ecg measures the timing and duration of each electrical phase in your heartbeat .