Detect peaks in signal vector data


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

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.

Input var Description Units Default value
data A vector (of all positive values) or matrix of data to be used in peak detection.N/AN/A
srThe 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.HzN/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/AN/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/AN/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 thresholdsecondsN/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/AN/A
varargin/… Additional inputs to be passed to FUNN/AN/A
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

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)

bugs@animaltags.org Last modified: 27 July 2017

  • tagwiki/tools/processing/detect_peaks.txt
  • Last modified: 2018/02/13 23:56
  • by das39