correct_peaks: Adjust a set of detected peaks to coincide with local signal...

View source: R/correct_peaks.R

correct_peaksR Documentation

Adjust a set of detected peaks to coincide with local signal maxima.

Description

Adjust a set of detected peaks to coincide with local signal maxima.

Usage

correct_peaks(
  sig,
  peak_inds,
  search_radius,
  smooth_window_size,
  peak_dir = "compare"
)

Arguments

sig

The 1d signal vector

peak_inds

Vector of the original peak indices

search_radius

The radius within which the original peaks may be shifted.

smooth_window_size

The window size of the moving average filter applied on the signal. Peak distance is calculated on the difference between the original and smoothed signal.

peak_dir

optional string denoting the expected peak direction: 'up' or 'down', 'both', or 'compare'.

Details

Functionality of peak_dir param: - If 'up', the peaks will be shifted to local maxima. - If 'down', the peaks will be shifted to local minima. - If 'both', the peaks will be shifted to local maxima of the rectified signal. - If 'compare', the function will try both 'up' and 'down' options, and choose the direction that gives the largest mean distance from the smoothed signal.

Value

shifted_peak_inds vector of the corrected peak indices.


PennStateDEPENdLab/experiment_pipeline documentation built on Nov. 27, 2024, 4:56 a.m.