...
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.
Note |
---|
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
...
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.
Expand |
---|
Code Block |
---|
def test_C3DFileAdapter(self):
try:
adapter = osim.C3DFileAdapter()
except AttributeError:
# C3D support not available. OpenSim was not compiled with BTK.
return
tables = adapter.readtables = C3DFileAdapter.readFile(os.path.join(test_dir, 'walking2.c3d'), 0)
1)
markers = tables['markers']
forces = tables['forces']
tables = adapter.read(os.path.join(test_dir, 'walking5.c3d'), 1)
# Marker data read from C3D.
markers = tables['markers']
# Flatten marker data.
markersFlat = markers.flatten()
# Make sure flattenned marker data is writable/readable to/from file.
markersFilename = 'markers.sto'
stoAdapter = osim.STOFileAdapter()
stoAdapter.write(markersFlat, markersFilename)
markersDouble = stoAdapter.read(markersFilename)
# Forces data read from C3d.
forces = tables['forces']
fpCalMats = forces.getTableMetaDataVectorMatrix("CalibrationMatrices")
fpCorners = forces.getTableMetaDataVectorMatrix("Corners")
fpOrigins = forces.getTableMetaDataVectorMatrix("Origins")
# Flatten forces data.
forcesFlat = forces.flatten()
# Make sure flattenned forces data is writable/readable to/from file.
forcesFilename = 'forces.sto'
stoAdapter.write(forcesFlat, forcesFilename)
forcesDouble = stoAdapter.read(forcesFilename)
# Clean up.
os.remove(markersFilename)
os.remove(forcesFilename) |
|
...
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.
...
Panel |
---|
borderColor | gray |
---|
bgColor | white |
---|
borderWidth | 5 |
---|
borderStyle | solid |
---|
|
Next: Tools for Preparing Motion Data Previous: Storage (.sto) Files Home: Preparing Your Data |
...