Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues #42 and #46 #47

Merged
merged 7 commits into from
Aug 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/g.part3.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
g.part3 = function(metadatadir=c(),f0,f1,anglethreshold = 5,timethreshold = 5,
metric="ENMO",ignorenonwear=FALSE,overwrite=FALSE,desiredtz="Europe/London") {
acc.metric="ENMO",ignorenonwear=FALSE,overwrite=FALSE,desiredtz="Europe/London") {
# description: function to apply sleep detection functions to milestone data generated by g.part1
#------------------------------------
# create output directory if it does not exist
Expand Down Expand Up @@ -58,7 +58,7 @@ g.part3 = function(metadatadir=c(),f0,f1,anglethreshold = 5,timethreshold = 5,
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)
SLE = g.sib.det(M,IMP,I,twd=c(-12,12),timethreshold=timethreshold,anglethreshold=anglethreshold,metric=metric,desiredtz=desiredtz)
SLE = g.sib.det(M,IMP,I,twd=c(-12,12),timethreshold=timethreshold,anglethreshold=anglethreshold,acc.metric=acc.metric,desiredtz=desiredtz)
L5list = SLE$L5list
if (length(SLE$output) > 0 & SLE$detection.failed == FALSE) {
id = as.character(unlist(strsplit(I$filename,"_"))[1])
Expand Down
4 changes: 2 additions & 2 deletions R/g.part5.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
g.part5 = function(datadir=c(),metadatadir=c(),f0=c(),f1=c(),strategy=1,maxdur=7,hrs.del.start=0,hrs.del.end =0,
loglocation= c(),excludefirstlast=FALSE,windowsizes=c(5,900,3600), metric="ENMO",
loglocation= c(),excludefirstlast=FALSE,windowsizes=c(5,900,3600), acc.metric="ENMO",
boutcriter.mvpa=0.8,boutcriter.in=0.9,boutcriter.lig=0.8,storefolderstructure=FALSE,
threshold.lig = c(40),
threshold.mod = c(100),
Expand Down Expand Up @@ -122,7 +122,7 @@ g.part5 = function(datadir=c(),metadatadir=c(),f0=c(),f1=c(),strategy=1,maxdur=7
IMP = g.impute(M,I,strategy=strategy,hrs.del.start=hrs.del.start,
hrs.del.end=hrs.del.end,maxdur=maxdur)
time = IMP$metashort[,1]
ACC = IMP$metashort[,metric] * 1000 #note that this is imputed ACCELERATION because we use this for describing behaviour
ACC = IMP$metashort[,acc.metric] * 1000 #note that this is imputed ACCELERATION because we use this for describing behaviour

if (length(which(names(IMP$metashort) == "anglez")) == 0) {
cat("Warning: anglez not extracted. Please check that do.anglez == TRUE")
Expand Down
4 changes: 2 additions & 2 deletions R/g.sib.det.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
g.sib.det = function(M,IMP,I,twd=c(-12,12),anglethreshold = 5,
timethreshold = c(5,10), metric = "ENMO", desiredtz="Europe/London") {
timethreshold = c(5,10), acc.metric = "ENMO", desiredtz="Europe/London") {
#==============================================================
# get variables
D = IMP$metashort
Expand Down Expand Up @@ -36,7 +36,7 @@ g.sib.det = function(M,IMP,I,twd=c(-12,12),anglethreshold = 5,
cat("metric anglez was not extracted, please make sure that anglez is extracted")
}
angle = as.numeric(as.matrix(D[1:nD,which(colnames(D)=="anglez")]))
ACC = as.numeric(as.matrix(D[1:nD,which(colnames(D)==metric)]))
ACC = as.numeric(as.matrix(D[1:nD,which(colnames(D)==acc.metric)]))
night = rep(0,length(angle))
if (length(which(is.na(angle) ==TRUE)) > 0) {
if (which(is.na(angle) ==TRUE)[1] == length(angle)) {
Expand Down
23 changes: 22 additions & 1 deletion inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
\name{NEWS}
\title{News for Package \pkg{GGIR}}
\newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
\section{Changes in version 1.5-11 (release date:01-8-2017)}{
\itemize{
\item Codecov badge added to the README file
\item Functions added to create dummy accelerometer file (csv) and dummy sleeplog (csv),
needed for testing
\item Default IVIS_epochsize_seconds parameter updated from 30 to 3600
\item g.part1 messages on the consolo are now condensed printing only the number of the
blocks loaded separated by spaces rather than new lines
\item Split g.part5 function into multiple smaller functions
\item Replace hard-coded "Europe/London" in g.part5 by desiredtz, to make the function
work for users outside the UK
\item Data frame output from g.part5 is now tidied up by removing empty rows and columns generated
\item Calculation of mean amplitude deviation (MAD) is now implemented in g.part1 by the argument do.mad
\item Percentiles and levels in g.part2 are now calculated for all the acceleration metrics selected
\item g.part3, g.part4 and g.part5 are now independent on metric ENMO to work, argument acc.metric allows
the user to select which metric to use to describe behavior
\item Argument dayborder is now included in g.part5 to consider the whole measurement in case the protocol
starts after midnight
}
}

\section{Changes in version 1.5-10 (release date:12-7-2017)}{
\itemize{
\item Date format recognition improved for Actigraph csv files
Expand Down Expand Up @@ -232,4 +253,4 @@
\itemize{
\item This was the first version
}
}
}
4 changes: 2 additions & 2 deletions man/g.part3.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ them as nocturnal sleep or day time sustained inactivity periods.
Typical users should work with function g.shell.GGIR only.
}
\usage{
g.part3(metadatadir=c(),f0,f1,anglethreshold = 5,timethreshold = 5,metric="ENMO",
g.part3(metadatadir=c(),f0,f1,anglethreshold = 5,timethreshold = 5,acc.metric="ENMO",
ignorenonwear=FALSE,overwrite=FALSE,desiredtz="Europe/London")
}
\arguments{
Expand All @@ -37,7 +37,7 @@ g.part3(metadatadir=c(),f0,f1,anglethreshold = 5,timethreshold = 5,metric="ENMO"
default = 5. This can be specified as multiple thresholds, each of
which will be implemented. For example, timethreshold = c(5,10)
}
\item{metric}{
\item{acc.metric}{
Which one of the metrics do you want to consider to analyze L5. The metric of interest need to be calculated in M (see \link{g.part1})
}
\item{ignorenonwear}{
Expand Down
4 changes: 2 additions & 2 deletions man/g.part5.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ based on bouted periods as well as non-bouted periods.
\usage{
g.part5(datadir=c(),metadatadir=c(),f0=c(),f1=c(),strategy=1,maxdur=7,
hrs.del.start=0,hrs.del.end =0,
loglocation= c(),excludefirstlast=FALSE,windowsizes=c(5,900,3600), metric="ENMO",
loglocation= c(),excludefirstlast=FALSE,windowsizes=c(5,900,3600), acc.metric="ENMO",
boutcriter.mvpa=0.8,boutcriter.in=0.9,boutcriter.lig=0.8,
storefolderstructure=FALSE,threshold.lig = c(40),threshold.mod = c(100),
threshold.vig = c(400),timewindow=c("MM","WW"),boutdur.mvpa = c(1,5,10),
Expand Down Expand Up @@ -70,7 +70,7 @@ M5L5res = 10,overwrite=FALSE,desiredtz="Europe/London",bout.metric=4,dayborder=0
\item{windowsizes}{
see \link{g.getmeta}
}
\item{metric}{
\item{acc.metric}{
Which one of the metrics do you want to consider to describe behaviour. The metric of interest need to be calculated in M (see \link{g.part1})
}
\item{boutcriter.mvpa}{
Expand Down
4 changes: 2 additions & 2 deletions man/g.sib.det.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
\usage{
g.sib.det(M,IMP,I,twd=c(-12,12),anglethreshold = 5,
timethreshold = c(5,10), metric = "ENMO", desiredtz="Europe/London")
timethreshold = c(5,10), acc.metric = "ENMO", desiredtz="Europe/London")
}
\arguments{
\item{M}{
Expand All @@ -31,7 +31,7 @@
\item{timethreshold}{
See \link{g.part3}
}
\item{metric}{
\item{acc.metric}{
Which one of the metrics do you want to consider to analyze L5. The metric of interest need to be calculated in M (see \link{g.part1})
}
\item{desiredtz}{
Expand Down