Skip to content

Commit

Permalink
2.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
erdogant committed Oct 7, 2023
1 parent 938908d commit 2d12f51
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 42 deletions.
2 changes: 1 addition & 1 deletion findpeaks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

__author__ = 'Erdogan Tasksen'
__email__ = '[email protected]'
__version__ = '2.5.3'
__version__ = '2.5.4'

# module level doc-string
__doc__ = """
Expand Down
9 changes: 9 additions & 0 deletions findpeaks/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
# import matplotlib.pyplot as plt
# from findpeaks import findpeaks

# %%
from findpeaks import findpeaks
X = [1,1,1.1,1,0.9,1,1,1.1,1,0.9,1,1.1,1,1,0.9,1,1,1.1,1,1,1,1,1.1,0.9,1,1.1,1,1,0.9,1,1.1,1,1,1.1,1,0.8,0.9,1,1.2,0.9,1,1,1.1,1.2,1,1.5,1,3,2,5,3,2,1,1,1,0.9,1,1,3,2.6,4,3,3.2,2,1,1,0.8,4,4,2,2.5,1,1,1]

fp = findpeaks(method='peakdetect', lookahead=1, verbose=3, whitelist=['peak', 'valley'], params={'delta': 1})
results = fp.fit(X)
fp.plot()


# %% New functionality:
import findpeaks as fp
import matplotlib.pyplot as plt
Expand Down
14 changes: 10 additions & 4 deletions findpeaks/findpeaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self,
window=None, # DEPRECATED IN LATER VERSIONS: specify in params
cu=None, # DEPRECATED IN LATER VERSIONS: specify in params
params_caerus={}, # DEPRECATED IN LATER VERSIONS: use params instead
params={'window': 3},
params={'window': 3, 'delta': 0},
figsize=(15, 8),
verbose=3):
"""Initialize findpeaks parameters.
Expand Down Expand Up @@ -132,13 +132,17 @@ def __init__(self,
* 'mean'
params : dict():
Denoising parameters for the methods. If None are defined, the default will be used:
caerus (default): {'window': 50, 'minperc': 3, 'nlargest': 10, 'threshold': 0.25}
lee_sigma (default): {'window': 7, 'sigma': 0.9, 'num_looks': 1, 'tk': 5}
* caerus (default): {'window': 50, 'minperc': 3, 'nlargest': 10, 'threshold': 0.25}
* lee_sigma (default): {'window': 7, 'sigma': 0.9, 'num_looks': 1, 'tk': 5}
* 'sigma': float, (default: 0.9): Speckle noise standard deviation, applies for methods: ['lee_sigma']
* 'num_looks': int, (default: 1): Number of looks of the SAR img, applies for methods: ['lee_sigma']
* 'tk': int, (default: 5): Threshold of neighbouring pixels outside of the 98th percentile, applies for methods: ['lee_sigma']
* cu : float, (default: 0.25): The noise variation coefficient, applies for methods: ['kuan','lee','lee_enhanced']
* window : int, (default : 3): Denoising window. Increasing the window size may removes noise better but may also removes details of image in certain denoising methods.
* peakdetect
'delta' : int (default: 0): this specifies a minimum difference between a peak and the following points, before a peak may be considered a peak. Useful to hinder the function
from picking up false peaks towards to end of the signal. To work well delta should be set to delta >= RMSnoise * 5.
When omitted delta function causes a 20% decrease in speed. When used Correctly it can double the speed of the function
togray : bool, (default : False)
Conversion to gray scale.
verbose : int (default : 3)
Expand Down Expand Up @@ -208,6 +212,8 @@ def __init__(self,
defaults = {'window': 50, 'minperc': 3, 'nlargest': 10, 'threshold': 0.25}
elif method=='lee_sigma':
defaults = {'window': 7, 'sigma': 0.9, 'num_looks': 1, 'tk': 5}
elif method=='peakdetect':
defaults = {'delta': 0}
defaults = {**{'window': 3}, **defaults}

params = {**defaults, **params}
Expand Down Expand Up @@ -321,7 +327,7 @@ def peaks1d(self, X, x=None, method='peakdetect'):
# Compute peaks based on method
if method=='peakdetect':
# Peakdetect method
max_peaks, min_peaks = peakdetect(X, lookahead=self.lookahead)
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)
elif method=='topology':
Expand Down
37 changes: 0 additions & 37 deletions make_sphinx_and_commit.sh

This file was deleted.

0 comments on commit 2d12f51

Please sign in to comment.