Peakfind

From Eigenvector Research Documentation Wiki
Revision as of 12:23, 23 April 2015 by imported>Donal (→‎Options)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Purpose

Automated identification of peaks.

Synopsis

[i0,iw] = peakfind(x,width,tolfac,w,options)
[i0,iw] = peakfind(x,width,options)

Description

Given a set of measured traces (x) PEAKFIND attempts to find the location of the peaks. Different algorithms are available and each is discussed in the Algorithm Section.

Inputs

  • x = matrix of measured traces. Each row of (x) is an individual trace with potential peaks.
  • width = number of points in Savitzky-Golay filter.

Optional Inputs

  • tolfac = tolerance on the estimated residuals, peaks heights are estimated to be > tolfac\*residuals {default: tolfac = 3}.
  • w = odd scalar window width for determining local maxima {default: w = 3} (see LOCALMAXIMA).
  • options = discussed below in the Options Section.

Outputs

  • i0 = cell array with each cell containing the indices of the location of the major peaks for each of the traces.
  • iw = cell array with each cell containing the indices of the location of the windows containing each peak in (i0). (If not included in the output argument list, it is not calculated and the algorithm is slightly faster.) .

Algorithm

Each peak finding algorithm uses the smoothed and second derivative data (see SAVGOL) and an estimate of the residuals. The smoothed and second derivative are estimated as:

d0 = savgol(x,width,2,0);
d2 = savgol(x,width,2,2);

The residuals are defined for the row/trace as

residuals = sqrt(mean((x(i,:)-d0(i,:)).\^2));

For options.algorithm = 'd0', locates a candidate set of peaks (pks) by identifying local maxima (within the specified window size) in the smoothed data:

pks = localmaxima(d0(i,:),w);
Next, the input (tolfac) is used to estimate two thresholds (tol0) and (tol2) using the smoothed and second derivative data:
tol0 = tolfac\*sqrt(mean((x(i,:)-d0(i,:)).\^2));
tol2 = tol0\*(max(d2(i,:))-min(d2(i,:)))/ ...
(max(d0(i,:))-min(d0(i,:)));
Finally, the set of major peaks are selected from the initial candidate set of peaks . To be accepted, the value of d0 and d2 at the peak location must surpass the estimated noise level of both d0 and d2 by the tolerance factor (tolfac).
i0{i} = pks(d0(i,pks)>tol0 & d2(i,pks)<-tol2);

For options.algorithm = 'd2', the algorithm operates similarly to what is described for d0 except that it locates candidate peaks as the local maxima on the second derivative data and to be accepted, a peak must only surpass the estimated noise level of d2 by the tolerance factor. That is, d0 is not considered at all in the calculation except to estimate the noise level.

For options.algorithm = 'd2r', as with 'd2', 'd2r' locates peaks in the second derivative data, d2, but selects the final set as those peaks which have a "relative" height (difference between closest d2 peak valley and d2 peak top) which surpasses the estimated noise level of d2 by the tolerance factor, tolfac.

Options

options = structure array with the following fields:

  • algorithm: [ {'d0'} | 'd2' | 'd2r' ] selects an algorithm used to identify peak location. These algorithms are complimentary and may work differently in the presense of backgrounds and other peak shape effects.
  • 'd0' : locates a candidate set of peaks by identifying local maxima (within the specified window size) in the smoothed data (d0). Next, a threshold on d0 and the second derivative (d2) is used to select a final set of peaks from this candidate set. To be accepted, the value of d0 and d2 at the peak location must surpass the estimated noise level of both d0 and d2 by the tolerance factor (tolfac).
  • 'd2' : locates candidate peaks as local maxima in the smoothed 2nd derivative data (d2) and selects a final set of peaks as those candidate peaks which surpass (by the tolerance factor, tolfac) the estimated noise level of d2. d0 position or value is not considered in any part of the selection except to estimate the noise level.
  • 'd2r' : as with 'd2', 'd2r' locates peaks in d2, but selects the final set as those peaks which have a "relative" height (difference between closest d2 peak valley and d2 peak top) which surpasses (by the tolerance factor, tolfac) the estimated noise level of d2.
  • npeaks: [ {'all'} | 'n' ] The maximum number of peaks to find.
  • {'all'} chooses all peaks that are > tolfac.
  • n positive integer is the maximum number of peaks.
  • com: [0] Center of Mass filter on peak positions. Relocates peaks to their "power-weighted" center of mass. That is, the intensity taken to the specified power is used to reloate the peak to its center of mass. Note this may not be an even interval. A value of zero (0) disables the center of mass correction. A value of 1 corresponds to a standard center of mass calculation. Higher values recalculate to the specified power before calculating center of mass.
  • peakdirection: [{'positive'}| 'negative' | 'both' ] specifies whether peaks are considered as upward, downward, or both upward and downward spikes in the spectrum profile.
  • 'positive' : locates positive-going spikes in the profile.
  • 'negative' : locates negative-going spikes in the profile.
  • 'both ' : locates positive or negative-going spikes in the profile. If npeaks value is specified then it applies to positive peaks and negative peaks separately. 'both' with npeaks=4 will identify up to 8 peaks. 'both' with npeaks='all' will identify all positive and all negative peaks.

See Also

fitpeaks, localmaxima