Run the Vallim native actigraphy sleep analysis pipeline
Source:R/pipeline.R
run_pipeline_native.RdOrchestrates the vendor-independent (Vallim) sleep analysis pipeline for a
single ActTrust recording. Shares the read / prepare / off-wrist / CSPD
epoch-scorer stages with run_pipeline(), then replaces Condor's
nights_df classification with the rule set developed by Julia Ribeiro da
Silva Vallim and ported from her condor pipeline (Fixes 25, 26a/b/c, 27, 29).
Usage
run_pipeline_native(
path,
tz = "UTC",
gap_s = 120,
params = acttrust_params(),
offwrist_args = list(),
sleep_args = list(),
classify_args = list(),
holidays = NULL,
free_days = c("Saturday", "Sunday"),
quiet = FALSE
)Arguments
- path
character(1). Path to the ActTrust.txtfile.- tz
character(1). Recording time zone. Default"UTC".- gap_s
numeric(1). Gap threshold (seconds) forcheck_consistency(). Default120.- params
Device parameter preset, as returned by
acttrust_params().- offwrist_args
list. Additional arguments fordetect_offwrist_bimodal().- sleep_args
list. Additional arguments fordetect_sleep_crespo().- classify_args
list. Additional arguments forclassify_sleep_episodes().- holidays
Holidays to treat as free days in addition to the days in
free_days. Accepts three forms, which can be mixed in the same vector:Dateobjects or"YYYY-MM-DD"strings for year-specific dates (e.g.as.Date("2019-03-04")for one Carnival day)."DD-MM"strings for dates that recur every year (e.g."25-12"for Christmas,"07-09"for Brazilian Independence Day). Stored inresult$holidaysand auto-forwarded by thezeitr_resultS3 methods ofcompute_sleep_metrics()andcompute_cpd_metrics(). DefaultNULL.
- free_days
A character vector of day names (
"Monday"through"Sunday", case-insensitive) or ISO integers (1 = Monday ... 7 = Sunday) identifying which days of the week are unconditionally treated as free days. Stored inresult$free_daysand auto-forwarded by thezeitr_resultS3 methods ofcompute_sleep_metrics()andcompute_cpd_metrics(). Defaultc("Saturday", "Sunday").- quiet
logical(1). Suppress timestamp warnings. DefaultFALSE.
Value
A zeitr_result S3 object with the same structure as run_pipeline(),
except nights additionally contains:
sleep_typecharacter–"main"or"secondary".bed_time,get_up_timePOSIXct – from JRSV bts/gts convention (last sleep epoch for get-up, not first wake epoch).
The is_nap column is retained for backwards compatibility
(is_nap == (sleep_type == "secondary")).
Details
Steps:
Read –
read_acttrust()Consistency check –
check_consistency()Prepare –
prepare_actigraphy()Off-wrist detection –
detect_offwrist_bimodal()Epoch scoring –
detect_sleep_crespo()(CSPD; same scorer asrun_pipeline())Episode extraction –
extract_sleep_episodes()Episode classification –
classify_sleep_episodes()(JRSV rules)Fine-grained state –
compute_waso()(Cole-Kripke within periods, forresult$data)
See also
run_pipeline() for the vendor (Condor) pipeline,
extract_sleep_episodes(), classify_sleep_episodes()