Skip to content

Commit

Permalink
2.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
erdogant committed May 17, 2024
1 parent f07d50f commit a1ceb08
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 26 deletions.
2 changes: 1 addition & 1 deletion findpeaks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

__author__ = 'Erdogan Tasksen'
__email__ = '[email protected]'
__version__ = '2.6.4'
__version__ = '2.6.5'

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

# %%
# Import library
from findpeaks import findpeaks
# Initialize findpeaks with cearus method.
# The default setting is that it only return peaks-vallyes with at least 5% difference. We can change this using params
# fp = findpeaks(method='caerus', params={'minperc': 10, 'window': 50})
fp = findpeaks(method='caerus')
# Import example data
X = fp.import_example('facebook')
# Fit
results = fp.fit(X)
# Make the plot
fp.plot()

# %%

from findpeaks import findpeaks
# Data
X = [1153,672,501,1068,1110,574,135,23,3,47,252,812,1182]
# Initialize
fp = findpeaks(lookahead=1)
results = fp.fit(X)
# Plot
fp.plot()
results.get('df')


# %% Issue29

# Import library
Expand Down Expand Up @@ -258,7 +285,7 @@
# fp = findpeaks(method='caerus', params_caerus={'minperc': 5, 'window': 50})
fp = findpeaks(method='caerus', params={'minperc': 5, 'window': 50})
results = fp.fit(X)

fp.plot()

# %% Issue 13
# https://github.com/erdogant/findpeaks/issues/13
Expand Down Expand Up @@ -366,7 +393,7 @@
results = fp.fit(X)
fp.plot()

fp = findpeaks(method="caerus", interpolate=None, params={'minperc': 100}, verbose=verbose)
fp = findpeaks(method="caerus", interpolate=None, params={'minperc': 50, 'window':50}, verbose=verbose)
# Make fit
results = fp.fit(X)
ax = fp.plot()
Expand Down
16 changes: 9 additions & 7 deletions findpeaks/findpeaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
from urllib.parse import urlparse

# #### DEBUG ONLY ####
# import stats as stats
# from stats import disable_tqdm
# import interpolate as interpolate
import stats as stats
from stats import disable_tqdm
import interpolate as interpolate
# #####################
import findpeaks.stats as stats
from findpeaks.stats import disable_tqdm
import findpeaks.interpolate as interpolate
# import findpeaks.stats as stats
# from findpeaks.stats import disable_tqdm
# import findpeaks.interpolate as interpolate


# #####################
Expand Down Expand Up @@ -346,7 +346,9 @@ def peaks1d(self, X, x=None, method='peakdetect', height=0):
# Post processing for the topology method
result['topology'] = stats._post_processing(X, Xraw, result['valley'], result['peak'], self.interpolate, 1)
elif method == 'caerus':
cs = caerus(**self.params)
caerus_params = self.params.copy()
if caerus_params.get('delta') is not None: caerus_params.pop('delta')
cs = caerus(**caerus_params)
result = cs.fit(X, return_as_dict=True, verbose=self.verbose)
# Post processing for the caerus method
result['caerus'] = stats._post_processing(X, Xraw,
Expand Down
34 changes: 18 additions & 16 deletions findpeaks/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
# Licence: MIT
# ----------------------------------------------------

import findpeaks.union_find as union_find
from findpeaks.filters.lee import lee_filter
from findpeaks.filters.lee_enhanced import lee_enhanced_filter
from findpeaks.filters.lee_sigma import lee_sigma_filter
from findpeaks.filters.kuan import kuan_filter
from findpeaks.filters.frost import frost_filter
from findpeaks.filters.median import median_filter
from findpeaks.filters.mean import mean_filter
# import findpeaks.union_find as union_find
# from findpeaks.filters.lee import lee_filter
# from findpeaks.filters.lee_enhanced import lee_enhanced_filter
# from findpeaks.filters.lee_sigma import lee_sigma_filter
# from findpeaks.filters.kuan import kuan_filter
# from findpeaks.filters.frost import frost_filter
# from findpeaks.filters.median import median_filter
# from findpeaks.filters.mean import mean_filter

# #### DEBUG ONLY ####
# import union_find as union_find
# from filters.lee import lee_filter
# from filters.lee_enhanced import lee_enhanced_filter
# from filters.lee_sigma import lee_sigma_filter
# from filters.kuan import kuan_filter
# from filters.frost import frost_filter
# from filters.median import median_filter
# from filters.mean import mean_filter
import union_find as union_find
from filters.lee import lee_filter
from filters.lee_enhanced import lee_enhanced_filter
from filters.lee_sigma import lee_sigma_filter
from filters.kuan import kuan_filter
from filters.frost import frost_filter
from filters.median import median_filter
from filters.mean import mean_filter
# ######################

from scipy.ndimage.morphology import generate_binary_structure, binary_erosion
Expand Down Expand Up @@ -570,6 +570,8 @@ def _post_processing(X, Xraw, min_peaks, max_peaks, interpolate, lookahead, labx
idx_peaks, _ = zip(*max_peaks)
idx_peaks = np.array(list(idx_peaks)).astype(int)
idx_valleys, _ = zip(*min_peaks)
# Add first and last row
# idx_valleys = np.array(idx_valleys)
idx_valleys = np.append(np.array(list(idx_valleys)), len(X) - 1).astype(int)
idx_valleys = np.append(0, idx_valleys)

Expand Down

0 comments on commit a1ceb08

Please sign in to comment.