Issues with "nonworn" sleep analysis

264 views
Skip to first unread message

Simone Verswijveren

unread,
Nov 6, 2023, 4:58:24 AM11/6/23
to R package GGIR
Dear GGIR team, 

Thank you for developing the incredibly valuable GGIR data processing R-package. I have used this several times now for 24-hour data processing with little issues, but I am using this for the first time for waking data only (i.e.., participants only wore their accelerometers for waking hours and were instructed to take monitors off for the night) and I am getting some odd results so I was hoping for your help.

I have set my GGIR parameters as below to indicate that the "notworn" sleep analysis should be used. For some reason, the processing with the "notworn" sleep settings have been applied to ActiGraph GT3X files for some of my participants, but other files seem to still be producing output with the T5A5 sleep settings. In total, I have approx 250 participants, and of those, only 25 end up having a person WW summary saved as "notworn.csv" and all other 225 are saved as T5A5.csv (i.e., all those participants that are included in the 24hr processed data are excluded from the _notworn data, and vice versa). Is there a way of "forcing" all my participants' data to be processed with the notworn sleep setting? None of them were instructed to wear the monitor for 24hours and I don't think it's likely that so many of them would have.

I have shared parameters below and welcome any feedback. 

Thank you! 

Simone



GGIR(

#Part 1
  datadir= "C:/Users/FOLDER",  
  outputdir= "C:/Users/FOLDER",  
  mode=c(1,2,3,4,5),
  studyname = "TESTNOTWORN",  
  #desiredtz = "Australia/Melbourne",
#Note: I tried with the desired timezone in Melbourne, and without it.
  
  overwrite = FALSE,
  idloc=2,
  storefolderstructure=TRUE,  
  print.filename= TRUE,   
  configfile = c(),
 
  windowsizes = c(5, 900, 3600),
  do.cal = TRUE,
   do.enmo = TRUE,
  acc.metric = "ENMO",
    
  do.enmoa = FALSE, #default is false
  do.anglex = FALSE, #default is false
  do.angley = FALSE, #default is false
  do.anglez = TRUE, #default is true
 
  part5_agg2_60sec = TRUE,
 
  dynrange = c(),
  printsummary=FALSE,  
  #############################################################################################################
 
  # Part 2 
  strategy = 1,  
  maxdur = 0,
  max_calendar_days = 0,
  
  hrs.del.start = 0, #only needed for strategy 1
  hrs.del.end = 0, #only needed for strategy 1
 
  includedaycrit = 8,
  includedaycrit.part5 = 0,  
  do.imp=TRUE,
  
  mvpathreshold = c(464.6),
  mvpadur = c(1, 5, 10),
 
  qwindow = c(0, 24), 
  #############################################################################################################
 
  # Parts 3 & 4 – sleep - NOT APPLICABLE
  HASIB.algo = "NotWorn",
  Guider = "nosleeplog_accnotworn",
  #^Note, I have also tested this with Guider = NotWorn but gives same issues.  
  #############################################################################################################
 
  # Part 5 – full-day time-use analysis
 
  threshold.lig = 32.6 , threshold.mod = 142.6, threshold.vig = 464.6,
 
  boutdur.in = c(1, 5, 10), boutdur.lig = c(1, 5, 10), boutdur.mvpa = c(1, 5, 10),
 
  boutcriter.in = 1.0, boutcriter.lig = 1.0, boutcriter.mvpa = 1.0,

  frag.metrics="all",
 
  timewindow = c("MM","WW"),
 
  do.report = c(1,2,3, 4, 5),
  
  do.sibreport=TRUE,
  sibreport=c(),
 
  dofirstpage=TRUE,
  epochvalues2csv=TRUE,
 
  save_ms5rawlevels = TRUE,  # saving time series classification
  save_ms5raw_format = "csv", # as csv
  save_ms5raw_without_invalid = TRUE,   # will get the full time series including the time segments that are not used in the part 5 reports
 
  outliers.only = TRUE,  # only relevant to do.visual
 
)
  

Vincent van Hees

unread,
Nov 15, 2023, 11:57:01 AM11/15/23
to Simone Verswijveren, R package GGIR
Hi Simone,

This sounds to me like GGIR is still using previously generated milestone data. To ensure you use the latest argument setting use overwrite = TRUE with mode = 3:5 to force GGIR to reprocess parts 3, 4 and 5 and overwrite previously derived milestone data.

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/a682759f-35ae-4afb-a762-bdd0d6d2beacn%40googlegroups.com.

Aaron Miatke

unread,
Dec 12, 2023, 2:14:50 AM12/12/23
to R package GGIR
Hi Vincent, 
Thanks for your response. I'm a colleague of Simone who is assisting with this project while she is on leave.

When trying to run the code with mode = 3:5 it fails to run and I get the below error message. This doesn't occur when running with mode = 1, or mode = 1:5. I'm not as familiar with GGIR as Simone, so this may be an oversight on my end. Any further advice would be greatly appreciated. 
 

 Part 3
1 P3 file NAFilename not recognisedError in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning messages:
1: package ‘GGIR’ was built under R version 4.3.2
2: In dir.create(file.path(paste(metadatadir, "/meta", sep = ""), "ms3.out")) :
  cannot create dir 'C:\[DIR]\meta\ms3.out', reason 'No such file or directory'
3: In dir.create(file.path(paste(metadatadir, "/meta", sep = ""), "sleep.qc")) :
  cannot create dir 'C:\ [DIR]  \meta\sleep.qc', reason 'No such file or directory'
4: In readChar(con, 5L, useBytes = TRUE) :
  cannot open compressed file 'C:/ [DIR]  /meta/basic/meta_NA', probable reason 'No such file or directory'


Regards,
Aaron

Vincent van Hees

unread,
Dec 12, 2023, 11:11:50 AM12/12/23
to Aaron Miatke, R package GGIR
In order to run mode 3:5 you need to make sure that the GGIR output folder is the folder you previously used, because this assumed that part 1 and 2 output are present, on which part 3, 4 and 5 rely. I made that suggestion to save you the time of having to reprocess part 1 and 2, but if you deleted the previous output then you have no choice other than to start again.

Regards,

Vincent

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

Aaron Miatke

unread,
Mar 11, 2024, 11:13:49 PM3/11/24
to R package GGIR
Hi Vincent,
Thanks for your help with this so far. I'm just following up from an email here for transparency. 

I've re-run this using the beta-version of GGIR, per your advice, in the hope of solving this. However, I'm still having issues.

The positive new is that I no longer receive any error messages when running my script. However, depending on which set of files I test this on I either receive no part-5 output, or a part-5 output with very few participants included (generally <25% of total sample).

My assumption is this is still related to sleep detection as I get a part 2 output for all participants, but the part 4 output has very few participants included. Hopefully this is as simple as changing an argument to relax sleep/inactivity detection or thresholds for included days. But after trying a few different variations on the above script I can't seem to resolve this. 

Any help would be appreciated.
Regards,
Aaron

Aaron Miatke

unread,
Mar 13, 2024, 7:59:24 PM3/13/24
to R package GGIR
As a quick follow up to the above, here is a copy of the most recent GGIR call we have used if this will help diagnose the issue



library(GGIR)

GGIR(
  ### Part 0 - General settings
  datadir= "Z:\\...",
  outputdir= "C:\\...",
 mode=c(1,2,3,4,5),
 studyname = "ADPRF",
  #desiredtz = "Australia/Melbourne",
  overwrite = T,


  idloc=2,
  storefolderstructure=TRUE,
  print.filename= TRUE,
  configfile = c(),

############################################################################################################
  # Part 1 – Raw data processing/data quality/extracts features/nonwear detection


  windowsizes = c(5, 900, 3600),
  do.cal = TRUE,
  do.enmo = TRUE,
  acc.metric = "ENMO",          
  do.enmoa = FALSE, #default is false
  do.anglex = FALSE, #default is false
  do.angley = FALSE, #default is false
  do.anglez = TRUE, #default is true

  #^All kept on default, as I will be using the enmo settings already specified above. The anglez is default true, as needed for sleep analyses. Kept in but   don't think it's needed to have this in.

  part5_agg2_60sec = TRUE,
  dynrange = c(),
  printsummary=FALSE,
  #############################################################################################################

  # Part 2 – data quality and descriptives


  strategy = 1,
  maxdur = 0,
  max_calendar_days = 0,
  hrs.del.start = 0, #only needed for strategy 1
  hrs.del.end = 0, #only needed for strategy 1

  #WornDuringSleep =FALSE,
  #part2ImpWithZero = TRUE,
  #part2ExcludeNonwear = TRUE,
  #^ These settings also tried (This bit of code was provided by Dr. Jairo H Migueles, during GGIR course). No information yet available online.
  includedaycrit = 8,
  #^ tell GGIR how many hours of valid data per day (midnight-midnight) is acceptable.
# have tried altering this number with no effect on number of participants in part 5 output
  includedaycrit.part5 = 0,
  #^ tell GGIR what fraction of the waking hours in a day (value below 1) is  acceptable.Default is 2/3, yet because we only have waking we want full proportion (e.g., 3/3 or 1).
  #have also tried changing this


  do.imp=TRUE,
  mvpathreshold = c(464.6),
  mvpadur = c(1, 5, 10),

  boutcriter = 1.0,


  qwindow = c(0, 24),

 #############################################################################################################
  # Parts 3 & 4 – sleep - NOT APPLICABLE

 HASPT.algo = "Notworn",
 HASIB.algo = "NotWorn",
 Guider = "Notworn",

# relyonguider = T,
# includenightcrit = 8,
# ignorenonwear = FALSE,
# Guider = "nosleeplog_accnotworn",
# have tried various alternatives including those commented out above, with various values for includenightcrit=



  #############################################################################################################
  # Part 5 – full-day time-use analysis

  # Part 5 loads the imputed acceleration data from part 2. Re-calculate variables based on the merged data (split by sleep period time & waking hours)
  # Added Hurter cutpoint in there for light: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6306859/


  threshold.lig = 32.6 , threshold.mod = 142.6, threshold.vig = 464.6,

  #^ Physical activity and Inactivity thresholds


  boutdur.in = c(1, 5, 10), boutdur.lig = c(1, 5, 10), boutdur.mvpa = c(1, 5, 10),

  #^ Bout durations for each intensity
  # Fraction of a bout that needs to meet the thresholds


  boutcriter.in = 1.0, boutcriter.lig = 1.0, boutcriter.mvpa = 1.0,

  # ^Based on Mai Chinapaws paper I have set the boutcriter.in on 1.0
  frag.metrics="all",

  # Reports


  timewindow = c("MM","WW"),

  do.report = c(2, 4, 5),
  do.sibreport=TRUE,
  sibreport=c(),
  visualreport = F,
  do.visual = F,


 save_ms5rawlevels = TRUE,  # saving time series classification
  save_ms5raw_format = "csv", # as csv
 save_ms5raw_without_invalid = TRUE,   #

 outliers.only = TRUE,  # only relevant to do.visual
)

Vincent van Hees

unread,
Mar 26, 2024, 6:34:35 AM3/26/24
to Aaron Miatke, R package GGIR
Hi Aaron,

#WornDuringSleep =FALSE,
#part2ImpWithZero = TRUE,
#part2ExcludeNonwear = TRUE,
Guider = "Notworn",

These are not GGIR arguments. Only the ones listed on https://cran.r-project.org/web/packages/GGIR/vignettes/GGIRParameters.html can be specified.

HASPT.algo = "Notworn",
HASIB.algo = "NotWorn",

Ok, this functionality has not been used that much and it may be good to carefully review that it correctly classifies the nights. Can you do this with the visualreport = TRUE option? And then review why certain days may be excluded from the part 5 report.

# relyonguider = T,
# includenightcrit = 8,

Note that commenting out arguments does not reset them to a default. You would have to delete the config.csv file in the output folder or explicitly specify the new argument value.

either receive no part-5 output, or a part-5 output with very few participants included (
The full part 5 report as stored in the results/QC folder should provide clarification for why days were excluded in the cleaned part 5 report as stored in the results folder.

Regards, Vincent

Aaron Miatke

unread,
Apr 5, 2024, 1:09:31 AM4/5/24
to R package GGIR
Hi Vincent,
Thanks for your help with this. I've re-run the script as you suggested and a couple of things jump out. 

When looking at the visuals it seems that there is a pretty good distinction between wear and non-wear time across all participants. For the majority of participants the day seems fine and the entirety of every night seems to be classified as non-wear (as we'd expect given we had a waking-wear protocol). I've attached the visual outputs for two participants.

However, when looking at the part 5 outputs things are a bit different. It seems that some participants may have a very small amount of sleep detected in part 4 for some reason, in which case those days are included in the part 5 output, whereas all other participants are excluded from the part 5 outputs. For example, from the two participants in the visual attached, night 3 for the participant 1 has a part 4, and subsequently a part 5 output, but all other days are excluded and participant 2 isn't included at all. 

When looking at the part 5 QC output, participants excluded from the main part 5 output also don't have a part 5 QC output. However for the few participants that are included in the main results we get each day in the QC folder. For some reason though it seems that the other days are detected as 100% non-wear. Again, I've attached the QC output for participant 1, the yellow row is the day that is included in the main part 5 output, all other days seem to be classified as 100% non-wear for some reason. 

Any ideas on how to solve this would be appreciated.
 
Regards,
Aaron
part5_daysummary_full_MM_NotWorn.xlsx
test1.pdf
test2.pdf

Vincent van Hees

unread,
Apr 9, 2024, 10:56:40 AM4/9/24
to Aaron Miatke, R package GGIR
Hi Aaron,

I am afraid I would have to really dive into this to investigate.
Is there any change that you or your group could hire me for a short consultancy project to investigate this? If yes, then please PM me.

Needless to say, that if anyone else in this list sees a solution that does not require my direct involvement then that is also fine.

Thanks,

Vincent

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

Reply all
Reply to author
Forward
0 new messages