find_peaks: Get peaks/valleys in waveform data

Description Usage Arguments Value Examples

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

1
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

1
2
3
4
5
6
7
8
### 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])

atamalu/GCalcium documentation built on July 12, 2019, 7:04 p.m.