Abstract. The wavelet transform is a widely used pre-filtering step for subsequent R spike detection by thresholding of the coefficients. The time-frequency decomposition is indeed a powerful tool to analyze non-stationary signals. Still, current methods use consecutive wavelet scales in an a priori restricted range and may therefore lack adaptativity. This paper introduces a supervised learning algorithm which learns the optimal scales for each dataset using the annotations provided by physicians on a small training set. For each record, this method allows a specific set of non consecutive scales to be selected, based on the record's characteristics. The selected scales are then used for the decomposition of the original long-term ECG signal recording and a hard thresholding rule is applied on the derivative of the wavelet coefficients to label the R spikes. This algorithm has been tested on the MIT-BIH arrhythmia database and obtains an average sensitivity rate of 99.7% and aver...