peakFinder: Finds peaks and throughs features in a time series

View source: R/signals_processing.R

peakFinderR Documentation

Finds peaks and throughs features in a time series

Description

Finds peaks and throughs features in a time series

Usage

peakFinder(
  x,
  sgol_p = 2,
  sgol_n = 25,
  mode = c("peaks", "valleys", "both"),
  correctionRangeSeconds,
  minPeakAmplitude
)

Arguments

x

a rats, ts, or a numeric vector.

sgol_p

smoothing filter order. If NA, the filtering is disabled.

sgol_n

smoothing filter length (must be odd).

mode

should the function return only 'peaks', 'valleys', or 'both'?

correctionRangeSeconds

the half range in which the real maximum/minimum value should be searched, in seconds. around the derivative shift. Should be less then the periodicity of the signal. 0.5 is good for skin conductance.

minPeakAmplitude

the minimum delta from valley to peak for detection. Skin conductance traditionally uses 0.05uS, or 0.03uS

Details

The function has a relatively simple yet robust implementation: after a Sgolay smoothing, the first derivative's sign changes are detected. Then, the actual minima or maxima is looked for in a given range. NOTE: the function ensures that no consecutive throughs or peaks are returned.

Value

a list of:

bool

a logical vector of the same length of x with TRUE value corresponding to a match

samples

the position of features relatively to x's index

time

temporal coordinates of the features (if x has a frequency attribute)

type

a character vector defining for each "samples" value if its a 'p' peak or a 'v' valley (trough)

y

The value of x correspoding to the detected features

amp

the positive (v->p) and negative (p->v) amplitudes of the detected features

i

The absolute position of the features along the signal. The values are independent from the 'mode' argument, allowing interaction between different calls of the function.


kleinbub/rIP documentation built on Dec. 21, 2024, 9:15 a.m.