biopsykit.signals.imu.static_moment_detection module

A set of util functions to detect static regions in a IMU signal given certain constrains.

biopsykit.signals.imu.static_moment_detection.find_static_moments(data, threshold, window_samples=None, window_sec=None, sampling_rate=0, overlap_samples=None, overlap_percent=None, metric='variance')[source]

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

The window size of sliding windows can either be specified in samples (window_samples) or in seconds (window_sec, together with sampling_rate).

The overlap of windows can either be specified in samples (overlap_samples) or in percent (overlap_percent).

Parameters
  • data (array with shape (n, 3) or (n, 2)) – 3D or 2D signal on which static moment detection should be performed (e.g. 3D-acc or 3D-gyr data)

  • window_samples (int, optional) – window size in samples or None if window size is specified in seconds + sampling rate. Default: None

  • window_sec (int, optional) – window size in seconds or None if window size is specified in samples. Default: None

  • sampling_rate (float, optional) – sampling rate of data in Hz. Only needed if window size is specified in seconds (window_sec parameter). Default: None

  • overlap_samples (int, optional) – overlap of windows in samples or None if window overlap is specified in percent. Default: None

  • overlap_percent (float, optional) – overlap of windows in percent or None if window overlap is specified in samples. Default: None

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

  • metric (str, optional) –

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

    • ’variance’ (default): Calculates variance value per window

    • ’mean’: Calculates mean value per window

    • ’maximum’: Calculates maximum value per window

    • ’median’: Calculates median value per window

Returns

dataframe with [“start”, “end”] columns indicating beginning and end of static regions within the input signal

Return type

DataFrame

Examples

>>> _find_static_sequences(data, window_length=128, overlap=64, inactive_signal_th = 5, metric = 'mean')

See also

sliding_window()

Details on the used windowing function for this method.

biopsykit.signals.imu.static_moment_detection.find_first_static_window_multi_sensor(signals, window_length, inactive_signal_th, metric)[source]

Find the first time window in the signal where all provided sensors are static.

Parameters
  • signals (Sequence of n arrays with shape (k, m) or a 3D-array with shape (k, n, m)) – The signals of n senors with m axis and k samples.

  • window_length (int) – Length of the required static signal in samples

  • inactive_signal_th (float) – The threshold for static windows. If metric(norm(window, axis=-1)) <= inactive_signal_th for all sensors, it is considered static.

  • metric (Literal['maximum', 'variance', 'mean', 'median']) – The metric that should be calculated on the vectornorm over all axis for each sensor in each window

Returns

Start and end index of the first static window.

Return type

(start, end)

Examples

>>> sensor_1_gyro = ...
>>> sensor_2_gyro = ...
>>> find_first_static_window_multi_sensor([sensor_1_gyro, sensor_2_gyro], window_length=128, inactive_signal_th=5)