From a98c06b35d4df80921f6996e9c32079d8011ef06 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Tue, 23 Jan 2024 13:41:19 +0100 Subject: [PATCH 01/10] #56 use first page time when header starttime is 2010-9-16 --- R/readGENEActiv.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/readGENEActiv.R b/R/readGENEActiv.R index a394343..085b39a 100644 --- a/R/readGENEActiv.R +++ b/R/readGENEActiv.R @@ -31,6 +31,12 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, x = gsub(pattern = "Device Model:", replacement = "", x = fh[grep(pattern = "Device Model", x = fh)[1]])) + if (starttime == "2010-09-16 09:10:00:000") { + # If recording started at this specific date and time then + # that indicates a known bug, use timestamp from first page instead + starttime = gsub(pattern = "Page Time:", replacement = "", + x = fh[grep(pattern = "Page Time", x = fh)[1]]) + } # Read acceleration, lux and temperature data rawdata = GENEActivReader(filename = filename, From 6afccc0bd817fc623970af27d9cff1fcf9b30ab3 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Tue, 23 Jan 2024 13:49:16 +0100 Subject: [PATCH 02/10] Update NEWS.Rd --- inst/NEWS.Rd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 4eb44c7..d66b719 100755 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -1,6 +1,11 @@ \name{NEWS} \title{News for Package \pkg{GGIRread}} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{Changes in version 0.3.3 (GitHub-only-release date:23-01-2024)}{ + \itemize{ + \item When GENEActiv device battery runs low before downloading data the timestamp in the file header will default to 2010-9-16. This is now corrected by using the timestamp from the first page header instead, issue #56 + } +} \section{Changes in version 0.3.2 (GitHub-only-release date:05-12-2023)}{ \itemize{ \item Improved handling of failed checksum in .cwa files #53 (credits: Lena Kushleyeva) From 80fd0a76610f91de463ecfac5427caa037dd53e5 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Tue, 23 Jan 2024 17:10:02 +0100 Subject: [PATCH 03/10] Create pull_request_template.md --- .github/pull_request_template.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..eacfb2d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,10 @@ + + + +Checklist before merging: + +- [ ] Existing tests still work (check by running the test suite, e.g. from RStudio). +- [ ] Added tests (if you added functionality) or fixed existing test (if you fixed a bug). +- [ ] Updated or expanded the documentation. +- [ ] Updated release notes in `inst/NEWS.Rd` with a user-readable summary. Please, include references to relevant issues or PR discussions. +- [ ] Added your name to the contributors lists in the `DESCRIPTION` file, if you think you made a significant contribution. From 5ae10096955ce7c38ddd8b97cc7f54d3bff26b76 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Tue, 23 Jan 2024 17:22:32 +0100 Subject: [PATCH 04/10] Update r_codecov.yml --- .github/workflows/r_codecov.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/r_codecov.yml b/.github/workflows/r_codecov.yml index 5a94268..cf9fa24 100644 --- a/.github/workflows/r_codecov.yml +++ b/.github/workflows/r_codecov.yml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: @@ -23,8 +23,28 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: covr + extra-packages: any::covr + needs: coverage - name: Test coverage - run: covr::codecov() - shell: Rscript {0} \ No newline at end of file + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package \ No newline at end of file From 72db84675b932296fd3aa9e66a34cc81c7c019c5 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Tue, 23 Jan 2024 17:36:27 +0100 Subject: [PATCH 05/10] minor rephrasing of code comment --- R/readGENEActiv.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/readGENEActiv.R b/R/readGENEActiv.R index 806a124..048e980 100644 --- a/R/readGENEActiv.R +++ b/R/readGENEActiv.R @@ -33,7 +33,9 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, if (starttime == "2010-09-16 09:10:00:000") { # If recording started at this specific date and time then - # that indicates a known bug, use timestamp from first page instead + # that indicates a known incorrectness of the timestamp (based on + # correspondence with manufacturer). In this case we should use the + # timestamp from first page instead. starttime = gsub(pattern = "Page Time:", replacement = "", x = fh[grep(pattern = "Page Time", x = fh)[1]]) } From 1fe834f36df2e0a88b4cae7d05450ecfd6620fa5 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Tue, 23 Jan 2024 17:53:14 +0100 Subject: [PATCH 06/10] Create codecov.yml --- codecov.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..d6a6357 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + informational: true + patch: + default: + target: auto + threshold: 1% + informational: true \ No newline at end of file From 1daeb84abf885be4dc5d309dd7dacb8223699859 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Wed, 24 Jan 2024 08:43:35 +0100 Subject: [PATCH 07/10] Use page time by default - omit attempt to use file header start time - omit +5 that is no longer needed because apparently this was the offset in the header timestamp --- R/readGENEActiv.R | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/R/readGENEActiv.R b/R/readGENEActiv.R index 048e980..6903dec 100644 --- a/R/readGENEActiv.R +++ b/R/readGENEActiv.R @@ -3,7 +3,7 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, # Extract information from the fileheader suppressWarnings({fh = readLines(filename, 69)}) - # fh = fh[1:30] + SN = gsub(pattern = "Device Unique Serial Code:", replacement = "", x = fh[grep(pattern = "Device Unique Serial Code", x = fh)[1]]) firmware = gsub(pattern = "Device Firmware Version:", replacement = "", @@ -12,8 +12,11 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, x = fh[grep(pattern = "Lux", x = fh)[1]])) Volts = as.numeric(gsub(pattern = "Volts:", replacement = "", x = fh[grep(pattern = "Volts", x = fh)[1]])) - starttime = gsub(pattern = "Start Time:", replacement = "", - x = fh[grep(pattern = "Start Time", x = fh)[1]]) + # We use first Page Time and not Start time from the file header + # because start time from the file header is known to be incorrect + # when battery runs out prior to end of recording + starttime = gsub(pattern = "Page Time:", replacement = "", + x = fh[grep(pattern = "Page Time", x = fh)[1]]) tzone = gsub(pattern = "Time Zone:", replacement = "", x = fh[grep(pattern = "Time Zone", x = fh)[1]]) @@ -30,16 +33,7 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, DeviceModel = gsub(pattern = " ", replacement = "", x = gsub(pattern = "Device Model:", replacement = "", x = fh[grep(pattern = "Device Model", x = fh)[1]])) - - if (starttime == "2010-09-16 09:10:00:000") { - # If recording started at this specific date and time then - # that indicates a known incorrectness of the timestamp (based on - # correspondence with manufacturer). In this case we should use the - # timestamp from first page instead. - starttime = gsub(pattern = "Page Time:", replacement = "", - x = fh[grep(pattern = "Page Time", x = fh)[1]]) - } - + # Read acceleration, lux and temperature data rawdata = GENEActivReader(filename = filename, start = start, end = end, @@ -77,7 +71,7 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, # Correct timestamps page_offset = (((start - 1) * 300) / rawdata$info$SampleRate) - starttime_num = as.numeric(starttime_posix) + 5 + page_offset #tzone + + starttime_num = as.numeric(starttime_posix) + page_offset rawdata$time = rawdata$time + abs(rawdata$time[1]) + starttime_num return(invisible(list( header = header, From 4b9eb59b4020db17dfc200bffe44eca4da64052f Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Wed, 24 Jan 2024 08:50:18 +0100 Subject: [PATCH 08/10] Update .Rbuildignore --- .Rbuildignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index 6dddbab..c6eb326 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,5 @@ ^\.github prepareNewRelease.R LICENSE +codecov.yml +*.Rproj \ No newline at end of file From 92c28781d00898fc70139c13eb0435ec4a81cd68 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Wed, 24 Jan 2024 08:54:21 +0100 Subject: [PATCH 09/10] Update .Rbuildignore --- .Rbuildignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Rbuildignore b/.Rbuildignore index c6eb326..567c6a0 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,4 +4,4 @@ prepareNewRelease.R LICENSE codecov.yml -*.Rproj \ No newline at end of file +^.Rproj \ No newline at end of file From 7644567c9ce63dd4ce60d82fd27ee12b520db006 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Wed, 24 Jan 2024 10:40:11 +0100 Subject: [PATCH 10/10] Update .Rbuildignore --- .Rbuildignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 567c6a0..315ca92 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,5 +3,4 @@ ^\.github prepareNewRelease.R LICENSE -codecov.yml -^.Rproj \ No newline at end of file +codecov.yml \ No newline at end of file