The OpenSim 4.0 API includes methods for reading C3D data into OpenSim formatted files. Marker (.trc) and Forceplate (.mot) data can be created using OpenSim C3DFileAdapter class, which uses a forked version of Arnaud Barre's BTK package. Use of the C3DFileAdapter and included Matlab utilities are described below.
Reading C3D files through Matlab
Documentation for the C3DFIleAdapter is located here. There is a working example Matlab script in your resources directory /Code/Matlab/c3dExport.m.
We have included a Matlab side class 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 format. The Matlab file can be found in your resources directory /Code/Matlab/Utilities/osimC3D.m.
To use the OpenSim classes directly, follow the code below. This code will give you OpenSim Times Series Tables for both markers and forces.
%% Read C3D into memory % Import OpenSim Library import org.opensim.modeling.* % Instantiate a C3DFileAdapter() c3dAdapter = C3DFileAdapter(); % Read c3d data data = c3dAdapter.read('walking2.c3d'); % Get a TimesSeriesTable with all the marker Data markers = data.get('markers'); % Get a TimeSeriesTable with all the Force Data forces = data.get('forces');
Reading Data through Python and C++
Some example code for using C3DFileAdapter through Python can be found below.
Example code for using the C3DFileAdapter in C++ is found below
Marker Data
Force Data