@@ -39,42 +39,6 @@ def find_peaks(x):
3939 soft_peaks = numpy .asarray (soft_peaks )+ 1
4040 return hard_peaks , soft_peaks
4141
42- def find_peaks (x ):
43- # Definitions:
44- # * Hard peak: a peak that is either /\ or \/
45- # * Soft peak: a peak that is either /-*\ or \-*/ (In that cas we define the middle of it as the peak)
46-
47- # Returns two numpy arrays:
48- # * hard_peaks contains the indexes of the Hard peaks
49- # * soft_peaks contains the indexes of the Soft peaks
50-
51- if len (x ) == 0 :
52- return numpy .empty ([0 ]), numpy .empty ([0 ])
53-
54- tmp = x [1 :]
55- tmp = numpy .append (tmp , [x [- 1 ]])
56- tmp = x - tmp
57- tmp [numpy .where (tmp > 0 )] = + 1
58- tmp [numpy .where (tmp == 0 )] = 0
59- tmp [numpy .where (tmp < 0 )] = - 1
60- tmp2 = tmp [1 :]
61- tmp2 = numpy .append (tmp2 , [0 ])
62- tmp = tmp - tmp2
63- hard_peaks = numpy .where (numpy .logical_or (tmp == - 2 ,tmp == + 2 ))[0 ]+ 1
64- soft_peaks = []
65- for iv in numpy .where (numpy .logical_or (tmp == - 1 ,tmp == + 1 ))[0 ]:
66- t = tmp [iv ]
67- i = iv + 1
68- while True :
69- if i == len (tmp ) or tmp [i ] == - t or tmp [i ] == - 2 or tmp [i ] == 2 :
70- break
71- if tmp [i ] == t :
72- soft_peaks .append (int (iv + (i - iv )/ 2 ))
73- break
74- i += 1
75- soft_peaks = numpy .asarray (soft_peaks )+ 1
76- return hard_peaks , soft_peaks
77-
7842
7943def correct_peaks (x , peaks_indexes , min_gap , max_gap , smooth_window ):
8044 N = x .shape [0 ]
0 commit comments