HDCZA algorithm made SPT and all sleep outputs abnormal

42 views
Skip to first unread message

joeck...@gmail.com

unread,
May 8, 2025, 10:15:21 PMMay 8
to R package GGIR
Dear GGIR community, 

I recently updated my GGIR code, and in doing so changed the sleep detection algorithm to HDCZA. I had previously been using L5+/-12 (LEGACY ALGORITHM) by specifying def.noc.sleep = c(), but decided to change to HDCZA because the GIGR sleep page says "Disclaimer: This legacy algorithm was used in publications and therefore kept inside GGIR. As performance is expected to be less than other available algorithm, we do not recommend using it."

However, I noticed that my sleep outputs using the HDCZA algorithm are completely off! I then reran everything all over again using my newly written code, but changing only the HDCZA algorithm back to legacy algorithm, and sleep outputs look totally fine, so I do know the difference was caused by the HDCZA algorithm. 

The sleep outputs using the HDCZA algorithm are odd in that the sleep period time windows are extremely small in many cases (less than 3 hours, even some nights less than 1 hour). In some cases, the SleepDurationinSpt is longer than the SPT window, resulting in sleep efficiency larger than 1. My participants are older adults, and it makes no sense to me why there are so many nights where they would sleep so little. Moreover, very obvious correlations that should exist between circadian variables (intradaily variability) and sleep (efficiency) were not significant, so this does lead me to believe that the sleep outputs are off. 

For now I have reverted back to using the legacy algorithm, but if the HDCZA algorithm is better, I would like to move towards using it. I am not sure if I am implementing the code wrong? 

Attached is my GGIR code with the HDZCA algorithm, and the part 4 person and night summaries. Please let me know if you have any insights on if I implemented the HDCZA algorithm wrong, or why the sleep outputs may look as they do. When you sort by  SptDuration, you can see how small some of the windows are. 

R version 4.4.2 (2024-10-31)
GGIR version 3.1-5

Thank you in advance for your help!

All my best,
Joanna







GGIR_HDZCA.R
part4_nightsummary_sleep_cleaned.csv
part4_summary_sleep_cleaned.csv

Vincent van Hees

unread,
May 15, 2025, 3:30:14 AMMay 15
to joeck...@gmail.com, R package GGIR
Hi Joanna,

Lot's of researchers have successfully used HDCZA on wrist data in gravitational units. The 2018 paper demonstrated the superior value to L12+/-5. HDCZA is not always perfect but especially when sleep is not too fragmented we expect a good classification.

My quick impression is that your R script seems fine.

Could you clarify:
  • What sensor brand are you using?
  • What file format are you using? E.g. file extension .csv, .bin, .gt3x, .cwa,....
  • Is the sensor worn on the wrist?
  • Does the data indicate high levels of non-wear?
  • Did the auto-calibration go well? (part 2 report)
  • Does the data indicate abnormal levels of physical activity? (would be an indication of poor sensor calibration)
In some cases, the SleepDurationinSpt is longer than the SPT window, resulting in sleep efficiency larger than 1.
I do not see these variables in the files you shared. There is no sleep efficiency. Also in your R script there is no reference to parameter sleepwindowType or to a sleep diary which you need to derive sleep efficiency. So, it looks like you are R script does not reflect what you did.

Best,

Vincent




Dr. Vincent van Hees | Independent consultant | https://accelting.com/
image

--
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, visit https://groups.google.com/d/msgid/RpackageGGIR/68bc79b8-e189-4afe-8daa-179d694abadcn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages