Skip to content

Commit

Permalink
Merge pull request #57 from wadpac/issue56_GENEActiv_firstpage
Browse files Browse the repository at this point in the history
Extract GENEActiv starttime from first page header.
  • Loading branch information
vincentvanhees authored Jan 24, 2024
2 parents 9c4aea2 + 7644567 commit 23e7a8b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
^\.github
prepareNewRelease.R
LICENSE
codecov.yml
10 changes: 10 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- Describe your PR here -->

<!-- Please, make sure the following items are checked -->
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.
28 changes: 24 additions & 4 deletions .github/workflows/r_codecov.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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}
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
14 changes: 8 additions & 6 deletions R/readGENEActiv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand All @@ -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]])
Expand All @@ -30,8 +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]]))



# Read acceleration, lux and temperature data
rawdata = GENEActivReader(filename = filename,
start = start, end = end,
Expand Down Expand Up @@ -69,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,
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true
5 changes: 5 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 23e7a8b

Please sign in to comment.