diff --git a/findpeaks/__init__.py b/findpeaks/__init__.py index eef92ea..eb06c2c 100644 --- a/findpeaks/__init__.py +++ b/findpeaks/__init__.py @@ -17,7 +17,7 @@ __author__ = 'Erdogan Tasksen' __email__ = 'erdogant@gmail.com' -__version__ = '2.5.3' +__version__ = '2.5.4' # module level doc-string __doc__ = """ diff --git a/findpeaks/examples.py b/findpeaks/examples.py index 7acbe6b..0deff5a 100644 --- a/findpeaks/examples.py +++ b/findpeaks/examples.py @@ -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 diff --git a/findpeaks/findpeaks.py b/findpeaks/findpeaks.py index 0ecd31c..6d61710 100644 --- a/findpeaks/findpeaks.py +++ b/findpeaks/findpeaks.py @@ -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. @@ -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) @@ -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} @@ -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': diff --git a/make_sphinx_and_commit.sh b/make_sphinx_and_commit.sh deleted file mode 100644 index 53e5fb1..0000000 --- a/make_sphinx_and_commit.sh +++ /dev/null @@ -1,37 +0,0 @@ -echo "$PWD" -cd docs -echo "$PWD" - -echo "Cleaning previous builds first.." -make.bat clean - -echo "Building new html.." -make.bat html - -echo "Press [q]uit to Quit and [Enter] key to: git add -> commit -> push." -read VAR - -cd .. - - - -if [[ $VAR = "" ]]; then - read -p "Ready?" - git pull - git add . - git commit -m "update sphinx pages" - git push - - read -p "All done! Press [Enter] to close this window." - exit -fi - - -if [ $VAR == "q" ]; then - echo Quit! -fi - -read -p "Press [Enter] to close this window." - - -