detectPeaks0 method
Helper for detectPeaks().
Detects peaks in data
between ixstart, ixend
(ixend exclusive).
noise
is used for differentiating peaks from noise.
All peaks <= threshold
will not be addedto the list.
Returns a list of sorted indices in the data array.
(could be empty, but not null).
If pickNegs
is true, find only negative peaks.
If maxPeaks
> 0, the returned list will only contain the maxPeaks
biggest peaks (or smallest for negative peaks)
Implementation
static List<int> detectPeaks0(Float64List data, int ixstart, int ixend,
double noise, double threshold, bool pickNegs, int maxPeaks) {
List<int> peakIndices = detectPeaksEmiAbs(
data, ixstart, ixend, noise, true, threshold, pickNegs)[0];
if (maxPeaks <= 0 || peakIndices.length <= maxPeaks) return peakIndices;
List<double> peakValues = [];
for (int i = 0; i < peakIndices.length; i++) {
peakValues.add(data[peakIndices[i]]);
}
// leave only the maxPeaks biggest peaks.
int peakix;
List<int> maxIndices = [];
for (int i = 0; i < maxPeaks; i++) {
peakix = Array1D.getMax(Float64List.fromList(peakValues))[1];
maxIndices.add(peakIndices[peakix]);
peakValues.removeAt(peakix); // already treated
peakIndices.removeAt(peakix);
}
maxIndices.sort();
return maxIndices;
}