.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/non_maximum_suppression.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_non_maximum_suppression.py: Non-Maximum Suppression for Gaussian Pulse Detection ==================================================== This example demonstrates the use of the NonMaximumSuppression class to detect Gaussian pulses in a one-dimensional signal. It generates a synthetic dataset of Gaussian pulses, applies the non-maximum suppression algorithm, and plots the results. .. GENERATED FROM PYTHON SOURCE LINES 10-33 .. code-block:: Python from DeepPeak.algorithms import NonMaximumSuppression from DeepPeak.signals import Kernel, SignalDatasetGenerator NUM_PEAKS = 3 SEQUENCE_LENGTH = 400 gaussian_width = 0.03 generator = SignalDatasetGenerator(n_samples=1, sequence_length=SEQUENCE_LENGTH) dataset = generator.generate( signal_type=Kernel.GAUSSIAN, n_peaks=(3, 3), amplitude=(10, 300), # Amplitude range position=(0.3, 0.7), # Peak position range width=gaussian_width, # Width range noise_std=2, # Add some noise categorical_peak_count=False, ) dataset.plot() .. image-sg:: /gallery/images/sphx_glr_non_maximum_suppression_001.png :alt: non maximum suppression :srcset: /gallery/images/sphx_glr_non_maximum_suppression_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 34-35 Configure and run the detector .. GENERATED FROM PYTHON SOURCE LINES 35-45 .. code-block:: Python peak_locator = NonMaximumSuppression( gaussian_sigma=0.003, threshold="auto", maximum_number_of_pulses=5, kernel_truncation_radius_in_sigmas=3, ) peak_locator.run(time_samples=dataset.x_values, signal=dataset.signals.squeeze()) peak_locator.plot() .. image-sg:: /gallery/images/sphx_glr_non_maximum_suppression_002.png :alt: Equal-width Gaussian pulse detection (coarse) :srcset: /gallery/images/sphx_glr_non_maximum_suppression_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.377 seconds) .. _sphx_glr_download_gallery_non_maximum_suppression.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: non_maximum_suppression.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: non_maximum_suppression.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: non_maximum_suppression.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_