skdh.preprocessing.CtaWearDetection#

class skdh.preprocessing.CtaWearDetection(temp_threshold=26.0, sd_crit=0.003, window_length=1, window_skip=1)#

Detect periods of wear/non-wear from accelerometer and temperature data. CTA stands for Combined Temperature and Acceleration.

Parameters:
temp_thresholdfloat, optional

Temperature threshold for determining wear or non-wear. From [1], 26 deg C is the default. NOTE that this was picked for GeneActiv devices, and likely is different for other devices, based on where the temperature sensor is located. This threshold may also depend on location and population.

sd_critfloat, optional

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

window_lengthint, optional

Length of the windows on which to detect wear and non wear, in minutes. Default is 1 minute.

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

In the original paper _[1] a window skip of 1 second is used to gain sub-minute resolution of wear time. However, in this implementation this is dropped, as minute-level resolution is already going to be more than enough resolution into wear times.

References

[1] (1,2)

S.-M. Zhou et al., “Classification of accelerometer wear and non-wear events in seconds for monitoring free-living physical activity,” BMJ Open, vol. 5, no. 5, pp. e007447–e007447, May 2015, doi: 10.1136/bmjopen-2014-007447.

[2]

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=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.