Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug capabilities for agcalibrate #38

Merged
merged 4 commits into from
Jun 5, 2024
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
4 changes: 2 additions & 2 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

gcalibrateC <- function(pathname = NULL, dataset = NULL, sf = NA_integer_) {
.Call(`_agcounts_gcalibrateC`, pathname, dataset, sf)
gcalibrateC <- function(pathname = NULL, dataset = NULL, sf = NA_integer_, debug = FALSE) {
.Call(`_agcounts_gcalibrateC`, pathname, dataset, sf, debug)
}

#' Upsample data if frequency is 30, 60, or 90 Hertz
Expand Down
7 changes: 5 additions & 2 deletions R/agread.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ agread <- function(path, parser = c("pygt3x", "GGIR", "read.gt3x"), tz = "UTC",
#' @param tz the desired timezone, Default: \code{UTC}
#' @param imputeTimeGaps Imputes gaps in the raw acceleration data, Default: FALSE
#' @param ... Additional arguments to pass into the agread function
#' @param debug print out diagnostic information for C++ code
#' @return Returns the calibrated raw acceleration data
#' @details This function uses a C++ implementation of the GGIR `g.calibrate` function to
#' return calibrated raw acceleration data.
Expand All @@ -101,10 +102,12 @@ agread <- function(path, parser = c("pygt3x", "GGIR", "read.gt3x"), tz = "UTC",
#' @importFrom data.table setDT setDF


agcalibrate <- function(raw, verbose = FALSE, tz = "UTC", imputeTimeGaps = FALSE, ...){
agcalibrate <- function(raw, verbose = FALSE, tz = "UTC", imputeTimeGaps = FALSE, ...,
debug = FALSE){
if(any(.get_sleep(raw))) stop("Calibration requires the data to be imported without imputed zeros.")
sf = .get_frequency(raw)
C <- gcalibrateC(dataset = as.matrix(raw[, c("X", "Y", "Z")]), sf = sf)
C <- gcalibrateC(dataset = as.matrix(raw[, c("X", "Y", "Z")]), sf = sf,
debug = as.logical(debug))

if(imputeTimeGaps){
if("last_sample_time" %in% names(attributes(raw))){
Expand Down
11 changes: 10 additions & 1 deletion man/agcalibrate.Rd

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

6 changes: 5 additions & 1 deletion man/agcounts-package.Rd

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

9 changes: 5 additions & 4 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// gcalibrateC
Rcpp::List gcalibrateC(Rcpp::Nullable<Rcpp::String> pathname, Rcpp::Nullable<Rcpp::NumericMatrix> dataset, int sf);
RcppExport SEXP _agcounts_gcalibrateC(SEXP pathnameSEXP, SEXP datasetSEXP, SEXP sfSEXP) {
Rcpp::List gcalibrateC(Rcpp::Nullable<Rcpp::String> pathname, Rcpp::Nullable<Rcpp::NumericMatrix> dataset, int sf, const bool debug);
RcppExport SEXP _agcounts_gcalibrateC(SEXP pathnameSEXP, SEXP datasetSEXP, SEXP sfSEXP, SEXP debugSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::Nullable<Rcpp::String> >::type pathname(pathnameSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable<Rcpp::NumericMatrix> >::type dataset(datasetSEXP);
Rcpp::traits::input_parameter< int >::type sf(sfSEXP);
rcpp_result_gen = Rcpp::wrap(gcalibrateC(pathname, dataset, sf));
Rcpp::traits::input_parameter< const bool >::type debug(debugSEXP);
rcpp_result_gen = Rcpp::wrap(gcalibrateC(pathname, dataset, sf, debug));
return rcpp_result_gen;
END_RCPP
}
Expand All @@ -38,7 +39,7 @@ END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_agcounts_gcalibrateC", (DL_FUNC) &_agcounts_gcalibrateC, 3},
{"_agcounts_gcalibrateC", (DL_FUNC) &_agcounts_gcalibrateC, 4},
{"_agcounts_upsampleC", (DL_FUNC) &_agcounts_upsampleC, 2},
{NULL, NULL, 0}
};
Expand Down
Loading
Loading