sit2standpy.detectors.Displacement

class sit2standpy.detectors.Displacement(gravity=9.81, thresholds=None, gravity_pass_ord=4, gravity_pass_cut=0.8, long_still=0.5, moving_window=0.3, duration_factor=10, displacement_factor=0.75, lmax_kwargs=None, lmin_kwargs=None, trans_quant=<sit2standpy.quantify.TransitionQuantifier object>)

Method for detecting sit-to-stand transitions based on requiring stillness before a transition, and the vertical displacement of a lumbar accelerometer for ensuring a transition.

Parameters:
gravity : float, optional

Value of gravitational acceleration measured by the accelerometer when still. Default is 9.81 m/s^2.

thresholds : {None, dict}, optional

Either None, for the default, or a dictionary of thresholds to change. See Notes. Default is None, which uses the default values.

gravity_pass_ord : int, optional

Low-pass filter order for estimating the direction of gravity by low-pass filtering the raw acceleration data. Default is 4.

gravity_pass_cut : float, optional

Low-pass filter frequency cutoff for estimating thd direction of gravity. Default is 0.8Hz.

long_still : float, optional

Length of time of stillness for it to be qualified as a long period of stillness. Used to determining integration limits when available. Default is 0.5s.

moving_window : float, optional

Length of the moving window for calculating the moving statistics for determining stillness. Default is 0.3s.

duration_factor : float, optional

The factor for the maximum difference between the duration before and after the generalized location of the sit to stand. Lower factors result in more equal time before and after the detection. Default is 10, which effectively removes this constraint.

displacement_factor : float, optional

Factor multiplied by the median of the vertical displacements to determine the threshold for checking if a transition is a partial transition or a full transition. Default is 0.75

lmax_kwargs : {None, dict}, optional

Additional key-word arguments for finding local maxima in the acceleration signal. Default is None, for no specified arguments. See scipy.signal.find_peaks for possible arguments.

lmin_kwargs : {None, dict}, optional

Additional key-word arguments for finding local minima in the acceleration signal. Default is None, which specifies a maximum value of 9.5m/s^2 for local minima. See scipy.signal.find_peaks for the possible arguments.

trans_quant : TransitionQuantifier

TransitionQuantifier object, which contains a quantify method, which accepts the following arguments: times, mag_acc_f, mag_acc_r, v_vel, v_pos. Only times is required. See sit2standpy.TransitionQuantifier.

Notes

Default thresholds:
  • stand displacement: 0.125
  • transition velocity: 0.2
  • accel moving avg: 0.2
  • accel moving std: 0.1
  • jerk moving avg: 2.5
  • jerk moving std: 3

Methods

apply(raw_acc, mag_acc, mag_acc_r, time, dt, …) Apply the displacement-based STS detection to the given data
apply(raw_acc, mag_acc, mag_acc_r, time, dt, power_peaks)

Apply the displacement-based STS detection to the given data

Parameters:
raw_acc : numpy.ndarray

(N, 3) array of the raw acceleration signal

mag_acc : numpy.ndarray

(N, ) array of filtered acceleration magnitude.

mag_acc_r : numpy.ndarray

(N, ) array of reconstructed acceleration magnitude.

time : numpy.ndarray

(N, ) array of time-stamps (in seconds) corresponding with the acceleration

dt : float

Sampling time difference

power_peaks : numpy.ndarray

Locations of the peaks in the CWT power data.

Returns:
sts : dict

Dictionary of sit2standpy.Transition objects containing information about a individual sit-to-stand transition. Keys for the dictionary are string timestamps of the start of the transition.