localMaximum: Identify local maximum within a slide window.

View source: R/localMaximum.R

localMaximumR Documentation

Identify local maximum within a slide window.

Description

The simplest local maximum detection using a sliding window searches for maxima in a window of a given size, and slides that window across the signal, shifting it one position at a time.

Usage

localMaximum(x, winSize = 5)

Arguments

x

a vector represents a signal profile

winSize

the slide window size, 5 by default.

Details

The default implementation found here shifts the window by half of its size instead of by one position at a time. This makes the implementation faster, at the expense of not being able to detect peaks that are too close to each other, if they appear in some positions with respect to the windows.

Additionally, this implementation removes all instances of peaks found at a distance less than the window size

Experimentally, we are exploring other algorithms for local maxima detection. These algorithms can be chosen setting the "MassSpecWavelet.localMaximum.algorithm" option. See the "Finding local maxima" vignette for further details.

Value

Return a vector with the same length of the input x. The position of local maximum is set as 1L, 0L else where.

Author(s)

Pan Du and Sergio Oller

See Also

getLocalMaximumCWT()

Examples


x <- rnorm(200)
lmax <- localMaximum(x, 5)
maxInd <- which(lmax > 0)
plot(x, type = "l")
points(maxInd, x[maxInd], col = "red")


zeehio/MassSpecWavelet documentation built on May 6, 2023, 1:32 a.m.