-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparameters.R
More file actions
108 lines (86 loc) · 3.42 KB
/
Copy pathparameters.R
File metadata and controls
108 lines (86 loc) · 3.42 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#####################################################################
#
#Folder where we find the meta and result folders generated by GGIR
baseEpoch="."
##(Re)definiendo variables adaptadas a nuestro proyecto
defineWhat=list(
nonWear=nonWear,
isOn=isOn,
SIB=SIB,
bed=bedGGIR,
VIG_01m=function(df) enmoOver (df, limInf=400/1000, pctBouts=0.8, durBoutMin=dminutes(1)),
MVPA_10m=function(df) enmoOver (df, limInf=100/1000, pctBouts=0.8, durBoutMin=dminutes(10)),
MVPA_05m=function(df) enmoOver (df, limInf=100/1000, pctBouts=0.8, durBoutMin=dminutes(5)),
INAC_20m=function(df) enmoUnder (df, limSup=40/1000, pctBouts=0.9, durBoutMin=dminutes(20)),
LIG_10m=function(df) enmoBetween(df, limInf=40/1000, limSup=100/1000, pctBouts=0.8, durBoutMin=dminutes(5))
)
#There a la lot of WHEN we want to do the measurements. Some typical are those
defineWhen=function(intervals,idBIN=""){
bed=genWhen_bedGGIR(intervals,label="bed")
awake= genWhen_awake(intervals,bed)
daily= genWhen_daily(intervals)
list(daily=daily,
bed=bed,
awake=awake
)
}
#Different authos have different criteria validity for some WHENs. Put here your criteria or add new one.
#Please write add the end some text that works as reason to remove that when in computations.
# It will be useful to know whay some data is not going to be used.
whenValidity=list(
################################
#Duration Criteria for validity
################################
directInvalidation=function(summary){
list(
invalidBedOfFirstDay(summary,reason="noBedBeforeOn"),
invalidDuration(summary,whatCond="isOn",whenCond="bed",maxDur=dhours(14),reason="bedTooLong"),
invalidDuration(summary,whatCond="isOn",whenCond="bed",minDur=dminutes(180),reason="bedTooShort"),
invalidDuration(summary,whatCond="nonWear",whenCond="daily",maxDur=dminutes(120),reason="nonWear")
) %>%
map_df(rbind)
},
##########################
#Propagation of invalidity
# If some WHEN is invalid, probably
# this will affect others. Write it here.
##########################
cascadeInvalid=list(
daily=c("awake"),
bed=c("awake")
)
)
# Perhaps we don not what to measure all WHATS in every WHEN.
#Put here what your are interested in measuring
whenMeasuresWhat=list(
"daily"=c("isOn", "nonWear", "MVPA_5m", "MVPA_10m","VIG_01m","INAC_20m","LIG_10m"),
"awake"=c("isOn","MVPA_5m", "MVPA_10m","VIG_01m","INAC_20m","LIG_10m","SIB"),
"bed"=c("isOn", "SIB")
)
#The duration of WHAT in WHEN is measured in seconds. If you prefer some other unit,
#modify it here:
durationToUserUnits=function(what,when){
case_when(
what == "isOn" ~ dhours(1),
what == "SIB" & when=="awake" ~ dminutes(1),
what == "SIB" ~ dhours(1),
what == "nonWear" ~ dhours(1),
what == "VPA_1m" ~ dminutes(1),
what == "MVPA_5m" ~ dminutes(1),
what == "MVPA_10m" ~ dminutes(1),
what == "INAC_20m" ~ dhours(1),
what == "LIG_10m" ~ dminutes(1),
what == "bed" ~ dhours(1),
TRUE ~ dseconds(1)
)
}
#################################################################
# We create a list with the data needed to execute a project
#################################################################
currentProject=list(
defineWhat=defineWhat,
defineWhen=defineWhen,
whenValidity=whenValidity,
whenMeasuresWhat=whenMeasuresWhat,
durationToUserUnits=durationToUserUnits
)