9

I'm looking to identify some peaks in some spectrograph data, and was trying to use the scipy.signal.find_peaks_cwt() function to do it.

However, the official documentation I've found isn't too descriptive, and tends to pick up false peaks in noise while sometimes not picking up actual peaks in the data.

Could anyone give me a better explanation of the parameters in this function that I can play with, including "widths", or could you show me some alternatives?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
NGXII
  • 407
  • 2
  • 9
  • 18
  • Did you try to look at the source for that function? – wwii Jun 24 '15 at 03:17
  • 1
    Or even in notes at the bottom of the description you linked? – jojeck Jun 24 '15 at 11:18
  • 1
    Possible duplicate of http://stackoverflow.com/questions/28822327/units-of-widths-argument-to-scipy-signal-cwt-function – Curt F. Jun 24 '15 at 20:43
  • I have read the notes, and that post is very helpful when it comes to understanding the widths parameter, thank you for posting it. I'm still unclear on the other optional parameters though, any ideas on those? I looked at the source, and since I'm fairly new to python its hard to really gain something from it.. I'll keep examining it though – NGXII Jun 24 '15 at 21:38

1 Answers1

6

If your signal is relatively clean, I suggest first using simpler alternatives, like the PeakUtils indexes function. The code is way more direct than with scipy.signal.find_peaks_cwt:

import numpy as np
from peakutils.peak import indexes
vector = [ 0, 6, 25, 20, 15, 8, 15, 6, 0, 6, 0, -5, -15, -3, 4, 10, 8, 13, 8, 10, 3, 1, 20, 7, 3, 0 ]
print('Detect peaks with minimum height and distance filters.')
indexes = indexes(np.array(vector), thres=7.0/max(vector), min_dist=2)
print('Peaks are: %s' % (indexes))

enter image description here

The Scipy find_peaks_cwt will really prove usefull in presence of noisy data, as it uses continuous wavelet transform.

Yoan Tournade
  • 623
  • 10
  • 15