A new electrocardiogram (ECG) segmentation method is proposed, which uses a Wavelet Tree Hidden Markov Model. The principle of this approach is, on one hand, to use wavelet coefficients to characterize the different ECG waves, and, on the other hand. to link these coefficients by a tree structure permitting to detect wave changes. By associating this method to a fusion method between scales based on the context concept, good results are obtained on a special database created for risk analysis of atrial fibrillation, particularly in P wave segmentation.