Skip to content

Motion processing

MariusKlug edited this page May 18, 2022 · 3 revisions

Pre-processing

Like the example for the EEG processing, there is one for motion processing. In general it works the same way, and importantly, if parts of the data were removed before doing the EEG processing, the same parts need to be removed the same way in the motion processing for the data to remain synchronized. You can find an example in example_bemobil_process_all_motion_data.m.

Here, the data is loaded, segments are removed, and then the bemobil_process_all_motion script is applied to the complete motion data set. This script will create a cleaned motion data set containing also two derivative channels (velocity and acceleration) in addition.

The script performs the following actions:

  1. Split the complete motion data into individual sets for each rigid body, each of them get treated with steps 2.-8.
  2. Clean the motion data, which includes removing excessively large jumps in the data and interpolation of samples with lost tracking (nan samples)
  3. Unwrapping Euler angles so there is no jump between -180° and +180° to allow lowpass-filtering
  4. Low-pass filter the data with the filter frequency given in bemobil_config.lowpass_motion
  5. Wrap the angles to pi again to ensure the data is as it was given
  6. Compute the first time-derivative (velocity), also ignoring the jumps from -180° to +180°
  7. As time-derivatives effectively amplify the high frequencies, it is recommended to add another low-pass filter here, as can be set in bemobil_config.lowpass_motion_after_derivative
  8. Compute the second time-derivative (acceleration) and add another low-pass filter as in 7.
  9. Merge all single rigid bodies into one large set again

The final processed motion set is then stored on disk in the folder specified in bemobil_config.motion_analysis_folder.

Event creation

The toolbox comes with an option to detect motion start and stop events. The bemobil_detect_motion_startstops function detects motion starts and stops based on a coarse and fine threshold of one or more given channels. If more than one channel is given, the square root of the sum of squares is taken as the detection data. A movement is detected firstly based on a coarse threshold of a given quantile of the data, then a fine threshold is applied afterwards based on the fine threshold quantile in a buffer around the detected coarse movement. Events and used parameters are stored in the EEG.etc struct so they can be copied between synchronized data sets of different modalities.

The algorithm was first used and published in Gramann, K., Hohlefeld, F.U., Gehrke, L. et al. Human cortical dynamics during full-body heading changes. Sci Rep 11, 18186 (2021). https://doi.org/10.1038/s41598-021-97749-8.

Here you can see an example of step detection using the left foot in a 10-meter there-and-back walk on a straight line. The velocity channels in x, y, and z coordinates were given, so the 3-D movement was used for detection. The coarse threshold was set to 0.9, which means that only movements exceeding the 90%-quantile were taken as movements (horizontal black line in the top plot). The fine movement threshold was set to 5% (default), and a minimum duration of 0.3s was chosen to exclude erroneous detections based on a jittery motion capture at the edges of the hallway.

Movement event example