From cd85a2397e2a5e2044b1cfdf34f71c1cf2d38beb Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Mon, 19 Feb 2024 18:42:29 +0100 Subject: [PATCH 1/4] fixes #1053 --- R/g.inspectfile.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/g.inspectfile.R b/R/g.inspectfile.R index 17dcb9b4b..b3b504834 100644 --- a/R/g.inspectfile.R +++ b/R/g.inspectfile.R @@ -28,8 +28,8 @@ g.inspectfile = function(datafile, desiredtz = "", params_rawdata = c(), # the output of this function for the original datafile is stored inside the RData file in the form of object I getbrand = function(filename = c(), datafile = c()) { sf = c(); isitageneactive = c(); mon = c(); dformat = c() #generating empty variables - extension = unlist(strsplit(filename,"[.]"))[2] - + extension = unlist(strsplit(filename,"[.]")) + extension = extension[length(extension)] switch(extension, "bin" = { dformat = FORMAT$BIN }, "cwa" = , From 7ae94f7d952d74570fb9360aeec39c71e2ad571a Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Mon, 19 Feb 2024 18:52:21 +0100 Subject: [PATCH 2/4] force user to specify rmc.firstrow.acc, fixes #1034 - update documentation to clarify to specify rmc.firstrow.acc - change default to NULL to make sure read.myacc.csv can also not run when and show error when not specified. --- R/read.myacc.csv.R | 5 +++-- man/read.myacc.csv.Rd | 2 +- vignettes/readmyacccsv.Rmd | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/R/read.myacc.csv.R b/R/read.myacc.csv.R index 6feb08c4c..41a907b72 100644 --- a/R/read.myacc.csv.R +++ b/R/read.myacc.csv.R @@ -1,5 +1,5 @@ read.myacc.csv = function(rmc.file=c(), rmc.nrow=Inf, rmc.skip=c(), rmc.dec=".", - rmc.firstrow.acc = 1, rmc.firstrow.header=c(), + rmc.firstrow.acc = c(), rmc.firstrow.header=c(), rmc.header.length = c(), rmc.col.acc = 1:3, rmc.col.temp = c(), rmc.col.time=c(), rmc.unit.acc = "g", rmc.unit.temp = "C", @@ -63,7 +63,8 @@ read.myacc.csv = function(rmc.file=c(), rmc.nrow=Inf, rmc.skip=c(), rmc.dec=".", } if (is.null(rmc.firstrow.acc) || rmc.firstrow.acc < 1) { - rmc.firstrow.acc = 1 + stop(paste0("\nParameter rmc.firstrow.acc always need to be specified ", + "when working with ad-hoc csv format data")) } skip = rmc.firstrow.acc - 1 if (!is.null(rmc.skip) && length(rmc.skip) > 0) { diff --git a/man/read.myacc.csv.Rd b/man/read.myacc.csv.Rd index 75c355689..6daff06fb 100644 --- a/man/read.myacc.csv.Rd +++ b/man/read.myacc.csv.Rd @@ -11,7 +11,7 @@ } \usage{ read.myacc.csv(rmc.file=c(), rmc.nrow=Inf, rmc.skip = c(), rmc.dec=".", - rmc.firstrow.acc = 1, rmc.firstrow.header=c(), + rmc.firstrow.acc = c(), rmc.firstrow.header=c(), rmc.header.length = c(), rmc.col.acc = 1:3, rmc.col.temp = c(), rmc.col.time=c(), diff --git a/vignettes/readmyacccsv.Rmd b/vignettes/readmyacccsv.Rmd index fb0f30837..b30047bf3 100644 --- a/vignettes/readmyacccsv.Rmd +++ b/vignettes/readmyacccsv.Rmd @@ -42,7 +42,7 @@ Internally GGIR loads csv files with accelerometer data and standardises the out # The read.myacc.csv function -As for the rest of GGIR functions, `read.myacc.csv` is intended to be used within function `GGIR`. All the arguments of the `read.myacc.csv` can be easily recognized as they all start by "rmc". The GGIR function checks whether the argument rmc.firstrow.acc is provided by the user; in such case, GGIR will derive the reading of the data to the `read.myacc.csv`. +As for the rest of GGIR functions, `read.myacc.csv` is intended to be used within function `GGIR`. All the arguments of the `read.myacc.csv` can be easily recognized as they all start by "rmc". The GGIR function checks whether the argument `rmc.firstrow.acc` is provided by the user; in such case, GGIR will attempt to read the data with `read.myacc.csv`. In other words you always need to specify `rmc.firstrow.acc` to use `read.myacc.csv`. ## Input arguments From 2af302f45bd4a30ee27004c7351ba3c978f06da6 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Mon, 19 Feb 2024 18:52:38 +0100 Subject: [PATCH 3/4] minor improvement to documentation of behaviouralcodes.csv --- vignettes/GGIR.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/GGIR.Rmd b/vignettes/GGIR.Rmd index 9e1aa73b6..eddd4e38e 100644 --- a/vignettes/GGIR.Rmd +++ b/vignettes/GGIR.Rmd @@ -1660,7 +1660,7 @@ correspond to the date of analysis. | invalidepoch | Is 1 if epoch was detect as invalid (e.g. non-wear), 0 if not. | | guider | Number to indicate what guider type was used, where 1=sleeplog, 2=HDCZA, 3=swetwindow, 4=L512, 5=HorAngle, 6=NotWorn | | window | Numeric indicator of the analysis window in the recording. If timewindow = "MM" then these correspond to calendar days, if timewindow = "WW" then these correspond to which wakingup-wakingup window in the recording, if timewindow = "OO" then these correspond to which sleeponset-sleeponset window in the recording. So, in a recording of one week you may find window numbers 1, 2, 3, 4, 5 and 6.| -| class_id | The behavioural class codes are documented in the exported csv file meta/ms5outraw/behaviouralcodes.csv. Class codes above class 8 will be analysis specific, because it depends on the number time variants of the bouts used. For example, if you look at MVPA lasting 1-10, 10-20, 30-40 then all of them will have their own class_id. | +| class_id | The behavioural class codes are documented in the exported csv file meta/ms5outraw/behaviouralcodes.csv. Class codes above class 8 will be analysis specific, because it depends on the number time variants of the bouts used. For example, if you look at MVPA lasting 1-10, 10-20, 30-40 then all of them will have their own class_id. In behaviouralcodes.csv you will find a column with class_names which match the behavioural classes as reported in the part 5 report. | | invalid_fullwindow | Fraction of the window (see above) that represents invalid data. I added this to make it easier to filter the timeseries based on whether days are valid or not. | | invalid_sleepperiod | Fraction of SPT within the current window that represents invalid data. | | invalid_wakinghours | Fraction of SPT within the current window that represents invalid data. | From d7eb6e3bc67f7bc8ccc046200cf716ddee8e84ca Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Mon, 19 Feb 2024 18:57:31 +0100 Subject: [PATCH 4/4] Update NEWS.md --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 09091601c..e1bf2433e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # CHANGES IN GGIR VERSION 3.0-6 +- Part 1: Need to specify rmc.firstrow.acc when working with ad-hoc csv file format now better documented and read.myacc.csv now produces an error when used directly and user forgets to specify rmc.firstrow.acc #1034. + - Part 1: - Improved readability and maintainability of the code #1027