View source: R/estimate_rest.R
| estimate_rest | R Documentation |
Runs the AcceleRest model on 30-second epochs of wrist-worn accelerometry. Predictions are made over context windows of 256 epochs (about 2.1 hours), so at least that much data is needed; predictions for an epoch are averaged across the overlapping windows covering it.
estimate_rest(
file,
model = NULL,
cache_dir = ar_cache_dir(),
repo_dir = cache_dir,
weights_dir = cache_dir,
context_window_shift = 1L,
max_batch_size = 16L,
device = NULL,
...
)
file |
a |
model |
the prediction heads to include, one or more of
|
cache_dir |
directory with the downloaded code and weights, see
|
repo_dir |
directory with the downloaded code, see
|
weights_dir |
directory with the downloaded weights, see
|
context_window_shift |
number of 30-second epochs to shift consecutive context windows. Smaller is slower but averages over more windows. |
max_batch_size |
number of context windows per forward pass. Higher is faster but uses more memory. |
device |
|
... |
additional arguments passed to |
A named list with a tibble for each head, with the epoch
number, start time of the epoch (NA for .h5 files), the
probability of each class, and the most probable class (prediction).
Epochs with no valid data have NA values. Sleep stage classes are
deep, light, rem, and wake; respiratory event classes are no_event and
event. The actipy information about the data is in attr(x, "info").
Lorenzen NR, Brink-Kjaer A, Jennum PJ, Mignot E (2026). AcceleRest: A Physiology-Aware Masked Autoencoder for Wrist Accelerometer-based Sleep Staging and Apnea Evaluation. medRxiv. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.64898/2026.01.28.26345056")}
# Runs only after ar_setup(), so Python is not set up otherwise
if (ar_have_repo() && ar_have_weights("linear_sleepstages") &&
ar_python_modules_installed()) {
data = ar_example_data(n_hours = 2.5)
out = estimate_rest(data, model = "linear_sleepstages",
context_window_shift = 32L)
head(out$linear_sleepstages)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.