Skip to content

Commit

Permalink
Merge pull request #1054 from wadpac/issue1053_handle_dots_in_filenames
Browse files Browse the repository at this point in the history
Minor issue fixes: handling multiple dots in filenames and clarify documentation for read.myacc.csv
  • Loading branch information
vincentvanhees authored Feb 19, 2024
2 parents 0e78399 + d7eb6e3 commit 96e8fcd
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions R/g.inspectfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -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" = ,
Expand Down
5 changes: 3 additions & 2 deletions R/read.myacc.csv.R
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion man/read.myacc.csv.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion vignettes/GGIR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
2 changes: 1 addition & 1 deletion vignettes/readmyacccsv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 96e8fcd

Please sign in to comment.