detectPeaks method

List<int> detectPeaks (Float64List array, int ixstart, int ixend, double noise, double threshold, String peakSign, int maxPeaks)

Detects peaks in array between ixstart, ixend (ixend exclusive). noise is used for differentiating peaks from noise, i.e. small variations of the array values, e.g. in case the values represent measurements.The noise is data dependent and must be estimated from the data. All peaks less or equal to threshold will not be added to the list. peakSign is one of PICK_POS, PICK_NEG, PICK_POSNEG to pick only positive or only negative peaks, or peak of any sign. If maxPeaks > 0, the returned list will only contain the maxPeaks biggest peaks (or smallest for negative peaks). Returns a list of sorted indices where the peaks occur in array.

Implementation

//   (could be empty, but not null).
static List<int> detectPeaks(Float64List array, int ixstart, int ixend,
    double noise, double threshold, String peakSign, int maxPeaks) {
  List<int> negpeaks, result;
  if (peakSign == PICK_POS) {
    result = detectPeaks0(
        array, ixstart, ixend, noise, threshold, false, maxPeaks);
  } else if (peakSign == PICK_POSNEG) {
    result = detectPeaks0(
        array, ixstart, ixend, noise, threshold, false, maxPeaks);
    negpeaks =
        detectPeaks0(array, ixstart, ixend, noise, threshold, true, maxPeaks);
    result.addAll(negpeaks);
    result.sort();
  } else if (peakSign == PICK_NEG) {
    result =
        detectPeaks0(array, ixstart, ixend, noise, threshold, true, maxPeaks);
  }
  return result;
}