The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

rester

R-CMD-check Codecov test coverage

The goal of rester is to estimate sleep stages and respiratory events from wrist-worn accelerometry. It wraps the AcceleRest model from https://github.com/NielsRLorenzen/AcceleRest, which predicts, for each 30-second epoch:

The model is described in Lorenzen et al. (2026); please cite it when using rester (see citation("rester")).

The Python requirements (torch, actipy, etc.) are declared with reticulate::py_require() when the package is loaded, so reticulate sets up the Python environment automatically.

Installation

You can install the development version of rester from GitHub with:

# install.packages("remotes")
remotes::install_github("jhuwit/rester")

Downloading the model

The AcceleRest code and pretrained weights are downloaded (not bundled) into ar_cache_dir(), which can be set with options(rester.cache_dir = ) or the RESTER_CACHE_DIR environment variable:

library(rester)
ar_setup()

which runs ar_download_repo() (downloading and extracting the code) and ar_download_weights(). The raw weights can be extracted with ar_load_weights().

Example

AcceleRest uses context windows of 256 epochs (about 2.1 hours), so at least that much data is needed. estimate_rest() takes a data.frame or a file:

library(rester)
data = ar_example_data(n_hours = 3)
out = estimate_rest(data, context_window_shift = 16L)
out$linear_sleepstages

file = "/path/to/device_file.gt3x.gz"
out = estimate_rest(file, context_window_shift = 32L)

context_window_shift = 1L averages predictions over the most windows but is much slower on a CPU.

Reading and preprocessing

Data are read and preprocessed by ar_read(), which estimate_rest() calls:

Python setup

The Python requirements (torch, actipy, etc.) are declared with reticulate::py_require() when the package is loaded. On Intel Macs, the last available torch is 2.2.2, which rester supports. On macOS, rester sets KMP_DUPLICATE_LIB_OK=TRUE (if unset) so torch and OpenMP-using readers can run in the same R session. py_estimate_rest() runs estimate_rest() in a separate R process.

Citation

citation("rester")

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. doi:10.64898/2026.01.28.26345056

Testing

The tests use mocks and download nothing. To also run the real model, which downloads the code, weights, and torch, set:

Sys.setenv(RESTER_FULL_TEST = "true", RESTER_TEST_CACHE_DIR = "/path/to/cache")
devtools::test()

On GitHub Actions, the full test runs on the ubuntu-latest (release) job.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.