An overview of the C3D File Design
C3D (Coordinate 3D) files are a subset of a more general (ADTech) file format designed by Andrew Dainis to hold data and their associated parameters within a single file. C3D files contrast with other formats typically used in biomechanical applications which have separate files for data and parameters, or where all parameters are included at the beginning of the file.
Design Goals
The ADTech file format was designed to provide a general and uniform file format for storing a variety of data and their parameters in an efficient manner. A primary goal was to provide the user with the ability to understand, examine, and if necessary modify the parameters.
The goals for the file format were as follows:
- Minimize storage requirements
- Minimize the number of files required to store data and its associated parameters
- Optimize for speed and efficiency of access
- Provide a facility for incorporating parameter descriptions
- Provide the facility for the casual user to display and modify all parameters
- Provide flexibility to store different kinds of data and their associated parameters
- There must be no limitations on the data length, or the type and number of parameters that can be stored
- The file must be easily expandable to store additional parameters and data
- The format must provide a means to retain full backwards compatibility, i.e., subsets of the file must work correctly even with the oldest programs
Binary vs. ASCII
Both types of files have advantages and disadvantages. ASCII files can readily include descriptions associated with parameters, and are readily manipulated by the use of common text editors. However they are very inefficient for storage and access, and very large files may present problems to some editors. Also, ASCII files must generally be accessed sequentially and are very inefficient if the files must be read non-sequentially.
Binary files are efficient in data storage and access and may also contain parameters and associated descriptions, but not in a form casually accessible to the user. Also, the file organization is specific to the type of data stored, i.e., the data and any parameters may only be accessed by specifically written programs which have a detailed knowledge of the file structure.
The ADTECH file format
To best meet all of the above requirements it was decided that the format should incorporate the following:
- The files will be binary format.
- Each file will have a "primary" parameter section where parameter information is stored according to a specified format.
- Data and their parameters will be in the same file, with a specified scheme to tell programs where the "primary" parameter section is located.
- Parameters may have the standard numerical types of byte, integer, float, and character.
- Parameters may have "dimensions" to also allow the definition of vector and matrix quantities.
- Parameters may have associated names and descriptions, and will be classified into groups for ease of use and access by the user.
- The way the data are stored and their location(s) within the file may be flexibly specified through the parameters.
Hence the basic ADTech file format, of which the C3D format is an example, has the following specifications:
- The first byte of the file contains the number of the 1st parameter record in the file (all records are considered to be 512 bytes long).
- The 2nd byte is a key byte and must contain decimal 80.
- The first 2 bytes of the first parameter record are the first two bytes of the file or are not used.
- Byte 3 of the 1st parameter record contains the number of parameter records.
- Byte 4 of the 1st parameter record codes the processor data type, i.e., 84 for PC (Intel), 85 for DEC, and 86 for Sun/MIPS systems.
- The parameters are stored starting at byte 5 of the first parameter record according to the parameter format specification described in the documentation. The parameters are stored in random order providing for much flexibility at the expense of some programming complexity.
- Each parameter has a data type, optional dimensions, a name, a description, and belongs to a group. Each group also has a name and a description
C3D files
In a C3D file the first record is used as a header record, the parameters typically start at record 2 (although that is not required), and the data section contains 3D point and analog channel data in a specified format.
With the exception of the first 4 bytes, the header record contains information largely duplicated in the parameter section. Its purpose is to provide simple access to certain parameters describing the data when it was not desired to do the more complex programming to read the full parameter section. It was recognized that the duplication of parameters may present some hazards to the programmer and user.
Each point coordinate and analog data word is stored as a 16-bit integer or 32-bit float. The 4th coordinate word for each point contains the camera usage bits, and a measurement residual value. The data are stored sequentially by frames, and within a frame they are stored sequentially by point number, followed by the analog channel data.
Additional comments
The ADTech file format can be used for storing other kinds of data, its advantage being that the parameter section may be read and manipulated by any program such as PRM that knows the parameter format. In the AMASS system several other files using the ADTech format were implemented, mainly for storing parameters.
Since the introduction of C3D files in 1986, the format has proved to be very versatile and has become a standard for the storage and exchange of raw 3D and analog data. Its flexibility and expandability has allowed C3D files to "evolve" by accommodating additional parameters and types of data.
Other parameter sections may be added to a file, with parameters in the "primary" parameter section indicating where in the file the new parameter sections may be found. This is also true for additional data sections or blocks. Hence a C3D file may have additional data and parameter sections while still retaining full backward compatibility. The only real requirement of a basic C3D file is that it have an appropriate "primary" parameter section which indicates where the coordinate/analog data start, and the coordinate/analog data be in a contiguous block.
In order to ensure backward compatibility, the basic parameter names and groups defined for the original C3D specification should always be included in the "primary" parameter section, even if they are duplicated under some other name.
From a presentation given by Dr. Andrew Danis at the 5th Annual Gait and Clinical Movement Analysis Meeting held at the Helen Hayes Hospital, West Haverstraw, NY in 1989.