This R Package reads the X, Y, and Z axes in a GT3X accelerometer file and converts it to Actigraphy counts. This work was inspired by Neishabouri et al. who released a preprint of "Quantification of Acceleration as Activity Counts in ActiGraph Wearables" on February 24, 2022. Here are the links to the article and Python implementation of this code on GitHub.
install.packages("devtools")
devtools::install_github("bhelsel/agcounts")
library(agcounts)
# path = "Full pathname to the GT3X file", e.g.:
path = system.file("extdata/example.gt3x", package = "agcounts")
get_counts(path = path, epoch = 60, write.file = FALSE, return.data = TRUE)
# path = "Full pathname to the GT3X file", e.g.:
path = system.file("extdata/example.gt3x", package = "agcounts")
get_counts(path = path, epoch = 60, write.file = TRUE, return.data = FALSE)
folder = "Full pathname to the folder where the GT3X files are stored"
files = list.files(path = folder, pattern = ".gt3x", full.names = TRUE)
sapply(files, get_counts, epoch = 60, write.file = TRUE, return.data = FALSE)
folder = "Full pathname to the folder where the GT3X files are stored"
files = list.files(path = folder, pattern = ".gt3x", full.names = TRUE)
cores = parallel::detectCores()
Ncores = cores - 1
cl = parallel::makeCluster(Ncores)
doParallel::registerDoParallel(cl)
`%dopar%` = foreach::`%dopar%`
foreach::foreach(i = files, .packages = "agcounts") %dopar% {
get_counts(path = i, epoch = 60, write.file = TRUE, return.data = FALSE)
}
parallel::stopCluster(cl)