Getting Started

Below we will cover some basic exploration of c3d files using EZC3D in Python. We focus on Python implementation (specifically interactive Python via Jupyter Notebook) because Python and Anaconda are free and well-maintained. A good starting point for setting up and getting familiar with Anaconda and Jupyter Notebooks can be found here.

For additional examples, as well as tutorials for the MATLAB and C++ inclined among us, visit the EZC3D GitHub.

Once you have your Python environment set up, make sure you install the ezc3d package using anaconda prompt:

conda install -c conda-forge ezc3d

EZC3D C3D Object

A c3d file is read into python using the ezc3d command ezc3d.c3d(). The resulting object is an ezc3d c3d class. Luckily, this class functions a lot like a Python dictionary (i.e. it has keys and values) which allows us to examine its structure in greater detail.

Exploring the C3D Object Structure

Let’s assign our c3d object to a variable c:

# import package
import ezc3d

# read in c3d file and assign to variable c
c = ezc3d.c3d(<'path to your c3d file'>)

Our variable c is now a c3d object with keys and values. We can examine its first level of structure using the command c.keys():

c = ezc3d.c3d(<'path to your c3d file'>)

c.keys()
# dict_keys(['header', 'parameters', 'data'])

The first level of structure for our c3d object contains three substructures: header, parameters, and data. We can access one level deeper within our c3d object by reusing the keys() command on one of our three substructures:

c = ezc3d.c3d(<'path to your c3d file'>)

c.keys()
# dict_keys(['header', 'parameters', 'data'])

c['header'].keys()
# dict_keys(['points', 'analogs', 'events'])

We can access deeper and deeper levels of nesting by adding dictionary keys together:

c = ezc3d.c3d(<'path to your c3d file'>)

c.keys()
# dict_keys(['header', 'parameters', 'data'])

c['header'].keys()
# dict_keys(['points', 'analogs', 'events'])

c['header']['points'].keys()
# dict_keys(['size', 'frame_rate', 'first_frame', 'last_frame'])