Code Monkey home page Code Monkey logo

ggir's Introduction

GitHub Actions R-CMD-check codecov

Getting started:

The package vignette and this short tutorial video provide an introduction to GGIR, including: How it can be installed, Key software features, and where to get help.

Contribution guidelines:

We always welcome contributions to the package. If you want to contribute to the development of GGIR, have a look at the contribution guidelines.

Images usaged

The copyright of the GGIR logo as contained in the file vignettes/GGIR-MASTERLOGO-RGB.png lies with Accelting (Almere, The Netherlands), please contact [email protected] to ask for permission to use this logo.

All other images in this repository are released under the Creative Commons Attribution 4.0 International (CC BY 4.0) license.

ggir's People

Contributors

egpbos avatar jcapde avatar jhmigueles avatar jspaaks avatar l-k- avatar m-patterson avatar mirkes avatar muschellij2 avatar sriramraju avatar tarensanders avatar tavoloperuno avatar thets avatar vincentvanhees avatar yochannah avatar zcx980605 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ggir's Issues

Running GGIR without sleeplog

I have some example GENEactive .bin and pre-processed csv files, but no sleep log. The shell script says GGIR will integrate sleep log (if available), but I can't find a way to run my code without an error in part 4:
Error in read.table(file = file, header = header, sep = sep, quote = quote, : no lines available in input
Because there is no file.

Am I missing something?

g.cwaread error

After installing GGIR in Windows and trying to read a cwa file with g.cwaread using

P = g.cwaread("D:/test.cwa",start=1,end=10)

I get

Error in Rcpp::sourceCpp("src/numUnpack.cpp") : file not found: 'C:/Users/Vincent/Documents/src/numUnpack.cpp' In addition: Warning messages: 1: In normalizePath(path.expand(path), winslash, mustWork) : path[1]="src": The system cannot find the file specified 2: In normalizePath(path.expand(path), winslash, mustWork) : path[1]="src/numUnpack.cpp": The system cannot find the path specified

I suppose installation / compilation fails.

@Mirkes can you help please?

Config files

To make it easier for user to keep track of function imput it would be good if GGIR had config-file functionality

error of "g.calibrate -> scale -> scale.default -> sweep Execution halted"

Hi Vincent,
I am running GGIR on csv files from Actigraph, for some data files, I have the following error:

Error in FUN(x, aperm(array(STATS, dims[perm]), order(perm)), ...) :
"non-numeric argument to binary operator
Calls: g.shell.GGIR ... g.part1 -> g.calibrate -> scale -> scale.default -> sweep
Execution halted".

If you have ideas why this would happen to some csv files, could you kindly advise?

Thanks a lot!

Regards,
Jiali

legend in plot

Vincent:
It would be great to include legend in visualisation_sleep.pdf

Thanks much.

Part 4 Error in `[.data.frame`(S, , coln1 + ((i - 1) * 2) + 1) : undefined columns selected

Hi Vincent - I have been able to make it work, finally, but it seems that now when part 4 tries to use the sleep log info I get an error in the data frame. I tried removing column names from first row, filling empty cells with '.' but I continue to get the same error.

Here is the script I am using, and also an example of a sleep log file (.csv).

Any help will be much appreciated.

Thanks
Diego

Not run:

mode= c(1,2,3,4)
datadir="/Volumes/G-DRIVEMINI/Sleep Files/Act_sleep_3m"
outputdir="/Volumes/G-DRIVEMINI/Sleep Files/Act_sleep_3m"
studyname="test3"
overwrite=TRUE
f0 = 1
f1 = 5
desiredtz ="America/Sao_Paulo"
g.shell.GGIR(#-------------------------------
# General parameters
#-------------------------------
mode=mode,
datadir=datadir,
outputdir=outputdir,
studyname=studyname,
f0=f0,
f1=f1,
overwrite = TRUE,
do.imp=TRUE,
idloc=1,
print.filename=TRUE,
storefolderstructure = FALSE,
#-------------------------------
# Part 1 parameters:
#-------------------------------
windowsizes = c(5,900,3600),
do.cal=TRUE,
do.enmo = TRUE,
do.lfenmo = TRUE,
do.enmoa = TRUE, # Absolute taken from the Euclidean norm minus one.
do.anglez=TRUE,
do.en = TRUE,
do.bfen = TRUE,
do.hfen = TRUE,
do.hfenplus = TRUE,
chunksize=1,
printsummary=TRUE,
#-------------------------------
# Part 2 parameters:
#-------------------------------
strategy = 1,
ndayswindow=7,
hrs.del.start = 0,
hrs.del.end = 0,
maxdur = 5,
includedaycrit = 16,
L5M5window = c(0,24),
M5L5res = 10,
winhr = c(5,10),
qlevels = c(0.1, 0.25, 0.5, 0.75, 0.9),
qwindow=c(0,24),
ilevels = c(seq(0,400,by=50),8000),
mvpathreshold =c(100,120),
epochvalues2csv = TRUE,
IVIS_windowsize_minutes = 60,
IVIS_epochsize_seconds = 5,
#-------------------------------
# Part 3 parameters:
#-------------------------------
timethreshold= c(5,10),
anglethreshold=3,
ignorenonwear = TRUE,
#-------------------------------
# Part 4 parameters:
#-------------------------------
#Labels detected sustained inactivity periods by g.part3 as either nocturnal sleep or daytime sustained inactivity
#Description
#Loads output from g.part3 as stored in milestone data and sleep log information (if available) and
#then uses these information sources to define nocturnal sleep and daytime sustained inactivity.

         idloc=2,
         excludefirstlast = FALSE,
         includenightcrit = 4, #Minimum number of valid hours per night (24 hour window between noon and noon)
         def.noc.sleep = c(19,9),
         loglocation= "/Volumes/G-DRIVEMINI/Sleep Files/Act_sleep_3m/sleeplog3m_r.csv",
         outliers.only = FALSE,
         criterror = 6,
         relyonsleeplog = FALSE,
         #relyonsleeplog: If TRUE then sleep onset and waking time are defined based on timestamps derived from sleep log 
         #if FALSE (default) the sleep log is only used to guide the accelerometer-based detection. 
         #If participants were instructed NOT to wear the accelerometer during waking hours then set to TRUE, in all other scenarios set to FALSE (FALSE).
         
         sleeplogidnum = TRUE,
         colid=1, #Column number in the sleep log spreadsheet in which the participant ID code is stored (default = 1)
         coln1=2, #Column number in the sleep log spreadsheet where the onset of the first night starts
         
         do.visual = TRUE,
         #nnights=5, #Number of nights for which sleep log information should be available.
         #It assumes that this is constant within a study. If sleep log information is missing for certain nights then leave these blank
         
         #-------------------------------
         # Part 5 parameters:
         #-------------------------------
         # Key functions: Merging physical activity with sleep analyses
         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("MM","WW"),
         #-----------------------------------
         # Report generation
         #-------------------------------
         do.report=c(4))

End(Not run)

sleeplog3m_r.xlsx

Code quality and speed

Code quality and speed need to be improved. Some functions are too large, variable names are often too cryptic and there is still some repetition of code that could be moved into generic functions.

Problems running Part2

Hi Vincent
I hope you can help? I can run Part1 fine, however when I run Part1 and 2 together, I receive this error message:
image

Please can you offer any advice?

Many thanks
Debbie

Prepare new 1.5-11 release

  • Update change log in NEWS.Rd summarizing the new features added by Jairo + and the key items listed in #41.
  • Updare version number and add Jairo as contributor in DESCRIPTION file and GGIR-package.Rd

GGIR package won't install

Good afternoon,

I have downloaded the GGIR_1.5-12.tar.gz package, but for some reason it will not install. I have tried two different laptops for this. Every time I try I get the following message below.
How could I solve this, please?
Many thanks,
Tanja

install.packages("C:/GGIR_1.5-12.tar.gz", repos = NULL, type = "source")

  • installing source package 'GGIR' ...
    ** package 'GGIR' successfully unpacked and MD5 sums checked
    ** libs

*** arch - i386
Warning: running command 'make -f "C:/PROGRA1/R/R-321.2/etc/i386/Makeconf" -f "C:/PROGRA1/R/R-321.2/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="GGIR.dll" OBJECTS="RcppExports.o init.o numUnpack.o resample.o"' had status 127
ERROR: compilation failed for package 'GGIR'

  • removing 'C:/Program Files/R/R-3.2.2/library/GGIR'
    Warning in install.packages :
    running command '"C:/PROGRA1/R/R-321.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" "C:/GGIR_1.5-12.tar.gz"' had status 1
    Warning in install.packages :
    installation of package โ€˜C:/GGIR_1.5-12.tar.gzโ€™ had non-zero exit status

Vignette

Package currently has no vignette. The package manual is currently the main resource for training. Addition of a package vignette with clear guidance on how to use the package would be good

no results for part4 and part5

It seems that for some reason no output is generated for part4 and part5.

Find below the errors that appear in the console, the script I am using, and the sessioninfo() information. If you need something else let me know. Many thanks

------Console---------------------------------------------------------------------
Report part 4
loading all the milestone data from part 4 this can take a few minutes
[1] "report not stored, because no results available"


Report part 5
loading all the milestone data from part 5 this can take a few minutes
generating output for every parameter configurations...
NA-NA-NA-NA-NAreport not stored, because no results available NA-NA-NA-NA-report not stored, because no results available NA-NA-NA--NAreport not stored, because no results available NA-NA-NA--report not stored, because no results available NA-NA--NA-NAreport not stored, because no results available NA-NA--NA-report not stored, because no results available NA-NA---NAreport not stored, because no results available NA-NA---report not stored, because no results available NA--NA-NA-NAreport not stored, because no results available NA--NA-NA-report not stored, because no results available NA--NA--NAreport not stored, because no results available NA--NA--report not stored, because no results available NA---NA-NAreport not stored, because no results available NA---NA-report not stored, because no results available NA----NAreport not stored, because no results available NA----report not stored, because no results available -NA-NA-NA-NAreport not stored, because no results available -NA-NA-NA-r...


Generate visual reports
[1] "File Sab14.bin.bin"
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ
In addition: Warning message:
In rm(outputfinal, outputfinal2) : object 'outputfinal2' not found


-----------Script----------------------------------
`mode= c(1,2,3,4,5)
datadir= c("C:/Alba/03_Data/GeneActiv_Sab11y")
outputdir= c("C:/Alba/03_Data/GeneActiv_Sab11y_results_sleeplog")
f0 = 1
f1 = 3

g.shell.GGIR(#-------------------------------
# General parameters
#-------------------------------
mode=mode,
datadir=datadir,
outputdir=outputdir,
studyname=studyname,
f0=f0,
f1=f1,
overwrite = F,
do.imp=TRUE,
idloc=1,
print.filename=FALSE,
storefolderstructure = FALSE,
#-------------------------------
# Part 1 parameters:
#-------------------------------
windowsizes = c(5,900,3600),
do.cal=TRUE,
do.enmo = TRUE,
do.anglez=TRUE,
chunksize=1,
printsummary=TRUE,
#-------------------------------
# Part 2 parameters:
#-------------------------------
strategy = 1,
ndayswindow=c(7,9),
hrs.del.start = 1,
hrs.del.end = 1,
maxdur = 9,
includedaycrit = 1,
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),
mvpathreshold =c(100,120),
mvpadur =c(1,5,10),
#-------------------------------
# Part 3 parameters:
#-------------------------------
timethreshold= c(5),
anglethreshold=5,
ignorenonwear = TRUE,
#-------------------------------
# Part 4 parameters:
#-------------------------------
excludefirstlast = FALSE,
includenightcrit = 5,
def.noc.sleep = c(),
loglocation= "C:/Alba/03_Data/sleeplog_example.csv",
coln1 = 2,
colid=1,
outliers.only = FALSE,
criterror = 4,
relyonsleeplog = FALSE,
sleeplogidnum = FALSE,
do.visual = TRUE,
nnights = 9,
visualreport = TRUE,
#-------------------------------
# Part 5 parameters:
#-------------------------------
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(1,2,3,4,5))`


-----------Sessioninfo----------

sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252 LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] GGIR_1.5-16

loaded via a namespace (and not attached):
[1] zoo_1.7-14 tools_3.3.2 Rcpp_0.12.10 grid_3.3.2 GENEAread_1.1.1 data.table_1.10.2 bitops_1.0-6
[8] lattice_0.20-34

plot to check data quality only output 7 days

Hi Vincent,

the QC file named: "plots to check data quality 1.pdf" is very useful to inspect non wear in the data. However, it only has 7 days of data while I do see 14 days of data from other reports. Any advice is greatly appreciated.

-Jian

Basic checks needed at the top of g.shell.GGIR, g.getmeta, g.calibrate

These functions load the raw data, and if something goes wrong users get an error messages that is hard to interpret. What we need is a simple check at the top of various functions related to data loading to on:

  • check that directory exists
  • check that file exists
  • check that user has read permissions
  • check that function arguments are sensible and otherwise give warnings/advise

generating csv epoch files for short lab data files

Hi Vincent,

I'm having trouble getting the epoch2csv files from short (approx 1 h) lab GENEActiv and ActiGraph files, it is ok for longer files - approx 2 h. A while back I previously successfully obtained these for a couple of the exact same files (version 1.5-3), but have been unable to replicate.

Main points:
I'm using GGIR 1.5-10 and have tried 1.5-9 and 1.4 and had the same result with each (I have been unable to install 1.5-3 for some reason).
I'm entering backup calibration coefficients, which are being used
I've set window sizes to (1,600,600), (1,300,300), (5,600,600) and (5,300,300) - same result with all
do.imp = FALSE
I've tried chunk sizes of 0.2 and 1.0

With the GENEActiv files the meta basic files are created, but for files shorter than 2 h (<1 MB) they are empty - only about 2 KB rather than about 200 KB
The epoch csv files are therefore only created for the files longer than 2 h
The warning is: Warning (2): data in block too short for doing non-wear detection

With the ActiGraph files, the meta basic file is created for files over about 13 MB, but as soon as it hits a shorter file it stops and says:
stop reading because there is not enough data in this block
Error in names(spheredata) = c("Euclidean Norm", "meanx", "meany", "meanz", :
'names' attribute [8] must be the same length as the vector [7]

Is it still possible to create csv epoch files for files of about an hour? And is it possible to 'turn off' the non-wear detection for short files?

Any advice much appreciated.

Cheers,
Alex

Metric freedom for parts 3, 4 and 5

Analysis stages 3, 4 and 5 are currently dependent on metric ENMO to be available, this limits research freedom. Adapt code to also work with other metrics

Incomplete output files

Hi,
I have run my ActiGraph files through GGIR for parts 1 and 2 only. Everything seemed to go smoothly. There were no error messages.
However, in the 'Results' folder is only a 'QC' folder. When I open this there are no summary files or the pdf report. Only the 'Meta' folder contains files.

I attach the script that I have used. Would you mind having a look whether I did anything wrong here? Or let me know else might have gone wrong?

Thanks for your advice.
Tanja
GGIR_activity_only_helpdesk20180121.pdf

Error while using g.shell.GGIR

I try to execute g.shell.GGIR with a csv. file from Actilife.

Find below the errors that appear in the script I am using. R studio is update (v 1.1.419) and R is update (v 3.4.2).
If you need something else let me know.

Many thanks,
Mathieu.

Part 1
[1] "P1 file1"
[1] "---------------------------------------------"
[1] "investigate calibration of the sensors..."

Loading block: 1 2 3 4 5 6 7[1] "get meta data..."

Loading block: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
End of file reached
[1] "save .RData-file with: calibration report, file inspection report and all meta data..."
[1] "P1 file2"
[1] "---------------------------------------------"
[1] "investigate calibration of the sensors..."

Loading block: 1
Warning (1): data in block too short for doing non-wear detection

stop reading because there is not enough data in this block
Error in names(spheredata) <- c("Euclidean Norm", "meanx", "meany", "meanz", :
attribut 'names' [8] must be the same length as the vector [7]
Moreover : There were 28 warnings (use warnings() to see them)

g.wavread in R 1.3.1

It seems that in earlier version of R g.wavread is not able to correctly extract the scaling factors from the Axivity file header.

timezone is hard coded in part5.R

Vincent,

I noticed desiredtz sometimed hard coded in part5.R

           L5HOUR = as.character(iso8601chartime2POSIX(L5HOUR,tz="Europe/London"))
           M5HOUR = as.character(iso8601chartime2POSIX(M5HOUR,tz="Europe/London"))

Thanks for your attention.

Dynamic range currently hard-coded per accelerometer brand

Dynamic rangeof the sensors is currently hard-coded per accelerometer brand, adapt functions g.shell.GGIR, g.part1 and g.getmeta to either have an optional user-defined dynamic range or attempt to extract dynamic range from file header

GT3X-csv data, g.part1(): Error in g.getstarttime, object 'starttime0' not found

Hi Vincent,

I am trying to use GGIR (version" 1.5-12) to analysis the csv file converted from .gt3x file (timestamps not exported). However, when I use the g.part1 function, I got the following error:

Loading block: 1Error in g.getstarttime(datafile = datafile, P = P, header = header, mon = mon, :
object 'starttime0' not found

If possible, could you kindly let me advise me on this? Thanks a lot!!!

Regards,
Jiali

==============the whole output chunk:

g.part1("./in", "./out", f0 = 1, f1= 1, desiredtz = "Asia/Shanghai")
[1] "P1 file1"
[1] "---------------------------------------------"
[1] "investigate calibration of the sensors..."

Loading block: 1 2 3 4 5 6 7

Summary of autocalibration procedure:

Status:
[1] "recalibration done, no problems detected"

Calibration error (g) before:
[1] 0.01400207

Callibration error (g) after:
[1] 0.005550402

Offset correction:
[1] -0.007008119 -0.006828931 -0.010021307

Scale correction:
[1] 0.9972895 1.0184210 0.9945531

Number of hours used:
[1] 84

Number of 10 second windows around the sphere:
[1] 24203

Temperature used (if available):
[1] FALSE

Temperature offset (if temperature is available):
[1] 0 0 0


[1] "get meta data..."

Loading block: 1Error in g.getstarttime(datafile = datafile, P = P, header = header, mon = mon, :
object 'starttime0' not found

Part 2: Error in matrix(0, nwindow_f, 1)

Hi Vincent - Thanks for the most recent update. I am now running it again and getting a new type of error when it reaches part2:

Error in matrix(0, nwindow_f, 1) : invalid 'nrow' value (< 0)

I have now set all metrics to == TRUE so I do not run into the same problem as before, but still getting this nrow error.

Thanks

Diego

Processing errors

Hi,

I've been hitting a number of stumbling blocks that I'm hoping to get some help with.

I have ~1600 pupils with 5 days wear split into 40 folders (one per school). Most have ran fine, but 2 schools keep failing. One in part 4 with the error message "Error in 1:nrow(spo) : argument of length 0
Calls: g.shell.GGIR -> g.part4" and the other in part 5 with the error message "Error in as.POSIXlt.character(w0[k], tz = desiredtz) : character string is not in a standard unambiguous format
Calls: g.shell.GGIR -> g.part5 -> as.POSIXlt -> as.POSIXlt.character"

Additionally, on inspecting the outputs from the different parts for the ones that did run, I seem to have 5 days wear time in part 2 and part 4, but only 1-2 days wear time when they combine in part 5. Any suggestions as to where I might be going wrong would be gratefully received?

Many thanks,

Kiya

Need non-wear time for user defined day.

My group is working with GGIR to reduce data from GENEActive accelerometers. We get through parts 1 and 2. The problem is that we are defining our days as between 5:00 and 23:00 and need the count of valid wear hours or non-wear hours for that time for each day. We are going to use the weighting method in a recent Xu et al paper (https://www.ncbi.nlm.nih.gov/pubmed/27405327) to address non-wear. From part 2 we get the number of valid minutes per day of wear, but it is per 24 hour day and the use of qwindow = c(5,23) does not give us the wear or non-wear time in our desired window. There must be a way to do this?

Thanks, Lee (University of New Mexico)

ActiLife csv

Hi Vincent,

I am trying to use ActiLife to export data to use in GGIR. I've exported it without the timestamp but I'm still having difficulties getting GGIR to run. I am getting the error:
Error in data.frame(value = H[, 2], row.names = H[, 1]) :
duplicate row.names: 0

Would you be able to provide a sample csv that works with GGIR? Or inform me what measures can be analyzed with GGIR. I've provided a screenshot of the possible measures that can be included.

Thank you,
Anissa
screen shot 2017-12-05 at 2 25 08 pm

Vignette reference to Genea

currently state '(not available anymore)', update sentence to clarify that this refers to the device and not to the functionality in GGIR

Part 2 Error : "error in readChar"

Hello,
I've come across an error that I haven't been able to solve. I've been running GGIR with success for some time, however within the past week it will not run past part 2 without throwing this error:
Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file 'myfolderpath/output_csvfiles_test/meta/basic/NA', probable reason 'No such file or directory'

I've uninstalled R and R studio and updated all GGIR packages. The output and directory folder paths are accurate. Does anyone have suggestions?
Thank you!

  • Jonathan

Failure to read CWA from Axtivity UKBiobank Data

The example .cwa file from the UKBiobank data fails to read in using g.cwaread. The file is loacted at https://biobank.ctsu.ox.ac.uk/crystal/refer.cgi?id=131620, with a hard link to the zip file at https://biobank.ctsu.ox.ac.uk/crystal/examples/accsamp.zip.

Edit: added downloader for reproducible script

zipfile = tempfile(fileext=".zip")
download.file("https://biobank.ctsu.ox.ac.uk/crystal/examples/accsamp.zip", destfile=zipfile)
fname = unzip(zipfile, files = "accsamp.cwa", exdir = tempdir())

After unzipping the file and running:

library(GGIR)
# x = g.cwaread("accsamp.cwa", progressBar=TRUE, end = Inf)
x = g.cwaread(fname, progressBar=TRUE, end = Inf)

the following error is

  |====================================================================  |  97%[1] "last block of data"
Error in accelRes[pos:last, ] = tmp : replacement has length zero

I set end = Inf, because in the code in g.cwaread (https://github.com/wadpac/GGIR/blob/master/R/g.cwaread.R#L274) has:

    if (is.numeric(end)) {
        end = end * pageLength
        if (end > numDBlocks * 120) {
            end = numDBlocks * 120
        }
        end = origin + end * step
    }

This has failed on data from the UKBiobank as well: 1234520_90001_0_0.cwa and 2942234_90001_0_0.cwa, for example. I can't seem to pinpoint exactly the issue. It occurs in the last block of data, when the resample command is called. The output (tmp) results in a matrix of 0 rows, but I can't seem to figure out a fix for a pull request.

The problem persists with the CRAN version on the current github commit 832d184

Referencing @Mirkes as the author of g.cwaread.

part5.R time_num at line 656

Vincent:
An error encountered with Part 5. It is the line at 656-658 of part5.R. This seems to be introduced in the release 1.5.9. Any insight where could cause this? Your advice is greatly appreciated.
(I have no sleep diary, 15 days of data, used the sample script from https://cran.r-project.org/web/packages/GGIR/vignettes/GGIR.html with minor changes)

Part 2
1


Part 3
1


Part 4
1


Part 5
1
Error in if (time_num < 12) time_num = time_num + 24 :
missing value where TRUE/FALSE needed

================
g.shell.GGIR(#=======================================
mode=mode,
datadir=datadir,
outputdir=outputdir,
f0=f0, f1=f1,

         #-------------------------------
         # Part 1:
         #-------------------------------
         # Key functions: reading file, auto-calibration, and extracting features
         do.enmo = TRUE,             do.anglez=TRUE,
         chunksize=1,                printsummary=TRUE,
         #-------------------------------
         # Part 2:
         #-------------------------------
         strategy = 2,               ndayswindow=14,
         hrs.del.start = 0,          hrs.del.end = 0,
         maxdur = 15,                 includedaycrit = 16,
         winhr = c(5,10),
         qlevels = c(c(1380/1440),c(1410/1440)),
         qwindow=c(0,24),
         ilevels = c(seq(0,400,by=50),8000),
         mvpathreshold =c(100,120),
         bout.metric = 4,
         closedbout=FALSE,
         #-------------------------------
         # Part 3:
         #-------------------------------
         # Key functions: Sleep detection
         timethreshold= c(5),        anglethreshold=5,
         ignorenonwear = TRUE,
         #-------------------------------
         # Part 4:
         #-------------------------------
         # Key functions: Integrating sleep log (if available) with sleep detection
         # storing day and person specific summaries of sleep
         excludefirstlast = FALSE,
         includenightcrit = 6,
         def.noc.sleep = c(),
         #loglocation= "C:/mydata/sleeplog.csv",
         outliers.only = TRUE,
         criterror = 4,
         relyonsleeplog = FALSE,
         sleeplogidnum = TRUE,
         colid=1,
         coln1=2,
         do.visual = TRUE,
         nnights = 14,
         #-------------------------------
         # Part 5:
         # Key functions: Merging physical activity with sleep analyses
         #-------------------------------
         threshold.lig = c(30), threshold.mod = c(100),  threshold.vig = c(400),
         boutcriter = 0.8,      boutcriter.in = 0.9,     boutcriter.lig = 0.8,
         boutcriter.mvpa = 0.8, boutdur.in = c(1,10,30), boutdur.lig = c(1,10),
         boutdur.mvpa = c(1),   timewindow = c("WW"),
         #-----------------------------------
         # Report generation
         #-------------------------------
         # Key functions: Generating reports based on meta-data
         do.report=c(2,4,5),
         visualreport=TRUE,     dofirstpage = TRUE,
         viewingwindow=1)

Separate different "Error"

Dear Vincent,
While running a 14 day .cwa file, there are a few error codes in the Part 1. It appears relevant to the following description:
"Next, the moving average over the nonmovement periods is taken from each of the three orthogonal sensor axes and used to generate a three-dimensional ellipsoid representation that should ideally be a sphere with radius 1 g. Here, deviations between the radius of the three-dimensional ellipsoid and 1 g (ideal calibration) can then be used to derive correction factors for sensor axis-specific calibration error."

Prio to autocalibration
Error (g) before:
[1] 0.04281636

Post autocalibration
Error (g) after:
[1] 0.003218808

In this context, "Error is somehow expected" - not a bad thing. But "Error" can be misunderstood as failure of program.

Another example of "Error" is
Error code 1: data in block too short for doing non-wear detection, it seems also not a bad error code. I guess this block of data is not big enough to be processed.

Then I have a really scary "Error" in Part 5. It failed right there.

I would like to propose to output different levels of Error. Or the 2nd place, instead of "Error", using "Warning"?

Part 5
1
Error in if (time_num < 12) time_num = time_num + 24 :
missing value where TRUE/FALSE needed

=====================

Part 1
[1] "P1 file1"
[1] "---------------------------------------------"
[1] "investigate calibration of the sensors..."
[1] "Loading block: 1"
[1] "Loading block: 2"
[1] "Loading block: 3"
[1] "Loading block: 4"
[1] "Loading block: 5"

End of file reached

stop reading because there is not enough data in this block


Summary of autocalibration procedure:

Status:
[1] "recalibration attempted with all available data, but possibly not good enough: Check calibration error variable to varify this"

Error (g) before:
[1] 0.04281636

Error (g) after:
[1] 0.003218808

Offset correction:
[1] -0.005223742 0.072656300 0.065878741

Scale correction:
[1] 1.0062811 0.9864897 1.0310247

Number of hours used:
[1] 48

Number of 10 second windows around the sphere:
[1] 8236

Temperature used (if available):
[1] TRUE

Temperature offset (if temperature is available):
[1] -4.225358e-05 2.101107e-03 -2.662689e-03


[1] "get meta data..."

warning: g.cwaread in beta version

Loading block: 1
Loading block: 2
Loading block: 3
Loading block: 4
Loading block: 5
Loading block: 6
Loading block: 7
Loading block: 8
Loading block: 9
Loading block: 10
Loading block: 11
Loading block: 12
Loading block: 13
Loading block: 14
Loading block: 15
Error code 1: data in block too short for doing non-wear detection
[1] "save .RData-file with: calibration report, file inspection report and all meta data..."


Error in readChar : cannot open the connection

Hello Vincent,
I've been troubleshooting this error since July after the most recent updates went into effect. I've been assured I have administrator rights and have added R to the antivirus exception list (both recommended).
This is the primary additional message, stopping GGIR leaving a meta data file in the 'basic' folder, but ms2.out is empty.

In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file 'C:/R/win-library/3.4/csvfiles_test/output_csvfiles_test/meta/basic/NA', probable reason 'No such file or directory'

After noticing that the 'ms2.out' folder was empty, I copied the meta file in 'basic' and pasted it into 'ms2.out'. I deleted the "meta_" text at the beginning of the pasted file. The error remained the same.

Could the issue be with my file names? Again, everything worked until the GGIR updates in the summer. Here is an example of my file names: 2051_(2013-04-11).csv
I've working with our IT department on solutions. Any insight would be much appreciated!
Thank you!

  • Jonathan

rename argument metric to acc.metric

The argument "metric" that was recently added may be a too generic name. There also is a bout metric, and possibly other metric types in the future. I think it should be something like acc.metric to specify that these are the metrics for acceleration.

GGIR version 1.5-7 bug

Dear Vincent,

Per your instruction on forum at https://groups.google.com/forum/#!topic/RpackageGGIR/kjJMePHDU_Q,
I am submitting an issue here.

The bug of src/numUnpack.cpp is NOT fixed in g.inspectfile(), g.getmeta(), g.calibrate() and a number of other places using the above functions.

Your attention is greatly appreciated.

library(GGIR)
I = g.inspectfile(datafile)
Error in Rcpp::sourceCpp("src/numUnpack.cpp") :
file not found: 'src/numUnpack.cpp'
In addition: Warning messages:
1: In normalizePath(dirname(file)) :
path[1]="src": No such file or directory
2: In normalizePath(file, winslash = "/") :
path[1]="src/numUnpack.cpp": No such file or directory
I = g.getmeta(datafile)
Error in Rcpp::sourceCpp("src/numUnpack.cpp") :
file not found: 'src/numUnpack.cpp'
I = g.calibrate(datafile)
Error in Rcpp::sourceCpp("src/numUnpack.cpp") :
file not found: 'src/numUnpack.cpp'

Incomplete output files

Hi Vincent,

I helped my colleague run her ActiGraph files through GGIR parts 1-4. However, we don't get the right output files. In the "results" folder there is only a "QC" folder but no summary files. This is the error message at the end: Error in matrix(" ", 1, (ncol(SUMMARY) - ncol(SUM$summary))) : invalid 'ncol' value (< 0).

Can you shine any light on where we might have gone wrong?

Kind regards,
Liezel

tests related to g.part5 which work locally do not pass on travis

tests related to g.part5 which work locally do not pass on travis
currently in the expandtests branch
need to investigate why they do not pass on travis:

  • timezone not enough specified?
  • decimal precision inconsistent?
    Possibly good to split up g.part5 into smaller functions anyway, because it is very large at the moment

Vignette updates

A number of enhancments to be made:

  • Expand intro on physical activity and sleep
  • Remove sentence about external harddrive
  • Add variable dictionary for parts 4 and 5
  • Add example of argument do.visual

error when runing g.shell.GGIR with "mode=c(1), visualreport = TRUE, ..."

Hi Vincent,

I was running GGIR on csv files from Actigraph, and I ran with g.shell.GGIR(). I first filled in all the arguments for g.shell.GGIR function that intends for mode = c(1, 2, 3, 4, 5). to make sure that each part in run after the previous one has finished, I change the mode = c(1) when I ran it in HPC cluster. Yet I kept getting message of error after message ""Warning: First run g.shell.GGIR with mode = 4 to generate required milestone data". Then I looked at the source code for function g.shell.GGIR(), I found that the function doesn't seem to allow for "mode=c(1), visualreport = TRUE, ...", this could be caused by the codes between line 240 and 247.

g shell ggir

if possible, could you kindly have a look at it~~
Thanks a lot!

Regards,
Jiali

Date not recognized in Actigraph input file using d-M-yyyy format

g.getmeta produces the following error when using an ActiGraph input file with the d-M-yyyy date format (created by ActiLife v6.13.3 Firmware v2.4.0):

Loading block: 1
date not recognized

Loading block: 2
Loading block: 3
End of file reached
Error in seq.default(starttime3, (starttime3 + ((nrow(metashort) - 1) * :
'from' cannot be NA, NaN or infinite

Input file line 4 reads: "Start Date 7-3-2016". When changing it manually to "Start Date 7/3/2016" the date is recognized and g.getmeta functions without issue.

unit tests needed

To improve efficiency of future code development more unit tests will be needed.

Improve output

Vincent, I am just logging in the things I observed for improvement.
The following output (P1 file1) from g.part1 should be replaced with the actual file name for clarity. As it stands right now, if there are multiple files to be processed, it is not clear which i file1, file2 etc.

Part 1
[1] "P1 file1"
[1] "---------------------------------------------"
[1] "investigate calibration of the sensors..."
[1] "Loading block: 1"
[1] "Loading block: 2"
[1] "Loading block: 3"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.