I'm trying to use the GGIR package in R to analyze raw actigraphy data. The excel tables with the raw data contain 4 columns (HEADER_TIMESTAMP, X, Y, Z). HEADER_TIMESTAMP is in the format "2000-01-08T12:30:00Z".
Example data:
HEADER_TIMESTAMP X Y Z
1/8/2000 12:30 0.534 0.106 -0.877
1/8/2000 12:30 0.487 0.126 -0.874
1/8/2000 12:30 0.519 0.085 -0.874
1/8/2000 12:30 0.543 0.114 -0.871
This 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)
Create a minimal dataset with HEADER_TIMESTAMP in "2000-01-08T12:30:00Z" format
actigraphy_data <- data.frame(
HEADER_TIMESTAMP = c("2000-01-08T12:30:00Z", "2000-01-08T12:30:00Z",
"2000-01-08T12:30:00Z", "2000-01-08T12:30:00Z"),
X = c(0.534, 0.487, 0.519, 0.543),
Y = c(0.106, 0.126, 0.085, 0.114),
Z = c(-0.877, -0.874, -0.874, -0.871)
)
write.csv(actigraphy_data, "C:/path_to_your_directory/actigraphy_data.csv", row.names = FALSE)
data_dir <- "C:/path_to_your_directory/"
g.shell.GGIR(mode=c(1,2,3,4,5),
datadir=data_dir ,
outputdir="C:/Users/...",
studyname="TEST",
minimumFileSizeMB = 0.01,
f0=1, #number of files - will need to change
f1=0,
# Time format to fix the issue:
#rmc.format.time = "%m/%d/%Y %I:%M:%S %p",
#desiredtz = "America/New_York",
#rmc.nrow = Inf,
#rmc.skip =0,
#rmc.firstrow.acc = 2,
#desiredtz = "America/New_York",
#rmc.unit.acc = "g",
#rmc.unit.time = 'POSIX',
#rmc.format.time = "%Y/%m/%d %H:%M:%S",
#rmc.col.time = 1,
#rmc.sf = 80,
overwrite = FALSE,
do.imp=TRUE,
idloc=2,
print.filename=TRUE,
storefolderstructure = TRUE,
#-------------------------------
# Part 1 parameters:
#-------------------------------
windowsizes = c(5,900,3600),
do.cal=TRUE,
do.enmo = TRUE,
do.anglez=TRUE,
do.mod = FALSE,
do.hfen = FALSE,
do.en = FALSE,
chunksize=1,
printsummary=TRUE,
#-------------------------------
# Part 2 parameters:
#-------------------------------
strategy = 2,
ndayswindow=7,
hrs.del.start = 0,
hrs.del.end = 0,
maxdur = 7,
includedaycrit = 16,
L5M5window = c(0,24),
M5L5res = 10,
winhr = c(5,10),
qlevels = c(c(1380/1440),c(1410/1440)),
qwindow=c(0,24),
ilevels = c(seq(0,400,by=50),8000),
excludefirstlast = TRUE,
#includenightcrit = 16,
mvpathreshold =c(100,120),
#-------------------------------
# Part 3 parameters:
#-------------------------------
timethreshold= 5,
anglethreshold=5,
ignorenonwear = TRUE,
#-------------------------------
# Part 4 parameters:
#-------------------------------
#excludefirstlast = TRUE,
includenightcrit = 16,
def.noc.sleep = c(1),
outliers.only = FALSE,
#criterror = 4,
relyonsleeplog = FALSE,
#sleeplogidnum = TRUE,
colid=1,
coln1=2,
do.visual = TRUE,
nnights = 9,
#-------------------------------
# Part 5 parameters:
#-------------------------------
# Key functions: Merging physical activity with sleep analyses
iglevels = TRUE,
threshold.lig = c(30,40,50),
threshold.mod = c(100,120),
threshold.vig = c(400,500),
boutcriter = 0.8,
boutcriter.in = 0.9,
boutcriter.lig = 0.8,
boutcriter.mvpa = 0.8,
boutdur.in = c(10,20,30),
boutdur.lig = c(1,5,10),
boutdur.mvpa = c(1,5,10),
timewindow = c("WW"),
#-----------------------------------
# Report generation
#-------------------------------
do.report=c(2,4,5), #want sleep report only
visualreport = FALSE,
dofirstpage = TRUE,
epochvalues2csv=TRUE,
viewingwindow=1)
#end
This is the error that I get when running the code:
"Errors and warnings for GT3XPLUS-AccelerationCalibrated-1x8x0.NEO1G62402505.2000-01-16-12-00-00-000-P0000.sensor.csv.gz$message [1] "character string is not in a standard unambiguous format"
$call as.POSIXlt.character(x, tz, ...)"
How can I either change the Header Timestamp format or change the GGIR code to match this format?