defindexes(y,thres=0.3,min_dist=1,thres_abs=False):"""Peak detection routine borrowed from
https://bitbucket.org/lucashnegri/peakutils/src/master/peakutils/peak.py
"""ifisinstance(y,np.ndarray)andnp.issubdtype(y.dtype,np.unsignedinteger):raiseValueError("y must be signed")ifnotthres_abs:thres=thres*(np.max(y)-np.min(y))+np.min(y)min_dist=int(min_dist)# compute first order differencedy=np.diff(y)# propagate left and right values successively to fill all plateau pixels (0-value)zeros,=np.where(dy==0)# check if the signal is totally flatiflen(zeros)==len(y)-1:returnnp.array([])iflen(zeros):# compute first order difference of zero indexeszeros_diff=np.diff(zeros)# check when zeros are not chained togetherzeros_diff_not_one,=np.add(np.where(zeros_diff!=1),1)# make an array of the chained zero indexeszero_plateaus=np.split(zeros,zeros_diff_not_o