skdh.sit2stand.Sit2Stand#
- class skdh.sit2stand.Sit2Stand(*, stillness_constraint=True, gravity=9.81, thresholds=None, long_still=0.5, still_window=0.3, gravity_pass_order=4, gravity_pass_cutoff=0.8, continuous_wavelet='gaus1', power_band=None, power_peak_kw=None, power_std_height=True, power_std_trim=0, lowpass_order=4, lowpass_cutoff=5, reconstruction_window=0.25, day_window=(0, 24))#
Sit-to-stand transfer detection and processing.
- Parameters:
- stillness_constraintbool, optional
Whether or not to impose the stillness constraint on the detected transitions. Default is True.
- gravityfloat, optional
Value of gravitational acceleration measured by the accelerometer when still. Default is 9.81 m/s^2.
- thresholdsdict, optional
A dictionary of thresholds to change for stillness detection and transition verification. See Notes for default values. Only values present will be used over the defaults.
- long_stillfloat, optional
Length of time of stillness for it to be considered a long period of stillness. Used to determine the integration window limits when available. Default is 0.5s
- still_windowfloat, optional
Length of the moving window for calculating the moving statistics for determining stillness. Default is 0.3s.
- gravity_pass_orderint, optional
Low-pass filter order for estimating the direction of gravity by low-pass filtering the raw acceleration. Default is 4.
- gravity_pass_cutofffloat, optional
Low-pass filter frequency cutoff for estimating the direction of gravity. Default is 0.8Hz.
- continuous_waveletstr, optional
Continuous wavelet to use for signal deconstruction. Default is gaus1. CWT coefficients will be summed in the frequency range defined by power_band
- power_band{array_like, int, float}, optional
Frequency band in which to sum the CWT coefficients. Either an array_like of length 2, with the lower and upper limits, or a number, which will be taken as the upper limit, and the lower limit will be set to 0. Default is [0, 0.5].
- power_peak_kw{None, dict}, optional
Extra key-word arguments to pass to scipy.signal.find_peaks when finding peaks in the summed CWT coefficient power band data. Default is None, which will use the default parameters except setting minimum height to 90, unless power_std_height is True.
- power_std_heightbool, optional
Use the standard deviation of the power for peak finding. Default is True. If True, the standard deviation height will overwrite the height setting in power_peak_kw.
- power_std_trimfloat, int, optional
Number of seconds to trim off the start and end of the power signal before computing the standard deviation for power_std_height. Default is 0s, which will not trim anything. Suggested value of trimming is 0.5s.
- lowpass_orderint, optional
Initial low-pass filtering order. Default is 4.
- lowpass_cutofffloat, optional
Initial low-pass filtering cuttoff, in Hz. Default is 5Hz.
- reconstruction_windowfloat, optional
Window to use for moving average, in seconds. Default is 0.25s.
- day_windowarray-like
Two (2) element array-like of the base and period of the window to use for determining days. Default is (0, 24), which will look for days starting at midnight and lasting 24 hours. None removes any day-based windowing.
Methods
convert_timestamps(t)Convert a timestamp/array of timestamps to a datetime object
predict(*, time, accel[, day_ends, tz_name])Predict the sit-to-stand transfers, and compute per-transition quantities
save_results(results, file_name)Save the results of the processing pipeline to a csv file
Notes
The default height threshold of 90 in power_peak_kw was determined on data sampled at 128Hz, and would likely need to be adjusted for different sampling frequencies. Especially if using a different sampling frequency, use of power_std_height=True is recommended.
stillness_constraint determines whether or not a sit-to-stand transition is required to start and the end of a still period in the data. This constraint is suggested for at-home data. For processing clinic data, it is suggested to set this to False, especially if processing a task where sit-to-stands are repeated in rapid succession.
- Default thresholds:
stand displacement: 0.125 :: min displacement for COM for a transfer (m)
displacement factor: 0.75 :: min factor * median displacement for a valid transfer
transition velocity: 0.2 :: min vertical velocity for a valid transfer (m/s)
duration factor: 10 :: max factor between 1st/2nd part duration of transfer
accel moving avg: 0.2 :: max moving avg accel to be considered still (m/s^2)
accel moving std: 0.1 :: max moving std accel to be considered still (m/s^2)
jerk moving avg: 2.5 :: max moving average jerk to be considered still (m/s^3)
jerk moving std: 3 :: max moving std jerk to be considered still (m/s^3)
References
[1]L. Adamowicz et al., “Assessment of Sit-to-Stand Transfers during Daily Life Using an Accelerometer on the Lower Back,” Sensors, vol. 20, no. 22, Art. no. 22, Jan. 2020, doi: 10.3390/s20226618.
- predict(*, time, accel, day_ends={}, tz_name=None)#
Predict the sit-to-stand transfers, and compute per-transition quantities
- Parameters:
- timendarray
(N, ) array of timestamps (in seconds since 1970-1-1 00:00:00)
- accelndarray
(N, 3) array of acceleration, with units of ‘g’.
- day_endsdict, optional
Optional dictionary containing (N, 2) arrays of start and stop indices for invididual days. Dictionary keys are in the format “{base}, {period}”. If not provided, or the key specified by day_window is not found, no day-based windowing will be done.
- Other Parameters:
- tz_name{None, str}, optional
IANA time-zone name for the recording location if passing in time as UTC timestamps. Can be ignored if passing in naive timestamps.