wadpac / GGIR

Code corresponding to R package GGIR
https://wadpac.github.io/GGIR/
Apache License 2.0
99 stars 62 forks source link

Can not process part one, seems to be related to "cannot open the connection" from gzfile(file, "wb") #1224

Open Chinate opened 2 days ago

Chinate commented 2 days ago

Describe the bug When I try to run GGIR function for my data, an error reported from part 3 that "No milestone data found for part(s) 2.", but the problem seems to start from part 1 since "g.part1" reports "[1] "cannot open the connection" $call gzfile(file, "wb")"

To Reproduce

  1. create mydata.csv using the same data as the example presented at the end of "https://cran.r-project.org/web/packages/GGIR/vignettes/readmyacccsv.html".

  2. place it in directory "/Users/zhiyuan/Desktop/2024_8_26/Project/5/test", and create directory "/Users/zhiyuan/Desktop/2024_8_26/Project/5/out".

  3. run ggir_test <- read.myacc.csv(rmc.file = "/Users/zhiyuan/Desktop/2024_8_26/Project/5/test/mydata.csv", rmc.nrow = Inf, rmc.skip = 0, rmc.dec = ".", rmc.firstrow.acc = 2, rmc.col.acc = 2:4, rmc.col.temp = 5, rmc.col.time=1, rmc.unit.acc = "g", rmc.unit.temp = "C", rmc.unit.time = "POSIX", rmc.format.time = "%d/%m/%Y %H:%M:%OS", desiredtz = "Europe/London", rmc.sf = 100), got a list as expected, which contains a data frame with 9 obs with 5 variables.

  4. run g.part1(datadir = "/Users/zhiyuan/Desktop/2024_8_26/Project/5/test", metadatadir = "/Users/zhiyuan/Desktop/2024_8_26/Project/5/out", minimumFileSizeMB = 0, f1 = 1, rmc.nrow = Inf, rmc.skip = 0, rmc.dec = ".", rmc.firstrow.acc = 2, rmc.col.acc = 2:4, rmc.col.temp = 5, rmc.col.time=1, rmc.unit.acc = "g", rmc.unit.temp = "C", rmc.unit.time = "POSIX", rmc.format.time = "%d/%m/%Y %H:%M:%OS", desiredtz = "Europe/London", rmc.sf = 100), got output that says "Error in gzfile(file, "wb") : cannot open the connection In addition: Warning message: In gzfile(file, "wb") : cannot open compressed file 'out//meta/basic/meta_mydata.csv.RData', probable reason 'No such file or directory'"

  5. Sensor brand: '...'

  6. Data format: 'csv'

  7. Approximate recording duration '...' days

  8. Are you using a sleep diary to guide the sleep detection: YES / NO

  9. Copy of R command used: '....'

  10. Have you tried processing your data based on GGIR's default argument values? Does the issue you report still appear? YES

Expected behavior g.part1 is expected to run without this error message

Screenshots CleanShot 2024-11-12 at 02 23 03@2x

Desktop (please complete the following information):

Additional context Also tested with data from https://ftp.cdc.gov/pub/pax_g/ data which contains accelerometer raw data for 7 consecutive days, problem still exists

Before submitting

tarensanders commented 2 days ago

I'm going to jump in to give Vincent a break.

The clue (as always) is in the error message:

cannot open compressed file 'out//meta/basic/meta_mydata.csv.RData', probable reason 'No such file or directory'"

R is trying to save a file to a directory that does not exist. Why doesn't it exist? Well, in g.part1 GGIR checks if the top level meta data folder exists, and if it doesn't it creates it and all of the sub-directories.

https://github.com/wadpac/GGIR/blob/c19ecd334c5d8e4119af5778d9bab40f56ca4106/R/g.part1.R#L50-L56

The problem is that you have created the first directory which passes the check, but not the subsequent directories. There are two ways to solve this:

So all you would be doing is:

GGIR(
             mode=c(1), # This is the same as just running g.part1
             datadir="/Users/zhiyuan/Desktop/2024_8_26/Project/5/test",
             outputdir="/Users/zhiyuan/Desktop/2024_8_26/Project/5/out",
             ...
)