Skip to content

Commit

Permalink
store activity and sleep log to RData file with filename that reflect…
Browse files Browse the repository at this point in the history
…s the input diary to ensure it is ignored if new sleeplog with a different name is selected
  • Loading branch information
vincentvanhees committed Jan 23, 2025
1 parent 349e7bb commit 8e7f4a8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
7 changes: 2 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

- Part 2:

- Fix bug in determining the number of files to be included in the part 2 report.
It may affect the part 2 csv report which may have had less recordings than expected
even though the missing recordings are just processed and visible in the output of
subsequent parts. #1252
- Fix bug in determining the files to be included in the part 2 report, which only considered the first N files processed by part 2 while using this N when working a file name list produced by part 1 which can be longer #1252

- Speed up activity diary extraction. #1250

Expand All @@ -17,7 +14,7 @@
boutcriter.mvpa). #1247

- Part 2 and 4: Both activity diary and sleep diary are now always reloaded if the derived
copy of it (in .RData) is older than the diary itself. #1250
copy of it (in .RData) is older than the diary itself or if the diary name has changed. #1250

- Visual report: Recently added visual report is now also able to handle epoch sizes not equal
to 1 minutes, and now also able to handle recordings
Expand Down
2 changes: 1 addition & 1 deletion R/g.part2.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ g.part2 = function(datadir = c(), metadatadir = c(), f0 = c(), f1 = c(),
# note that this filtering is only use if parameter nonwearFiltermaxHours is specified.
use_qwindow_as_diary = FALSE
}
tmp_activityDiary_file = paste0(metadatadir, "/meta/activityDiary.RData")
tmp_activityDiary_file = paste0(metadatadir, "/meta/activityDiary_", basename(params_247[["qwindow"]]), ".RData")

if (!file.exists(tmp_activityDiary_file) || (file.exists(tmp_activityDiary_file) &&
file.info(params_247[["qwindow"]])$mtime >= file.info(tmp_activityDiary_file)$mtime)) {
Expand Down
2 changes: 1 addition & 1 deletion R/g.part4.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ g.part4 = function(datadir = c(), metadatadir = c(), f0 = f0, f1 = f1,
dolog = FALSE
}
if (dolog == TRUE) {
sleeplogRDataFile = paste0(metadatadir,"/meta/sleeplog.RData")
sleeplogRDataFile = paste0(metadatadir,"/meta/sleeplog_", basename(params_sleep[["loglocation"]]), ".RData")
# only re-process sleeplog if sleeplog.RData does not exist or if sleeplog
# is from a date equal to or after sleeplog.RData
if (!file.exists(sleeplogRDataFile) ||
Expand Down
7 changes: 6 additions & 1 deletion R/g.part5.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ g.part5 = function(datadir = c(), metadatadir = c(), f0=c(), f1=c(),

fnames.ms5 = dir(paste(metadatadir, "/meta/ms5.out", sep = ""))
# path to sleeplog milestonedata, if it exists:
sleeplogRDA = paste(metadatadir, "/meta/sleeplog.RData", sep = "")

if (length(params_sleep[["loglocation"]]) > 0) {
sleeplogRDA = paste0(metadatadir,"/meta/sleeplog_", basename(params_sleep[["loglocation"]]), ".RData")
} else {
sleeplogRDA = paste(metadatadir, "/meta/sleeplog.RData", sep = "")
}
if (file.exists(sleeplogRDA) == TRUE) {
sleeplog = logs_diaries = c()
load(sleeplogRDA)
Expand Down

0 comments on commit 8e7f4a8

Please sign in to comment.