IMU (.imu)

IMU (.imu)#

Contains functions for resampling, processing and correcting IMU data.

worklab.imu.align_signals(signal1, signal2)[source]#

Align IMU signals based on correlation of sensors

Parameters:
  • signal1 (pd.Series) – signal to align with

  • signal2 (pd.Series) – signal to align to

Returns:

  • signal2 (pd.Series) – signal to align to

  • lag (np.int) – number of samples to shift signals to align sensors

worklab.imu.camber_angle(wheel_data, accel_units='g')[source]#

Camber estimated from wheel IMU

Parameters:
  • wheel_data (pd.DataFrame) – DataFrame with wheeldata

  • accel_units (string) – default is g, other inputs can be m/s2

Returns:

wheel_data – DataFrame with processed wheeldata

Return type:

pd.DataFrame

worklab.imu.change_imu_orientation(sessiondata, inplace=False)[source]#

Changes IMU orientation from in-wheel to on-wheel

Parameters:
  • sessiondata (dict) – original sessiondata structure

  • inplace (bool) – perform operation inplace

Returns:

sessiondata – sessiondata with reoriented gyroscope data

Return type:

dict

worklab.imu.cut_imu(sessiondata, slice_1=1, slice_2=5)[source]#

Align IMU signals based on correlation of sensors

Parameters:
  • sessiondata (dict) – original sessiondata structure

  • slice_1 (np.int) – starting time to cut data (s)

  • slice_2 (np.int) – stopping time to cut data (s), if input is ‘end’ (string), it will cut till the end

Returns:

sessiondata – cut sessiondata

Return type:

dict

worklab.imu.frame_rot(sessiondata, ca=20, ws=0.34, side='right', method='ahrs')[source]#

Estimate frame rotational velocity with one IMU

Parameters:
  • sessiondata (dict) – original sessiondata structure

  • ca (float) – camber angle (degrees)

  • ws (float) – radius of the wheels (meters)

  • side (string) – wheel is situated on which side, default is ‘right’

  • method (string) – One IMU processing method, default is ‘ahrs’ (can be changed to Klimstra)

Returns:

sessiondata – sessiondata structure with estimated frame rotational data

Return type:

dict

worklab.imu.gyro_bias(wheel_data)[source]#

Gyroscope bias based on Klimstra

Parameters:

wheel_data (pd.DataFrame) – DataFrame with wheeldata

Returns:

wheel_data – DataFrame with processed wheeldata

Return type:

pd.DataFrame

worklab.imu.imu_synch(sessiondata, right_wheel=True, inplace=False)[source]#

Synchronise wheel and frame sensor IMUs

Parameters:
  • sessiondata (dict) – original sessiondata structure

  • right_wheel (boolean) – if set to True, right wheel is used, if set to False, left wheel is used

  • inplace (bool) – perform operation inplace

Returns:

sessiondata – sessiondata with reoriented gyroscope data

Return type:

dict

worklab.imu.mounting_misallignment(wheel_data)[source]#

Mounting misallignment based on Klimstra

Parameters:

wheel_data (pd.DataFrame) – DataFrame with wheeldata

Returns:

wheel_data – Dataframe with processed wheeldata

Return type:

pd.Dataframe

worklab.imu.offset(sessiondata, n_sensors=2, right_wheel=True, gyro_offset=False)[source]#

Remove potential offset in IMU data

Parameters:
  • sessiondata (dict) – resampled sessiondata structure

  • right_wheel (bool) – if set to True, right wheel is used, if set to False, left wheel is used

  • n_sensors (float) – number of sensors used, 2: right wheel and frame, 3: right, left wheel and frame

  • gyro_offset (bool) – if set to True, an additional gyroscope_z frame offset correction will be used

Returns:

sessiondata – sessiondata with offset removed

Return type:

dict

worklab.imu.process_imu(sessiondata, camber=18, wsize=0.32, wbase=0.8, n_sensors=3, sensor_type='ximu3', side='right', inplace=False, method='ahrs', alignment_correction=False)[source]#

Calculate wheelchair kinematic variables based on NGIMU data

Parameters:
  • sessiondata (dict) – original sessiondata structure

  • camber (float) – camber angle in degrees

  • wsize (float) – radius of the wheels (meters)

  • wbase (float) – width of wheelbase (meters)

  • n_sensors (float) – number of sensors used: 1: wheel 2: wheel and frame, 3: right wheel, left wheel and frame

  • sensor_type (string) – type of sensor, ‘ngimu’ or ‘ximu3’ is for xio-technologies, ‘move’ is for movesense

  • side (string) – wheel is situated on which side, default is ‘right’ (only change with one or two sensors)

  • inplace (bool) – performs operation inplace

  • method (string) – One IMU processing method, default is ‘ahrs’ (can be changed to Klimstra)

  • alignment_correction (bool) – Additional alignment correction based on rotational velocity

Returns:

sessiondata – sessiondata structure with processed data

Return type:

dict

worklab.imu.push_imu(acceleration, sfreq=400.0)[source]#

Push detection based on velocity signal of IMU on a wheelchair.

Parameters:
  • acceleration (np.array, pd.Series) – acceleration data structure

  • sfreq (float) – sampling frequency

Return type:

push_idx, acc_filt, n_pushes, cycle_time, push_freq

References

van der Slikke, R., Berger, M., Bregman, D., & Veeger, D. (2016). Push characteristics in wheelchair court sport sprinting. Procedia engineering, 147, 730-734.

worklab.imu.resample_imu(sessiondata, sfreq=400.0)[source]#

Resample all devices and sensors to new sample frequency.

Resamples all devices and sensors to new sample frequency. Sample intervals are not fixed with ngimu so resampling before further analysis is recommended. Translated from xio-Technologies.

Parameters:
  • sessiondata (dict) – original session data structure to be resampled

  • sfreq (float) – new intended sample frequency

Returns:

sessiondata – resampled session data structure

Return type:

dict

References

xioTechnologies/NGIMU-MATLAB-Import-Logged-Data-Example

worklab.imu.wheelchair_odometry(sessiondata, rot_window=5, vel_window=5, turn_threshold=15, anchor_alpha=0.01, turn_smooth_window=7)[source]#

Compute wheelchair odometry from IMU + skid velocity.

Parameters:
  • sessiondata (pandas.DataFrame) – original sessiondata structure

  • rot_window (int, optional) – Rolling window size for smoothing rotational velocity. Larger = smoother heading, but slower response.

  • vel_window (int, optional) – Rolling window size for smoothing velocity. Larger = smoother velocity, but may flatten peaks.

  • turn_threshold (float, optional) – Threshold (deg/s) above which a sample is considered part of a turn. Controls where anchoring and turn‑smoothing are applied.

  • anchor_alpha (float, optional) – Strength of turn‑anchored heading correction. Higher = more correction during turns.

  • turn_smooth_window (int, optional) – Window size for smoothing heading inside detected turns. Larger = smoother turns, but may distort sharp manoeuvres.

Returns:

df – Same dataframe with added columns: - ‘dist_x’ : integrated x‑position - ‘dist_y’ : integrated y‑position

Return type:

pandas.DataFrame