Skip to content

Commit

Permalink
Merge pull request #995 from wadpac/issue991_v3_tempcolumn_adhoccsv_c…
Browse files Browse the repository at this point in the history
…alibration

Extension to PR 993
  • Loading branch information
vincentvanhees authored Dec 13, 2023
2 parents 55f233b + ee9d3df commit 4e33a63
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

- Part 5: Fix bug in recently added functionality for studying overlap between sibs and self-reported behaviours #989.

- Part 1: Fix bug in adhoc-csv format calibration process as it could not extract temperature column #991
- Part 1:Enable use of temperature data in adhoc-csv format throughout GGIR #991

- Part 1: Fix bug that caused a mismatch between IDs and filenames in part 1 when movisens participant folders did not contain the acc.bin file #994.

Expand Down
2 changes: 1 addition & 1 deletion R/convertEpochData.R
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ convertEpochData = function(datadir = c(), metadatadir = c(),
}
if (is.na(vmcol[1]) == FALSE) {
D = as.matrix(D, drop = FALSE) # convert to matrix as data.frame will auto-collapse to vector
colnames(D)[vmcol] = c("NeishabouriCount_vm")
colnames(D)[vmcol] = c("NeishabouriCount_x")
}
keep = c(acccol, vmcol)[!is.na(c(acccol, vmcol))]
D = D[, keep, drop = FALSE]
Expand Down
23 changes: 8 additions & 15 deletions R/g.getmeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
QClog = NULL
if (temp.available == FALSE) {
metalong = matrix(" ", ((nev/(sf*ws2)) + 100), 4) #generating output matrix for 15 minutes summaries
} else if (temp.available == TRUE && mon != MONITOR$MOVISENS) {
} else if (temp.available == TRUE && mon != MONITOR$MOVISENS && mon != MONITOR$AD_HOC) {
metalong = matrix(" ", ((nev/(sf*ws2)) + 100), 7) #generating output matrix for 15 minutes summaries
} else if (temp.available == TRUE && mon == MONITOR$MOVISENS) {
} else if (temp.available == TRUE && (mon == MONITOR$MOVISENS || mon == MONITOR$AD_HOC)) {
metalong = matrix(" ", ((nev/(sf*ws2)) + 100), 5) #generating output matrix for 15 minutes summaries
}
#===============================================
Expand Down Expand Up @@ -364,10 +364,10 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
(mon == MONITOR$AXIVITY && dformat == FORMAT$CSV) ||
(mon == MONITOR$AD_HOC && use.temp == FALSE)) {
metricnames_long = c("timestamp","nonwearscore","clippingscore","en")
} else if (mon == MONITOR$GENEACTIV || (mon == MONITOR$AXIVITY && dformat == FORMAT$CWA) ||
(mon == MONITOR$AD_HOC & use.temp == TRUE)) {
} else if (mon == MONITOR$GENEACTIV || (mon == MONITOR$AXIVITY && dformat == FORMAT$CWA)) {
metricnames_long = c("timestamp","nonwearscore","clippingscore","lightmean","lightpeak","temperaturemean","EN")
} else if (mon == MONITOR$MOVISENS) {
} else if (mon == MONITOR$MOVISENS || (mon == MONITOR$AD_HOC & use.temp == TRUE)) {
# at the moment read.myacc.csv does not facilitate extracting light data, so only temperature is used
metricnames_long = c("timestamp","nonwearscore","clippingscore","temperaturemean","EN")
}
rm(SWMT)
Expand Down Expand Up @@ -424,7 +424,7 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
} else if (mon == MONITOR$MOVISENS) {
temperaturecolumn = 4
} else if (mon == MONITOR$AD_HOC) {
temperaturecolumn = params_rawdata[["rmc.col.temp"]]
temperaturecolumn = which(colnames(data) == "temperature")
}
if (mon != MONITOR$AD_HOC && mon != MONITOR$MOVISENS) {
light = as.numeric(data[, lightcolumn])
Expand All @@ -435,7 +435,6 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
}
temperature = as.numeric(data[, temperaturecolumn])
}

# Initialization of variables
data_scaled = FALSE
if (mon == MONITOR$ACTIGRAPH && dformat == FORMAT$GT3X) {
Expand Down Expand Up @@ -485,12 +484,6 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
data = apply(data, 2,as.numeric)
}
}
if (ncol(data) >= 4 & mon == MONITOR$AD_HOC) {
columns_to_use = params_rawdata[["rmc.col.acc"]]
} else {
columns_to_use = 1:3
}
data = data[,columns_to_use]
suppressWarnings(storage.mode(data) <- "numeric")
if ((mon == MONITOR$ACTIGRAPH || mon == MONITOR$AD_HOC || mon == MONITOR$VERISENSE) && use.temp == FALSE) {
data = scale(data,center = -offset, scale = 1/scale) #rescale data
Expand Down Expand Up @@ -610,7 +603,7 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
metalong[count2:((count2 - 1) + length(NWav)),col_mli] = NWav; col_mli = col_mli + 1
metalong[(count2):((count2 - 1) + length(NWav)),col_mli] = CWav; col_mli = col_mli + 1
if (mon == MONITOR$GENEACTIV || (mon == MONITOR$AXIVITY && dformat == FORMAT$CWA) ||
mon == MONITOR$MOVISENS) { # going from sample to ws2
mon == MONITOR$MOVISENS || (mon == MONITOR$AD_HOC && length(params_rawdata[["rmc.col.temp"]]) != 0)) { # going from sample to ws2
if (mon == MONITOR$GENEACTIV || mon == MONITOR$AXIVITY) {
#light (running mean)
lightc = cumsum(c(0,light))
Expand Down Expand Up @@ -646,7 +639,7 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
col_mli = col_mli + 1
metalong[(count2):((count2 - 1) + length(NWav)), col_mli] = round(temperatureb, digits = n_decimal_places)
col_mli = col_mli + 1
} else if (mon == MONITOR$MOVISENS) {
} else if (mon == MONITOR$MOVISENS || (mon == MONITOR$AD_HOC && length(params_rawdata[["rmc.col.temp"]]) != 0)) {
metalong[(count2):((count2 - 1) + length(NWav)), col_mli] = round(temperatureb, digits = n_decimal_places)
col_mli = col_mli + 1
}
Expand Down

0 comments on commit 4e33a63

Please sign in to comment.