Skip to content

Commit

Permalink
Merge pull request #1199 from wadpac/issue1198_addfirstwake
Browse files Browse the repository at this point in the history
Issue1198 addfirstwake
  • Loading branch information
vincentvanhees authored Sep 30, 2024
2 parents da87efb + d5a7b8c commit 7a402c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGES IN GGIR VERSION 3.1-?

- Part 5: Fixed minor bug in g.part5.addfirstwake causing the first wake is not correctly added when
no SIBs are detected from the beginning of the recording until the first detected night. #1198

- Part 5: Add parameters require_complete_lastnight_part5 to control whether last window is included if last night is incomplete. #1196

- General: GGIR version look-up in .onattach() no longer crashes when computer is offline, fixes #1203.
Expand Down
6 changes: 4 additions & 2 deletions R/g.part5.addfirstwake.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ g.part5.addfirstwake = function(ts, summarysleep, nightsi, sleeplog, ID,
if (is.na(wake_night1_index)) wake_night1_index = 0
if (wake_night1_index < firstwake & wake_night1_index > 1 &
(wake_night1_index - 1) > nightsi[1]) {
newWakeIndex = max(which(ts$sibdetection[1:(wake_night1_index - 1)] == 1))
newWakeIndex = c()
firstSIBs = which(ts$sibdetection[1:(wake_night1_index - 1)] == 1)
if (length(firstSIBs) > 0) newWakeIndex = max(firstSIBs)
if (length(newWakeIndex) == 0) {
newWakeIndex = wake_night1_index - 1
}
Expand All @@ -94,4 +96,4 @@ g.part5.addfirstwake = function(ts, summarysleep, nightsi, sleeplog, ID,
}
}
return(ts)
}
}

0 comments on commit 7a402c7

Please sign in to comment.