sleep_efficiency calculation question

40 views
Skip to first unread message

Ruth Bieber-Stanley

unread,
Jun 13, 2024, 11:16:17 AMJun 13
to R package GGIR
Hello, 

My name is Ruth. The study I am an RA for is looking at the sleep_efficiency variable as provided in the part5daysummary output. We tried to manually calculate this variable to understand where it came from. Based on the description of this variable in the cran.r guide webpage, we understood that sleep_efficiency = SleepDurationInSpt / SptDuration. However, there is a discrepancy between the manually calculated variable using the formula above and the data that part5daysummary provides. I have attached a screenshot to show the discrepancy in these data. The yellow columns are the most important ones, and the rows with the largest discrepancy between the R output sleep_efficiency values and the manually calculated ones (using the formula I described above) are marked with red hash marks. If this is important, our guider is the HDCZA algorithm. I believe we are using the vanHees2015 algorithm. 

If we could better understand where the differences in these data comes from, that would be very helpful. It would also be helpful to know precisely how the sleep_efficiency value is derived from the other extant variables.

Thank you in advance! 

Ruth, on behalf of CWRU ASF team 

sleep_efficiency var screenshot.png


Vincent van Hees

unread,
Jun 24, 2024, 7:35:02 AM (5 days ago) Jun 24
to Ruth Bieber-Stanley, R package GGIR
Dear Ruth,

What report are you referring to? These variables can in theory occur in both part 4 and 5 csv report?

I assume part 5, because when using HDCZA part 4 should not show sleep_efficiency.

Part 5 copies most sleep variables from part 4, but in addition calculates the percentage of SPT window epochs that are sleep and calls this somewhat confusionly sleep_efficiency. If you use a 1 minute epoch resolution in part 5 then this can be different than the 5 second epoch resolution based on which the Sleep duration variables are calculated.

On my to do list:
  • replace name sleep_efficiency in part 5 report by sleep_efficiency_after_onset.
  • fix issue with sleep_efficiency calculation in part 4 where it incorrectly uses the guider instead of the detected sleep duration.

Best, Vincent
--
You received this message because you are subscribed to the Google Groups "R package GGIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to RpackageGGIR...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/RpackageGGIR/0f3dd3c2-4909-4322-ab05-ff1990fe2f2bn%40googlegroups.com.

Vincent van Hees

unread,
Jun 24, 2024, 10:47:26 AM (5 days ago) Jun 24
to Ruth Bieber-Stanley, R package GGIR
correct to my previous message

  • fix issue with sleep_efficiency calculation in part 4 where it incorrectly uses the guider instead of the detected sleep duration.

I now see this is not a bug, it is correct. Either way, I do not think it relates to your question.

Vincent

Ruth Bieber-Stanley

unread,
Jun 26, 2024, 10:02:49 AM (3 days ago) Jun 26
to R package GGIR
Hello Vincent, 

This is a helpful response, thank you. That all makes sense, I appreciate the clarification. 

If you could, we have a few follow-up questions also related to the sleep_efficiency variable.

- The script computes other variables e.g. WASO, sleep duration, sleep duration in SPT (i.e. the part 4 variables that would be used to calculate sleep efficiency in part 5) but sometimes in part 5 output, there is no sleep_efficiency calculation for certain days, even if the data is complete in the part 4 night summary output. Could you explain why this might be happening?

- Relatedly, we have noticed that in some cases,  the number of days with sleep data for these parameters in the part4nightsummary csv differs from the part 5 output, e.g. we get 3 nights of data for part5daysummary but 7 days of data in part 4. In other cases, we sometimes see the opposite -- e.g. we would get 7 days of data in the part 5 output but only 4 days of data in part 4 night summary. Do you know where this discrepancy in number of days of data in parts 4 and 5 comes from?

Any insight you could provide would be greatly appreciated. 

Thank you,

Ruth Bieber-Stanley
Reply all
Reply to author
Forward
0 new messages