biopsykit.signals.imu package

Module for processing IMU data.

biopsykit.signals.imu.var_norm_windows(data)[source]

Compute the norm of the variance of each axis for a windowed signal.

This function computes the norm of variance according to:

\[var_{norm} = \sqrt{var_x^2 + var_y^2 + var_z^2}\]

where \(var_i\) is the variance of axis \(i\) in the window

Parameters

data (DataFrame) – input data, split into windows using sliding_windows_imu()

Returns

norm of variance for windowed signal

Return type

DataFrame

biopsykit.signals.imu.convert_acc_data_to_g(data, inplace=False)[source]

Convert acceleration data from \(m/s^2\) to g.

Parameters
  • data (AccDataFrame or ImuDataFrame) – dataframe containing acceleration data.

  • inplace (bool, optional) – whether to perform the operation inplace or not. Default: False

Returns

acceleration data converted to g

Return type

AccDataFrame or ImuDataFrame

biopsykit.signals.imu.sliding_windows_imu(data, window_samples=None, window_sec=None, sampling_rate=0, overlap_samples=None, overlap_percent=None)[source]

Create sliding windows from IMU data.

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).

If the input data has the shape (m, n) the output data will have the following shape: (m * window_size, num_windows), where x depends on the number of data sources (acc, gyr, or both) and the axes (x, y, z). The number of windows depends on the input length of the array (n), the window size, and the window overlap.

The output data will be a DataFrame where the windowed values of each axes are concatenated to one row. This means that the output data has a multi-level column index with two levels if the input data only has one column level (axis): axis (“x”, “y”, “z”) as the first level and samples (array index within the window) as second level. If the input data has two column levels (channel and axis) the output dataframe will have three levels: channel, axis, and samples.

Parameters
  • data (array_like) – input 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

Returns

sliding windows from input data

Return type

DataFrame

See also

sliding_window_view()

create sliding window of input array. low-level function with less input parameter configuration possibilities