find_peaks {GCalcium} | R Documentation |
Get peaks/valleys in waveform data
Description
‘find_peaks' finds peaks or valleys in waveform by using inflection points, with filter of ’n' increasing/decreasing points on both sides of each inflection point.
Usage
find_peaks(x, n.points = 3)
Arguments
x |
vector of numbers |
n.points |
the number of decreasing (peaks) or increasing (valleys) data points on left and right of inflection point required to be considered a "peak". A positive number as an input finds peaks, and a negative number finds valleys. |
Value
a numeric vector of indices
Examples
### Format data frame
df.new <- format_data(GCaMP)
### How many peaks are there in trial 1 with 10 decreasing data points on each side?
peak.indices <- find_peaks(df.new$Trial1, n.points = 10)
### When do they occur?
data.frame(times = df.new$Time[peak.indices], vals = df.new$Trial1[peak.indices])
[Package GCalcium version 1.0.0 Index]