1. A computer-readable memory medium storing program instructions, wherein the program instructions, if executed by a computer system, cause the computer system to: perform a multiscale short-time Fourier transform (STFT) on a set of samples to obtain a transform array that is parameterized by window width, window displacement τ and frequency ω, wherein the set of samples represents a portion of an electrocardiogram (ECG) signal, wherein the portion of the ECG signal includes a number of waveform features; operate on the transform array to determine a plurality of peaks in the transform array, wherein said operating includes determining, for each of the plurality of peaks, a window width value, a window displacement value, a frequency value and a power value; generate, for each of the plurality of peaks, a refined window width value and a refined window displacement value, by: computing an inner product between the set of samples and each of a plurality of functions, wherein the plurality of functions are windowed sinusoids (a) having a common frequency equal to the frequency value of the peak, (b) being centered at times that are in a neighborhood of the window displacement value of the peak, and (c) having a common width that is based on the width value of the peak; and solving a linear system Av=c for the unknown vector v, wherein the vector c is determined by the inner products, wherein the matrix A is determined by said times that are in the neighborhood of the window displacement value of the peak.