skdh.preprocessing.CountWearDetection#
- class skdh.preprocessing.CountWearDetection(nonwear_window_min=90, epoch_seconds=60, use_actigraph_package=False)#
Detect periods of wear/non-wear from acceleromter data using an implementation similar to the ActiGraph counts metric. Consecutive periods of zero activity counts are classified as non-wear.
- Parameters:
- nonwear_window_minint, optional
Minutes of zero count to consider nonwear. Default is 90 [2].
- epoch_secondsint, optional
Number of seconds to accumulate counts for. Default is 60 seconds.
- use_actigraph_packagebool, optional
Use the internal calculation of activity counts (
skdh.utility.get_activity_counts()), or the Python package published by ActiGraph.
Methods
convert_timestamps(t)Convert a timestamp/array of timestamps to a datetime object
predict([time, accel, fs])Detect periods of non-wear.
save_results(results, file_name)Save the results of the processing pipeline to a csv file
See also
utility.get_activity_countsactivity count calculation
Notes
Note that the internal method for calculating activity counts will give slightly different results than the package by ActiGraph, due to handling down-sampling differently to handle different devices better.
References
[1]C. E. Matthews et al., “Amount of Time Spent in Sedentary Behaviors in the United States, 2003–2004,” American Journal of Epidemiology, vol. 167, no. 7, pp. 875–881, Apr. 2008, doi: 10.1093/aje/kwm390.
[2]L. Choi, Z. Liu, C. E. Matthews, and M. S. Buchowski, “Validation of Accelerometer Wear and Nonwear Time Classification Algorithm,” Medicine & Science in Sports & Exercise, vol. 43, no. 2, pp. 357–364, Feb. 2011, doi: 10.1249/MSS.0b013e3181ed61a3.
- predict(time=None, accel=None, *, fs=None, **kwargs)#
Detect 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 (N, 2) indicating the start and stop indices of wear.