Skip to content

Commit

Permalink
Merge pull request #519 from wadpac/issue284_dynamicrange
Browse files Browse the repository at this point in the history
Issue284 dynamicrange
  • Loading branch information
vincentvanhees authored Feb 22, 2022
2 parents 31453e7 + 457d60a commit e6531b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 5 additions & 7 deletions R/g.cwaread.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
g.cwaread = function(fileName, start = 0, end = 0, progressBar = FALSE, desiredtz = "",
configtz = c(), interpolationType=1) {

if (length(configtz) == 0) configtz = desiredtz
# Credits: The code in this function was contributed by Dr. Evgeny Mirkes (Leicester University, UK)
#========================================================================
Expand Down Expand Up @@ -110,12 +109,12 @@ g.cwaread = function(fileName, start = 0, end = 0, progressBar = FALSE, desiredt
upperDeviceId = readBin(fid, integer(), size = 2, signed = FALSE) #offset 11 12
if (upperDeviceId >= 65535) upperDeviceId = 0
uniqueSerialCode = upperDeviceId * 65536 + lowerDeviceId
suppressWarnings(readChar(fid, 23, useBytes = TRUE)) #offset 13..34
# sensorConfig = readBin(fid, raw(), size = 1) #offset 35
suppressWarnings(readChar(fid, 23, useBytes = TRUE)) #offset 13..35
# sample rate and dynamic range accelerometer
samplerate_dynrange = readBin(fid, integer(), size = 1) #offset 36
frequency_header = round( 3200 / bitwShiftL(1, 15 - bitwAnd(samplerate_dynrange, 15)))
accrange = bitwShiftR(16,(bitwShiftR(samplerate_dynrange,6)))
if (samplerate_dynrange < 0) samplerate_dynrange = samplerate_dynrange + 256
accrange = bitwShiftR(16, (bitwShiftR(abs(samplerate_dynrange), 6)))
suppressWarnings(readChar(fid, 4, useBytes = TRUE)) #offset 37..40
version = readBin(fid, integer(), size = 1) #offset 41
# Skip 982 bytes and go to the first data block
Expand All @@ -138,7 +137,7 @@ g.cwaread = function(fileName, start = 0, end = 0, progressBar = FALSE, desiredt
uniqueSerialCode = uniqueSerialCode, frequency = frequency_header,
start = start,
device = "Axivity", firmwareVersion = version, blocks = numDBlocks,
accrange = accrange, hardwareType=hardwareType
accrange = accrange, hardwareType = hardwareType
)
return(invisible(
returnobject
Expand Down Expand Up @@ -227,7 +226,7 @@ g.cwaread = function(fileName, start = 0, end = 0, progressBar = FALSE, desiredt
# modified for backwards-compatibility ... therefore undo this...
if (bitwAnd(tsOffset, 0x8000L) != 0) {
frequency_data = round( 3200 / bitwShiftL(1, 15 - bitwAnd(samplerate_dynrange, 15)))
accrange = bitwShiftR(16,(bitwShiftR(samplerate_dynrange,6)))
accrange = bitwShiftR(16,(bitwShiftR(abs(samplerate_dynrange),6)))
# Need to undo backwards-compatible shim:
# Take into account how many whole samples the fractional part
# of timestamp accounts for:
Expand Down Expand Up @@ -270,7 +269,6 @@ g.cwaread = function(fileName, start = 0, end = 0, progressBar = FALSE, desiredt
# Set names and Normalize accelerations
if (is.na(header$accrange == TRUE)) {
header$accrange = 8
# header$accrange = 8 # needed for (old) AX3 when used at non-8g setting
}
if (Naxes == 3) {
colnames(data)=c("x","y","z")
Expand Down
4 changes: 3 additions & 1 deletion inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
\name{NEWS}
\title{News for Package \pkg{GGIR}}
\newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
\section{Changes in version 2.6-1 (release date:??-??-2022)}{
\section{Changes in version 2.6-1 (release date:22-02-2022)}{
\itemize{
\item Part 1: Fixed bug that prohibitted processing files in subfolders.
\item Part 1: Dynamic range can now be extracted from Axivity .cwa files when not equal to 8g.
\item Part 2: Qwindows logically ordered in reports.
\item Part 2: Fixed bug #516 regarding passing on of dateformat.
\item Part 4: Fixed bug introduced in 2.6-0 relating to sleeplog guider being assined even when no sleeplog used.
\item Part 5: Improved handling of missing sleep estimate for first night.
\item General: Fix bug introduced in 2.6-0 relating to storage of configuration file on comma-separated machines
Expand Down

0 comments on commit e6531b3

Please sign in to comment.