gaitmap.utils.static_moment_detection.find_static_samples#

gaitmap.utils.static_moment_detection.find_static_samples(signal: ndarray, window_length: int, inactive_signal_th: float, metric: typing_extensions.Literal[maximum, variance, mean, median, squared_mean] = 'mean', overlap: int | None = None) tuple[numpy.ndarray, int, float][source]#

Search for static samples within given input signal, based on windowed L2-norm thresholding.

Warning

Due to edge cases at the end of the input data where window size and overlap might not fit your data, the last window might be discarded for analysis and will therefore always be considered as non-static!

Parameters:
signalarray with shape (n, 3)

3D signal on which static moment detection should be performed (e.g. 3D-acc or 3D-gyr data)

window_lengthint

Length of desired window in units of samples

inactive_signal_thfloat

Threshold to decide whether a window should be considered as active or inactive. Window will be tested on <= threshold

metricstr or Callable

Metric which will be calculated per window, one of the following strings:

‘mean’ (default)

Calculates mean value per window

‘squared_mean’

The same as mean, but the norm of the signal is squared before calculating the mean. This option exists to provide an implementation of the ARED Zupt detector [1].

‘maximum’

Calculates maximum value per window

‘median’

Calculates median value per window

‘variance’

Calculates variance value per window

overlapint, optional

Length of desired overlap in units of samples. If None (default) overlap will be window_length - 1

Returns:
static_momentsarray with shape (n,)

Boolean array with length n to indicate static (=True) or non-static (=False) for each sample

min_indexint

Index of the sample with the lowest value of the given metric. This is calculated aas the center index of the window with the lowest value.

min_valuefloat

Value of the given metric at the sample with the lowest value of the given metric or rather the window with the lowest value. Note, that this value can be larger than the threshold, if no ZUPTs were detected.

See also

gaitmap.utils.array_handling.sliding_window_view

Details on the used windowing function for this method.

References

[1]

I. Skog, J.-O. Nilsson, P. Händel, and J. Rantakokko, “Zero-velocity detection—An algorithm evaluation,” IEEE Trans. Biomed. Eng., vol. 57, no. 11, pp. 2657-2666, Nov. 2010.

Examples

>>> test_data = load_gyro_data(path)
>>> get_static_moments(gyro_data, window_length=128, overlap=64, inactive_signal_th=5, metric="mean")