|
9 | 9 | import matplotlib.pyplot as plt |
10 | 10 | # from findpeaks import findpeaks |
11 | 11 |
|
| 12 | +# %% |
| 13 | + |
| 14 | +import matplotlib.pyplot as plt |
| 15 | +# Import library |
| 16 | +from findpeaks import findpeaks |
| 17 | +# Initialize |
| 18 | +fp = findpeaks(method='topology') |
| 19 | +# Example 1d-vector |
| 20 | +X = fp.import_example('1dpeaks') |
| 21 | + |
| 22 | +# Plot |
| 23 | +# plt.figure(figsize=(15, 8), dpi=100) |
| 24 | +# plt.plot(X) |
| 25 | +# plt.grid(True) |
| 26 | +# plt.xlabel('Time') |
| 27 | +# plt.ylabel('Value') |
| 28 | + |
| 29 | +# Fit topology method on the 1D vector |
| 30 | +results = fp.fit(X) |
| 31 | +# Plot the results |
| 32 | +fp.plot_persistence(figsize=(25,8)) |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +# %% |
| 37 | +import numpy as np |
| 38 | +from scipy.ndimage import gaussian_filter |
| 39 | +from findpeaks import findpeaks |
| 40 | +rng = np.random.default_rng(42) |
| 41 | +x = rng.normal(size=(50, 50)) |
| 42 | +x = gaussian_filter(x, sigma=10.) |
| 43 | +# peak and valley |
| 44 | +fp = findpeaks(method="topology", whitelist=['peak', 'valley'], denoise=None) |
| 45 | +results = fp.fit(x) |
| 46 | + |
| 47 | +fp.plot(figsize=(25, 15), figure_order='horizontal', marker='x') |
| 48 | +# fp.plot_persistence() |
| 49 | +# fp.plot_mesh() |
| 50 | + |
| 51 | +# %% |
| 52 | + |
| 53 | +# Import library |
| 54 | +from findpeaks import findpeaks |
| 55 | +# Initializatie |
| 56 | +fp = findpeaks(scale=True, denoise=None, togray=True, imsize=(300, 300)) |
| 57 | +# Import image example |
| 58 | +img = fp.import_example('2dpeaks_image') |
| 59 | +# Fit |
| 60 | +results = fp.fit(img) |
| 61 | +# Tens of thousands of peaks are detected at this point. |
| 62 | +fp.plot(figure_order='horizontal', text=False) |
| 63 | +# fp.plot_mesh() |
| 64 | + |
| 65 | + |
12 | 66 | # %% |
13 | 67 | # ============================================================================= |
14 | 68 | # Issue with numpy > 1.26.4 |
|
57 | 111 | X = [10,11,9,23,21,11,45,20,11,12] |
58 | 112 | fp = findpeaks(method="topology", lookahead=1, verbose='info') |
59 | 113 | results = fp.fit(X) |
60 | | -ax = fp.plot() |
| 114 | +ax = fp.plot(text=True) |
61 | 115 | ax = fp.plot_persistence() |
62 | 116 |
|
63 | 117 | # fp.check_logger(verbose='info') |
|
204 | 258 | # %% |
205 | 259 | from findpeaks import findpeaks |
206 | 260 | path = r'https://erdogant.github.io/datasets/images/complex_peaks.png' |
207 | | -fp = findpeaks(method='topology', whitelist='peak', denoise='lee_enhanced', params={'window': 5}, verbose='debug') |
| 261 | +fp = findpeaks(method='topology', whitelist='peak', denoise='lee_enhanced', params={'window': 5}) |
208 | 262 | X = fp.imread(path) |
209 | 263 | results = fp.fit(X) |
210 | 264 | ax = fp.plot_persistence() |
|
0 commit comments