Clustering algorithm for QRS and ST-T waveform typing