Closed muschellij2 closed 3 years ago
Hi,
Unlike other accelerometer loggers, the explicit aim of the AX devices was to record the direct, raw output of the underlying sensor. This avoids any blocking/aliasing which might occur if the resampling was done on the device itself, while also allowing the user the choice of whether to process the data later if they would like to simulate device-based resampling at an exact rate. To enable this, while the underlying sensor's internal clock is slightly variable, samples periodically receive a time stamp from a more precise real-time clock.
The means that, while you might see a slightly variable number of raw samples per given epoch, you can choose to use the true sample values over the epoch, or choose to simulate a fixed rate by resampling with any number of approaches. Because this was not done on the device itself before recording, you are free to change your mind later.
I'm reading in the sample CWA file from UK Biobank from this page https://biobank.ctsu.ox.ac.uk/crystal/field.cgi?id=90001 (Resources tab). I wrapped https://github.com/digitalinteraction/openmovement/blob/master/Software/AX3/cwa-convert/c/main.c into the
read.cwa
package (https://github.com/muschellij2/read.cwa) and thepycwa
wraps theaccProcess.py
code from https://github.com/activityMonitoring/biobankAccelerometerAnalysis/tree/master/accelerometer to compare the results. As you can see from the counts from the data indicate some seconds have > 100 (the sampling rate) records, but I'm wondering if some resampling is done in any way.Created on 2020-11-02 by the reprex package (v0.3.0.9001)
Session info
sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.2 (2020-06-22) #> os macOS Catalina 10.15.6 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz America/New_York #> date 2020-11-02 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.0.0) #> backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.2) #> cli 2.1.0 2020-10-12 [1] CRAN (R 4.0.2) #> colorout * 1.2-2 2020-06-01 [2] Github (jalvesaq/colorout@726d681) #> crayon 1.3.4 2017-09-16 [2] CRAN (R 4.0.0) #> data.table 1.13.2 2020-10-19 [1] CRAN (R 4.0.2) #> digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.2) #> dplyr * 1.0.2 2020-08-18 [2] CRAN (R 4.0.2) #> ellipsis 0.3.1 2020-05-15 [2] CRAN (R 4.0.0) #> evaluate 0.14 2019-05-28 [2] CRAN (R 4.0.0) #> fansi 0.4.1 2020-01-08 [2] CRAN (R 4.0.0) #> fs 1.5.0 2020-07-31 [2] CRAN (R 4.0.2) #> generics 0.0.2 2018-11-29 [2] CRAN (R 4.0.0) #> GGIR * 2.1-3 2020-10-22 [1] Github (wadpac/GGIR@49aedcd) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2) #> highr 0.8 2019-03-20 [2] CRAN (R 4.0.0) #> hms 0.5.3 2020-01-08 [2] CRAN (R 4.0.0) #> htmltools 0.5.0 2020-06-16 [2] CRAN (R 4.0.0) #> jsonlite 1.7.1 2020-09-07 [1] CRAN (R 4.0.2) #> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.2) #> lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.2) #> lifecycle 0.2.0 2020-03-06 [2] CRAN (R 4.0.0) #> lubridate * 1.7.9 2020-06-08 [2] CRAN (R 4.0.0) #> magrittr 1.5 2014-11-22 [2] CRAN (R 4.0.0) #> Matrix 1.2-18 2019-11-27 [2] CRAN (R 4.0.2) #> pillar 1.4.6 2020-07-10 [2] CRAN (R 4.0.2) #> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.0.0) #> purrr 0.3.4 2020-04-17 [2] CRAN (R 4.0.0) #> pycwa * 0.1.0 2020-10-30 [1] local #> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.0.2) #> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.0.2) #> R.utils 2.10.1 2020-08-26 [1] CRAN (R 4.0.2) #> R6 2.4.1 2019-11-12 [2] CRAN (R 4.0.0) #> Rcpp 1.0.5 2020-07-06 [2] CRAN (R 4.0.0) #> read.cwa * 0.2.1 2020-10-26 [1] local #> readr * 1.4.0 2020-10-05 [1] CRAN (R 4.0.2) #> reprex 0.3.0.9001 2020-09-30 [1] Github (tidyverse/reprex@d3fc4b8) #> reticulate 1.18 2020-10-25 [1] CRAN (R 4.0.2) #> rlang 0.4.8.9000 2020-10-22 [1] Github (r-lib/rlang@7a36238) #> rmarkdown 2.4 2020-09-30 [1] CRAN (R 4.0.2) #> rstudioapi 0.11 2020-02-07 [2] CRAN (R 4.0.0) #> sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 4.0.0) #> stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2) #> stringr 1.4.0 2019-02-10 [2] CRAN (R 4.0.0) #> styler 1.3.2 2020-02-23 [2] CRAN (R 4.0.0) #> tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.2) #> tidyselect 1.1.0 2020-05-11 [2] CRAN (R 4.0.0) #> utf8 1.1.4 2018-05-24 [2] CRAN (R 4.0.0) #> vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2) #> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.2) #> xfun 0.18 2020-09-29 [1] CRAN (R 4.0.2) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.0) #> #> [1] /Users/johnmuschelli/Library/R/4.0/library #> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/libraryJust the r code (without output):