Skip to content

Commit

Permalink
use GGIR parameter mode from config file, fixes #103
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvanhees committed Mar 25, 2024
1 parent 64760ab commit 4aad6f2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CONTRIBUTING.md
INSTRUCTIONS_TOOL_MAINTAINERS.md
UCloud_files
HabitusGUIbookmark.RData
codecov.yml
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Package: HabitusGUI
Title: R Shiny App for Processing Behavioural Data
Description: Shiny app to ease processing behavioural data with research software such as GGIR, hbGPS,and hbGIS.
Version: 0.3.2
Date: 2024-03-24
Date: 2024-03-25
Authors@R:
c(person(given = "Vincent",
family = "van Hees",
role = c("aut", "cre"),
email = "[email protected]"))
License: Apache License version 2.0 | file LICENSE
Imports: shiny, shinyFiles, GGIR, bslib, methods, jsonlite, DT,
magrittr, shinyjs, callr, hbGPS, hbGIS
magrittr, shinyjs, callr, hbGPS, hbGIS, data.table
Remotes: habitus-eu/hbGPS, habitus-eu/hbGIS
LazyData: true
Suggests: testthat, covr, rmarkdown
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import(hbGPS)
import(shiny)
import(shinyFiles)
importFrom(callr,r_bg)
importFrom(data.table,fread)
importFrom(hbGIS,hbGIS)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)
Expand Down
29 changes: 26 additions & 3 deletions R/GGIRshiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,35 @@
#' @return no object is returned, only a new file is created in the output directory
#' @import GGIR
#' @importFrom utils write.table
#' @importFrom data.table fread
#' @export
#'

GGIRshiny = function(rawaccdir, outputdir, sleepdiary = c(), configfile = c()) {
if (length(sleepdiary) == 0) sleepdiary = c()
if (length(configfile) == 0) configfile = c()
if (length(configfile) == 0) {
configfile = c()
modeIS = ""
} else {
configfile = "D:/Dropbox/Work/sharedfolder/DATA/Habitus/GPSprocessing/JosefMarch2024/config_GGIR_counts.csv"
# extract mode from config file
config = data.table::fread(file = configfile, data.table = FALSE)
modeChar = config$value[which(config$argument == "mode")]
# check that mode is nothing more than a numeric vector
checkMode = suppressWarnings(as.numeric(gsub(x = modeChar, pattern = "c|[(]|[)]|:|,", replacement = "")))
if (is.numeric(checkMode) == FALSE) {
stop("\nUnexpected value for parameter mode")
} else {
modeNum = eval(parse(text = modeChar))
}
if (min(modeNum) > 0 && max(modeNum) <= 6) {
# use mode value from config file if values are plausible
modeIS = paste0(", mode = ", modeChar)
} else {
# do not use mode value and let GGIR use its default
modeIS = ""
}
}

# create R script with the code to run the data analysis via a command line call
# in this way turning off or restarting the app will not kill the data analysis
Expand All @@ -25,10 +48,10 @@ GGIRshiny = function(rawaccdir, outputdir, sleepdiary = c(), configfile = c()) {
"if (length(args) == 4) {",
"GGIR::GGIR(datadir = args[1], outputdir = args[2], ",
"configfile = args[3], loglocation = args[4],",
"do.parallel = TRUE)",
"do.parallel = TRUE", modeIS,")",
"} else {",
"GGIR::GGIR(datadir = args[1], outputdir = args[2], ",
"configfile = args[3], do.parallel = TRUE)",
"configfile = args[3], do.parallel = TRUE", modeIS,")",
"}"),
fileConn)
close(fileConn)
Expand Down
3 changes: 2 additions & 1 deletion inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
\name{NEWS}
\title{News for Package \pkg{HabitusGUI}}
\newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
\section{Changes in version 0.3.2 (GitHub-only-release date: 20-03-2024)}{
\section{Changes in version 0.3.2 (GitHub-only-release date: 25-03-2024)}{
\itemize{
\item Changed default for save_ms5rawlevels in template config.csv to TRUE
\item Fix issue with old activityCounts dependency that we was not
correctly deprecated in the previous release
\item Add hbGIS parameter documentation for use inside the GUI
\item Now uses GGIR parameter mode as set by user and do not fall back on GGIR default, fixes #103
}
}
\section{Changes in version 0.3.1 (GitHub-only-release date: 22-01-2024)}{
Expand Down

0 comments on commit 4aad6f2

Please sign in to comment.