Skip to content

JeevanRJ/forceplate-data-analysis

Repository files navigation

Force Plate CoP Metrics (MATLAB)

MATLAB functions for computing common center of pressure (CoP) metrics from force plate recordings, including:

  • CoP Path Length (total)
  • Sway Velocity (total; and optional AP/ML components)
  • 95% CoP Ellipse Area
  • Coefficient of Variation (CV) of CoP displacement (AP/ML/radial)

These scripts are designed for batch processing across many trials stored in a struct array (one element per trial).


Author

Jeevan Jayasuriya
NeuroErgonomics Lab
University of Wisconsin–Madison


What’s in this repo

Core metric functions

  • CoP_PathLength.m
    Computes total CoP path length per trial and saves a CSV.

  • CoP_SwayVelocity.m
    Computes total CoP path length and total sway velocity per trial and saves a CSV.

  • CoP_vel_APandML.m
    Computes AP, ML, and total path length and sway velocity per trial and saves a CSV and .mat.

  • CoP_EllipseArea.m
    Computes 95% ellipse area of CoP (AP–ML) per trial and saves a CSV.
    Includes optional plotting for a selected range of trials.

  • CoP_CoefVatiation.m
    Computes CoP coefficient of variation (CV) using absolute displacement:

    • CV_AP = std(|AP|) / mean(|AP|)
    • CV_ML = std(|ML|) / mean(|ML|)
    • CV_R = std(r) / mean(r), where r = sqrt(AP^2 + ML^2)
      Saves a CSV.

Input data format

All functions expect an input struct array named FFAllStruct (or equivalent), where each element is one trial and contains force plate channels:

Required fields per trial:

  • Fx, Fy, Fz (forces)
  • Mx, My (moments)

Optional (recommended) metadata fields:

  • trialID, Subject, Activity, Stimulation, Session, Trial, etc.

The scripts attempt to carry through metadata when writing CSV outputs (when those fields exist).


CoP computation used

The scripts compute CoP from forces and moments (in mm), using:

  • CoP_ML = (-(My + Fx * az0) / Fz) * 1000
  • CoP_AP = ((Mx - Fy * az0) / Fz) * 1000

Where:

  • az0 is the vertical offset (default set to 0)
  • near-zero Fz values are set to NaN to avoid division artifacts

CoP is then centered by subtracting its mean (omitnan) before metric calculation.


Filtering and sampling assumptions

Most functions use the following defaults (can be edited inside each file):

  • Sampling rate: 1000 Hz
  • Low-pass filter: 4th-order Butterworth, cutoff 10 Hz
  • applyFilter = true by default

If your force plate sampling rate differs, update samplingRate in each function accordingly.


Outputs

Each function writes a CSV in the current working directory:

  • CoP_length.csv
  • CoP_and_Sway_Velocity.csv
  • CoP_and_Sway_Velocity_with_AP_ML.csv (+ also saves CoP_and_Sway_Velocity_with_AP_ML.mat)
  • CoP_ellipse_area.csv
  • CoP_CV Measures.csv

In addition, functions return an updated struct (e.g., FFAllStructWithCoP) with computed fields appended.


Quick start

  1. Add this repo to your MATLAB path:
addpath(genpath(pwd));
  1. Ensure your trial struct array exists in the workspace as FFAllStruct.

  2. Run any metric:

Path length (total)

FFAllStructWithCoP = calculate_CoP_path_length(FFAllStruct);

Total sway velocity + total path length

FFAllStructWithCoP = calculate_CoP_path_length_and_sway_velocity(FFAllStruct);

AP/ML/Total path length + sway velocity (recommended)

FFAllStructWithCoP = calculate_CoP_path_length_and_sway_velocity(FFAllStruct);

Note: CoP_vel_APandML.m and CoP_SwayVelocity.m define the same function name but produce different outputs/files.
Recommendation: keep only one of them in your MATLAB path (or rename one function) to avoid name conflicts.

Ellipse area (with optional plotting)

plotRange = 1:10;  % plot trials 1–10 (optional)
FFAllStructWithCoP = calculate_CoP_ellipse_area_with_plot(FFAllStruct, plotRange);

CoP coefficient of variation (CV)

CoPstats = calculate_CoP_CV_allinone_abs(FFAllStruct);

Common pitfalls

  • Duplicate function name conflict:
    Both CoP_SwayVelocity.m and CoP_vel_APandML.m define
    calculate_CoP_path_length_and_sway_velocity. MATLAB will call whichever is first on the path.

    • Fix: rename one function (and file), or remove the one you don’t use.
  • Incorrect sampling rate:
    Update samplingRate if your force plate is not 1000 Hz.

  • Near-zero vertical force:
    The scripts set small Fz values to NaN. If your task includes flight phases or unloading, expect gaps.


License

MIT License (see LICENSE).

About

Force plate data preprocessing and analysis

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages