Title: | Peak Functions for Peak Detection in Univariate Time Series |
---|---|
Description: | Provides peak functions, which enable us to detect peaks in time series. The methods implemented in this package are based on Girish Keshav Palshikar (2009) <https://www.researchgate.net/publication/228853276_Simple_Algorithms_for_Peak_Detection_in_Time-Series>. |
Authors: | Shota Ochi [aut, cre, cph] |
Maintainer: | Shota Ochi <[email protected]> |
License: | GPL-3 |
Version: | 0.1.2 |
Built: | 2025-03-07 05:20:03 UTC |
Source: | https://github.com/shotaochi/scorepeak |
Computes max, min, mean, and standard deviation of temporal neighbors.
max_neighbors(data, w, side, boundary = "reflecting") min_neighbors(data, w, side, boundary = "reflecting") mean_neighbors(data, w, side, boundary = "reflecting") sd_neighbors(data, w, side, boundary = "reflecting")
max_neighbors(data, w, side, boundary = "reflecting") min_neighbors(data, w, side, boundary = "reflecting") mean_neighbors(data, w, side, boundary = "reflecting") sd_neighbors(data, w, side, boundary = "reflecting")
data |
a numeric vector. Length of data must be greater than 1. |
w |
window size. w must be odd and greater than 2 and smaller than double length of data. |
side |
determines which side of neighbors of data point will be used in calculation. "left", "l": left temporal neighbors, "right", "r": right temporal neighbors, "both", "b": left and right temporal neighbors, "all", "a": data point and its left and right temporal neighbors. |
boundary |
determines how data points in the beginning and end of the time series will be treated. "reflecting", "r": reflecting boundary condition, "periodic", "p": periodic boundary condition, "discard", "d", discarding data points in the beginning and end of the time series. See the vignette "Introduction to scorepeak" for detail. |
a numeric vector
Shota Ochi
data("ecgca102") max_neighbors(ecgca102, 11, "all") min_neighbors(ecgca102, 11, "all") mean_neighbors(ecgca102, 11, "all") sd_neighbors(ecgca102, 11, "all")
data("ecgca102") max_neighbors(ecgca102, 11, "all") min_neighbors(ecgca102, 11, "all") mean_neighbors(ecgca102, 11, "all") sd_neighbors(ecgca102, 11, "all")
detect local maxima in univariate time series data
detect_localmaxima(data, w = 3, boundary = "reflecting")
detect_localmaxima(data, w = 3, boundary = "reflecting")
data |
a numeric vector. Length of data must be greater than 1. |
w |
window size. w must be odd and greater than 2 and smaller than double length of data. |
boundary |
determines how data points in the beginning and end of the time series will be treated. "reflecting", "r": reflecting boundary condition, "periodic", "p": periodic boundary condition, "discard", "d", discarding data points in the beginning and end of the time series. See the vignette "Introduction to scorepeak" for detail. |
a logical vector. TRUE indicates local peak. FALSE indicates not local peak.
Shota Ochi
data("ecgca102") peaks <- detect_localmaxima(ecgca102) plot(ecgca102, type = "l") points(which(peaks), ecgca102[peaks], pch = 1, col = "red")
data("ecgca102") peaks <- detect_localmaxima(ecgca102) plot(ecgca102, type = "l") points(which(peaks), ecgca102[peaks], pch = 1, col = "red")
This data is a part of ecgca102.edf file of Non-Invasive Fetal Electrocardiogram Database.
data("ecgca102")
data("ecgca102")
a numeric vector
Non-Invasive Fetal Electrocardiogram Database (https://doi.org/10.13026/C2X30H)
Goldberger AL, Amaral LAN, Glass L, Hausdorff JM, Ivanov PCh, Mark RG, Mietus JE, Moody GB, Peng C-K, Stanley HE. PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals. Circulation 101(23):e215-e220 [Circulation Electronic Pages; http://circ.ahajournals.org/cgi/content/full/101/23/e215]; 2000 (June 13).
scorepeak package provides several types of peak function. See the vignette "Introduction to scorepeak" for detail.
score_type1(data, w, boundary = "reflecting") score_type2(data, w, boundary = "reflecting") score_type3(data, w, boundary = "reflecting")
score_type1(data, w, boundary = "reflecting") score_type2(data, w, boundary = "reflecting") score_type3(data, w, boundary = "reflecting")
data |
a numeric vector. Length of data must be greater than 1. |
w |
window size. w must be odd and greater than 2 and smaller than double length of data. |
boundary |
determines how data points in the beginning and end of the time series will be treated. "reflecting", "r": reflecting boundary condition, "periodic", "p": periodic boundary condition, "discard", "d", discarding data points in the beginning and end of the time series. See the vignette "Introduction to scorepeak" for detail. |
a numeric vector
Shota Ochi
data("ecgca102") plot(ecgca102, type = "l", ylim = c(-0.38, 0.53)) points(seq(length(ecgca102)), score_type1(ecgca102, 51), col = "red", type = "l") points(seq(length(ecgca102)), score_type2(ecgca102, 51), col = "blue", type = "l") points(seq(length(ecgca102)), score_type3(ecgca102, 51), col = "green", type = "l")
data("ecgca102") plot(ecgca102, type = "l", ylim = c(-0.38, 0.53)) points(seq(length(ecgca102)), score_type1(ecgca102, 51), col = "red", type = "l") points(seq(length(ecgca102)), score_type2(ecgca102, 51), col = "blue", type = "l") points(seq(length(ecgca102)), score_type3(ecgca102, 51), col = "green", type = "l")
scorepeak provides peak functions and its building blocks. Peak functions enable us to detect peaks.