The typical file format for experimental motion capture data in the biomechanics community is C3D. C3D is a flexible format that can store marker, force plate, EMG, and event data. Despite being very flexible, data in C3D files are stored in binary format and require specialized readers to access. To read more information on the C3D file format, we encourage you to visit C3D.org to learn more.
Starting with OpenSim 4.0, C3D reading and conversion into OpenSim formats is available. Currently, use of C3D reading is limited to C++ and scripting and we will be working to support direct C3D reading in the GUI in future releases. The easiest way to use OpenSim to read your C3D data is through the Matlab interface. Once you have setup OpenSim use in Matlab, you can read C3D files and write marker and force data to .trc and .mot file formats, easily.
C3DFileAdapter only supports reading Type-2 Force plates (AMTI & Bertec). If you have a Type-3 (Kistler), or any other type, please consider donating your C3D files of forceplate data to the OpenSim project. To contribute C3D files, please email opensim@stanford.edu.
Reading C3D files through Matlab
osimC3D
We have included a utility in Matlab that can be used to perform some common operations, such as rotating data, converting data into Matlab data types, and writing marker and force data to OpenSim file formats. The Matlab file can be found in your resources directory /Code/Matlab/Utilities/osimC3D.m. An example of using the osimC3D function is in the expandable section below. In this example, we
- read a C3D file containing markers and forces,
- get some information about the data (rate, number of markers, and number of forces),
- rotate the data, and
- then write the markers to a .trc file, and the forces to a .mot file.
Reading C3D files through Python and C++
Some example code for using C3DFileAdapter through Python can be found below. This code is part of a test script that runs the C3D reader and writes data marker and force data to a storage (.sto) file.
Example code for using the C3DFileAdapter in C++ is found below. This code is part of a test script that runs the C3D reader and checks for correct values.
Converting Force, COP, and NaNs
When computing Center of Pressure (COP), often the numerical value will be computed as NaN (Not A Number). NaN values occur when the force values become zero. Typically, most COP computation systems include some cut-off value that zeros all forces below a threshold, which stops these NaNs from occurring. OpenSim does not do any processing of your force or COP and so when converting your C3D files to mot files, you may encounter NaN values. This is problematic during Inverse Dynamics analysis as you will get all NaN values for the output moments. This is because OpenSim splines the force and COP data before computing joint moments and don't know how to deal with NaN values. If you find that your mot files are containing NaNs for COPs after conversion, you don't necessarily have to perform additional computations to remove the NaNs. The C3DFileAdapter includes an input parameter that determines how the forces are represented, so you can use the appropriate input parameter to have the forces and moments represented at the origin of the plate, rather than as a COP. This negates any chance for NaNs being included in your forces.