New to GGIR - error advice

383 views
Skip to first unread message

gemm...@yahoo.co.uk

unread,
May 9, 2022, 10:50:22 AM5/9/22
to R package GGIR
Hello

I am new to GGIR so sorry if this is obvious :)  

Background: I am looking at delirium in hospitalised patients with parkinsons disease to explore whether wearable sensors could aid in identification of delirium.  They wore a wrist sensor during their admission.  I am hoping to show sleep disruption, fragmentation and day night reversal which is a suggested feature.  

I haven't used a sleep diary as pts are generally too agitated, however 'lights' on the ward are out at 10pm and wake is generally 7am. (Not exact but the best i can go with).  I am wanting to set the guider however I am receiving the following error. please see below and also the code I am using.  Also wondering if it is possible for only the guider I set to be used? sorry again if this is completely obvious, i am just getting to grips with it.

Many thanks
Gemma
GGIR.PNG


ibrary(GGIR)
g.shell.GGIR(#=======================================
             # INPUT NEEDED:
             mode=c(1,2,3,4,5),
             overwrite = TRUE,
             #datadir= args[1],
             #outputdir= args[2],
             idloc=2, #id location (1 = file header, 2 = filename)Rcpp::
             datadir = rawdatadir,
             outputdir = outputpath,
             #f0=1, f1=2,
             #-------------------------------
             # Part 1:
             #-------------------------------
             # Key functions: reading file, auto-calibration, and eastracting features
             do.enmo = TRUE, do.anglez=TRUE,
             chunksize=1, # number between 0.2 and 1 to specificy the size of chunks to be loaded as a fraction of a 24 hour period,
             # e.g. 0.5 equals 12 hour chunks. The default is 1(24 hrs). influence the
             printsummary=TRUE,
             
             #-------------------------------
             # Part 2:
             #-------------------------------
             # Key functions: Non-wear detection, imputation, and basic descriptives
             strategy = 2, #only relevant when strategy = 3
             ndayswindow=7, # only relevant when strategy = 3, then this is the size of the window as a number of days
             hrs.del.start = 0, # Only relevant when strategy = 2. How many HOURS need to be ignored at the START of the measurement?
             hrs.del.end = 0, # Only relevant when strateg
             y = 2, #How many HOURS need to be ignored at the END of the measurement?
             maxdur = 8, # How many DAYS of measurement do you maximumally expect?
             includedaycrit = 8, # number of minimum valid hours in a day to attempt physical activity analysis
             winhr = 5, # size of M5 and L5 (5 hours by default) if two values c(5,10)
             # given then the code will calculate each value seperately
             qlevels = c(c(1380/1440),c(1410/1440)), # array of percentiles for which value needs to be extracted.
             
             qwindow=c(0,24),
             # To specify windows over which all variables are calculated. If value = c(0,24) all variables will only be calculated over the full 24 hours
             # in a day, If value =c(8,24) variables will be calculated over the window 0-8, 8-24 and 0-24. Previously this functionality was limited to the
             # distribution in acceleration metric values, but now it also derives N valid hours, L5M5 analysis and MVPA.
             
             ilevels = c(seq(0,400,by=50),8000), #acceleration values (metric ENMO) from which a frequency distribution needs to be derived
             # set value at c() if you do not want quantiles。 This will generate few columns in analysis results: [A,B)_ENMO_mg_0-24h
             # Time spent in minutes between (and including) acceleration value A in mg and (excluding) acceleration value B in mg.
             # This is only done for metric ENMO at the moment, and only done if ilevels is not left blank
             
             mvpathreshold =c(100,120), #Threshold for MVPA estimation. Threshold needs to be based on metric ENMO. This can be a single number or an array
             # of numbers, e.g. c(100,120). In the later case the code will estimate MVPA seperately for each threshold. If this variable is left blank c()
             # then MVPA is not estimated
             
             bout.metric = 4,
             # option 4: using sliding window across the data to test bout criteria per window and do not allow for breaks of 1 minute or longer.
             # it requires the first and last epoch to require the threshold criteria.
             
             closedbout=FALSE, #TRUE if you want breaks in bouts to be counted towards time spent in bouts (argument only active for bout.metric 1 and 2)
             # M5L5res = 10, #resolution in minutes of M5 and L5 calculation say 14.5 = 14:30, 14.33 = 14:20
             # winhr = c(5,10), # size of M5 and L5 (5 hours by default) Starting hour of M5 and L5 on a scale from 0 to 24
             # Vector of window size(s) (unit: hours) of L5 and M5 analysis (dedault = 5 hours)
             # Starting time in hours of the most active five* hours in the day within the time interval as specified (* window size defined by argument winhr)
             # Starting time in hours of the least active five* hours within the time interval as specified (* window size defined by argument winhr)
             #-------------------------------
             # Part 3:
             #-------------------------------
             # Key functions: Sleep detection
             timethreshold= c(5,10), # Time threshold (minutes) for sustained inactivity periods detection, default = 5.
             # This can be specified as multiple thresholds, each of which will be implemented. For example, timethreshold = c(5,10)
             anglethreshold=5,
             ignorenonwear = TRUE, # If TRUE then ignore detected monitor non-wear periods to avoid confusion between
             # monitor non-wear time and sustained inactivity (default = TRUE)
             #-------------------------------
             # Part 4:
             #-------------------------------
             # Key functions: Integrating sleep log (if available) with sleep detection
             # storing day and person specific summaries of sleep
             excludefirstlast = FALSE, # If TRUE then the first and last night of the measurement are ignored for the sleep assessment.
             includenightcrit = 16, # Minimum number of valid hours per night (24 hour window between noon and noon)
             #def.noc.sleep = c(1), # e.g. def.noc.sleep=c(1) then the window will be detected with the method as
             def.noc.sleep = c(22, 7),
             # described in van Hees et al. 2018 Scientific Reports.
             relyonsleeplog=FALSE,
             outliers.only = TRUE,
             criterror = 4,
           
             sleeplogidnum = FALSE,
             colid=1,
             coln1=2,
             do.visual = TRUE,
             nnights = 7,
             #-------------------------------
             # Part 5:
             # Key functions: Merging physical activity with sleep analyses
             #-------------------------------
             excludefirstlast.part5 = FALSE,
             threshold.lig = c(30,40), #threshold(s) for inactivity (can be more than one number) unit in milligravity(mg)
             threshold.mod = c(100), #threshold(s) for moderate activity (can be more than one number) if we have two number then the code will estimate MVPA seperately
             # for each threshold
             threshold.vig = c(400), #threshold(s) for vigorous activity (can be more than one number)
             boutcriter = 0.8, # The variable boutcriter is a number between 0 and 1 and defines what fractionof a bout needs to be above the mvpathreshold
             boutcriter.in = 0.9, #fraction of an inactivity bout that needs to be below the threshold (needs to be 1 number)
             boutcriter.lig = 0.8, #fraction of an light activity bout that needs to be between the thresholds (needs to be 1 number)
             boutcriter.mvpa = 0.8, #fraction of an light activity bout that needs to be above the threshold (needs to be 1 number)
             boutdur.in = c(1,10,30),# Durations of inactivty bouts in minutes to be extracted. Inactivity bouts are detected in the segments of the data
             # which were not labelled as sleep or MVPA bouts. The default duration values is c(10,20,30), this will start with the identification of 30 minute
             # bouts, followed by 20 minute bouts in the rest of the data, and followed by 10 minute bouts in the rest of the data.
             boutdur.lig = c(1,10), # Durations of light activty bouts in minutes to be extracted. Light activity bouts are detected in the segments of
             # the data which were not labelled as sleep, MVPA, or inactivity bouts. The default duration values is c(1,5,10), this will start with the
             # identification of 10 minute bouts, followed by 5 minute bouts in the rest of the data, and followed by 1 minute bouts in the rest of the data.
             boutdur.mvpa = c(1), # Durations of mvpa bouts in minutes to be extracted. The default values is c(1,5,10) and will start with the identification of 10 minute bouts, followed by 5
             # minute bouts in the rest of the data, and followed by 1 minute bouts in the rest of the data.
             timewindow = c("WW", "MM"), # Timewindow over which summary statistics are derived. Value can be "MM"
             # (midnight to midnight), "WW" (waking time to waking time), or both c("MM","WW").
             #-----------------------------------
             # Report generation
             #-------------------------------
             # Key functions: Generating reports based on meta-data
             do.report=c(2,3,4,5),
             visualreport=TRUE,
             dofirstpage = TRUE,
             viewingwindow=1
)

taren....@gmail.com

unread,
May 9, 2022, 11:04:45 PM5/9/22
to R package GGIR
Hi Gemma,

Can you post the config file (located in the output folder)? It looks like GGIR thinks that there is a log file for some reason. You could also try removing colid and coln1 since they relate to columns in the logfile.

Taren

gemm...@yahoo.co.uk

unread,
May 11, 2022, 10:30:38 AM5/11/22
to R package GGIR
Hi Taren

Thank you for getting back to me, its much appreciated.  I have attached the config file and will re-run again after removing colid and coln1 as you suggest.  Thanks again

Gemma

config.csv

gemm...@yahoo.co.uk

unread,
May 13, 2022, 8:38:46 AM5/13/22
to R package GGIR
Hello

Thanks for the help so far it is much appreciated  :)
I ran the code again without colid and coln1 (as I have no sleep diary and just want to set the sleep time window guider to 10pm to 7am) I and still getting the error 'def.noc.sleep does not have length 1, not comparable, we assume you want to use the sleep log'

Part 4 code below (Full code in previous thread)

             # Part 4:
             #-------------------------------
             # Key functions: Integrating sleep log (if available) with sleep detection
             # storing day and person specific summaries of sleep
             excludefirstlast = FALSE, # If TRUE then the first and last night of the measurement are ignored for the sleep assessment.
             includenightcrit = 16, # Minimum number of valid hours per night (24 hour window between noon and noon)
             #def.noc.sleep = c(1), # e.g. def.noc.sleep=c(1) then the window will be detected with the method as
             def.noc.sleep = c(22, 7),
             # described in van Hees et al. 2018 Scientific Reports.
             relyonsleeplog=FALSE,
             outliers.only = TRUE,
             criterror = 4

Thanks again
Gemma

Vincent van Hees

unread,
May 16, 2022, 3:40:47 PM5/16/22
to gemm...@yahoo.co.uk, R package GGIR
Hello Gemma,

I suspect that this issue relates to a bug in GGIR 2.6-0 on CRAN, which was an update the broke the def.noc.sleep = c(22,7) functionality. This has been fixed in the development version of GGIR on GitHub (see installation instructions here). Alternatively you could wait for the next GGIR release, which is hopefully later this month.

With kind regards,

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/e527061f-c1d5-4770-bc3f-7e4773075c22n%40googlegroups.com.

gemm...@yahoo.co.uk

unread,
May 19, 2022, 8:36:26 AM5/19/22
to R package GGIR
Thank you Vincent

I have re ran the code using the development version but I still receive the same error  'def.noc.sleep does not have length 1, not comparable, we assume you want to use the sleep log'
A colleague ran the same data on his GGIR version 2.3 and it worked brilliantly :)
This is probably a silly question but can the old version still be accessed or is it best to wait for the next release? 

I find the functionality and reproducibility of GGIR brilliant so want to thank you for the open access.

Kind regards
Gemma

Vincent van Hees

unread,
May 27, 2022, 11:16:30 AM5/27/22
to gemm...@yahoo.co.uk, R package GGIR
Hi Gemma,​

I have re ran the code using the development version but I still receive the same error  'def.noc.sleep does not have length 1, not comparable, we assume you want to use the sleep log'

Are you also specifying loglocation? If yes, then that makes sense because GGIR either uses a sleeplog or the time window you are trying to specify. You are providing both which confuses GGIR. If not, then make sure loglocation is set to c(), because it may reload a previously stored value from the config.csv file.

can the old version still be accessed or is it best to wait for the next release? 

To use older versions of GGIR do. First install the remotes package.

Next, if you want to install older versions from CRAN:
remotes::install_version(“GGIR”, version = “2.5-0”) 
If you want to install older versions from GitHub:
remotes::install_github(“wadpac/GGIR”, ref = “2.5-0”) 

Thanks,
Vincent

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

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