Skip to contents

Locates samples where the first derivative crosses zero from positive to non-positive AND the prior slope magnitude exceeds threshold_factor * max(|dx|).

Usage

morie_dsp_derivative_detect(x, fs = 1, threshold_factor = 0.5)

Arguments

x

Numeric vector.

fs

Sampling frequency (Hz). Default 1.

threshold_factor

Slope threshold fraction. Default 0.5.

Value

Integer vector of peak indices.

References

Rangayyan & Krishnan (2015), Ch. 4, sec. 4.3.

Examples

set.seed(1)
x <- rep(0, 300); x[c(60, 150, 240)] <- 5
x <- stats::filter(x, rep(1 / 5, 5), sides = 2)
x[is.na(x)] <- 0
str(morie_dsp_derivative_detect(as.numeric(x), fs = 100), max.level = 1)
#>  int [1:3] 58 148 238