Skip to content

Commit

Permalink
Merge pull request #892 from wadpac/issue891_skipLastDay
Browse files Browse the repository at this point in the history
Issue891 skip last day
  • Loading branch information
vincentvanhees authored Sep 11, 2023
2 parents 6f7f8bb + 9875f2f commit 7bbb934
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 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 2.10-3

- Part 5: Fix minor bug by which GGIR skipped the last day if measurement finishes before midnight and timewindow = MM #891

- Part 4: Added parameter sleepefficiency.metric to decide if in-bed time (denominator) should be guider_spt or acc_spt + latency #811

# CHANGES IN GGIR VERSION 2.10-2
Expand Down
10 changes: 9 additions & 1 deletion R/g.part5.definedays.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ g.part5.definedays = function(nightsi, wi, indjump, nightsi_bu,
}
}
} else {
qqq = c(NA, NA)
if (length(qqq_backup) > 1) {
# if there is remaining time after previous day...
if (Nts > qqq_backup[2]) {
qqq = c(qqq_backup[2] + 1, Nts)
}
} else {
# else, do not analyse this day
qqq = c(NA, NA)
}
}
# in MM, also define segments of the day based on qwindow
if (!is.na(qqq[1]) & !is.na(qqq[2])) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_chainof5parts.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ test_that("chainof5parts", {

expect_true(dir.exists(dirname))
expect_true(file.exists(rn[1]))
expect_that(nrow(output),equals(3)) # changed because part5 now gives also first and last day
expect_that(nrow(output),equals(4)) # 2023-09-04: changed because part5 now gives also first and last day
expect_that(ncol(output),equals(160)) # changed because intensity gradient now included in the test
expect_that(round(as.numeric(output$wakeup[2]), digits = 4), equals(36))
dirname_raw = "output_test/meta/ms5.outraw/40_100_400"
Expand Down

0 comments on commit 7bbb934

Please sign in to comment.