Issue with generating single output file for multiple batches

297 views
Skip to first unread message

Samanta Gudziunaite

unread,
Jul 12, 2023, 5:04:52 AM7/12/23
to R package GGIR
Hello All,

I hope that this post finds everyone well and someone is able to help me. 

I am trying to analyse my accelerometer data (ActiGraph GT9X, wrist-worn). The issue is that even if I reduce the wear time to two hours (one day a week or weekend), GGIR will generate the output file, but it excludes multiple participants. I am unsure as to why, but also how to amend this as I require all my participant's files. 


The cut-points I am using align with Hildebrand et al. (2011), and the GGIR package runs smoothly for all steps until it generates the output files. I can process the files one by one without issues, however, as I have multiple batches across different time points, compiling them into one Excel file would be more beneficial. I have amended the top of GGIR to enable it to read multiple files and generate a single output.


Best regards,
Samanta

Samanta Gudziunaite

unread,
Jul 20, 2023, 4:20:15 AM7/20/23
to R package GGIR
Hello,

I am still having the below warning messages and some of the files are not processing after part 2. 

_________________
Here is the error message:

GGIR version: 2.8.2
________________________________________________________________________________________________
 Part 1

Checking that user has read access permission for all files in data directory: Yes
Checking that user has write access permission for directory specified by argument outputdir: Yes

 Busy processing ... see ~/Desktop/GGIR/OUTPUT/output_TEST/meta/basic for progress

Errors and warnings for SG_S1_W1_011.csv$message
[1] "missing value where TRUE/FALSE needed"

$call
if (sf == 0) stop("Sample frequency not recognised")


_____________________________________________________________________________________________
 Part 2

 Busy processing ... see ~/Desktop/GGIR/OUTPUT/output_TEST/meta/ms2.out for progress

Errors and warnings for meta_SG_S1_W1__006.csv.RData$message
[1] "the condition has length > 1"

$call
if (params_cleaning[["maxdur"]] > NDAYS) params_cleaning[["maxdur"]] = NDAYS


Errors and warnings for meta_SG_S1_W1_008.csv.RData$message
[1] "object 'DAYL5HOUR' not found"

$call
g.getM5L5(avday, ws3, t0_LFMF = t_TWDI[1], t1_LFMF = t_TWDI[length(t_TWDI)],
    M5L5res = params_247[["M5L5res"]], winhr_value, qM5L5 = params_247[["qM5L5"]],
    MX.ig.min.dur = params_247[["MX.ig.min.dur"]])


Errors and warnings for meta_SG_S1_W1_009.csv.RData$message
[1] "the condition has length > 1"

$call
if (params_cleaning[["maxdur"]] > NDAYS) params_cleaning[["maxdur"]] = NDAYS


Errors and warnings for meta_SG_S1_W1_010.csv.RData$message
[1] "the condition has length > 1"

$call
if (params_cleaning[["maxdur"]] > NDAYS) params_cleaning[["maxdur"]] = NDAYS


Errors and warnings for meta_SG_S1_W1_016.csv.RData$message
[1] "object 'DAYL5HOUR' not found"

$call
g.getM5L5(avday, ws3, t0_LFMF = t_TWDI[1], t1_LFMF = t_TWDI[length(t_TWDI)],
    M5L5res = params_247[["M5L5res"]], winhr_value, qM5L5 = params_247[["qM5L5"]],
    MX.ig.min.dur = params_247[["MX.ig.min.dur"]])


Errors and warnings for meta_SG_S1_W1_017.csv.RData$message
[1] "object 'DAYL5HOUR' not found"

$call
g.getM5L5(avday, ws3, t0_LFMF = t_TWDI[1], t1_LFMF = t_TWDI[length(t_TWDI)],
    M5L5res = params_247[["M5L5res"]], winhr_value, qM5L5 = params_247[["qM5L5"]],
    MX.ig.min.dur = params_247[["MX.ig.min.dur"]])


_____________________________________________________________________________________________
 Part 3

 Busy processing ... see ~/Desktop/GGIR/OUTPUT/output_TEST/meta/ms3.out for progress

_____________________________________________________________________________________________
 Part 4
 1 2 3 4 5 6 7
_____________________________________________________________________________________________
 Part 5

 Busy processing ... see ~/Desktop/GGIR/OUTPUT/output_TEST/meta/ms5.out for progress

Errors and warnings for SG_S1_W1__003.csv.RData$message
[1] "object 'class.in.ids' not found"

$call
LEVELS %in% class.in.ids


Errors and warnings for SG_S1_W1_007.csv.RData$message
[1] "object 'class.in.ids' not found"

$call
LEVELS %in% class.in.ids


Errors and warnings for SG_S1_W1_013.csv.RData$message
[1] "object 'class.in.ids' not found"

$call
LEVELS %in% class.in.ids


_____________________________________________________________________________________________
 Report part 2
 1 2File SG_S1_W1__006.csv.RData not available in part 2 3 4 5 6File SG_S1_W1_008.csv.RData not available in part 2 7File SG_S1_W1_009.csv.RData not available in part 2 8File SG_S1_W1_010.csv.RData not available in part 2 9 10 11File SG_S1_W1_016.csv.RData not available in part 2 12File SG_S1_W1_017.csv.RData not available in part 2 13
_____________________________________________________________________________________________
 Report part 4
 loading all the milestone data from part 4 this can take a few minutes

_____________________________________________________________________________________________
 Report part 5
 loading all the milestone data from part 5 this can take a few minutes
 generating csv report for every parameter configurations...
 MM-35.6-191.6-695.8-T5A5 WW-35.6-191.6-695.8-T5A5Warning messages:
1: In (function (mode = 1:5, datadir = c(), outputdir = c(), studyname = c(),  :
 
Argument iglevels has been provided more than once. Try to avoid this.
2: In (function (mode = 1:5, datadir = c(), outputdir = c(), studyname = c(),  :
 
Argument boutcriter has been provided more than once. Try to avoid this.

_________________
Here is my code:
library(GGIR)
library(bitops)
library(covr)
library(testthat)
library(knitr)
library(rmarkdown)
library(data.table)
library(Rcpp)
library(foreach)
library(doParallel)
library(signal)
library(zoo)
library(matlab)
library(GENEAread)
library(tuneR)
library(unisensR)
library(ineq)
library(stats)
library(utils)

#========================================
#General parameters
#========================================
g.shell.GGIR(
  mode = c(1:5),
  datadir = c("~/Desktop/GGIR/TEST"),
  outputdir = c("~/Desktop/GGIR/OUTPUT"),
  studyname = c("TEST"),
  f0 = 1,
  f1 = 14,
  overwrite = TRUE, #Overwrite previously generated milestone
  #IF FALSE then it will skip the previously processed files
  do.imp = TRUE,
  print.filename = TRUE,
  storefolderstructure = TRUE,
 
 
  #=======================================
  #Part 1
  #=======================================
  windowsizes = c(10, 900, 3600), #10 s epoch, 15 min non-wear
  do.cal = TRUE,
  do.anglez = TRUE,
  do.enmo = TRUE,
  do.mad = FALSE,
  do.hfen = FALSE,
  do.en = FALSE,
  chunksize = 1,
  printsummary = TRUE,
 
 
  #========================================
  #Part 2
  #========================================
  strategy = 3, #see manual p43; '2' = only data between 1st and last midnight used for imputation
  hrs.del.start = 0, #needed if 'strategy'=1; how many hours after start of data collection did wearing
  hrs.del.end = 0, #needed if 'strategy'=1; how many hours before end of data collection did wearnig of
  maxdur = 0, #how many days after start of data collection did data collection end; 0 is default if unknown
  ndayswindow = 7, #used if 'strategy'=3 ; it is size of the window as number of days
  includedaycrit = 10, #minimum number of valid hours/day
  qwindow = c(0,24), #time windows over which all variables are calculated; can be multiple windows for seg
  #for hourly analysis use qwindow = c(0:24),
  mvpathreshold = c(35.6, 191.6, 695.8), #needed if including bout metrics ; can be multiple value: mvpathreshold =
  mvpadur = c(1,5,10),
  boutcriter = c(0.8),
  bout.metric = 4, #see manual p35 (there are 6 options)
  closedbout = FALSE,
  M5L5res = 10, #time resolution of M5L5 analyses in minutes  (default = 10 mins)
  qM5L5 = c(0.1, 0.25, 0.5, 0.75, 0.9), #percentiles to be calculated over L5 and M5 window
  winhr = c(1,6), #mp during most and least active continuous x hrs of the day (continous MX metrics)
  #these period (can be < 1.....so 0.5 would be 30 minutes); it can be multiple values: winhr = c(5,10)
  ilevels = c(0,50,100,150,200,250,300,350,700,8000), #user-defined acceleration bins - useful for
  xcludefirstlast = TRUE, #to ignore 1st and last night of measurement for sleep analysis
  includenightcrit = 10, #minimum nu mber of valis hours /night
  iglevels = TRUE, #IG calculated as described in original Rowlands et al. (2018)
  MX.ig.min.dur = 1, #IG calcuated for least and most active continous periods (in hours ) set by 'winhr'
  #values must be <= the lowest 'winhr' values
  qlevels = c(
    960/1440, #most active 2/3rds of the day
    1320/1440, #most active 120 mins
    1380/1440, #most active 60 mins
    1414/1440, #most active 30 mins
    1425/1440, #most active 15 mins
    1435/1440), #most active 5 mins
  #these are the MX metrics (minimun acceleration (mg) for the most active accumulated X minutes); change..
  #denominator values, depending on qwindows duration(e.g., qwindows = c(7,23) for waking hours totals 960
 
 
  #========================================
  # Part 3 + 4 #include additional arguments if using sleep logs (pp. 56-61 in manual)
  #========================================
  timethreshold = 5,  #time threshold in minutes for sustained periods of inactivity
  anglethreshold = 5, #angle threshold (degrees) for sustained inactivity periods detection (default = 5)
  ignorenonwear = TRUE,
  def.noc.sleep = 1, #time window of sustained inactivity periods detection (default = 5)
  #can be set to times (def.noc.sleep = c(21,8)), or set to a sleep algorithm (1 is default based on van H)
  outliers.only = FALSE,
  criterror = 4, #relevant if sleep log used; see manual p.60
  do.visual = TRUE,
 
  #========================================
  #Part 5
  #========================================
  iglevels = TRUE,
  #winhr = c(1), #set for mg during most and least active consecutive x hrs of the day plus start time of
  #(can be < 1.....so  0.5 would be 30 minutes for least and most active continuoys period analysis
  #M5L5res = c(60), #resolution of time in minutes for least and most active continous period analysis
  threshold.lig = c(35.6), #Child - AG wrist
  threshold.mod = c(191.6), #Child = AG wrist
  threshold.vig = c(695.8),
  boutcriter = 0.8, #number between 0 and 1 define what fraction of a bout needs to be above the intense
  boutcriter.in = 0.9,
  boutcriter.lig = 0.8,
  boutcriter.mvpa = 0.8,
  boutdur.in = c(10,20,30), #bout durations in minutes
  boutdur.lig = c(1,5,10),
  boutdur.mvpa = c(1,5,10),
  timewindow = c("WW", "MM"), #WW: waking up to waking up as approach for describing 24-hour time-use;
  #alternative is MM: midnight to midnight ; sleep output does difer depending on which 'timewindow' is
  includedaycrit.part5 = 2/3, #inclusion criteria for number of valid used in part 5; can be expressed as
  #or as the number of hours in the qwindow period  #Only used in this function if save_ms5rawlevels is  TRUE
  #as it only affects the time series files stored
  frag.metrics = "all",
  part5_agg2_60seconds = TRUE,
 
 
 
  #=======================================
  #Visual report
  #=======================================
 
  do.report = c(1:5),
  visualreport = FALSE,
  dofirstpage = TRUE,
  epochvales2csv = TRUE, #generates csv file with time-stamped epoch-level acceleration & angle-2 values
  viewingwindow = 1)
____________

Best regards,

Samanta

Vincent van Hees

unread,
Jul 21, 2023, 9:40:14 AM7/21/23
to Samanta Gudziunaite, R package GGIR
Hi Samanta,

Please install R packages read.gt3x and GGIRread and try again.

The issue with the current release of GGIR is that it does not check for the availability of those dependencies. This will be fixed in the next CRAN release, they are having their annual summer break now, so this will have to wait till August or September. In the mean time installing those dependencies should address the issue.

Best wishes,

Vincent

------- 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/a9365790-7ca2-42a5-811b-0cb48d6d5209n%40googlegroups.com.

Samanta Gudziunaite

unread,
Jul 24, 2023, 7:41:42 AM7/24/23
to R package GGIR
Hi Vincent,

Thank you for your quick reply. 

Your suggestion for installing install R packages read.gt3x and GGIRread worked, thank you. 

I have a follow up question regarding time spent in MVPA; I previously set my criteria for LPA, MPA, and MVPA using cut-points derived from Hildebrand 2016 (light: 35.6, moderate: 201.4, and vigorous: 707.0). As I understand, part two should calculate time spent in MVPA, however, in the output files there are multiple variable names. For example, I can see MVPA_E10S_T35.6_ENMO_0.24hr (as I understand there are MVPA based on 10s epoch over 24 hours with the different thresholds, first one being light PA of 35.6 mg), or, would I need to focus on AD_MVPA_E10S_T35.6_ENMO_0.24hr? Just to clarify, which one would be the correct variable for time-spent in LPA? 

Thank you for your time and patiences, apologies for any simple questions, I am new to PA analysis! I look forward to hearing from you. 

Best wishes,
Samanta

Vincent van Hees

unread,
Aug 10, 2023, 12:54:47 PM8/10/23
to Samanta Gudziunaite, R package GGIR
Hi Samanta,

GGIR facilitates multiple definitions of MVPA and leaves it up to the user to choice.
I did that because you may want different definitions for different populations and wear locations. For example for data on the wrist in adults it may be desirable to work either with 1 minute epochs or with bouts that have a length of at least one minute.

See also my blog post on measuring adherence to PA guidelines from a couple of years ago: https://www.accelting.com/updates/how-to-measure-pa-guideline-adherence/

Vincent

------- Original Message -------

Samanta Gudziunaite

unread,
Oct 5, 2023, 6:14:07 AM10/5/23
to R package GGIR
Hi Vincent,

Thank you for your reply, I have followed Hildebrand 2016 cutpoints and set them for LPA, MPA, VPA, and will later calculate MVPA. If I look to the output which contains the long format, I can see that upon screening the data, it appears that some of the rows are below 60 mins, which is as expected due to the SED time not yet being calculated, however, some of the rows add up to more than 60 mins. I thought this might be to do with the sensitivity and specificity, but then if I am only focussing on GGIR parts 1 - 2 so I am not sure why this is happening? Then I thought maybe it could be because I've specified all hours for qwindows, and perhaps it's a problem with the back end of GGIR? I have attached a screenshot for the long output for participant 007 between 08:00-09:00 hrs. I hope that you can help. 


Here is my code:
library(GGIR)
library(bitops)
library(covr)
library(testthat)
library(knitr)
library(rmarkdown)
library(data.table)
library(Rcpp)
library(foreach)
library(doParallel)
library(signal)
library(zoo)
library(matlab)
library(GENEAread)
library(tuneR)
library(unisensR)
library(ineq)
library(stats)
library(utils)
library(read.gt3x)
library(GGIRread)


#========================================
#General parameters
#========================================
g.shell.GGIR(
  mode = c(1:2),

  datadir = c("~/Desktop/GGIR/TEST"),
  outputdir = c("~/Desktop/GGIR/OUTPUT"),
  studyname = c("TEST"),
  f0 = 1,
  f1 = 62,
  qwindow = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24), #time windows over which all variables are calculated; can be multiple windows for seg

  #for hourly analysis use qwindow = c(0:24),
  mvpathreshold = c(35.6, 201.4, 707.0), #Hildebrand 2016 cut-points needed if including bout metrics ; can be multiple value: mvpathreshold =

  mvpadur = c(1,5,10),
  boutcriter = c(0.8),
  bout.metric = 4, #see manual p35 (there are 6 options)
  closedbout = FALSE,
  M5L5res = 10, #time resolution of M5L5 analyses in minutes  (default = 10 mins)
  qM5L5 = c(0.1, 0.25, 0.5, 0.75, 0.9), #percentiles to be calculated over L5 and M5 window
  winhr = c(1:24), #mp during most and least active continuous x hrs of the day (continous MX metrics)

  #these period (can be < 1.....so 0.5 would be 30 minutes); it can be multiple values: winhr = c(5,10)
  ilevels = c(0,50,100,150,200,250,300,350,700,8000), #user-defined acceleration bins - useful for
  xcludefirstlast = TRUE, #to ignore 1st and last night of measurement for sleep analysis
  includenightcrit = 8, #minimum number of valid hours /night

  iglevels = TRUE, #IG calculated as described in original Rowlands et al. (2018)
  MX.ig.min.dur = 1, #IG calcuated for least and most active continous periods (in hours ) set by 'winhr'
  #values must be <= the lowest 'winhr' values
  qlevels = c(
    960/1440, #most active 2/3rds of the day
    1320/1440, #most active 120 mins
    1380/1440, #most active 60 mins
    1414/1440, #most active 30 mins
    1425/1440, #most active 15 mins
    1435/1440), #most active 5 mins
  #these are the MX metrics (minimum acceleration (mg) for the most active accumulated X minutes); change..

  #denominator values, depending on qwindows duration(e.g., qwindows = c(7,23) for waking hours totals 960
 
 
  #========================================
  # Part 3 + 4 #include additional arguments if using sleep logs (pp. 56-61 in manual)
  #========================================
  timethreshold = 5,  #time threshold in minutes for sustained periods of inactivity
  anglethreshold = 5, #angle threshold (degrees) for sustained inactivity periods detection (default = 5)
  ignorenonwear = TRUE,
  def.noc.sleep = 1, #time window of sustained inactivity periods detection (default = 5)
  #can be set to times (def.noc.sleep = c(21,8)), or set to a sleep algorithm (1 is default based on van H)
  outliers.only = FALSE,
  criterror = 4, #relevant if sleep log used; see manual p.60
  do.visual = TRUE,
 
  #========================================
  #Part 5
  #========================================
  iglevels = TRUE,
  #winhr = c(1), #set for mg during most and least active consecutive x hrs of the day plus start time of
  #(can be < 1.....so  0.5 would be 30 minutes for least and most active continuoys period analysis
  #M5L5res = c(60), #resolution of time in minutes for least and most active continous period analysis
  threshold.lig = c(35.6), #Child - AG wrist
  threshold.mod = c(201.4), #Hildebrand 2016
  threshold.vig = c(707.0),

  boutcriter = 0.8, #number between 0 and 1 define what fraction of a bout needs to be above the intense
  boutcriter.in = 0.9,
  boutcriter.lig = 0.8,
  boutcriter.mvpa = 0.8,
  boutdur.in = c(10,20,30), #bout durations in minutes
  boutdur.lig = c(1,5,10),
  boutdur.mvpa = c(1,5,10),
  timewindow = c("WW", "MM"), #WW: waking up to waking up as approach for describing 24-hour time-use;
  #alternative is MM: midnight to midnight ; sleep output does difer depending on which 'timewindow' is
  includedaycrit.part5 = 2/3, #inclusion criteria for number of valid used in part 5; can be expressed as
  #or as the number of hours in the qwindow period  #Only used in this function if save_ms5rawlevels is  TRUE
  #as it only affects the time series files stored
  frag.metrics = "all",
  part5_agg2_60seconds = TRUE,
 
 
  #=======================================
  #Visual report
  #=======================================
 
  do.report = c(1:5),
  visualreport = FALSE,
  dofirstpage = TRUE,
  epochvalues2csv = TRUE, #generates csv file with time-stamped epoch-level acceleration & angle-2 values
  viewingwindow = 1)








I look forward to hearing from you.

Thank you and best wishes,
Samanta

Screenshot 2023-10-05 at 10.48.40.png

Vincent van Hees

unread,
Oct 11, 2023, 9:39:38 AM10/11/23
to Samanta Gudziunaite, R package GGIR
Sorry Samantha, I do not understand your question.
You will have to be a lot more specific. What do you mean by some of the rows are below 60 minutes. If you need more elaborate guidance on how to use GGIR I would strongly advise you to sign up to our GGIR training course: https://www.accelting.com/ggir-training/

As a general comment:

library(bitops)
library(covr)
library(testthat)
library(knitr)
library(rmarkdown)
library(data.table)
library(Rcpp)
library(foreach)
library(doParallel)
library(signal)
library(zoo)
library(matlab)
library(GENEAread)
library(tuneR)
library(unisensR)
library(ineq)
library(stats)
library(utils)
library(read.gt3x)
library(GGIRread)

is not needed and bad practise. GGIR will call the other R packages it needs, you as a user should never need to do that.

Vincent

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