skdh.preprocessing.DETACH#
- class skdh.preprocessing.DETACH(sd_thresh=0.008, low_temperature_threshold=26.0, high_temperature_threshold=30.0, decrease_threshold=-0.2, increase_threshold=0.1, n_axes_threshold=2, window_size=1)#
DEvice Temperature and Acceleration CHange algorithm for detecting wear/non-wear.
- Parameters:
- sd_threshfloat, optional
Standard deviation threshold for an acceleration axis to trigger non-wear. Default is 0.008 g (8 milli-g).
- low_temperature_thresholdfloat, optional
Low temperature threshold for non-wear classification. Default is 26.0 deg C.
- high_temperature_thresholdfloat, optional
High temperature threshold for non-wear classification. Default is 30.0 deg C.
- decrease_thresholdfloat, optional.
Temperature decrease rate-of-change threshold for non-wear classification. Default is -0.2.
- increase_thresholdfloat, optional
Temperature increase rate-of-change threshold for non-wear classification. Default is 0.1
- n_axes_threshold{1, 2, 3}
Number of axes that must be below sd_thresh to be considered non-wear. Default is 2.
- window_size{int, ‘scaled’, ‘original’}, optional
Window size in seconds, ‘original’, or ‘scaled’. ‘Original’ uses the original 4-second long windows from [1], which was developed at a sampling frequency of 75hz for GeneActiv devices. ‘scaled’ uses the same principal as in [1] but will scale the window length to match the input sampling frequency (by a factor of 300, which is the block size for GeneActiv devices). Maximum if providing an integer is 15 seconds. Default is a window size of 1 second.
Methods
convert_timestamps(t)Convert a timestamp/array of timestamps to a datetime object
predict([time, accel, temperature, fs])Detect periods of non-wear.
save_results(results, file_name)Save the results of the processing pipeline to a csv file
Notes
This algorithm was based on work done with GENEActiv devices. While efforts were made to keep the algorithm device-agnostic, this should be kept in mind when deploying in alternative devices.
Copyright (c) 2022 Adam Vert. Implementation here courtesy of release under an MIT license. The original implementation, and license can be found on GitHub <https://github.com/nimbal/vertdetach>.
References
- predict(time=None, accel=None, temperature=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.
- temperaturenumpy.ndarray
(N,) array of measured temperature values during recording in deg C.
- 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.