| Title: | Baseline Package for Reading Actigraphy and Activity Data |
|---|---|
| Description: | Provides baseline functions for reading actigraphy and activity data, relying on baseline functions from 'actibase'. Reads data from 'Axivity' 'CWA' <https://axivity.com/> , ActiGraph 'GT3X' <https://ametris.com/actigraph-wgt3x-bt>, 'SensorLog' <https://sensorlog.berndthomas.net/>, and 'SensorLogger' <https://www.tszheichoi.com/sensorlogger> zipped CSV files. |
| Authors: | John Muschelli [aut, cre] (ORCID: <https://orcid.org/0000-0001-6469-1750>) |
| Maintainer: | John Muschelli <[email protected]> |
| License: | GPL-3 |
| Version: | 0.5.0 |
| Built: | 2026-10-05 16:36:00 UTC |
| Source: | https://github.com/jhuwit/actiread |
Convert vectors ensuring no new NA
acti_convert_sensorlogger_time(x)acti_convert_sensorlogger_time(x)
x |
a vector |
A converted 'vector' the same length as 'x' or errors if there are introduced NAs.
Decompresses .bz2, .gz, and .xz files to a temporary file. If
extension is NULL, the destination extension is inferred after removing
the compression extension from path.
acti_decompress_file(path, extension = NULL)acti_decompress_file(path, extension = NULL)
path |
Path to an activity-data file, optionally compressed. |
extension |
Output file extension. Defaults to |
A list with path, the usable file path, and temporary, which is
TRUE when a temporary decompressed file was created. Callers should
delete path when temporary is TRUE.
file = acti_decompress_file(acti_example_cwa()) if (file$temporary) { unlink(file$path) }file = acti_decompress_file(acti_example_cwa()) if (file$temporary) { unlink(file$path) }
Activity/Actigraphy Example Data
acti_example_gt3x() acti_example_cwa() acti_example_geneactiv() acti_example_sensorlog_file() acti_example_sensorlogger_file() acti_example_sensorlogger_location_file()acti_example_gt3x() acti_example_cwa() acti_example_geneactiv() acti_example_sensorlog_file() acti_example_sensorlogger_file() acti_example_sensorlogger_location_file()
A file path
library(actiread) acti_example_gt3x() acti_example_cwa() acti_example_sensorlogger_file()library(actiread) acti_example_gt3x() acti_example_cwa() acti_example_sensorlogger_file()
actipy
Read CWA File with actipy
acti_py_read_cwa( path, lowpass_hz = FALSE, calibrate_gravity = FALSE, detect_nonwear = FALSE, resample_hz = FALSE, ..., tz = "UTC", apply_tz = TRUE, verbose = TRUE )acti_py_read_cwa( path, lowpass_hz = FALSE, calibrate_gravity = FALSE, detect_nonwear = FALSE, resample_hz = FALSE, ..., tz = "UTC", apply_tz = TRUE, verbose = TRUE )
path |
Path to cwa file |
lowpass_hz |
Frequency of low pass filter |
calibrate_gravity |
perform gravity calibration method of van Hees et al. 2014 https://doi.org/10.1152/japplphysiol.00421.2014 |
detect_nonwear |
Flag nonwear episodes in the data by setting them to
|
resample_hz |
Target frequency (Hz) to resample the signal. If
|
... |
additional arguments to pass to |
tz |
time zone for the data |
apply_tz |
turn the |
verbose |
print diagnostic messages, higher values = more verbosity. |
A tibble with attributes of a header, sample rate, and
transformations
if (requireNamespace("reticulate", quietly = TRUE) && requireNamespace("arrow", quietly = TRUE)) { if (reticulate::py_module_available("actipy") && reticulate::py_module_available("pyarrow")) { data = acti_py_read_cwa(acti_example_cwa()) } }if (requireNamespace("reticulate", quietly = TRUE) && requireNamespace("arrow", quietly = TRUE)) { if (reticulate::py_module_available("actipy") && reticulate::py_module_available("pyarrow")) { data = acti_py_read_cwa(acti_example_cwa()) } }
Read CWA File
acti_read_cwa( path, start = 0, end = Inf, tz = "UTC", ..., apply_tz = TRUE, verbose = TRUE ) acti_read_cwa_header(path)acti_read_cwa( path, start = 0, end = Inf, tz = "UTC", ..., apply_tz = TRUE, verbose = TRUE ) acti_read_cwa_header(path)
path |
Path to cwa file |
start |
where to start in the file, passed to GGIRread::readAxivity |
end |
where to end in the file, passed to GGIRread::readAxivity |
tz |
time zone for the data |
... |
additional arguments to pass to |
apply_tz |
turn the |
verbose |
print diagnostic messages, higher values = more verbosity. |
A tibble with attributes of a header, sample rate, and
transformations
data = acti_read_cwa(acti_example_cwa()) data = acti_read_cwa( acti_example_cwa(), tz = NULL, apply_tz = FALSE, verbose = FALSE )data = acti_read_cwa(acti_example_cwa()) data = acti_read_cwa( acti_example_cwa(), tz = NULL, apply_tz = FALSE, verbose = FALSE )
Read GENEActiv Binary File
acti_read_geneactiv( path, start = 0, end = Inf, tz = "UTC", ..., verbose = TRUE ) acti_read_geneactiv_header(path)acti_read_geneactiv( path, start = 0, end = Inf, tz = "UTC", ..., verbose = TRUE ) acti_read_geneactiv_header(path)
path |
Path to geneactiv binary file |
start |
where to start in the file, passed to GGIRread::readGENEActiv |
end |
where to end in the file, passed to GGIRread::readGENEActiv |
tz |
time zone for the data |
... |
additional arguments to pass to |
verbose |
print diagnostic messages, higher values = more verbosity. |
A tibble with attributes of a header, sample rate, and
transformations
data = acti_read_cwa(acti_example_cwa()) data = acti_read_cwa( acti_example_cwa(), tz = NULL, apply_tz = FALSE, verbose = FALSE )data = acti_read_cwa(acti_example_cwa()) data = acti_read_cwa( acti_example_cwa(), tz = NULL, apply_tz = FALSE, verbose = FALSE )
Read GT3X file
acti_read_gt3x( path, asDataFrame = TRUE, imputeZeroes = TRUE, verbose = TRUE, ..., fill_zeroes = TRUE, apply_tz = FALSE, check_attributes = TRUE, tz = "GMT" ) acti_info_gt3x(path, ...)acti_read_gt3x( path, asDataFrame = TRUE, imputeZeroes = TRUE, verbose = TRUE, ..., fill_zeroes = TRUE, apply_tz = FALSE, check_attributes = TRUE, tz = "GMT" ) acti_info_gt3x(path, ...)
path |
Path to gt3x file |
asDataFrame |
convert to an |
imputeZeroes |
Impute zeros in case there are missingness?
Default is |
verbose |
print diagnostic messages, higher values = more verbosity. |
... |
additional arguments to pass to |
fill_zeroes |
Rows with all zeros will be filled in with the last observation carried forward as is done with ActiLife. Recommended |
apply_tz |
Apply the timezone from the header |
check_attributes |
Check that the attributes are included This is a sanity check,
including checking that |
tz |
timezone to project the data into. The data read in via
|
A data.frame
library(actiread) data = acti_read_gt3x(acti_example_gt3x()) data = acti_read_gt3x( acti_example_gt3x(), tz = NULL, apply_tz = FALSE, verbose = FALSE, fill_zeroes = FALSE ) info = acti_info_gt3x(acti_example_gt3x())library(actiread) data = acti_read_gt3x(acti_example_gt3x()) data = acti_read_gt3x( acti_example_gt3x(), tz = NULL, apply_tz = FALSE, verbose = FALSE, fill_zeroes = FALSE ) info = acti_info_gt3x(acti_example_gt3x())
Read SensorLog Data
acti_read_sensorlog(file, verbose = FALSE, robust = FALSE) acti_sensorlog_csv_spec() acti_sensorlog_csv_colnames_mapping()acti_read_sensorlog(file, verbose = FALSE, robust = FALSE) acti_sensorlog_csv_spec() acti_sensorlog_csv_colnames_mapping()
file |
A character vector of SensorLog files, usually from unzipping the file |
verbose |
print diagnostic messages. Either logical or integer, where higher values are higher levels of verbosity. |
robust |
if |
A data.frame of data
library(actiread) file = acti_example_sensorlog_file() df = acti_read_sensorlog(file) head(df)library(actiread) file = acti_example_sensorlog_file() df = acti_read_sensorlog(file) head(df)
actipy for reticulate
Require actipy for reticulate
acti_require_actipy(..., python_version = "3.9")acti_require_actipy(..., python_version = "3.9")
... |
additional arguments to pass to reticulate::py_require |
python_version |
version of python passed to reticulate::py_require |
invisible NULL
Rewrite a CSV that may have issues with export from SensorLog
acti_rewrite_sensorlog_csv( file, outfile = tempfile(fileext = ".csv"), verbose = FALSE )acti_rewrite_sensorlog_csv( file, outfile = tempfile(fileext = ".csv"), verbose = FALSE )
file |
Input CSV file |
outfile |
Output CSV file |
verbose |
Print Diagnostic messages |
A file path to the new CSV
sl_file = actiread::acti_example_sensorlog_file() tfile = tempfile() files = utils::unzip(sl_file, exdir = tfile) result = actiread::acti_rewrite_sensorlog_csv(files)sl_file = actiread::acti_example_sensorlog_file() tfile = tempfile() files = utils::unzip(sl_file, exdir = tfile) result = actiread::acti_rewrite_sensorlog_csv(files)
Read SensorLogger Data
acti_sensorlogger_location_colnames_mapping() acti_sensorlogger_location_spec() acti_read_sensorlogger_location(file, ...) acti_read_sensorlogger(file, verbose = FALSE, ...) acti_read_sensorlogger_general(file, ..., verbose = FALSE)acti_sensorlogger_location_colnames_mapping() acti_sensorlogger_location_spec() acti_read_sensorlogger_location(file, ...) acti_read_sensorlogger(file, verbose = FALSE, ...) acti_read_sensorlogger_general(file, ..., verbose = FALSE)
file |
A character vector of SensorLogger files, usually from unzipping the file, or a zip file of SensorLogger files |
... |
additional arguments to pass to |
verbose |
print diagnostic messages. Either logical or integer, where higher values are higher levels of verbosity. |
A data.frame of data
Transform timezone offset to timezone
tzoffset_to_tz(x)tzoffset_to_tz(x)
x |
A character vector |
A character vector
tzoffset_to_tz(c("+00:00", "-05:00", "+01:00"))tzoffset_to_tz(c("+00:00", "-05:00", "+01:00"))