> For the complete documentation index, see [llms.txt](https://help.imotions.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.imotions.com/lab/analysis/biosensor-analysis/r-notebook-body-tracking-kinematics.md).

# R Notebook: Body Tracking Kinematics

Run the Body Tracking Kinematics R notebook to compute speed and acceleration of body landmarks and angles between limbs from video-based body pose data.

*The Body Tracking Kinematics R Notebook computes the speed and acceleration of selected body landmarks as well as the angle between selected limbs based on the body pose extracted from processing videos in a study.*

### Body Tracking Kinematics Overview

iMotions allows analysis of [Body and Hand Pose](https://help.imotions.com/lab/import-and-post-processing/body-and-hand-pose-detection-analysis-video-based-motion-capture.md) data with the Body Tracking Kinematics R Notebook.

This R Notebook applies signal processing to obtain kinematics, movement, and angle data about selected body parts.

#### Requirements

* Study must contain video with Body and Hand Pose post processing applied/completed.
* iMotions v11.1.0 or newer.

## How to Process Body Tracking Kinematics

1. Select a study that contains video with Body and Hand Pose data.
2. Create a new analysis for the study (with the Add Analysis button that appears when hovering on the study).
3. Advance through the steps “Segmentation Settings” and “Segmentation Criteria”.
4. In “Signal processing”, click “+” next to “Active flows”.
5. Select “Pose Detection Analysis” from “Devices”.
6. Select “Body Tracking Kinematics” from “Algorithm”.

At first, you find a list of body landmarks and body angles. You have to select at least one landmark and one angle to proceed.

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-702077c6a6e32e1a04dc9bb3bfbb2c124b8119da%2F8762e83b4c_image-3QRSJQ63.webp?alt=media)

### Body Tracking Kinematics Settings

Under **preprocessing**, you have the following options:

* Gap interpolation length: The raw position data about the selected body landmark may have missing data, due to obstruction, blur, or failure to process the video. These gaps in the data can be filled with a linear interpolation. Gaps below the set time window (default 120 ms) will be interpolated, gaps above the set time window will just return NA values.
* Low-pass filter cutoff frequency: This smoothens out potential jitter in the data. Lower values will lead to a higher smoothing.

**Thresholding parameters** are used to classify movements from times of stillness:

* A threshold value (in pixels per second) can be set. If speed is above this threshold, a movement is classified. (Please note that data processed with the MediaPipe algorithm requires a higher threshold than data processed with the RTMO algorithm.)
* Alternatively, a threshold can be computed based on a baseline signal. This requires a specific stimulus during which the respondent was standing still. The 95th percentile of the speed during this stimulus is calculated, and the threshold set to a value three times higher than the 95th percentile of the baseline.
* A minimum duration between two movements (default 350 ms) can be set to merge very short phases of stillness with the classified movement period, as they can arise from jitter in the data.
* A minimum movement duration (default 70 ms) can be set to discard very short periods of movement, as they can arise from jitter in the data.

**How to decide the right set of parameters:**

To determine the amount of noise/ jitter in the data, we recommend to visually inspect the raw data and its inherent noise. Look at phases of stillness as well as phases when the movement you are interested in is taking place, and set the threshold based on the calculated speed during these times.

If the speed shows high variability during periods of stillness, we recommend to lower the low-pass filter cutoff frequency to obtain a higher level of smoothing. (Please note that high smoothing can make it impossible to detect small actual movements.)

### Method

**Data retrieval**: The raw signals (X, Y, and Z coordinates of body landmarks) are obtained from the [Body and Hand Pose processing](https://help.imotions.com/lab/import-and-post-processing/body-and-hand-pose-detection-analysis-video-based-motion-capture.md). The data can come from either of two models, RTMO or MediaPipe.

**Data interpolation**: Possible gaps in the signal due to signal drops are identified and linearly interpolated based on the set threshold. Else, each fragment of signal is analyzed separately.

**Filtering**: A zero-lag fourth-order low-pass Butterworth filter with the set cutoff value is applied to the body tracking signals to remove noise and make the signals more smooth (Stenum, Rossi, and Roemmich, 2021). Lowering this value will make the signal even more smooth. This is advantageous when wanting to detect overall movement as one big movement, but will also detect small breaks between movements as movement. Increasing this value will make the signal less smoothed. This is advantageous when wanting to separate all small movement, but can also introduce noise as movement.

**Kinematic calculation**: The kinematic calculations consist of speed and acceleration magnitude.

The speed is the magnitude calculation of the velocity on the three different axes calculated with the following formula:

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-64a4ab0df0dcde3e9a951442611a3af9875d475a%2Fa2a7308d26_image-54L2WRXV.webp?alt=media)

Where ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-6b146d31f2705de52499e098eb2d1c86db62a9fb%2Fb0c3c48926_image-3DPVBSFS.webp?alt=media) is the speed and vx, vy, and vz are the velocity along the different axes. For the x axis, it is given by the following formula: ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-d08c868f9952f76b513f2b5d939ebd1737e759ff%2Fbcae45c62f_image-HK1HVYTQ.webp?alt=media)

Where ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-dc49ef30d4c70cc37f4615a019cabe0f913c324a%2Fe8ee78ea00_image-3I3XCEXY.webp?alt=media) is the change in position (displacement) and ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-dc6a1fb2a08a335c0b6d2f6d8a11e239533610a1%2F14659d3ba6_image-BKLJQCT5.webp?alt=media)is the change in time. This is then filtered using a zero-lag, fourth order low-pass Butterworth filter with a cutoff frequency at 10 Hz. (Michaels et al., 2025).

The acceleration magnitude is the magnitude calculation of the acceleration on the three different axes calculated with the following formula:

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-0ee29d59607938494953a9fe0b63dce56bf0db79%2F544d6154e0_image-F2LKORSU.webp?alt=media)

Where ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-67d80d49b66d673d3979928d41fecb4f10091c64%2Fcc7c11fbe1_image-7YOXOF4H.webp?alt=media) is the acceleration magnitude and ax, ay, and az are the acceleration along the different axes. For the x axis, it is given by the following formula: ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-7fd69f94347985c39d37b685dcb1a2eb70885bbd%2F526e03707b_image-EJYQFHAU.webp?alt=media)

Where ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-9bd30e636da09da9223bc2e8aef96a4141c5bbda%2F3410c55b7d_image-7CTW18G0.webp?alt=media) is the change in velocity. This was then filtered using a zero-lag, fourth order low-pass Butterworth filter with a cutoff frequency at 8 Hz (Michaels et al., 2025).

**Angle calculation**: The angles are predefined angles between body parts calculated from the interpolated data. E.g. the Left Shoulder Angle is the angle between the three body landmarks; Left Elbow, Left Shoulder, and Left Hip. First, the two vectors ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-33f98ccce3af0dfdfffe3ec3e94971efaa1d5861%2F21673923a1_image-W3BMJX5S.webp?alt=media) between the points (A, B, and C) are calculated using the following formulas:

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-1118bb8d8d1c14107c052c3fef8aa49557f1782a%2F24b99a6cb3_image-6PRPEHS2.webp?alt=media)

The angle ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-69995b009859d50be8277b5ddf37b6a409f175e6%2Ff34928a3ab_image-KMQROFXQ.webp?alt=media) between the vectors is then calculated using the following formula:

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-eeaa878cbaa4b916452d73593572f2b4388c1799%2Fccedc208d7_image-8LOOZFBA.webp?alt=media)

Where ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-02dff7c6d5286ca5aabebc61e27dfe4554fdc9ac%2F9dee0ee62d_image-Y6EHT12S.webp?alt=media)is the dot product and ![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-01eb977461f7a9a7fe62dc157980dda29c4c279d%2F822a3ba041_image-O9DXMKPB.webp?alt=media) is the length of the vector. The selected angle is calculated over time and returned as a signal.

**Movements**: A threshold is applied to the speed signal, where onsets and offsets of the movements are detected. Onsets are all the points where the speed signal crosses from below the threshold value to above. Offsets are the points where the speed signal crosses from above the threshold value to below. The duration of a movement is the time between the onset/ offset pair.

To deal with the speed signal fluctuating around the threshold, movements separated by a time duration inferior to the set minimum duration are merged together. In addition, movements detected due to small artifacts in the signal are removed if the duration is below the set minimum movement duration value.

**Movement peaks**: The maximum speed value within a movement is defined as the movement peak.

### Outputs

**After signal processing, you can access the following new signals in the Respondent Replay:**

Kinematics of the selected body landmark(s), e.g. left wrist

* Interpolated X/ Y/ Z position (in pixels)
* Speed (in pixels per second)
* Acceleration Magnitude (in pixels per second squared)

Movement of the selected body landmark(s), e.g. left wrist

* Movement (binary signal indicating when movement was detected)
* Movement Peak (binary signal indicating when the maximum speed was reached)

Angle of the selected body angles, e.g. left elbow

* Angle (in degrees)

In addition to the signals, you can also access **Analysis Markers** indicating the selected body landmark’s movement with an event every time there is an

* onset
* offset
* peak

Under **Analysis metrics**, you can access statistics on the following metrics:

Kinematics of the selected body landmark(s), e.g. left wrist

* Average speed (in pixels per second)
* Average Acceleration Magnitude (in pixels per second squared)

Movement of the selected body landmark(s), e.g. left wrist.

These statistics are based on the time intervals during which movement was detected, as opposed to the Kinematics metrics which are based on the entire timeline.

* Count of how often the landmark was detected to move
* Time moving (in milliseconds)
* Percentage moving (%)
* Average Movement Duration (in milliseconds)
* Average Movement Speed (in pixels per second)
* Average Movement Peak Speed (in pixels per second)

Angle of the selected body angles, e.g. left elbow

* Average
* Minimum
* Maximum

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-048d871a73067a17b52082a6ba28e9c2e02097f0%2Fc5d9996e69_image-6Z0APIN5.webp?alt=media)

> Please note that the calculations are based on the pixels in the video. Hence, the speed and acceleration values may vary if the same movement is executed closer or farther away from the camera. **We recommend to perform all recordings at the same distance to camera.**

### Export Files

There are three types of files you can export: Sensor Data files, and two types of R processing files: Body tracking metrics (called BodyMetrics.csv) and Body movement table (called BodyMovementTable.csv).

**Sensor Data file**: This is the raw sensor data export. It can also include R-processed signals by ticking the “R analysis Body Tracking Kinematics” under Sensor Data > Sensors

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-bf52618be29a3c262c2347db026e3aad237a1bed%2F2301635274_image-IP5L6ZQK.webp?alt=media)

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-d9df0ea7b051436cab040b07c61a7a825dcb85f7%2Fec436794f4_image-G5CKTZGY.webp?alt=media)

The SensorData file can look as follows:

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-ee71bbb4297f4a134d5d8e85f7729d8587c0b61a%2F19de334bab_image-3SWJJB6T.webp?alt=media)

Body tracking metrics file: This file includes the processed results from R Notebooks across respondents and stimuli/ time intervals.

Body movement table: This file lists the detected body movements segment by segment, with an index number, onset, offset, duration, and peak of each movement per respondent, also indicating during which stimulus/ annotation/ scene it happened. You will find a column called truncation type that will describe whether the identified movement is truncated (incomplete for the given stimulus/ scene/ annotation) or whole (complete).

You can access the exported files by

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-38f61f62fd7cb3e78c84a4410ff3204320714d08%2F53e770b537_image-KO0FZEEY.webp?alt=media)

(1) clicking on the ‘Export’ button,

(2) under ‘R PROCESSING’, you can

(3) select to have individual metrics exports (to obtain a separate export file per modality) or a Single multi-modal export (relevant when you use more than one modality), you can click on

(4) ‘Body Tracking Export’. Here, by expanding the accordion menu, you can access further options.

(5) When you finally click the blue Export button, you will export the Body tracking metrics as well as Body movement table files, which can look as follows:

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-cdca6fe73704f0b7c23d744dbecf91069a1cc3b9%2F4fdc635967_image-HVG9Q070.webp?alt=media)

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-884a04080d4a6135ce5e96c9828dee36a50e64df%2F09cafab2fe_image-M6GAAHB8.webp?alt=media)

Descriptions of the Body tracking metrics data (with the left wrist as well as left elbow as examples):

| Left Wrist Average Speed                  | Average speed of the left wrist in the current interval.                                                          |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| Left Wrist Average Acceleration Magnitude | Average acceleration magnitude of the left wrist in the current interval.                                         |
| Left Wrist Movement Count                 | Count of left wrist movements in the current interval.                                                            |
| Left Wrist Time Moving                    | Total amount of time during which the respondent was classified to move their left wrist in the current interval. |
| Left Wrist Percentage Moving              | Percentage of the current interval during which the respondent was classified to move their left wrist.           |
| Left Wrist Average Movement Duration      | Average duration of all left wrist movements classified in the current interval.                                  |
| Left Wrist Average Movement Speed         | Average total speed of all left wrist movements classified in the current interval.                               |
| Left Wrist Average Movement Peak Speed    | Average peak speed of all left wrist movements classified in the current interval.                                |
| Average Left Elbow Angle                  | Average of left elbow angle in the current interval.                                                              |
| Maximum Left Elbow Angle                  | Maximum of left elbow angle in the current interval.                                                              |
| Minimum Left Elbow Angle                  | Minimum of left elbow angle in the current interval.                                                              |

Descriptions of the Body movement table:

| Movement Index             | Movement number, counting from start of the recording.                                                                                                                             |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Movement Index by Stimulus | Movement number, counting from start of the stimulus.                                                                                                                              |
| Movement Onset             | Start time of the movement (relative to recording start).                                                                                                                          |
| Movement Offset            | End time of the movement (relative to recording start).                                                                                                                            |
| Movement Duration          | Duration of the movement.                                                                                                                                                          |
| Movement Speed             | The average speed of the movement                                                                                                                                                  |
| Peak Time                  | Time when the movement reached its maximum speed (relative to recording start).                                                                                                    |
| Peak Movement Speed        | Maximum speed of the movement.                                                                                                                                                     |
| Event Type                 | Type of the body part moving.                                                                                                                                                      |
| Truncation Type            | Whole: The movement started and ended within the interval; Partial: The movement started or ended outside of the interval. Data was truncated to start or end within the interval. |
| Device                     | Name of the sensor used to collect the body tracker data.                                                                                                                          |
| Flow Name                  | User-defined name of the algorithm used to perform the body movement analysis.                                                                                                     |

### Reports

When clicking the Reports button, you can access the entire description of the signal processing steps along with additional tables and references.

![](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-06812c95fa56c7be1d651b9e8da6f2cb02805ae3%2Fb3baea814d_image-G3MS2C2K.webp?alt=media)

### References

Michaels, R., T. V. Barreira, S. N. Robinovitch, J. J. Sosnoff, and Y. Moon. 2025. “Estimating Hip Impact Velocity and Acceleration from Video-Captured Falls Using a Pose Estimation Algorithm,” January.

Stenum, J., C. Rossi, and R. T. Roemmich. 2021. “Two-Dimensional Video-Based Analysis of Human Gait Using Pose Estimation,” April.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.imotions.com/lab/analysis/biosensor-analysis/r-notebook-body-tracking-kinematics.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
