Skip to content

Commit 25fa760

Browse files
authored
Merge pull request #45 from PhysicalActivityOpenTools/issue41_documentation
include references on nonwear and sleep
2 parents 46e84da + 88425e3 commit 25fa760

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

R/classifySleep.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#' @return Numeric vector with classified activities including nighttime and sleep.
2424
#' @export
2525
#' @references GGIR R Package. doi: 10.1123/jmpb.2018-0063
26+
#' @references Ahmadi MN, Nathan N, Sutherland R, Wolfenden L, Trost SG. Non-wear
27+
#' or sleep? Evaluation of five non-wear detection algorithms for raw accelerometer
28+
#' data. J Sports Sci. 2020 Feb;38(4):399-404. doi: 10.1080/02640414.2019.1703301
2629
#' @author Matthew N. Ahmadi <[email protected]>
2730
classifySleep = function(anglez, starttime, classifier, infoClassifier, ts, do.sleep, do.nonwear) {
2831
# original code provided by Matthew N. Ahmadi
@@ -95,7 +98,6 @@ classifySleep = function(anglez, starttime, classifier, infoClassifier, ts, do.s
9598
e = which(ts$nonwear == 2)
9699
if (length(e) > 0) ts$activity[e] = nighttime_id
97100
# DETECT SLEEP WITHIN THE NIGHTTIME
98-
99101
ts$sleep_windows_orig = ts$nighttime
100102
ts$sleep_periods = rep(0,nrow(ts))
101103
if (any(ts$activity == nighttime_id)) {

R/detectNonWear.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
#' @return Numeric vector of length = nrow(data) indicating wear (0) and nonwear (1).
1818
#' @export
1919
#' @references GGIR R Package. doi: 10.1123/jmpb.2018-0063
20-
#' @references van Hees VT, Renström F, Wright A, Gradmark A, Catt M, Chen KY,
21-
#' Löf M, Bluck L, Pomeroy J, Wareham NJ, Ekelund U, Brage S, Franks PW.
22-
#' Estimation of daily energy expenditure in pregnant and non-pregnant women
23-
#' using a wrist-worn tri-axial accelerometer. PLoS One. 2011;6(7):e22922.
24-
#' doi: 10.1371/journal.pone.0022922
20+
#' @references Ahmadi MN, Nathan N, Sutherland R, Wolfenden L, Trost SG. Non-wear
21+
#' or sleep? Evaluation of five non-wear detection algorithms for raw accelerometer
22+
#' data. J Sports Sci. 2020 Feb;38(4):399-404. doi: 10.1080/02640414.2019.1703301
2523
#' @author Matthew N. Ahmadi <[email protected]>
2624
detectNonWear = function(data, sf, epoch, sdThreshold = 13/1000) {
2725
# original code provided by Matthew N. Ahmadi

R/inbed.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
#'
1111
#' @return List with identificators of inbed time.
1212
#' @export
13+
#' @references GGIR R Package. doi: 10.1123/jmpb.2018-0063
14+
#' @references van Hees VT, Sabia S, Jones SE, Wood AR, Anderson KN, Kivimäki M,
15+
#' Frayling TM, Pack AI, Bucan M, Trenell MI, Mazzotti DR, Gehrman PR, Singh-Manoux BA,
16+
#' Weedon MN. Estimating sleep parameters using an accelerometer without sleep diary.
17+
#' Sci Rep. 2018 Aug 28;8(1):12975. doi: 10.1038/s41598-018-31266-z.
18+
#' @references Ahmadi MN, Nathan N, Sutherland R, Wolfenden L, Trost SG. Non-wear
19+
#' or sleep? Evaluation of five non-wear detection algorithms for raw accelerometer
20+
#' data. J Sports Sci. 2020 Feb;38(4):399-404. doi: 10.1080/02640414.2019.1703301
1321
#' @author Matthew N. Ahmadi <[email protected]>
1422
inbed = function(angle, k = 60, perc = 0.1, inbedthreshold = 15,
1523
bedblocksize = 30, outofbedsize = 60, ws3 = 5) {
@@ -27,8 +35,7 @@ inbed = function(angle, k = 60, perc = 0.1, inbedthreshold = 15,
2735
nomov = c(0, nomov, 0)
2836
s1 = which(diff(nomov) == 1)
2937
e1 = which(diff(nomov) == -1)
30-
bedblock = which((e1 - s1) > ((60/ws3) * bedblocksize *
31-
1))
38+
bedblock = which((e1 - s1) > ((60/ws3) * bedblocksize * 1))
3239
if (length(bedblock) > 0) {
3340
s2 = s1[bedblock]
3441
e2 = e1[bedblock]

0 commit comments

Comments
 (0)