skdh.gait.substeps.PreprocessGaitBout#
- class skdh.gait.substeps.PreprocessGaitBout(correct_orientation=True, filter_cutoff=20.0, filter_order=4, ap_axis_filter_kw=None)#
Preprocess acceleration data for gait using the newer/V2 method.
- Parameters:
- correct_orientationbool, optional
Correct the accelerometer orientation if it is slightly mis-aligned with the anatomical axes. Default is True.
- filter_cutofffloat, optional
Low-pass filter cutoff in Hz. Default is 20.0
- filter_orderint, optional
Low-pass filter order. Default is 4.
- ap_axis_filter_kw{None, dict}, optional
Key-word arguments for the filter applied to the acceleration data before cross-correlation when estimating the AP axis. If None (default), the following are used:
N: 4
Wn: [0.25, 7.5] - NOTE, this should be in Hz, not radians. fs will be passed into the filter setup at filter creation time.
btype: band
output: sos - NOTE that this will always be set/overriden
See
scipy.signal.butter()for full options.
Methods
convert_timestamps(t)Convert a timestamp/array of timestamps to a datetime object
get_ap_axis(fs, accel, v_axis)Estimate the AP axis index
get_ap_axis_sign(fs, accel, ap_axis)Estimate the sign of the AP axis
get_step_time(fs, accel, ap_axis)Estimate the average step time for the walking bout.
predict(time, accel, *[, fs, v_axis, ap_axis])save_results(results, file_name)Save the results of the processing pipeline to a csv file
- get_ap_axis(fs, accel, v_axis)#
Estimate the AP axis index
- Parameters:
- fs
- accel
- v_axis
- Returns:
- ap_axis{0, 1, 2}
Index of the AP axis in the acceleration data
- static get_ap_axis_sign(fs, accel, ap_axis)#
Estimate the sign of the AP axis
- Parameters:
- fsfloat
Sampling frequency in Hz.
- accelnumpy.ndarray
- ap_axisint
Anterior-Posterior axis
- Returns:
- ap_axis_sign{-1, 1}
Sign of the AP axis.
- static get_step_time(fs, accel, ap_axis)#
Estimate the average step time for the walking bout.
- Parameters:
- fs
- accel
- ap_axis
- Returns:
- mean_step_timefloat
Mean step time for the walking bout
- predict(time, accel, *, fs=None, v_axis=None, ap_axis=None)#
- Parameters:
- timenumpy.ndarray
(N, ) array of unix timestamps, in seconds
- accelnumpy.ndarray
(N, 3) array of accelerations measured by a centrally mounted lumbar inertial measurement device, in units of ‘g’.
- fsfloat, optional
Sampling frequency in Hz of the accelerometer data. If not provided, will be computed form the timestamps.
- v_axis{None, 0, 1, 2}, optional
Index of the vertical axis in the acceleration data. Default is None. If None, will be estimated from the acceleration data.
- ap_axis{None, 0, 1, 2}, optional
Index of the Anterior-Posterior axis in the acceleration data. Default is None. If None, will be estimated from the acceleration data.
- Returns:
- resultsdict
Dictionary with the following items that can be used for future processing steps:
v_axis: provided or estimated vertical axis index.
v_axis_est: estimated vertical axis index.
v_axis_sign: sign of the vertical axis.
ap_axis: provided or estimated AP axis index.
ap_axis_est: estimated AP axis index.
ap_axis_sign: estimated sign of the AP axis.
mean_step_freq: estimated mean step frequency during this gait bout.
accel_filt: filtered and detrended acceleration for this gait bout.