Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Package: agcounts
Type: Package
Title: Calculate 'ActiGraph' Counts from Accelerometer Data
Version: 0.6.9
Version: 0.7.0
Authors@R: c(
person(c("Brian", "C."), "Helsel", email = "[email protected]", role = c("aut", "cre")),
person(c("Paul", "R."), "Hibbing", role = "ctb"),
person(c("Robert N."), "Montgomery", role = "ctb"),
person(c("Eric D."), "Vidoni", role = "ctb"),
person("Jonathan", "Clutton", role = "ctb"),
person("John", "Muschelli", role = "ctb"),
person("University of Kansas", role = "cph")
)
Description: Calculate 'ActiGraph' counts from the X, Y, and Z axes of a triaxial
Expand All @@ -20,7 +21,6 @@ Depends:
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
Imports:
data.table,
gsignal,
Expand Down Expand Up @@ -54,3 +54,4 @@ LinkingTo:
RcppArmadillo
URL: https://github.com/bhelsel/agcounts
BugReports: https://github.com/bhelsel/agcounts/issues
Config/roxygen2/version: 8.0.0
10 changes: 5 additions & 5 deletions R/agread.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ agread <- function(path, parser = c("pygt3x", "GGIR", "read.gt3x"), tz = "UTC",
parser <- "GGIR"
}
switch(parser,
"pygt3x" = .pygt3xReader(path = path, verbose = verbose, ...),
"GGIR" = .ggirReader(path = path, verbose = verbose, ...),
"read.gt3x" = .gt3xReader(path = path, verbose = verbose, ...),
"pygt3x" = .pygt3xReader(path = path, verbose = verbose, tz = tz, ...),
"GGIR" = .ggirReader(path = path, verbose = verbose, tz = tz, ...),
"read.gt3x" = .gt3xReader(path = path, verbose = verbose, tz = tz, ...),
stop("No method exists yet for ", sQuote(parser), call. = FALSE)
)
}
Expand All @@ -56,7 +56,7 @@ agread <- function(path, parser = c("pygt3x", "GGIR", "read.gt3x"), tz = "UTC",
# Return Data
colnames(raw) <- c("time", "X", "Y", "Z")
raw$time <- as.POSIXct(raw$time, origin = "1970-01-01 00:00:00", tz=tz)
meta <- read.gt3x::parse_gt3x_info(path)
meta <- read.gt3x::parse_gt3x_info(path, tz = tz)
attr(raw, "start_time") <- meta$`Start Date` %>% lubridate::force_tz(tz)
attr(raw, "stop_time") <- meta$`Stop Date` %>% lubridate::force_tz(tz)
raw
Expand All @@ -66,7 +66,7 @@ agread <- function(path, parser = c("pygt3x", "GGIR", "read.gt3x"), tz = "UTC",
if(verbose) print("Reading data with read.gt3x and calibrating with GGIR.")
I <- GGIR::g.inspectfile(datafile = path)
C <- GGIR::g.calibrate(datafile = path, use.temp = FALSE, printsummary = FALSE, inspectfileobject = I)
raw <- read.gt3x::read.gt3x(path, asDataFrame = TRUE, imputeZeroes = TRUE)
raw <- .gt3xReader(path, tz = tz, verbose = verbose, ...)
raw[, 2:4] <- scale(raw[, 2:4], center = -C$offset, scale = 1/C$scale)
if(C$nhoursused==0) message("\n There is not enough data to perform the GGIR autocalibration method. Returning data as read by read.gt3x.")
raw
Expand Down
12 changes: 7 additions & 5 deletions man/agcounts-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/testthat/test_agread.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ testthat::test_that("Check that data can be read into agcounts using each agread
expect_equal(nrow(rawData), 18000)
expect_equal(ncol(rawData), 4)

invisible(capture.output(rawData <- agread(path = file, parser = "read.gt3x", verbose = FALSE, tz = "EST")))
expect_true(lubridate::tz(rawData$time) == "EST")

raw <- read.gt3x(path = file, asDataFrame = TRUE)
sf <- agcounts:::.get_frequency(raw)
invisible(capture.output(agcalibrated <- agcalibrate(raw)))
Expand Down
Loading