Skip to main content

Pure Python C3D reader and writer for biomechanics and motion capture data

Project description

pupyC3D

PyPI version Python

A pure Python library for reading and writing C3D files, commonly used in biomechanics and motion capture applications.

Features

  • Pure Python: No external dependencies except NumPy
  • Cross-platform: Works on Windows, macOS, and Linux
  • Full C3D support: Read and write C3D files with complete parameter and data access
  • Multiple processor formats: Supports Intel, DEC, and MIPS processor formats
  • Easy to use: Simple API for accessing 3D coordinates, parameters, and metadata

Installation

From PyPI (recommended)

pip install pupyC3D

From source

# Clone the repository
git clone https://github.com/Norton-breman/pupyC3D.git
cd pupyC3D

# Install in development mode
pip install -e .

Quick Start

Reading a C3D file

from pupyC3D import C3DFile

# Load a C3D file
c3d = C3DFile('example.c3d')

# Access header information
print(f"Number of 3D points: {c3d.point_count}")
print(f"Number of frames: {c3d.frame_count}")

# Access parameter groups
point_group = c3d.get_parameter_group('POINT')
if point_group:
    labels_param = point_group.get_parameter('LABELS')
    if labels_param:
        print(f"Point labels: {labels_param.value}")

# Access points data
points_list = c3d.get_point_names()
point_data = c3d.get_point_data(points_list[0])
# getting multiple points data
points_data = c3d.get_points_data(points_list)
# Access analog data
if c3d.analog_count > 0:
    analog_list = c3d.get_analog_names()
    analog_data = c3d.get_analog_data(analog_list[0])

Writing a C3D file

from pupyC3D import C3DFile
import numpy as np

# Create a new C3D file
c3d = C3DFile()

# Add parameter groups and parameters
point_group = c3d.add_parameter_group('POINT')
if point_group:
    labels_param = point_group.add_parameter('LABELS')
    labels_param.value = np.array(['MARKER1', 'MARKER2', 'MARKER3'])
    labels_param.data_type = -1  # String type

# Save the file
c3d.write('output.c3d', overwrite=True)

C3D File Format

C3D files contain:

  • Header: Basic file information (number of points, frames, etc.)
  • Parameters: Organized in groups (POINT, ANALOG, TRIAL, etc.)
  • Data: 3D coordinates and analog data

API Reference

Main Classes

  • C3DFile: Main class for reading/writing C3D files
  • ParameterGroup: Container for related parameters
  • Parameter: Individual parameter with typed data
  • ProcStream: Low-level binary data processor

Key Methods

  • C3DFile.read_file(): Load C3D file from disk
  • C3DFile.write(): Save C3D file to disk
  • C3DFile.get_parameter_group(): Access parameter groups by name or ID
  • C3DFile.add_parameter_group(): Create new parameter groups

Requirements

  • Python 3.6+
  • NumPy

License

This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. See the LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

Antoine MARIN (antoine.marin@univ-rennes2.fr)

Changelog

v0.1.0

  • Initial release
  • Basic C3D reading and writing functionality
  • Support for Intel, DEC, and MIPS processor formats
  • Complete parameter and data access

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pupyc3d-0.1.3.tar.gz (127.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pupyc3d-0.1.3-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file pupyc3d-0.1.3.tar.gz.

File metadata

  • Download URL: pupyc3d-0.1.3.tar.gz
  • Upload date:
  • Size: 127.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for pupyc3d-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8fcafc87659cc4ee669f4d9f7775aec471ad8cdb272bb332bb68a7d312fe08ea
MD5 2c797a748208746b102469f1c57fd743
BLAKE2b-256 1402da265041314c37469b525046477ca3dfb16614e45c14626d310c84a687b5

See more details on using hashes here.

File details

Details for the file pupyc3d-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pupyc3d-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for pupyc3d-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4cb6ede2291226cb3911fc4039fd2d9ff39d4c0e7ec2e9a3b1bd09bb9d03b135
MD5 0b64498b66de7d4c2132fde624b65528
BLAKE2b-256 13f83b9eb04d3a5a4bd3553db47d3332f05b776717b905439d5eed4aeedef9c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page