Skip to content

Commit

Permalink
Merge pull request #1004 from wadpac/corrupt-axivity
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvanhees authored Dec 21, 2023
2 parents f350e27 + 9018d63 commit 1f24d5d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CHANGES IN GGIR VERSION 3.0-3

- Part 2: Fix bug where data_quality_report.csv contained incorrect filehealth[...] values whenever some of these values were supposed to be blank #1003

- Part 1: Fix bug where on machines with GMT timezone and R >= 4.3.0, for GENEActiv .bin files, the starting timestamps of M$metalong and M$metashort were truncated to midninght #1000

# CHANGES IN GGIR VERSION 3.0-2
Expand Down
28 changes: 14 additions & 14 deletions R/g.analyse.perfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ g.analyse.perfile = function(I, C, metrics_nav,
# them and logging the information.
# Normally we do not expect issue with cwa files, but by logging the information
# we will facilitate better insight into when this happens.
filesummary[vi:(vi + 6)] = c(file_summary$Dur_imputed, # total imputed
file_summary$Dur_chsum_failed, # checksum
file_summary$Dur_nonincremental, # nonincremental id between blocks
file_summary$Dur_freqissue_5_10, # bias 5-10%
file_summary$Dur_freqissue_10_20, # bias 10-20%
file_summary$Dur_freqissue_20_30, # bias 20-30%
file_summary$Dur_freqissue_30) # bias >30%
filesummary[vi:(vi + 6)] = c(ifelse(is.null(file_summary$Dur_imputed), " ", file_summary$Dur_imputed), # total imputed
ifelse(is.null(file_summary$Dur_chsum_failed), " ", file_summary$Dur_chsum_failed), # checksum
ifelse(is.null(file_summary$Dur_nonincremental), " ", file_summary$Dur_nonincremental), # nonincremental id between blocks
ifelse(is.null(file_summary$Dur_freqissue_5_10), " ", file_summary$Dur_freqissue_5_10), # bias 5-10%
ifelse(is.null(file_summary$Dur_freqissue_10_20), " ", file_summary$Dur_freqissue_10_20), # bias 10-20%
ifelse(is.null(file_summary$Dur_freqissue_20_30), " ", file_summary$Dur_freqissue_20_30), # bias 20-30%
ifelse(is.null(file_summary$Dur_freqissue_30), " ", file_summary$Dur_freqissue_30)) # bias >30%
s_names[vi:(vi + 6)] = c("filehealth_totimp_min",
"filehealth_checksumfail_min",
"filehealth_niblockid_min", # non incremental block id
Expand All @@ -87,13 +87,13 @@ g.analyse.perfile = function(I, C, metrics_nav,
"filehealth_fbias2030_min",
"filehealth_fbias30_min")
vi = vi + 7
filesummary[vi:(vi + 6)] = c( file_summary$Nblocks_imputed,
file_summary$Nblocks_chsum_failed,
file_summary$Nblocks_nonincremental,
file_summary$Nblock_freqissue_5_10,
file_summary$Nblock_freqissue_10_20,
file_summary$Nblock_freqissue_20_30,
file_summary$Nblock_freqissue_30)
filesummary[vi:(vi + 6)] = c( ifelse(is.null(file_summary$Nblocks_imputed), " ", file_summary$Nblocks_imputed),
ifelse(is.null(file_summary$Nblocks_chsum_failed), " ", file_summary$Nblocks_chsum_failed),
ifelse(is.null(file_summary$Nblocks_nonincremental), " ", file_summary$Nblocks_nonincremental),
ifelse(is.null(file_summary$Nblock_freqissue_5_10), " ", file_summary$Nblock_freqissue_5_10),
ifelse(is.null(file_summary$Nblock_freqissue_10_20), " ", file_summary$Nblock_freqissue_10_20),
ifelse(is.null(file_summary$Nblock_freqissue_20_30), " ", file_summary$Nblock_freqissue_20_30),
ifelse(is.null(file_summary$Nblock_freqissue_30), " ", file_summary$Nblock_freqissue_30))
s_names[vi:(vi + 6)] = c("filehealth_totimp_N",
"filehealth_checksumfail_N",
"filehealth_niblockid_N",
Expand Down
1 change: 1 addition & 0 deletions R/g.applymetrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ g.applymetrics = function(data, sf, ws3, metrics2do,
xm[which(xm[1:S2check] == 0)] = xm[which(xm[1:S2check] != 0)[1]]
# tail
LN = length(xm)
S2check = min(LN-1, S2check)
xm_tail = xm[(LN - S2check):LN]
lastvalue = xm_tail[which(xm_tail != 0)][1]
if (length(lastvalue) == 0) lastvalue = xm[which(xm != 0)][1]
Expand Down
20 changes: 17 additions & 3 deletions R/g.getmeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,14 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
if (filecorrupt == FALSE & filetooshort == FALSE & filedoesnotholdday == FALSE) {
cut = count:nrow(metashort)
if (length(cut) > 1) {
metashort = as.matrix(metashort[-cut,])
tmp = metashort[-cut,]
# for a very small file, there could be just one row in metashort[-cut,], so it gets coerced to a vector.
# But what we actually need is a 1-row matrix. So we need to transpose it.
if(is.vector(tmp)) {
metashort = as.matrix(t(tmp))
} else {
metashort = as.matrix(tmp)
}
}
if (nrow(metashort) > 1) {
starttime3 = round(as.numeric(starttime)) #numeric time but relative to the desiredtz
Expand All @@ -737,9 +744,16 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
time6 = strftime(time6, format = "%Y-%m-%dT%H:%M:%S%z")
metashort[,1] = as.character(time6)
}
cut2 = (count2):nrow(metalong) # how it was
cut2 = count2:nrow(metalong)
if (length(cut2) > 1) {
metalong = as.matrix(metalong[-cut2,])
tmp = metalong[-cut2,]
# for a very small file, there could be just one row in metalong[-cut2,], so it gets coerced to a vector.
# But what we actually need is a 1-row matrix. So we need to transpose it.
if(is.vector(tmp)) {
metalong = as.matrix(t(tmp))
} else {
metalong = as.matrix(tmp)
}
}
if (nrow(metalong) > 2) {
starttime4 = round(as.numeric(starttime)) #numeric time but relative to the desiredtz
Expand Down
4 changes: 2 additions & 2 deletions R/g.plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ g.plot = function(IMP, M, I, durplot) {
if (length(fname2) > 1) fname = paste0(fname2[1], fname2[2])

# Time variable and duration of recording
ws3 = M$windowsize[1]
ws2 = M$windowsize[2]
ws3 = M$windowsizes[1]
ws2 = M$windowsizes[2]
n_ws2_perday = (1440*60) / ws2
timeline = 1:nrow(M$metalong)
durplot = durplot * n_ws2_perday
Expand Down

0 comments on commit 1f24d5d

Please sign in to comment.