Skip to content

Commit

Permalink
Merge pull request #1158 from wadpac/issues1155_chunksize_1154_adhoccsv
Browse files Browse the repository at this point in the history
Reduce constraints on value of chunksize and make sure time gap imputation cal also run for adhoc csv
  • Loading branch information
vincentvanhees authored Jun 24, 2024
2 parents db8a657 + 0cf0c8e commit 756e1f3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: GGIR
Type: Package
Title: Raw Accelerometer Data Analysis
Version: 3.1-1
Date: 2024-06-04
Version: 3.1-2
Date: 2024-06-26
Authors@R: c(person("Vincent T","van Hees",role=c("aut","cre"),
email="[email protected]"),
person("Jairo H","Migueles",role="aut",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- Report part 5: fix bug that was introduced on 2024-Feb-19 in the calculation of wear percentage #1148

- Part 1: Enable timegap imputation for ad-hoc csv data. #1154

- Part 1: Reduce constraints on value for parameter chunksize #1155.

- Report part 5: Rename variable sleep_efficiency to sleep_efficiency_after_onset, #1157

- Vignette: Migrated many sections from main CRAN vignette to wadpac.github.io/GGIR/
Expand Down
3 changes: 1 addition & 2 deletions R/check_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ check_params = function(params_sleep = c(), params_metrics = c(),
check_class("Raw data", params = params_rawdata, parnames = boolean_params, parclass = "boolean")
check_class("Raw data", params = params_rawdata, parnames = character_params, parclass = "character")

if (params_rawdata[["chunksize"]] > 1.5) params_rawdata[["chunksize"]] = 1.5
if (params_rawdata[["chunksize"]] < 0.2) params_rawdata[["chunksize"]] = 0.2
if (params_rawdata[["chunksize"]] < 0.05) params_rawdata[["chunksize"]] = 0.05
}
if (length(params_247) > 0) {
# iglevels and qwindow can be numeric or character, so not tested
Expand Down
6 changes: 4 additions & 2 deletions R/g.getmeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,17 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
}
}

if (params_rawdata[["imputeTimegaps"]] && (dformat == FORMAT$CSV || dformat == FORMAT$GT3X)) {
if (params_rawdata[["imputeTimegaps"]] && (dformat == FORMAT$CSV ||
dformat == FORMAT$AD_HOC_CSV ||
dformat == FORMAT$GT3X)) {
P = g.imputeTimegaps(data, sf = sf, k = 0.25,
PreviousLastValue = PreviousLastValue,
PreviousLastTime = PreviousLastTime,
epochsize = c(ws3, ws2))
data = P$x
PreviousLastValue = data[nrow(data), c("x", "y", "z")]
if ("time" %in% colnames(data)) {
PreviousLastTime = as.POSIXct(data$time[nrow(data)])
PreviousLastTime = as.POSIXct(data$time[nrow(data)], origin = "1970-1-1")
} else {
PreviousLastTime = NULL
}
Expand Down
4 changes: 4 additions & 0 deletions R/g.imputeTimegaps.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ g.imputeTimegaps = function(x, sf, k=0.25, impute = TRUE,
}
# refill if first value is not consecutive from last value in previous chunk
if (!is.null(PreviousLastTime)) {
if (!inherits(x = PreviousLastTime, what = "numeric") &&
inherits(x = x$time[1], what = "numeric")) {
PreviousLastTime = as.numeric(PreviousLastTime)
}
first_deltatime = diff(c(PreviousLastTime, x$time[1]))
if (!is.numeric(first_deltatime)) { # in csv axivity, the time is directly read as numeric (seconds)
units(first_deltatime) = "secs"
Expand Down
7 changes: 5 additions & 2 deletions man/GGIR.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,15 @@ GGIR(mode = 1:5,
\item{chunksize}{
Numeric (default = 1).
Value between 0.2 and 1 to specify the size of chunks to be
Value to specify the size of chunks to be
loaded as a fraction of an approximately 12 hour period for auto-calibration
procedure and as fraction of 24 hour period for the metric calculation, e.g.,
0.5 equals 6 and 12 hour chunks, respectively.
For machines with less than 4Gb of RAM memory or with < 2GB memory per process
when using \code{do.parallel = TRUE} a value below 1 is recommended.}
when using \code{do.parallel = TRUE} a value below 1 is recommended.
The value is constrained by GGIR to not be lower than 0.05. Please note that
setting 0.05 will not produce output when 3rd value of parameter windowsizes
is 3600.}
\item{dynrange}{
Numeric (default = NULL).
Expand Down

0 comments on commit 756e1f3

Please sign in to comment.