Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions notebooks/user_guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"outputs_hidden": false
"outputs_hidden": false,
"is_executing": true
},
"tags": [
"remove-input"
]
],
"ExecuteTime": {
"start_time": "2025-12-07T17:59:35.894792Z"
}
},
"outputs": [],
"source": [
"import pathlib\n",
"import warnings\n",
Expand All @@ -21,7 +23,9 @@
"import shapely\n",
"\n",
"warnings.filterwarnings(\"ignore\")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -891,6 +895,40 @@
"get_invalid_trajectory(traj_data=traj, walkable_area=walkable_area_faulty)"
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"## Preprocessing\n",
"\n",
"\n",
"### Trajectory Projector\n",
"\n",
"When working with head trajectories, participants may occasionally lean over obstacles. As a result, their trajectories can leave the walkable area for some frames, and these data cannot be processed by PedPy.\n",
"\n",
"To address this, there is a function that moves trajectory points that lie inside a wall or too close to it. The distance that should remain between the point and the wall afterward is calculated by linear interpolation. The new distance lies within the interval between start_distance and end_distance:\n",
"\n",
"$$\n",
"d' = (d-b)*{(e-s) \\over (e-b)}+s\n",
"$$\n",
"\n",
"- d' is the new distance to the wall\n",
"- d is the original distance to the wall\n",
"- b corresponds to back_distance\n",
"- s corresponds to start_distance\n",
"- e corresponds to end_distance\n",
"\n",
"If a point lies inside the geometry or too close to it, it will be pushed outward. The distance interval for these points starts at back_distance, which must be negative because it represents the maximum depth inside the wall, and ends at end_distance. Points located deeper inside an obstacle are assigned a smaller new distance than points located near the boundary of the interval.\n",
"\n",
"For example, a point lying deep inside an obstacle will receive a new distance close to start_distance, which represents the minimum possible value for new_distance. A point that is already outside the obstacle but needs to be adjusted for smoother results will also receive a new distance, but this value will be only slightly larger than its original distance.\n",
"\n",
"It is essential that end_distance is larger than start_distance, and that back_distance is negative. Depending on the geometry and the parameter values, it can also be beneficial to buffer the geometry beforehand to create thicker walls. If the walls are too thin, the function may accidentally move the point to the wrong side.\n",
"\n",
"The function returns a pedpy.TrajectoryData, either the corrected version of the trajectory or the\n",
" original trajectory, if the original trajectory was valid.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading
Loading