Using read.gt3x_ggir or read.gt3x in GGIR

107 views
Skip to first unread message

Julia ZZ

unread,
Aug 26, 2022, 11:36:14 AM8/26/22
to R package GGIR
Hi all,

I wonder if anyone try to apply read.gt3x_ggir or read.gt3x while using GGIR. I would like to apply this in my codes, but I meet some problems. For example, I have 14 gt3x files, and I don't want to generate the csv files of them. In stead, I would like to read the gt3x directly and then use GGIR to process them to have part 1 milestone files. What should I do? The following codes are what I am using, but they are not working. It would be great if someone familiar about read.gt3x_ggir or read.gt3x in GGIR can help me with it. Thank you very much.

#=======================================================
#test how to read in gt3x files using read.gt3x
library(GGIR)
library(read.gt3x)
datadir <- dirname("V:/test_gt3x/DL 12/886.gt3x") # location of .gt3x files
gt3xfolders <- unzip.gt3x("V:/test_gt3x/DL 12", location = tempdir())
gt3xfolder <- gt3xfolders[1]
X <- read.gt3x(gt3xfolder)
X <- as.data.frame(X)
#=======================================================

#=======================================================
#test to use the datadir_test to run the ggir, not working
outputdir="V:/test_gt3x/DL 12"

g.shell.GGIR(
  mode=c(1),
  datadir=X,
  outputdir=outputdir,
  studyname="Attempt1",
  idloc=6,
  f0=1,
  f1=14,
  print.filename=FALSE,
  storefolderstructure = FALSE,
  do.parallel=TRUE,
  overwrite=FALSE,
 
  #part 1#
  windowsizes = c(5,900,3600),
  do.anglez=TRUE,
  chunksize = c(1),
  printsummary=TRUE,
 
  #part 2#
  strategy = 2 , # this strategy gets rid of first data before first midnight and last midnight
  includedaycrit = 16, M5L5res = 10, #already in default
  winhr = 5,
  qwindow=c(0,24),
  qwindow_dateformat = "%d/%m/%Y",
  qlevels = c(c(1380/1440),c(1410/1440)),
  ilevels = c(0,36, 201, 707, 8000),
  mvpathreshold = c(201),
  boutcriter = 0.8,
  bout.metric = 6 ,
  epochvalues2csv=TRUE,
  mvpadur=c(1,5,10),
  iglevels = TRUE, #this function calculates intensity gradient
  do.parallel = TRUE,
 
  #part3#
  timethreshold= c(5),
  acc.metric="ENMO",
  anglethreshold=5,
  ignorenonwear = TRUE,
 
  #part4#
  #newly added codes with sleep log#
  loglocation= "C:/Users/xzhu/Desktop/DL 12/sleep_log_v2.csv", #not working if using advanced file
  def.noc.sleep=1,
  colid=1,
  coln1=4,
  includenightcrit = 4,
  outliers.only = TRUE,
  relyonguider = FALSE,
  sleeplogidnum = FALSE,
  sleeplogsep=",",
  criterror = 4,
  do.visual = FALSE,
  nnights = 30,
  sleepwindowType = "SPT",
  meta.sleep.folder = "C:/Users/xzhu/Desktop/DL 12/output_CSV_kid/meta/ms3.out",
 
  #part 5#
  threshold.lig = c(35.6),
  threshold.mod = c(201.4),
  threshold.vig = c(707.0),
  #Hildebrand 2014 and 2016 intensity thresholds#
  excludefirstlast = FALSE,
  boutcriter = 0.8,
  boutcriter.in = 0.9,
  boutcriter.lig = 0.8,
  boutcriter.mvpa = 0.8,
  boutdur.in = c(10),
  boutdur.lig = c(1),
  boutdur.mvpa = c(1),
  timewindow = c("WW"),
 
  do.report=c(2,4,5),
  dofirstpage=TRUE,
  visualreport=TRUE,
  viewingwindow=1)

options(nwarnings = 10000)
warnings()




Sincerely,
Julia

ben_m...@hotmail.com

unread,
Aug 26, 2022, 2:52:54 PM8/26/22
to R package GGIR
Hi Julia,

I'm pretty sure this is now embedded within the GGIR function so you just specify the data directory as normal and it automatically detects the gt3x extension. This can be seen in g.inspectfile.R in github. So, if you change your line to datadir = datadir it should work fine.  

As an additional note, if you are using the later versions of GGIR you can just replace g.shell.GGIR( with GGIR( as exampled here: https://cran.r-project.org/web/packages/GGIR/vignettes/GGIR.html#236_Example_call

Kind regards,
Ben 

Julia ZZ

unread,
Aug 26, 2022, 3:17:27 PM8/26/22
to R package GGIR
Hi Ben,

Thank you so much. You are correct. I am overthinking about it. It is working now.

Julia

Reply all
Reply to author
Forward
0 new messages