skdh.preprocessing.AccelThresholdWearDetection#

class skdh.preprocessing.AccelThresholdWearDetection(sd_crit=0.013, range_crit=0.067, apply_setup_criteria=True, shipping_criteria=False, shipping_temperature=False, window_length=60, window_skip=15)#

Detect periods of wear/non-wear from accelerometer data only, based on thresholds of the accelerometer standard deviation and range.

Parameters:
sd_critfloat, optional

Acceleration standard deviation threshold for determining non-wear. Default is 0.013 [3], which was observed for GeneActiv devices during motionless bench tests, and will likely depend on the brand of accelerometer being used.

range_critfloat, optional

Acceleration window range threshold for determining non-wear. Default is 0.067, which was found for several GeneActiv accelerometers in a bench test as the 75th percentile of the ranges over 60 minute windows.

apply_setup_criteriabool, optional

Apply criteria to the beginning of the recording to account for device setup. Default is True.

shipping_criteria{bool, int, list}, optional

Apply shipping criteria to the ends of the trial. Options are False (default, no criteria applied), True (criteria applied to the first and last 24 hours), an integer (criteria applied to the first and last shipping_criteria hours), or a length 2 list of integers (criteria applied to the first shipping_criteria[0] hours and the last shipping_criteria[1] hours).

shipping_temperaturebool, optional

Apply the shipping_criteria rules to temperature_factor. For example, setting to true would mean with temperature_factor=2 that during the first and last 24 hours (or specified times) the temperature could solely determine non-wear. Default is False.

window_lengthint, optional

Number of minutes in a window used to determine non-wear. Default is 60 minutes.

window_skipint, optional

Number of minutes to skip between windows. Default is 15 minutes, which would result in window overlaps of 45 minutes with the default 60-minute window_length.

Methods

convert_timestamps(t)

Convert a timestamp/array of timestamps to a datetime object

predict(*, time, accel[, fs])

Detect the periods of non-wear

save_results(results, file_name)

Save the results of the processing pipeline to a csv file

Notes

Non-wear is computed by the following:

\[\begin{split}NW_{acc} = \sum_{i=\{x,y,z\}}[(a_{(sd, i)} < S) \& (a_{(range, i)} < R)]\\ NW = NW_{acc} >= 2\end{split}\]

where \(a_{sd}\) is the acceleration standard deviation of a window, \(a_{range}\) is the range of acceleration of a window, \(S\) is the sd_crit, \(R\) is range_crit.

apply_setup_criteria is the rule that if the data starts with a period of non-wear of less than 3 hours followed by a non-wear period of any length, then that first block of wear is changed to non-wear.

shipping_criteria is an additional rule that may help in cases where the device is being shipped either to or from the participant (or both). Wear periods at the start of the recording are filtered by those less than 3 hours that are followed by 1 hour of non-wear are re-classified as non-wear. Wear periods at the end of the recording that are less than 3 hours that are preceded by 1 hour of non-wear are re-classified as non-wear.

References

[1]

V. T. van Hees et al., “Separating Movement and Gravity Components in an Acceleration Signal and Implications for the Assessment of Human Daily Physical Activity,” PLOS ONE, vol. 8, no. 4, p. e61691, Apr. 2013, doi: 10.1371/journal.pone.0061691.

[2]

V. T. van Hees et al., “Estimation of Daily Energy Expenditure in Pregnant and Non-Pregnant Women Using a Wrist-Worn Tri-Axial Accelerometer,” PLOS ONE, vol. 6, no. 7, p. e22922, Jul. 2011, doi: 10.1371/journal.pone.0022922.

[3]

I. C. da Silva et al., “Physical activity levels in three Brazilian birth cohorts as assessed with raw triaxial wrist accelerometry,” International Journal of Epidemiology, vol. 43, no. 6, pp. 1959–1968, Dec. 2014, doi: 10.1093/ije/dyu203.

predict(*, time, accel, fs=None)#

Detect the periods of non-wear

Parameters:
timenumpy.ndarray

(N, ) array of unix timestamps (in seconds) since 1970-01-01.

accelnumpy.ndarray

(N, 3) array of measured acceleration values in units of g.

fsfloat, optional

Sampling frequency, in Hz. If not provided, will be computed from time.

Returns:
resultsdict

Dictionary of inputs, plus the key wear which is an array-like (N, 2) indicating the start and stop indices of wear.