diff --git a/NEWS.md b/NEWS.md index a692f0bd4..5eae56338 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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. diff --git a/R/convertEpochData.R b/R/convertEpochData.R index 5f5da78fa..fa05a9664 100644 --- a/R/convertEpochData.R +++ b/R/convertEpochData.R @@ -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] diff --git a/R/g.getmeta.R b/R/g.getmeta.R index eaccb6072..94e74f079 100644 --- a/R/g.getmeta.R +++ b/R/g.getmeta.R @@ -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 } #=============================================== @@ -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) @@ -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]) @@ -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) { @@ -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 @@ -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)) @@ -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 }