Skip to content

Commit

Permalink
Merge pull request #104 from habitus-eu/issue103_GGIRmode
Browse files Browse the repository at this point in the history
Use GGIR parameter mode as specified by GUI user
  • Loading branch information
vincentvanhees authored Mar 25, 2024
2 parents 64760ab + bc609c6 commit 233485e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 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
2 changes: 1 addition & 1 deletion .github/workflows/r_new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
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
7 changes: 4 additions & 3 deletions 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
\item Fix issue with old activityCounts dependency that was not
correctly deprecated in the previous release
\item Add hbGIS parameter documentation for use inside the GUI
\item Added 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 233485e

Please sign in to comment.