Skip to content

Commit

Permalink
fixes #53
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvanhees committed Dec 1, 2023
1 parent 0694fd1 commit 44fa412
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Description: For processesing accelerometer data generated in the mechanical sha
URL: https://github.com/wadpac/mechanicalshakerexperiments
License: Apache License version 2.0 | file LICENSE
Suggests: testthat, covr, knitr, rmarkdown
Imports: gdata, doParallel, foreach, GENEAread, GGIR, GGIRread, read.gt3x, data.table, lubridate, signal, zoo, ggplot2, ggpubr, pracma, readxl, viridis
Imports: doParallel, foreach, GENEAread, GGIR, GGIRread, read.gt3x, data.table, lubridate, signal, zoo, ggplot2, ggpubr, pracma, readxl, viridis
Depends: stats, utils, R (>= 3.5.0)
NeedsCompilation: no
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
Encoding: UTF-8
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ importFrom(GGIR,g.downsample)
importFrom(GGIRread,readAxivity)
importFrom(GGIRread,resample)
importFrom(data.table,fread)
importFrom(gdata,read.xls)
importFrom(ggplot2,scale_x_discrete)
importFrom(graphics,abline)
importFrom(graphics,plot)
Expand Down
18 changes: 14 additions & 4 deletions R/getwindows.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' @param data Data object
#' @param experimentfile .xlsx file with protocol description, defaults to file stored inside the code
#' @return List of data.frames with the accelerometer time series where each list item represents 1 recording
#' @importFrom gdata read.xls
#' @export


Expand All @@ -17,12 +16,24 @@ getwindows <- function(brand, experiment, path, data, experimentfile = c()) {
if (length(experimentfile) == 0) {
experimentfile = system.file("datadescription/data_description.xlsx", package = "mechanicalshakerexperiments")[1]
}
description <- gdata::read.xls(experimentfile, header = TRUE)
tz = "Europe/Amsterdam"
description <- as.data.frame(readxl::read_excel(path = experimentfile, col_types = "text"))
for (jj in 7:8) {
description[, jj] = suppressWarnings(format(x = as.POSIXct(as.numeric(description[, jj]) * (60*60*24),
origin = "1899-12-30",
tz = tz),
format = "%H:%M:%S"))
}
description[, 2] = suppressWarnings(format(x = as.POSIXct(as.numeric(description[, 2]) * (60*60*24),
origin = "1899-12-30",
tz = tz),
format = "%Y-%m-%d"))

description <- description[which(description$experiment == experiment),]
# Calculate indices for the windows to select
start_time <- c()
end_time <- c()
tz = "Europe/Amsterdam"

if (experiment == "box") {
start <- strftime(toString(paste(description$date[1], description$start_time[1]), sep = " "), format = "%Y-%m-%d %H:%M:%OS2", tz = tz)
start_time <- start
Expand Down Expand Up @@ -58,7 +69,6 @@ getwindows <- function(brand, experiment, path, data, experimentfile = c()) {
selected_data <- data.frame()
#Select the windows
cat("file ")
tz = "Europe/Amsterdam"
for(pp in 1:length(data)) { # pp is file number?
cat(paste0(" ",pp))
if (brand %in% c("Axivity", "GENEActiv")) {
Expand Down
3 changes: 1 addition & 2 deletions R/loaddata.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ loaddata <- function(path, brand, experiment, windows = TRUE, experimentfile, ac
cl <- parallel::makeCluster(Ncores) #not to overload your computer
doParallel::registerDoParallel(cl)
i = NULL

`%myinfix%` = foreach::`%dopar%`
parallelLoad <- function(file_path, file_list, brand, experiment, windows, path) {
foreach::foreach(i = 1:length(file_list), .packages = c("read.gt3x", "GGIRread", "GENEAread"),
Expand Down Expand Up @@ -214,7 +213,7 @@ loaddata <- function(path, brand, experiment, windows = TRUE, experimentfile, ac
}
if (brand %in% c("Axivity", "GENEActiv") == FALSE) {
rawdata = rawdata[which(rawdata$time >= start & rawdata$time <= end),]
}else {
} else {
if (brand == "GENEActiv") {
rawdata$data.out = rawdata$data.out[which(rawdata$data.out$time >= start & rawdata$data.out$time <= end),]
} else if (brand == "Axivity") {
Expand Down

0 comments on commit 44fa412

Please sign in to comment.