Skip to contents

Motion Capture and Biomechanics Analysis for PhysioExperiment Objects

PhysioMoCap provides a comprehensive motion capture, pose estimation, and biomechanical analysis toolkit built on the PhysioExperiment data model. With 177 exported functions – the largest package in the PhysioExperiment ecosystem – it covers the full analysis pipeline from file I/O through kinematics, kinetics, gait analysis, movement variability, EMG integration, and clinical statistics. PhysioMoCap supports optical motion capture (C3D, Venus3D), markerless pose estimation (OpenPose, DeepLabCut, MediaPipe, OpenCap), skeletal animation formats (BVH, ASF/AMC), OpenSim musculoskeletal modeling, and standardized datasets (GaitRec).

Installation

You can install PhysioMoCap from r-universe:

install.packages("PhysioMoCap",
  repos = c("https://x-biosignal.r-universe.dev", "https://cloud.r-project.org"))

Or install the development version from GitHub:

# install.packages("remotes")
remotes::install_github("x-biosignal/PhysioMoCap")

Quick Start

library(PhysioMoCap)

# Read a C3D motion capture file
pe <- readC3D("walking_trial.c3d")

# Inspect the data
pe
samplingRate(pe)    # e.g., 120 Hz
channelNames(pe)   # marker names

# Detect gait events (heel strikes, toe offs)
events <- detectEvents(pe, schema = schema_gait())

# Segment into gait cycles
phases <- segmentPhases(pe, events, schema = schema_gait())

# Compute gait parameters (speed, cadence, step length, symmetry)
gait <- calculateGaitParameters(pe, events)
gait

# Visualize the gait cycle
plotGaitCycle(pe, events, channels = c("L_Ankle_y", "R_Ankle_y"))

Features

File I/O

Read data from all major motion capture, pose estimation, and biomechanics formats through a unified interface:

Optical motion capture: - readC3D() – C3D binary format (marker positions, analog data, force plates) - readVenus3D() – Venus3D optical tracking system - readMoCapCSV() – generic CSV with configurable column mapping

Markerless pose estimation: - readOpenPose() – OpenPose JSON keypoint output - readDeepLabCut() – DeepLabCut HDF5/CSV pose estimation - readMediaPipe() – MediaPipe holistic/pose landmarks - readOpenCap() – OpenCap cloud-based markerless capture

Skeletal animation: - readBVH() – BioVision Hierarchy motion files - readASF() / readAMC() – Acclaim skeleton and motion data

OpenSim musculoskeletal modeling: - readTRC() – marker coordinate files - readMOT() – motion/force data files - readSTO() – storage files (IK, ID, muscle analysis results) - readOpenSimOutputs() – batch read all OpenSim tool outputs

Standardized datasets: - readGaitRec() – GaitRec clinical gait database

Auto-detection: - readMoCapAuto() – automatically detect format and call the appropriate reader

Skeleton and Kinematics

Define skeletal models and compute joint-level kinematics:

Gap Handling

Detect and fill missing marker data in optical tracking recordings:

Marker Tracking

Automated marker labeling and swap correction for optical systems:

  • trackMarkers() – frame-to-frame marker assignment using the Hungarian algorithm
  • detectSwaps() – identify marker label swaps between frames
  • correctSwaps() – automatically correct detected label swaps

Signal Processing

General-purpose signal processing adapted for motion data:

Biomechanics

Center of mass, segment inertia, and gravity compensation:

Phase and Event Analysis

Event detection and movement phase segmentation with pre-built task schemas:

Pre-built task schemas: - TaskSchema() / validateSchema() / getSchema() / listSchemas() – schema management - schema_gait() – walking (heel strike, toe off, stance, swing) - schema_running() – running (flight phase, contact phase) - schema_jump() – vertical/horizontal jump (takeoff, flight, landing) - schema_cycling() – pedaling (top dead center, power phase, recovery) - schema_balance() – postural balance (quiet stance, perturbation, recovery) - schema_cutting() – cutting maneuvers (approach, plant, push-off) - schema_throw() – throwing (wind-up, acceleration, release, follow-through)

Movement Analysis

Variability, similarity, and dimensionality reduction for movement waveforms:

Gait Analysis

Spatiotemporal gait parameters and symmetry assessment:

Force Plate Kinetics

Ground reaction force analysis and contact detection:

Inverse Dynamics

Joint moment and power estimation from kinematics and kinetics:

EMG Integration

Electromyography processing and synchronization with motion data:

Clinical Statistics

Reliability and agreement metrics commonly used in rehabilitation research:

  • icc() – intraclass correlation coefficient (ICC) for inter-rater/test-retest reliability
  • sem() – standard error of measurement
  • mdc() – minimal detectable change
  • blandAltman() – Bland-Altman limits of agreement analysis
  • cohensD() – Cohen’s d effect size
  • etaSquared() – eta-squared effect size for ANOVA designs

OpenSim Integration

Interface for OpenSim musculoskeletal simulation workflows:

Visualization

Biomechanics-specific plotting functions:

Benchmarking and Validation

Tools for validating analysis pipelines against reference data:

Onboarding

Helpers for new users to explore the package without external data:

Use Cases

Application Key Functions
Clinical gait analysis readC3D(), detectEvents(), calculateGaitParameters(), plotGaitCycle()
Markerless pose tracking readOpenPose(), readDeepLabCut(), readMediaPipe()
Running biomechanics schema_running(), analyzeForcePlate(), computeLoadingRate()
Movement variability dtwDistance(), dtwClustering(), waveformPCA(), fPCA()
Musculoskeletal modeling readTRC(), run_opensim_toolchain(), inverseDynamics3D()
Rehabilitation assessment icc(), sem(), mdc(), blandAltman(), symmetryIndex()
EMG-MoCap integration normalizeEMG(), alignEMGtoMoCap(), plotMultiPanel()
Balance/postural control schema_balance(), calculateCOP(), plotTrajectory()

Dependencies

  • R (>= 4.2)
  • PhysioCore – core data structures and accessors
  • ggplot2 – visualization
  • jsonlite – JSON parsing (OpenPose, MediaPipe)
  • SummarizedExperiment, S4Vectors – Bioconductor infrastructure
  • stats, utils, rlang, scales – base R and tidyverse utilities

Optional (in Suggests):

  • signal – additional DSP functions
  • c3dr – C3D binary format parsing
  • rhdf5 – HDF5 support (DeepLabCut)
  • uwot – UMAP dimensionality reduction
  • Rtsne – t-SNE dimensionality reduction
  • httr – HTTP requests (OpenCap cloud API)
  • PhysioIO – extended file I/O capabilities

PhysioExperiment Ecosystem

PhysioMoCap is part of the PhysioExperiment ecosystem, a suite of R packages for multi-modal physiological signal analysis:

Package Description
PhysioCore Core data structures and accessors
PhysioIO File I/O (EDF, HDF5, BIDS, CSV, MAT)
PhysioPreprocess Preprocessing (filters, ICA, resampling)
PhysioAnalysis Analysis and visualization
PhysioCrossModal Cross-modal coupling and connectivity
PhysioMoCap Motion capture and biomechanics

Visit the r-universe page to browse all available packages.

License

MIT License. See LICENSE for details.

Author

Yusuke Matsui

Governance & support

Part of the Physio ecosystem. Community and policy documents live in the umbrella repository: