View Full Version : Matlab code, Input: .c3d file, Ouput: ankle, knee, hip joint angles and moments??

08-24-2011, 11:05 AM
Hi all,

Does anyone either have or know of available Matlab code that reads in .c3d files and outputs ankle, knee, and hip joint angles and moments?


Pete Shull
Stanford University
PhD Candidate, Mechanical Engineering

08-25-2011, 09:25 AM
If you are working in the Microsoft Windows environment then you can use the C3Dserver (http://www.c3dserver.com) - this is a small DLL that provides high-level support to read and write the data within C3D files for almost any application running in the Microsoft environment.

The C3Dserver (http://www.c3dserver.com) includes a manual documenting all of the functions with examples, as well as several applications that use the C3Dserver, including a basic C3D file editing utility written in Visual Basic using the C3Dserver (http://www.c3dserver.com) DLL. The sample applications include their source code so that you can see exactly how to use the application - the installation includes both MATLAB and LABview examples. Manuals for the C3Dserver (http://www.c3dserver.com) and the C3D format description (http://www.c3d.org) are also on-line.

The C3Dserver (http://www.c3dserver.com) application, together with documentation and sample code can be downloaded free of charge from the http:///www.c3dserver.com web site. This free version runs slower than the licensed version (we sell a site license to use the full speed C3Dserver on any number of PC's at one location for $495) but otherwise the free version functions exactly the same as the full speed licensed version - code written for the free version simply runs faster on the licensed version.

08-26-2011, 02:11 AM
Hi Pete

The BTK-Toolbox is a very nice tool for reading c3d-Files fast. You can download the whole software for free:


Enjoy it.

08-26-2011, 07:45 AM
Hi Pete,
Just to complete Cora
The BTK-Toolbox is an open-source and cross-platform library (Mac, Linux, Windows) for reading and editing c3d files.
For matlab wrapping, you can download a binary or compiled version on : http://code.google.com/p/b-tk/downloads/list (http://code.google.com/p/b-tk/downloads/list)
A full documentation is available on http://b-tk.googlecode.com/svn/doc/Matlab/0.1/index.html (http://b-tk.googlecode.com/svn/doc/Matlab/0.1/index.html).

Kind regards

Stéphane ARMAND
Willy Taillard Laboratory of Kinesiology
University Hospitals of Geneva

08-29-2011, 01:54 PM
Hi Pete,

There is a project on simtk.org started by Tim Dorn to extract data from C3D files in MATLAB. You may be able to modify some of the scripts for your purposes: https://simtk.org/home/c3dtoolbox

Samuel Hamner
Neuromuscular Biomechanics Lab
Stanford University

09-01-2011, 12:13 PM
Thanks everyone for the helpful suggestions!

Pete Shull
Stanford University
PhD Candidate, Mechanical Engineering

02-25-2013, 10:33 AM
I am reading this thread and i would like to ask, if with these options, matlab, labview and/or c3dserver are possible to get this kind of data, (ankle, knee, hip joint angles in the X,Y and Z plane, and moments) , even if the c3d file doesn´t got it, i mean if the c3d file only have the trace data. Is it possible to process the c3d file to generate the data.
Thank you in advance.

02-26-2013, 07:49 AM
The C3D file is initially created by the motion capture system to store the trajectory and analog information (forces EMG etc) that is collected. A C3D file will always have the raw data but does not necessarily have the processed data - the angles, moments etc.

The structure of the C3D file allows a post-data-collection application to calculate these additional values and write the results back to the C3D file while leaving the original data unchanged. These calculations can be performed with many different applications and since the data is stored in the C3D format you are not limited to any specific application - you can write your own application to calculate the results and verify the calculations performed by other applications.

02-28-2013, 09:59 PM
Thanks Edmund for your answer here and in the private message, your info has been very helpful and when you say.
"These calculations can be performed with many different applications"
What other applications do you mean ?
And about the c3dserver, is there any tutorial of how to process for example the angles of the gait cycle from a raw data c3d file with c3dserver, where do i start, Visual Studio; standalone c3dserver application ? I dont really know how to start.

Thank you again and i hope my questions can help others too.

03-01-2013, 09:58 AM
Hi Pete,

I developed Matlab code to process Optotrak output files for motion analysis. This was back at Western University(Canada) about 7 years ago, but they may still have it in use. Let me know if you'd like details to contact and follow up.

Tim Bhatnagar
PhD Candidate
Mechanical Engineering
University of British Columbia

03-01-2013, 11:08 AM
The C3Dserver (http://www.c3dserver.com) is mostly concerned with giving you access to the data in the C3D file - it doesn't assume that the point and analog data has any particular model or subject. It could be data from someone walking but it could just as easily be from a small robot wandering around (http://www.technologyreview.com/view/511881/toothbrushes-bristlebots-and-the-nature-of-intelligence/) - you can process this data using Excel, MATLAB, LabVIEW, C++, Pascal or whatever language you chose to use to perform calculations on the data.

So you start with a C3D file that contains your data, you then chose a language that you are comfortable using to write for processing algorithms (Visual Studio is fine) and then you write your program. You use the C3Dserver from within your programming language just to read the data from the C3D file, you perform your calculations and you generate the results - these can be written back to the C3D file using the C3Dserver, or you can send them to a printer or write them to another file.

If you are looking for details of how to calculate joint angles, moments etc - these will depend on the marker model that you use and you probably need to start a new thread on the forum to get the best answers on performing gait modeling. These sorts of calculations have a long history going back to The Boston Software, the Helen Hayes Model and software from the Cleveland Clinic - there's a package written by Dwight Meglan at The Ohio University for the Analysis and Display of Human Motion (http://www.c3d.org/appanz.html) that is available with documentation and complete source code (MS-DOS) and can be downloaded from the C3D web site.

I'm sure that there are other, more recent, packages available if you ask around.