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.2.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.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pupyc3d-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 ac51a20a1567b1b67a4b120f0b70f86dba8cd260c8a3d4f9692f8aa111b242ca
MD5 de9619f6692245da0167e36365b47eef
BLAKE2b-256 658f6882a980bf326f082e84451af369f7b0c50a46a391614857e1000ce3242c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pupyc3d-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a0a3e882fc35fca16cc2160dab2a00a367c050fb918b9584c6a57f2d8a9f0272
MD5 d5fcc1e4db2008f13548007694e243b0
BLAKE2b-256 eeba055b69f8a507f03be2ca852aed7724882c4d2594bd4772725caeff93e13b

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