flag_choi: Apply Choi et al nonwear algorithm

View source: R/flag_choi.R

flag_choiR Documentation

Apply Choi et al nonwear algorithm

Description

Apply Choi et al nonwear algorithm

Usage

flag_choi(
  x,
  activity_threshold = 0,
  min_period_len = 90,
  spike_tolerance = 2,
  min_window_len = 30,
  window_spike_tolerance = 0,
  print_output = F
)

Arguments

x

a numeric vector, no NAs. Values correspond to timestamps for each epoch, note that 1 epoch is 60s.

activity_threshold

values below activity_threshold are classified as nonwear as per Choi et al. (2011). The activity threshold is the value of the count that is considered "zero", since we are searching for a sequence of zero counts. Default threshold is 0.

min_period_len

the minimum length of the consecutive zeros that can be considered valid non wear time. Default value is 90 (since we have 60sec epoch data, this equals 90 mins).

spike_tolerance

any count that is above the activity threshold is considered a spike. The tolerence defines the number of spikes that are acceptable within a sequence of zeros. The default is 2, meaning that we allow for 2 spikes in the data, i.e. artifactual movement.

min_window_len

minimum length of upstream or downstream time window (referred to as window2 in the paper) for consecutive zero counts required before and after the artifactual movement interval to be considered a nonwear time interval.

window_spike_tolerance

accepted number of spikes in upstream and downstream windows.

print_output

if set to True, then print the output of the non wear sequence, start index, end index, duration, start time, end time and epoch values. Default is False.

Details

Implements non-wear algorithm closely following that of Choi et al. (2011).

Med Sci Sports Exerc. 2011 Feb;43(2):357-64. doi: 10.1249/MSS.0b013e3181ed61a3. Validation of accelerometer wear and nonwear time classification algorithm. Choi L1, Liu Z, Matthews CE, Buchowski MS.

Code implementation from:https://github.com/shaheen-syed/ActiGraph-ActiWave-Analysis/

Value

nonwear vector, non wear time encoded as T, and wear time encoded as F.

Examples

## Not run: 
minute_data %>%
  group_by(id) %>%
  mutate(nonwear = flag_choi(1 - is.na(HR)))

## End(Not run)

audiracmichelle/fitibble documentation built on Feb. 2, 2023, 3:51 p.m.