detect_peaks
Detect peaks in signal vector data
Syntax
Matlab & Octave
peaks = detect_peaks(data, sr, FUN, thresh, bktime, plot_peaks, varargin) %Matlab & Octave peaks <- detect_peaks(data, sr, FUN = NULL, thresh = NULL, bktime = NULL, plot_peaks = NULL, ...) #R
Description
This function detects peaks in jerk data that exceed a specified threshold and returns each peak's start time, end time, maximum jerk value, time of the maximum jerk, threshold level, and blanking time.
Inputs
Input var | Description | Units | Default value |
---|---|---|---|
data | A vector (of all positive values) or matrix of data to be used in peak detection. | N/A | N/A |
sr | The sampling rate in Hz of the acceleration signals. This is the same as fs in other tagtools functions. This is used to calculate the bktime in the case that the input for bktime is missing. | Hz | N/A |
FUN | A function to be applied to data before the data is run through the peak detector. Only specify the function name (i.e. 'njerk'). If left blank, the data input will be immediately passed through the peak detector. | N/A | N/A |
thresh | The threshold level above which peaks in the jerk signal are detected. Inputs must be in the same units as the units of jerk (see output peaks). If the input for thresh is missing/empty, the default level is the 0.99 quantile. | N/A | N/A |
bktime | The specified length of time (seconds) between jerk values detected above the threshold value (from the moment the first peak recedes below the threshold level to the moment the second peak surpasses the threshold level) that is required for each value to be considered a separate and unique peak. If the input for bktime is missing/empty the default value for the blanking time is set as the .85 quantile of the vector of time differences for signal values above the specified threshold | seconds | N/A |
plot_peaks | A conditional input. If the input is true or missing/empty, an interactive plot is generated, allowing the user to manipulate the thresh and bktime values and observe the changes in peak detection. If the input is false, a non-interactive plot is generated. Look to the command window for help on how to use the plot upon running of this function. | N/A | N/A |
varargin/… | Additional inputs to be passed to FUN | N/A | N/A |
Outputs
Output var | Description | Units |
---|---|---|
peaks | A structure (Matlab & Octave) or list (R) containing each peak's start time, end time, maximum jerk value, time of the maximum jerk, threshold level, and blanking time. | N/A |
Example
Matlab & Octave
The example below uses data from the file testset3.nc. You can download it from the animaltags website's example data sets. If the file is saved in your current working directory, load it via:
testset3 = load_nc(‘testset3.nc’)
detect_peaks(data = testset3.A.data, sr = testset3.A.sampling_rate, FUN = njerk, thresh = NULL, bktime = NULL, plot_peaks = NULL, fs = testset3.A.sampling_rate)
R
The example below uses data from the file testset3.nc. You can download it from the animaltags website's example data sets. If the file is saved in your current working directory, load it via:
testset3 <- load_nc(‘testset3.nc’)
detect_peaks(data = testset3$A$data, sr = testset3$A$sampling_rate, FUN = njerk, thresh = NULL, bktime = NULL, plot_peaks = NULL, fs = testset3$A$sampling_rate)
About
bugs@animaltags.org Last modified: 27 July 2017