Skip to content

Commit

Permalink
handle first wake identification in case that no SIBs are detected in…
Browse files Browse the repository at this point in the history
… g.part5.addfirstwake #1198
  • Loading branch information
jhmigueles committed Sep 12, 2024
1 parent 4fdceaa commit 64e1569
Showing 1 changed file with 4 additions and 2 deletions.
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 64e1569

Please sign in to comment.