From 64e15694e55870b8bc0670f5164ddba6ced3a609 Mon Sep 17 00:00:00 2001 From: Jairo H Migueles Date: Thu, 12 Sep 2024 15:50:45 +0200 Subject: [PATCH 1/2] handle first wake identification in case that no SIBs are detected in g.part5.addfirstwake #1198 --- R/g.part5.addfirstwake.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/g.part5.addfirstwake.R b/R/g.part5.addfirstwake.R index 4fc63a9e5..3e9deb1b7 100644 --- a/R/g.part5.addfirstwake.R +++ b/R/g.part5.addfirstwake.R @@ -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 } @@ -94,4 +96,4 @@ g.part5.addfirstwake = function(ts, summarysleep, nightsi, sleeplog, ID, } } return(ts) -} \ No newline at end of file +} From 3250647a09fc4b715d8f8d6f4965d4053ddb1c94 Mon Sep 17 00:00:00 2001 From: Jairo H Migueles Date: Thu, 12 Sep 2024 15:52:47 +0200 Subject: [PATCH 2/2] update NEWS --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index fb827382e..296c4c348 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# CHANGES IN GGIR VERSION 3.1-5 + +- 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 + # CHANGES IN GGIR VERSION 3.1-4 - Part 3: Update threshold used for HorAngle to 60 degree, and auto-setting HASPT.ignore.invalid to NA when NotWorn guider is used. #1186