added find peaks and valleys, now to determine the shape of the signal