Class PeakProminences


  • public class PeakProminences
    extends Object
    Utility class for calculating the prominence of peaks in a signal. This class includes methods to validate parameters and compute the prominence of peaks, which is a measure of how much a peak stands out relative to its surrounding signal.
    • Constructor Detail

      • PeakProminences

        public PeakProminences()
    • Method Detail

      • argWlenAsExpected

        public static int argWlenAsExpected​(Integer value)
        Validates and ensures the input window length (`wlen`) is of type `int` and greater than 1. This method is used to process and validate the `wlen` parameter for peak prominence and width calculations.
        Parameters:
        value - The input value to validate and convert.
        Returns:
        The original `value` rounded up to an integer, or -1 if `value` is null (indicating no value was provided).
        Throws:
        IllegalArgumentException - if `value` is not larger than 1.
      • call

        public static PeakProminenceOutput call​(double[] x,
                                                int[] peaks,
                                                int wlen)
        Calculates the prominence of each peak in a signal. Peak prominence is defined as the vertical distance between the peak and its lowest contour line, which is the higher of the lowest points to its left and right within the specified window.
        Parameters:
        x - A signal array containing peaks to evaluate.
        peaks - Indices of peaks in the signal array `x`.
        wlen - A window length in samples. The window length is rounded up to the nearest odd integer. If `wlen` is smaller than 2, the entire signal `x` is used for prominence calculation.
        Returns:
        A PeakProminenceOutput object containing:
        • Array of prominences for each peak.
        • Array of left base indices for each peak.
        • Array of right base indices for each peak.
        Throws:
        IllegalArgumentException - if `x` or `peaks` is null, or if any value in `peaks` is an invalid index for `x`.