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,
  mode = c("peaks", "valleys", "both"),
  sgolay_args = list(),
  FIR_args = list(),
  correctionRangeSeconds = 0,
  minPeakAmplitude = 0,
  sgol_p,
  sgol_n
)

Arguments

x

a rats, ts, or a numeric vector.

mode

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

sgolay_args

a named list of arguments to be passed to sgolay) Savitzky-Golay smoothing filter. 'p' and 'n' must be present, representing the filter order and length (this must be an odd value). If empty, the filtering is disabled.

FIR_args

a named list of arguments to be passed to FIR) filtering function. 'cut' and 'type' must be present, representing . If empty, the filtering is disabled.

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

sgol_p

OBSOLETE parameter: smoothing filter order of the sgolay filter.

sgol_n

OBSOLETE parameter: smoothing filter length (must be odd).

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

x

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 June 11, 2025, 3:39 a.m.