Processing Mocap Data

This documentation is WIP:

Nimble is focused on human motion and biomechanics analysis. We include many utilities that will be familiar to biomechanics practitioners: loading C3D files, loading multiple OpenSim formats, and the algorithms that power AddBiomechanics.

To load C3D files, check out:

class nimblephysics.biomechanics.C3DLoader
static debugToGUI(file: nimblephysics_libs._nimblephysics.biomechanics.C3D, server: nimblephysics_libs._nimblephysics.server.GUIWebsocketServer) None
static fixupMarkerFlips(c3d: nimblephysics_libs._nimblephysics.biomechanics.C3D) None
static loadC3D(uri: str) nimblephysics_libs._nimblephysics.biomechanics.C3D

To run some heuristics to clean up the C3D data, you can use:

class nimblephysics.biomechanics.MarkerFixer
static generateDataErrorsReport(immutableMarkerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], dt: float) nimblephysics_libs._nimblephysics.biomechanics.MarkersErrorReport

This will return you an object with a field markerObservationsAttemptedFixed

class nimblephysics.biomechanics.MarkersErrorReport
property info
property markerObservationsAttemptedFixed
property warnings

For OpenSim files, check out:

nimblephysics.biomechanics.OpenSimParser

alias of <module ‘nimblephysics_libs._nimblephysics.biomechanics.OpenSimParser’>

This class is the basis of the kinematic fit (just bone scaling, marker offsets, and IK, no dynamics) for AddBiomechanics.

class nimblephysics.biomechanics.MarkerFitter
addZeroConstraint(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, name: str, loss: Callable[[nimblephysics_libs._nimblephysics.biomechanics.MarkerFitterState], float]) None
autorotateC3D(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, c3d: nimblephysics_libs._nimblephysics.biomechanics.C3D) None
checkForEnoughMarkers(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]]) bool
checkForFlippedMarkers(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], init: nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization, report: nimblephysics_libs._nimblephysics.biomechanics.MarkersErrorReport) bool
debugTrajectoryAndMarkersToGUI(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, server: nimblephysics_libs._nimblephysics.server.GUIWebsocketServer, init: nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], forcePlates: List[nimblephysics_libs._nimblephysics.biomechanics.ForcePlate] = None, goldOsim: nimblephysics_libs._nimblephysics.biomechanics.OpenSimFile = None, goldPoses: numpy.ndarray[numpy.float64[m, n]] = array([], shape=(0, 0), dtype=float64)) None
findJointCenters(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, initializations: nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization, newClip: List[bool], markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]]) None
generateDataErrorsReport(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], dt: float) nimblephysics_libs._nimblephysics.biomechanics.MarkersErrorReport
getInitialization(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], newClip: List[bool], params: nimblephysics_libs._nimblephysics.biomechanics.InitialMarkerFitParams = InitialMarkerFitParams(numBlocks=12)) nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization
getMarkerIsTracking(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, marker: str) bool
getNumMarkers(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter) int
optimizeBilevel(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], initialization: nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization, numSamples: int, applyInnerProblemGradientConstraints: bool = True) nimblephysics_libs._nimblephysics.biomechanics.BilevelFitResult
static pickSubset(markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], subsetSize: int) List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]]
removeZeroConstraint(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, name: str) None
runKinematicsPipeline(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], newClip: List[bool], params: nimblephysics_libs._nimblephysics.biomechanics.InitialMarkerFitParams, numSamples: int = 20, skipFinalIK: bool = False) nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization
runMultiTrialKinematicsPipeline(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, markerTrials: List[List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]]], params: nimblephysics_libs._nimblephysics.biomechanics.InitialMarkerFitParams, numSamples: int = 50) List[nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization]
runPrescaledPipeline(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], params: nimblephysics_libs._nimblephysics.biomechanics.InitialMarkerFitParams) nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization
saveTrajectoryAndMarkersToGUI(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, path: str, init: nimblephysics_libs._nimblephysics.biomechanics.MarkerInitialization, markerObservations: List[Dict[str, numpy.ndarray[numpy.float64[3, 1]]]], frameRate: int, forcePlates: List[nimblephysics_libs._nimblephysics.biomechanics.ForcePlate] = None, goldOsim: nimblephysics_libs._nimblephysics.biomechanics.OpenSimFile = None, goldPoses: numpy.ndarray[numpy.float64[m, n]] = array([], shape=(0, 0), dtype=float64)) None
setAnatomicalMarkerDefaultWeight(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, weight: float) None
setAnthropometricPrior(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, prior: nimblephysics_libs._nimblephysics.biomechanics.Anthropometrics, weight: float = 0.001) None
setCustomLossAndGrad(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, loss: Callable[[nimblephysics_libs._nimblephysics.biomechanics.MarkerFitterState], float]) None
setDebugJointVariability(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, debug: bool) None
setDebugLoss(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, debug: bool) None
setIgnoreJointLimits(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, ignore: bool) None
setInitialIKMaxRestarts(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, starts: int) None
setInitialIKSatisfactoryLoss(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, loss: float) None
setIterationLimit(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, iters: int) None
setMarkerIsTracking(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, marker: str, isTracking: bool = True) None
setMaxAxisWeight(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, weight: float) None
setMaxJointWeight(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, weight: float) None
setMaxMarkerOffset(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, offset: float) None
setMinAxisFitScore(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, score: float) None
setMinJointVarianceCutoff(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, cutoff: float) None
setMinSphereFitScore(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, score: float) None
setRegularizeAllBodyScales(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, weight: float) None
setRegularizeAnatomicalMarkerOffsets(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, weight: float) None
setRegularizeIndividualBodyScales(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, weight: float) None
setRegularizeTrackingMarkerOffsets(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, weight: float) None
setTrackingMarkerDefaultWeight(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, weight: float) None
setTrackingMarkers(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter, trackingMarkerNames: List[str]) None
setTriadsToTracking(self: nimblephysics_libs._nimblephysics.biomechanics.MarkerFitter) None