From 24794b75f82add0ba1eb6fe65f15ccf9d20e6165 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Fri, 28 Jun 2024 17:41:06 +0200 Subject: [PATCH] re-insert option to control HDCZA internal thresholds, but let them default to the thresholds used in the paper. --- R/HASPT.R | 7 +++++-- man/GGIR.Rd | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/R/HASPT.R b/R/HASPT.R index 6fd651aa0..ac11a7a48 100644 --- a/R/HASPT.R +++ b/R/HASPT.R @@ -1,5 +1,5 @@ HASPT = function(angle, sptblocksize = 30, spt_max_gap = 60, ws3 = 5, - HASPT.algo="HDCZA", HDCZA_threshold = 0.2, invalid, + HASPT.algo="HDCZA", HDCZA_threshold = c(), invalid, HASPT.ignore.invalid=FALSE, activity = NULL) { tib.threshold = SPTE_start = SPTE_end = part3_guider = c() # internal functions --------- @@ -25,7 +25,10 @@ HASPT = function(angle, sptblocksize = 30, spt_max_gap = 60, ws3 = 5, x = zoo::rollapply(angle, width = k1, FUN = medabsdi, fill = 0) # 5 minute rolling median of the absolute difference if (is.null(HDCZA_threshold)) { - threshold = quantile(x, probs = 0.1) * 15 + HDCZA_threshold = c(10, 15) + } + if (length(HDCZA_threshold) == 2) { + threshold = quantile(x, probs = HDCZA_threshold[1] / 100) * HDCZA_threshold[2] if (threshold < 0.13) { threshold = 0.13 } else if (threshold > 0.50) { diff --git a/man/GGIR.Rd b/man/GGIR.Rd index d100a8ed7..07a6130d0 100755 --- a/man/GGIR.Rd +++ b/man/GGIR.Rd @@ -1159,7 +1159,9 @@ GGIR(mode = 1:5, et al. 2018 Scientific Report (doi: 10.1038/s41598-018-31266-z). However, doing so has not been supported by research yet and is only intended to facilitate methodological research, so we advise sticking with the default in - line with the publication. + line with the publication. Further, if HDCZA_threshold is set to a numeric vector of + length 2, e.g. c(10, 15), that will be used as percentile and + multiplier for the above mentioned 6th step. } \item{HASPT.ignore.invalid}{