Skip to content

Commit

Permalink
removed height with the github version of peakdetect because it break…
Browse files Browse the repository at this point in the history
…s findpeaks at several places
  • Loading branch information
erdogant committed Feb 18, 2024
1 parent f6b7afb commit 8a8fead
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
11 changes: 5 additions & 6 deletions findpeaks/findpeaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ class findpeaks():
* https://erdogant.github.io/findpeaks/
"""

def __init__(self,
height=None,
method=None,
whitelist=['peak', 'valley'],
lookahead=200,
Expand All @@ -88,6 +86,7 @@ def __init__(self,
cu=None, # DEPRECATED IN LATER VERSIONS: specify in params
params_caerus={}, # DEPRECATED IN LATER VERSIONS: use params instead
params={'window': 3, 'delta': 0},
# height=None,
figsize=(15, 8),
verbose=3):
"""Initialize findpeaks parameters.
Expand Down Expand Up @@ -209,7 +208,7 @@ def __init__(self,
self.denoise = denoise
self.figsize = figsize
self.verbose = verbose
self.height = height
# self.height = height

# Store parameters for caerus
defaults = {}
Expand Down Expand Up @@ -331,14 +330,14 @@ def peaks1d(self, X, x=None, method='peakdetect', height=0):
result = {}

# Interpolation
if self.interpolate is not None:
if self.interpolate is not None and self.interpolate>0:
X = interpolate.interpolate_line1d(X, n=self.interpolate, method=2, showfig=False, verbose=self.verbose)

# Compute peaks based on method
if method == 'peakdetect':
# Peakdetect method
max_peaks, min_peaks = peakdetect(X, lookahead=self.lookahead, delta=self.params['delta'],
height=self.height)
# max_peaks, min_peaks = peakdetect(X, lookahead=self.lookahead, delta=self.params['delta'], height=self.height)
max_peaks, min_peaks = peakdetect(X, lookahead=self.lookahead, delta=self.params['delta'])
# Post processing for the peak-detect
result['peakdetect'] = stats._post_processing(X, Xraw, min_peaks, max_peaks, self.interpolate,
self.lookahead)
Expand Down
4 changes: 3 additions & 1 deletion findpeaks/tests/test_findpeaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_fit(self):
assert np.all(np.isin(results['persistence'].columns, ['x', 'y', 'birth_level', 'death_level', 'score']))

# CHECK RESULTS METHOD TOPOLOGY
# Let op, soms gaat deze ook op 6 vanwege een stochastic components
assert results['persistence'].shape[0] == 7

# CHECK RESULTS METHOD with LIMIT functionality
Expand All @@ -100,7 +101,8 @@ def test_fit(self):
assert len(results['Xdetect'][results['Xdetect'] != 0]) == len(results['Xranked'][results['Xranked'] != 0])

# CHECK OUTPUT METHOD PEAKDETECT
fp = findpeaks(method="peakdetect", lookahead=1, verbose=3, height=0)
# fp = findpeaks(method="peakdetect", lookahead=1, verbose=3, height=0)
fp = findpeaks(method="peakdetect", lookahead=1, verbose=3)
X = fp.import_example('1dpeaks')
results = fp.fit(X)
assert fp.type == 'peaks1d'
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
peakdetect==1.1
scipy==1.11.4
matplotlib
numpy
Expand All @@ -9,4 +8,5 @@ caerus>=0.1.9
opencv-python
xarray
joblib
peakdetect==1.1
# git+https://github.com/arvinnick/peakdetect.git
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'caerus>=0.1.9',
'xarray',
'joblib'],
# dependency_links=['https://github.com/arvinnick/peakdetect/tarball/master#egg=peakdetect-1.2'],
python_requires='>=3',
name='findpeaks',
version=new_version,
Expand Down

0 comments on commit 8a8fead

Please sign in to comment.