| Type: | Package |
| Title: | Create Metrics Actigraphy and Activity Analysis |
| Version: | 0.4.0 |
| Description: | Provides functions for calibrating, counting, and summarizing actigraphy and activity data into specific metrics and sleep measures. The metrics include activity counts, step counts, activity index, Monitor Independent Movement Summary Unit (MIMS), mean amplitude deviation (MAD), and provides wrappers for sleep estimation from activity counts using Tudor-Locke (2014) <doi:10.1139/apnm-2013-0173> and Sadeh (1994) <doi:10.1093/sleep/17.3.201>. |
| License: | GPL-3 |
| Depends: | R (≥ 4.1.0) |
| Suggests: | testthat, utils, covr, knitr, httr, rmarkdown, MIMSunit, data.table, reticulate, stepcount (≥ 0.6.0), actigraph.sleepr (≥ 0.3.1), agcounts (≥ 0.6.7), callr |
| Encoding: | UTF-8 |
| VignetteBuilder: | knitr |
| Imports: | actibase, actiread, dplyr, lubridate, assertthat, purrr, tibble, rlang, stats, tidyr, walking (≥ 0.8.0), methods |
| LazyData: | true |
| Config/roxygen2/version: | 8.0.0 |
| URL: | https://jhuwit.github.io/actimetrics/ |
| BugReports: | https://github.com/jhuwit/actimetrics/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-09-08 16:17:38 UTC; johnmuschelli |
| Author: | John Muschelli |
| Maintainer: | John Muschelli <muschellij2@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-17 09:10:15 UTC |
Process Count Data
Description
Process Count Data
Process Count Data
Usage
acti_calculate_counts(
data,
epoch = 60L,
resample = TRUE,
lfe_select = FALSE,
verbose = TRUE
)
acti_calculate_wear(
data,
method = c("choi", "troiano"),
use_magnitude = TRUE,
...
)
acti_calculate_nonwear(
data,
method = c("choi", "troiano"),
use_magnitude = TRUE,
...
)
acti_apply_cole_kripke(data)
acti_apply_tudor_locke(data, ...)
acti_apply_sadeh(data, ...)
Arguments
data |
A |
epoch |
epoch length in seconds. Default is 60 seconds.
See |
resample |
(recommended) resample the data to 30Hz using actibase::acti_resample vs. using the resampling method from agcounts::calculate_counts. |
lfe_select |
Apply the Actigraph Low Frequency Extension filter.
See |
verbose |
print diagnostic messages. Either logical or integer, where |
method |
Method for detecting non-wear, either "choi" or "troiano",
corresponding to |
use_magnitude |
If |
... |
additional arguments to pass to |
Value
A data.frame of transformed data
A data.frame of transformed data with columns axis1-3,
counts, and counts_log10.
A data.frame of transformed data
Note
This calls the downstream wear-processing helpers used by
actigraph.sleepr
Examples
path = actiread::acti_example_gt3x()
ac = actiread::acti_read_gt3x(path)
out = acti_calculate_counts(ac)
data = actimetrics::acti_count_data
wear = actimetrics::acti_calculate_wear(data)
tro_wear = actimetrics::acti_calculate_wear(data, method = "troiano")
ck = actimetrics::acti_apply_cole_kripke(data)
tl = actimetrics::acti_apply_tudor_locke(ck)
sadeh = actimetrics::acti_apply_sadeh(ck)
Calculate Step Counts via Oak/Forest
Description
Calculate Step Counts via Oak/Forest
Usage
acti_calculate_forest(data, ...)
Arguments
data |
A |
... |
Additional arguments passed to |
Value
A tibble with minute-level time, steps columns.
Examples
Sys.setenv("SSQ_PARALLEL" = 0)
if (reticulate::py_module_available("forest")) {
data = actiread::acti_read_gt3x(actiread::acti_example_gt3x())
steps = acti_calculate_forest(data, sample_rate = 100)
}
Calculate Summary Measures from Raw Accelerometer Data
Description
Calculate Summary Measures from Raw Accelerometer Data
Usage
acti_calculate_measures(
data,
unit = "1 min",
fix_zeros = TRUE,
dynamic_range = NULL,
calculate_mims = TRUE,
calculate_ac = TRUE,
flag_data = TRUE,
flags = NULL,
ensure_all_time = TRUE,
verbose = TRUE,
sample_rate = NULL,
...
)
acti_calculate_ai(
data,
unit = "1 min",
ensure_all_time = TRUE,
verbose = FALSE
)
acti_calculate_activity_index(
data,
unit = "1 min",
ensure_all_time = TRUE,
verbose = FALSE
)
acti_calculate_flags(data, unit = "1 min", ensure_all_time = TRUE)
acti_calculate_n_idle(data, unit = "1 min", ensure_all_time = TRUE)
acti_calculate_enmo(...)
acti_calculate_ai_defined(...)
acti_calculate_mad(
data,
unit = "1 min",
ensure_all_time = TRUE,
verbose = FALSE
)
acti_calculate_auc(
data,
unit = "1 min",
sample_rate = NULL,
allow_truncation = FALSE,
ensure_all_time = TRUE,
verbose = TRUE
)
acti_calculate_fast_mims(
data,
unit = "1 min",
dynamic_range = NULL,
sample_rate = NULL,
allow_truncation = TRUE,
ensure_all_time = TRUE,
verbose = TRUE,
...
)
acti_calculate_mims(
data,
unit = "1 min",
dynamic_range = c(-6, 6),
ensure_all_time = TRUE,
...
)
Arguments
data |
An object with columns |
unit |
length of time to calculate measures over. a character string
specifying a time unit or a multiple of a unit to be rounded to.
Valid base units are |
fix_zeros |
Should |
dynamic_range |
Dynamic range of the device, in gravity units |
calculate_mims |
Should MIMS units be calculated? |
calculate_ac |
Should Activity Counts from the |
flag_data |
Should the downstream overlay |
flags |
the flags to calculate,
passed to the downstream overlay |
ensure_all_time |
if |
verbose |
print diagnostic messages |
sample_rate |
sample rate of data, if not specified in header of object |
... |
additional arguments to pass to |
allow_truncation |
truncate small values |
Value
A data set with the calculated features
Examples
file = actiread::acti_example_gt3x()
res = actiread::acti_read_gt3x(file, verbose = FALSE)
res = res[1:12000, ]
measures = acti_calculate_measures(
res,
dynamic_range = NULL,
calculate_mims = FALSE,
calculate_ac = FALSE,
flag_data = FALSE
)
auc = acti_calculate_auc(res)
mims = acti_calculate_mims(res, dynamic_range = NULL)
if (requireNamespace("data.table", quietly = TRUE)) {
dt = data.table::as.data.table(res)
out = acti_calculate_measures(dt, calculate_mims = FALSE, flag_data = FALSE,
calculate_ac = FALSE)
}
Calculate Step Counts via Oak/Forest
Description
Calculate Step Counts via Oak/Forest
Usage
acti_calculate_sdt(data, sample_rate = NULL, ...)
Arguments
data |
A |
sample_rate |
Sample rate in Hz. If omitted, it is taken from the input object when available. |
... |
Additional arguments passed to |
Value
A tibble with minute-level time, steps columns.
Examples
data = actiread::acti_read_gt3x(actiread::acti_example_gt3x())
steps = acti_calculate_sdt(data)
Calculate Step Counts via stepcount
Description
Use the stepcount package to estimate steps from raw accelerometer data
and summarize them to minute-level epochs (as opposed to 10s default)
Usage
acti_calculate_stepcount(data, sample_rate = NULL, ..., epoch = "1 minute")
Arguments
data |
A |
sample_rate |
Sample rate in Hz. If omitted, it is taken from the input object when available. |
... |
Additional arguments passed to |
epoch |
epoch unit to aggregate the data to, passed to
|
Value
A tibble with minute-level time, steps, and walking
columns.
Examples
# reticulate::py_require("stepcount==3.11.0", python_version = "3.10", action = "add")
# sc = try({ reticulate::import("stepcount") })
if (stepcount::have_stepcount()) {
data = actiread::acti_read_gt3x(actiread::acti_example_gt3x())
steps = acti_calculate_stepcount(data, sample_rate = 100)
steps = acti_calculate_stepcount(data, model_type = "rf")
}
Calculate Step Counts via Verisense
Description
Calculate Step Counts via Verisense
Usage
acti_calculate_verisense(
data,
resample_to_15hz = TRUE,
method = c("original", "revised"),
...
)
Arguments
data |
A |
resample_to_15hz |
resample data to 15Hz,
passed to |
method |
parameters to estimate walking, either original or revised,
passed to |
... |
Additional arguments passed to |
Value
A tibble with minute-level time, steps columns.
Examples
data = actiread::acti_read_gt3x(actiread::acti_example_gt3x())
steps = acti_calculate_verisense(data)
Calibrate Accelerometer Data using agcounts
Description
This uses the van Hees calibration method typically exposed through GGIR,
implemented here via agcounts::agcalibrate().
Usage
acti_calibrate(
data,
verbose = TRUE,
fill_zeroes = TRUE,
round_after_calibration = TRUE,
...
)
Arguments
data |
Either a GT3X file, |
verbose |
print diagnostic messages, higher number result in higher verbosity |
fill_zeroes |
Should |
round_after_calibration |
Should the data be rounded after calibration? Will round to 3 digits |
... |
Additional arguments to pass to |
Value
A calibrated dataset with the same columns as the input data,
but with the X/Y/Z values calibrated using the van Hees method.
Examples
res = acti_calibrate(data = actiread::acti_example_gt3x())
Example Actigraphy/Activity Count Data
Description
Example Actigraphy/Activity Count Data
Usage
acti_count_data
Format
A data.frame with the columns
- time
time at the minute level
- axis1
axis1 (Y) counts
- axis2
axis2 (X) counts
- axis3
axis3 (Z) counts
- counts
vector magnitude of all 3 axes column
This data was taken from running agcounts::calculate_counts via acti_calculate_counts on actibase::acti_raw_data.
Process Count Data
Description
Process Count Data
Usage
acti_process(
data,
lfe_select = FALSE,
method = c("choi", "troiano"),
use_magnitude = TRUE,
verbose = TRUE,
...
)
Arguments
data |
A |
lfe_select |
Apply the Actigraph Low Frequency Extension filter.
See |
method |
Method for detecting non-wear, either "choi" or "troiano",
corresponding to |
use_magnitude |
If |
verbose |
print diagnostic messages. Either logical or integer, where |
... |
additional arguments to pass to |
Value
A data frame containing activity counts and wear-time indicators.
Note
For acti_process_gt3x, the ... argument are passed to
actiread::acti_read_gt3x()
Default MIMS worker functions
Description
Default MIMS worker functions
Usage
mims_default_extrapolation(data, dynamic_range = NULL)
mims_default_interpolation(data)
mims_default_filtering(data)
Arguments
data |
data set of data, usually time and X/Y/Z. Usually from
|
dynamic_range |
dynamic range of the data. Will be passed to
|
Value
A data set of data
Default MIMS Pre-processing
Description
Default MIMS Pre-processing
Usage
mims_default_processing(
data,
use_extrapolation = TRUE,
use_filtering = TRUE,
verbose = TRUE,
dynamic_range = NULL,
round_after_processing = FALSE
)
Arguments
data |
Data set of raw accelerometry values, usually time and X/Y/Z.
Usually from |
use_extrapolation |
If |
use_filtering |
If |
verbose |
print diagnostic messages |
dynamic_range |
the dynamic ranges of the input signal. Passed to
|
round_after_processing |
Should the result be rounded to 3 decimal values after processing, to make similar to standard accelerometry? |
Value
A processed data set
Perform step count calculation in a separate Python environment
Description
Perform step count calculation in a separate Python environment
Usage
py_acti_calculate_forest(
...,
pyenv_function = function() {
reticulate::import("forest")
},
show = FALSE
)
Arguments
... |
arguments passed to |
pyenv_function |
function that loads the |
show |
Logical, whether to show the standard output on the
screen while the child process is running, passed to |
Value
The output from acti_calculate_forest().
Examples
Sys.setenv("SSQ_PARALLEL" = 0)
data = actiread::acti_read_gt3x(actiread::acti_example_gt3x())
steps = py_acti_calculate_forest(data, sample_rate = 100)
Perform step count calculation in a separate Python environment
Description
Perform step count calculation in a separate Python environment
Usage
py_acti_calculate_stepcount(
...,
pyenv_function = function() {
stepcount::py_require_stepcount()
},
show = FALSE
)
Arguments
... |
arguments passed to |
pyenv_function |
function that loads the |
show |
Logical, whether to show the standard output on the
screen while the child process is running, passed to |
Value
The output from acti_calculate_stepcount().
A tibble with minute-level time, steps, and walking columns.
Examples
if (stepcount::have_stepcount()) {
data = actiread::acti_read_gt3x(actiread::acti_example_gt3x())
steps = py_acti_calculate_stepcount(data, sample_rate = 100)
}