Click or drag to resize

PeakFinderSavitzkyGolay Class

Class PeakFinderSavitzkyGolay uses smooth Savitzky-Golay derivatives to find peaks in data and acts as a collection for the found peaks.
Inheritance Hierarchy
SystemObject
  CenterSpace.NMath.CorePeakFinderBase
    CenterSpace.NMath.CorePeakFinderSavitzkyGolay

Namespace: CenterSpace.NMath.Core
Assembly: NMath (in NMath.dll) Version: 7.4
Syntax
public class PeakFinderSavitzkyGolay : PeakFinderBase, 
	ICloneable

The PeakFinderSavitzkyGolay type exposes the following members.

Constructors
 NameDescription
Public methodPeakFinderSavitzkyGolay(DoubleVector, Int32) An instance of a Savitkzy-Golay peak finder, using a third degree polynomial.
Public methodPeakFinderSavitzkyGolay(DoubleVector, Int32, Int32) An instance of a Savitkzy-Golay peak finder. The width of the filter must be less than the length of the data, and the polynomial degree must be less than the filter width.
Top
Properties
 NameDescription
Public propertyAbscissaInterval Gets\Sets the abscissa interval for the data. This is used to scale the derivatives to the correct units.
Public propertyInputData Gets / Sets the input data. Set nullifies current peak list.
(Inherited from PeakFinderBase)
Public propertyItem Gets the extrema via index operator.
(Inherited from PeakFinderBase)
Public propertyNumberPeaks Gets the number of peaks found.
(Inherited from PeakFinderBase)
Public propertyRootFindingTolerance Gets\Sets the root finders error tolerance. Default is 0.00001;
Public propertySlopeSelectivity Slope selectivity is between [0,Double.MaxValue] (default = 0.0). Peak finding selectivity increases with larger values. A value of 0 returns all peaks (all smoothed derivative zero crossings).
Top
Methods
 NameDescription
Public methodApplySortOrder Applies the desired sort order on the found peaks.
(Inherited from PeakFinderBase)
Public methodClone Creates a deep copy of this SavitzkyGolayPeakFinder instance.
Public methodGetAllPeaks Returns a list of all
C#
Extrema
found.
(Inherited from PeakFinderBase)
Public methodLocatePeakIndices Locates the Indices in the vector preceeding the peak.
(Overrides PeakFinderBaseLocatePeakIndices)
Public methodLocatePeaks Locates the all peak abscissae and their smoothed ordinates in current data set.
(Overrides PeakFinderBaseLocatePeaks)
Public methodRetainPeaks(FuncExtrema, Boolean) Retains
C#
Extrema
in
C#
this
instance that don't satisfy the
C#
FilterDelegate
.
(Inherited from PeakFinderBase)
Public methodRetainPeaks(FuncExtrema, Extrema, Extrema, Boolean, Boolean) Retains
C#
Extrema
in
C#
this
instance that satisfy the
C#
FilterDelegate
, simultaneously for each Extrema, FilterDelegate(extrema[i-1], extrema[i], extrema[i+1]). This allows the filtering of extrema based on the two immediate neighbors. End-point extrema can be dropped at will based on boolean
C#
DropEdgePeaks
.
(Inherited from PeakFinderBase)
Public methodSelectPeaksObsolete.
Deprecated. Selects and returns a list of
C#
Extrema
e that satisfy the
C#
FilterDelegate
.
(Inherited from PeakFinderBase)
Public methodSelectPeaksForwardOrder Selects and returns a list of
C#
Extrema
e that satisfy the
C#
FilterDelegate
.
(Inherited from PeakFinderBase)
Public methodSelectPeaksReverseOrder Selects and returns a list of
C#
Extrema
e that satisfy the
C#
FilterDelegate
.
(Inherited from PeakFinderBase)
Top
Fields
 NameDescription
Protected fieldfindpeaks_ If false, report valleys, otherwise report peaks.
Protected fieldpeakabscissae_ List of the peaks abscissae.
(Inherited from PeakFinderBase)
Protected fieldpeakvalues_ List of peaks ordinates.
(Inherited from PeakFinderBase)
Top
Remarks
Typically the degree of the smoothing polynomial is between 3 and 5. The selectivity of the peak finder can be reduced by increasing the SlopeSelectivity. If SlopeSelectivity is set to 0 (default), all found peaks are reported. For proper scaling of the peak abscissa locations, set AbscissaInterval to the data sample interval.

The filter's parameters must satisfied the follow two rules. 1. The filter width must be less than the length of the data. 2. The polynomial degree must be less than the filter width.

Example
C#
// Build a sinc() function.
double step_size = 0.1;
DoubleVector x = new DoubleVector(5000, 0.01, step_size);
DoubleVector sinc = NMathFunctions.Sin(x) / x;

// Build a peak finder with a width of 6, and 4th degree smoothing polynomial.
PeakFinderSavitzkyGolay pf = new PeakFinderSavitzkyGolay(sinc, 6, 4);
pf.AbscissaInterval = step_size; // Scale abscissa locations.
pf.SlopeSelectivity = 0;         // Return all peaks.
pf.LocatePeaks();                // Locate peaks

// Dump peaks to console.
for (int i = 0; i < pf.NumberPeaks; i++)
  Console.WriteLine("Found peak at = ({0},{1})", pf[i].X, pf[i].Y);
See Also