From 724ba1118f94dcd46187dc2c07db64c60dc25a78 Mon Sep 17 00:00:00 2001 From: Francisco Javier Baron Lopez Date: Thu, 11 May 2017 23:52:04 +0200 Subject: [PATCH 1/4] g.part1 can be called with a parameter called strategy, that in g.part3 was fixed to strategy=1. That produced error computing sib periods when using strategy=2. Now is fixed. --- R/g.part3.R | 4 ++-- R/g.shell.GGIR.R | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/g.part3.R b/R/g.part3.R index d24bf36..ddccd43 100644 --- a/R/g.part3.R +++ b/R/g.part3.R @@ -1,5 +1,5 @@ g.part3 = function(metadatadir=c(),f0,f1,anglethreshold = 5, - timethreshold = 5,ignorenonwear=FALSE,overwrite=FALSE,desiredtz="Europe/London") { + timethreshold = 5,ignorenonwear=FALSE,overwrite=FALSE,desiredtz="Europe/London",strategy=1) { # description: function to apply sleep detection functions to milestone data generated by g.part1 #------------------------------------ # create output directory if it does not exist @@ -57,7 +57,7 @@ g.part3 = function(metadatadir=c(),f0,f1,anglethreshold = 5, M = c() load(paste(metadatadir,"/meta/basic/",fnames[i],sep="")) if (M$filecorrupt == FALSE & M$filetooshort == FALSE) { - IMP = g.impute(M,I,strategy=1,hrs.del.start=0,hrs.del.end=0,maxdur=0) + IMP = g.impute(M,I,strategy=strategy,hrs.del.start=0,hrs.del.end=0,maxdur=0) SLE = g.sib.det(M,IMP,I,twd=c(-12,12),timethreshold=timethreshold,anglethreshold=anglethreshold,desiredtz=desiredtz) L5list = SLE$L5list if (length(SLE$output) > 0 & SLE$detection.failed == FALSE) { diff --git a/R/g.shell.GGIR.R b/R/g.shell.GGIR.R index 0fc487f..9e6c50c 100644 --- a/R/g.shell.GGIR.R +++ b/R/g.shell.GGIR.R @@ -195,7 +195,7 @@ g.shell.GGIR = function(mode=c(1,2),datadir=c(),outputdir=c(),studyname=c(),f0=1 if (f1 == 0) f1 = length(dir(paste(metadatadir,"/meta/basic",sep=""))) g.part3(metadatadir=metadatadir,f0=f0, f1=f1,anglethreshold=anglethreshold,timethreshold=timethreshold, - ignorenonwear=ignorenonwear,overwrite=overwrite,desiredtz=desiredtz) + ignorenonwear=ignorenonwear,overwrite=overwrite,desiredtz=desiredtz,strategy=strategy) } if (dopart4 == TRUE) { cat('\n') From f6b7b577161d03c359f42fd25c35b820d8a396dd Mon Sep 17 00:00:00 2001 From: Francisco Javier Baron Lopez Date: Thu, 11 May 2017 23:52:04 +0200 Subject: [PATCH 2/4] nfeatures augmented to 500 --- .Rbuildignore | 2 ++ .gitignore | 7 +++++++ GGIR.Rproj | 17 +++++++++++++++++ R/g.part3.R | 4 ++-- R/g.part5.R | 2 +- R/g.shell.GGIR.R | 2 +- 6 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 .Rbuildignore create mode 100644 .gitignore create mode 100644 GGIR.Rproj diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..91114bf --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,2 @@ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..56843bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata +src/*.o +src/*.so +src/*.dll diff --git a/GGIR.Rproj b/GGIR.Rproj new file mode 100644 index 0000000..21a4da0 --- /dev/null +++ b/GGIR.Rproj @@ -0,0 +1,17 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/R/g.part3.R b/R/g.part3.R index d24bf36..ddccd43 100644 --- a/R/g.part3.R +++ b/R/g.part3.R @@ -1,5 +1,5 @@ g.part3 = function(metadatadir=c(),f0,f1,anglethreshold = 5, - timethreshold = 5,ignorenonwear=FALSE,overwrite=FALSE,desiredtz="Europe/London") { + timethreshold = 5,ignorenonwear=FALSE,overwrite=FALSE,desiredtz="Europe/London",strategy=1) { # description: function to apply sleep detection functions to milestone data generated by g.part1 #------------------------------------ # create output directory if it does not exist @@ -57,7 +57,7 @@ g.part3 = function(metadatadir=c(),f0,f1,anglethreshold = 5, M = c() load(paste(metadatadir,"/meta/basic/",fnames[i],sep="")) if (M$filecorrupt == FALSE & M$filetooshort == FALSE) { - IMP = g.impute(M,I,strategy=1,hrs.del.start=0,hrs.del.end=0,maxdur=0) + IMP = g.impute(M,I,strategy=strategy,hrs.del.start=0,hrs.del.end=0,maxdur=0) SLE = g.sib.det(M,IMP,I,twd=c(-12,12),timethreshold=timethreshold,anglethreshold=anglethreshold,desiredtz=desiredtz) L5list = SLE$L5list if (length(SLE$output) > 0 & SLE$detection.failed == FALSE) { diff --git a/R/g.part5.R b/R/g.part5.R index fffefad..a7ca10d 100644 --- a/R/g.part5.R +++ b/R/g.part5.R @@ -38,7 +38,7 @@ g.part5 = function(datadir=c(),metadatadir=c(),f0=c(),f1=c(),strategy=1,maxdur=7 # specify parameters ffdone = fnames.ms5 #ffdone is now a list of files that have already been processed by g.part5 wdaynames = c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") - nfeatures = 500 + nfeatures = 1000 ws3 = windowsizes[1] ds_names = rep("",nfeatures) di = 1 diff --git a/R/g.shell.GGIR.R b/R/g.shell.GGIR.R index 0fc487f..9e6c50c 100644 --- a/R/g.shell.GGIR.R +++ b/R/g.shell.GGIR.R @@ -195,7 +195,7 @@ g.shell.GGIR = function(mode=c(1,2),datadir=c(),outputdir=c(),studyname=c(),f0=1 if (f1 == 0) f1 = length(dir(paste(metadatadir,"/meta/basic",sep=""))) g.part3(metadatadir=metadatadir,f0=f0, f1=f1,anglethreshold=anglethreshold,timethreshold=timethreshold, - ignorenonwear=ignorenonwear,overwrite=overwrite,desiredtz=desiredtz) + ignorenonwear=ignorenonwear,overwrite=overwrite,desiredtz=desiredtz,strategy=strategy) } if (dopart4 == TRUE) { cat('\n') From 0b8c7192497f5063499f4f62ddf8187541a67193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Bar=C3=B3n=20L=C3=B3pez?= Date: Sun, 28 May 2017 16:06:04 +0200 Subject: [PATCH 3/4] Update g.part5.R --- R/g.part5.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/g.part5.R b/R/g.part5.R index fffefad..af80aa5 100644 --- a/R/g.part5.R +++ b/R/g.part5.R @@ -38,7 +38,7 @@ g.part5 = function(datadir=c(),metadatadir=c(),f0=c(),f1=c(),strategy=1,maxdur=7 # specify parameters ffdone = fnames.ms5 #ffdone is now a list of files that have already been processed by g.part5 wdaynames = c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") - nfeatures = 500 + nfeatures = 1000 ws3 = windowsizes[1] ds_names = rep("",nfeatures) di = 1 @@ -763,4 +763,4 @@ g.part5 = function(datadir=c(),metadatadir=c(),f0=c(),f1=c(),strategy=1,maxdur=7 } } } -} \ No newline at end of file +} From fd9033d0cbf2704c4a4ab1dd5839f6043dead96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Bar=C3=B3n=20L=C3=B3pez?= Date: Sun, 4 Jun 2017 01:41:37 +0200 Subject: [PATCH 4/4] Update g.part5.R Control de errores --- R/g.part5.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/g.part5.R b/R/g.part5.R index af80aa5..e715a0e 100644 --- a/R/g.part5.R +++ b/R/g.part5.R @@ -110,7 +110,14 @@ g.part5 = function(datadir=c(),metadatadir=c(),f0=c(),f1=c(),strategy=1,maxdur=7 } # load output g.part2 selp = which(fnames.ms2 == fnames.ms3[i]) # so, fnames.ms3[i] is the reference point for filenames + try({ + hayError=TRUE load(file=paste(metadatadir,"/meta/ms2.out/",fnames.ms2[selp],sep="")) + hayError=FALSE + }) + if(hayError){ + stop(paste(metadatadir,"/meta/ms2.out/",fnames.ms2[selp],sep="")) + } daysummary = SUM$daysummary summary = SUM$summary # load output g.part4