In one example, a method includes determining a slope of a cardiac electrogram. The method may also include determining a threshold value based on a maximum of the slope of the cardiac electrogram. The method may further include identifying a last point of the cardiac electrogram before the slope of the cardiac electrogram crosses the threshold as one of an onset or an offset of a wave. In another example, the method further includes receiving an indication of local ventricular motion associated with a cardiac contraction, and determining an electromechanical delay between the identified onset and the local ventricular motion. Some examples include providing the electromechanical delay for configuration of cardiac resynchronization therapy.