Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Authored by Souvik Mandal, Ph.D.

Project Leader & Instructor, Computational Behavioral Sciences, LS100, FAS, Harvard University | Linkedin ID: souvik-mandal-phd


Last updated: 2026-07-02

Open in Colab Open in GitHub Codespaces

Goal

This notebook takes joint angles (computed in the previous notebook) and produces biomechanical indices under different scenarios.
The users need to define what input to use (single frame, averaged windows, single/multiple angles) and how to score (discrete categories or continuous scores).

You can compute biomechanical indices under various scenarios:

  1. Different Inputs

    • (a) One angle at one frame

    • (b) Average of one angle over a user-defined window of frames

    • (c) Multiple angles at one frame

    • (d) Average of multiple angles, each over a user-defined window

  2. Different Outputs

    • Discrete categories (e.g., good, average, bad) based on user-defined thresholds

    • Continuous scores (e.g., 0–10 or 0–100) based on user-defined mapping

Every place where criteria are needed is provided as a separate code block for students to edit.

Imports & Environment Check (Code)

Load Angles CSV

Load a *_angles.csv file generated by Notebook 2.
It should contain columns like:

  • video, frame, time_ms

  • angle_<name> for each computed angle (e.g., angle_left_knee)

  • confidence_<name> for each angle with values in {'good','low','least'} (from Notebook 2)

User Parameters — Angle Selection, Frame Windows, Confidence Handling

YOU NEED TO ENTER YOUR CRITERIA HERE.

We will compute biomechanical indices for:

  • All frames (no filtering)

  • Only frames where specified angle thresholds are satisfied

  • A running average across the whole sequence using a user-defined window size

You control this via selection_mode:

  • "all_frames" — use every frame

  • "angle_thresholded" — keep only frames satisfying your rules

  • "running_avg" — compute a rolling mean per angle (window size in frames)

The rest of the notebook (discrete labels / continuous scores) will apply to the angles produced by your selection mode.

Build the working angle table based on your selection mode

  • Filters by selected_video (if set)

  • Optionally keeps only rows with acceptable confidence per angle

  • Applies one of:

    • All frames: keep angles as-is

    • Angle thresholded: keep only frames satisfying your angle conditions

    • Running average: replace each selected angle with its rolling average across the entire sequence

Compute indices on the resulting angle table

From here on, use work_df (not the raw angles_df).
Any discrete labels or continuous scores you’ve defined will be computed:

  • Per frame (row-wise), for the frames remaining in work_df

  • On either raw angles (all/thresholded) or running-averaged angles (running_avg mode)

Compute indices on the resulting angle table

From here on, use work_df (not the raw angles_df).
Any discrete labels or continuous scores you’ve defined will be computed:

  • Per frame (row-wise), for the frames remaining in work_df

  • On either raw angles (all/thresholded) or running-averaged angles (running_avg mode)

Save the per-frame indices

This writes a tidy CSV with angles (raw or running-average per your choice), plus any labels and scores you defined.