Improvement in the reliability of segmentation of a signal, such as an ECG signal, is achieved through the use of duration constraints. The signal is analysed using a hidden Markov model. The duration constraints specify minimum allowed durations for specific states of the model. The duration constraints can be incorporated either in the model itself or in a Viterbi algorithm used to compute the most probable state sequence given a conventional model. The derivation of a confidence measure from the model can be used to assess the quality and robustness of the segmentation and to identify any signals for which the segmentation is unreliable, for example due to the presence of noise or abnormality in the signal.