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.1.tar.gz (130.1 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.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pupyc3d-0.1.1.tar.gz
  • Upload date:
  • Size: 130.1 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.1.tar.gz
Algorithm Hash digest
SHA256 ae7f57c81e976d7270cc41d8456af423e3e69fca5d8044453ba63f372b80d60d
MD5 8cb6d55e1f94a71438c407e6abd83fa0
BLAKE2b-256 56179ca0b49daf52c541e5bd63a8b72c7f1b6e685de05f883c11cc8d131e5ec5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pupyc3d-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1b591d4b65dd77da37595584e19cae03586acf3115a6acae415aa8a4c33a97c
MD5 2ff69a60e31b1cd3d75911460495ed3a
BLAKE2b-256 8401ca96fc51ab9e21aec8ce7db12c83f38e7b3bb2ca769445ef98cf2711a32d

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