Fixing issues with the sleep visualization

43 views
Skip to first unread message

K B

unread,
Nov 15, 2021, 6:52:20 PM11/15/21
to R package GGIR
Hi Vincent,

I'm working on a research project that is using actigraph devices to track daily activity, but we are also concerned with certain aspects of sleep. The sleep visualization file has been very helpful for seeing and thinking about what nights of sleep look like, but I do not have sleep log data and I've noticed some issues with how the HDCZA algorithm is defining the SPT. In particular, there are a handful of nights I have data for where it is clear that there was awakening in the middle of night followed by the participant going back to sleep, but the SPT window ends when the awakening occurs.

So my question is this: is there any way I can help the HDCZA algorithm to better detect the hours of actual sleep? I do have sleep diary data where each participant says what time they went to bed, what time they woke up, and how many awakenings they had during the night, but I don't think this is the same as the sleep log that is described in the package. Is there any way I can use my sleep diary data in place of the sleep log? Can I manually add sleep times and wakeup times? Any ideas on this would be incredibly helpful!

Thanks,
Karl Brown

Vincent van Hees

unread,
Nov 16, 2021, 11:36:14 AM11/16/21
to K B, R package GGIR
Hi Karl,

Thanks for reaching out, yes I fully understand your problem.

GGIR now facilitates two types of sleep log, see: https://cran.r-project.org/web/packages/GGIR/vignettes/GGIR.html#232_Key_arguments_related_to_sleep_analysis paragraphs 2.3.2.1 and 2.3.2.2.

What you could do is convert your sleeplog into either of these formats. At least for the nights were you observed those issues, but if feasible also for all other nights.

An interactive way to inspect and where needed adjust sleep classifications would be nice. This is what some of the commercial sleep monitors offer. If anyone reading this would be interested in developing this or is in a position to sponsor me to develop this then please contact me. For example, I think this could be done via a Shiny app embedded in GGIR.

Cheers, Vincent

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

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
--
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/bf94addc-a00c-4065-a50e-b10e248697d7n%40googlegroups.com.

K B

unread,
Nov 18, 2021, 1:00:12 PM11/18/21
to R package GGIR

Vincent, 

Thank you so much, this has been very helpful. I reformatted the sleep diary that I have into the a form that is in the vignette. After changing the code within the GGIR shell to incorporate the sleep log, I have not been able to get the code to run. I am getting errors that read:

Error in if (WKN2 > SLN2) { : missing value where TRUE/FALSE needed
In addition: Warning message:
In g.loadlog(loglocation, coln1, colid, nnights, sleeplogidnum) :
  NAs introduced by coercion

There are a fair number of nights where the participants in my study failed to record sleep/wake times, so there are a handful of NA's in the sleep log. Could that be causing the issue? Do you have any advice on how to deal with this?

Thanks,
Karl Brown

Vincent van Hees

unread,
Nov 24, 2021, 11:01:18 AM11/24/21
to K B, R package GGIR
The sleeplog should not have NA values, leave the cells for missing values blank as we explain in the vignette: https://cran.r-project.org/web/packages/GGIR/vignettes/GGIR.html#232_Key_arguments_related_to_sleep_analysis.

Thanks,
Vincent

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

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
Reply all
Reply to author
Forward
0 new messages