Skip to main content

Interface to easily deal with a C3D file, including some helpful methods for dealing with gait analysis (e.g. detecting heel strike)

Project description

PyC3DSample

Interface to easily deal with a C3D file, including some helpful methods for dealing with gait analysis (e.g. detecting heel strike)

Installation

pip install pyc3dsample

Basic usage

Initialize PyC3DSample object and get general information about C3D file by just printing the object

from pyc3dsample import PyC3DSample

Test = PyC3DSample(<path_to_c3dfile>)
print(Test)
ID          : <path_to_c3dfile>
FrameRate   : 100.0
TimeStep    : 0.01
FirstFrame  : 0
LastFrame   : 203
TotalFrames : 204

To get the progression of the left hip angles with respect to the X-axis.

Test.get_TimeProgress("LHipAngles_X")

To get events (e.g. left or right foot strike, or a general event added by the user)

# Get events -> List of (<label>, <time [s]>)
print(Test.Events)
[('Event', 0.99)]

Get progression of the left knee angles with respect to the X-axis from 100 ms before an event, until the event itself.

EventEvent = round(
    [e for e in Test.Events if e[0] == 'Event'][0][1], 2
)
print(
    Test.get_TimeProgressRange("LKneeAngles_X", EventEvent-0.1, EventEvent)
)
[[ 0.89       38.35063553]
 [ 0.9        34.10266495]
 [ 0.91       29.63624573]
 [ 0.92       25.12419128]
 [ 0.93       20.75816917]
 [ 0.94       16.72034645]
 [ 0.95       13.15703011]
 [ 0.96       10.16346359]
 [ 0.97        7.78041172]
 [ 0.98        5.99653673]
 [ 0.99        4.75045919]]

Get and plot position and velocity of the RHEE marker along the global z-axis.

RHEE_Z  = Test.get_TimeProgress("RHEE_Z")
RHEE_Zd = Test.get_TimeProgress1D("RHEE_Z")

# Plot
fig, axs = plt.subplots(2, 1, sharex=True)

# Position
axs[0].plot(RHEE_Z[:,0], RHEE_Z[:,1])
axs[0].set_ylabel("Position [mm]")
axs[0].set_title("RHEE Marker Position (z)", loc="left", fontsize="large")
# Velocity
axs[1].plot(RHEE_Zd[:,0], RHEE_Zd[:,1])
axs[1].set_ylabel("Velocity [mm/s]")
axs[1].set_xlabel("Time [s]")
axs[1].set_title("RHEE Marker Velocity (z)", loc="left", fontsize="large")
axs[0].grid()
axs[1].grid()
fig.tight_layout()
plt.show()

Example of RHEE Marker Trajectory

To identify heel strikes.

rHeelStrike_Time = Test.get_HeelStrike('R')
print(f"Right heel strike at : {rHeelStrike_Time}")

lHeelStrike_Time = Test.get_HeelStrike('L')
print(f"Left heel strike at  : {lHeelStrike_Time}")
Right heel strike at : 0.53
Left heel strike at  : 1.11

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

pyc3dsample-0.0.4.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

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

pyc3dsample-0.0.4-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pyc3dsample-0.0.4.tar.gz.

File metadata

  • Download URL: pyc3dsample-0.0.4.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyc3dsample-0.0.4.tar.gz
Algorithm Hash digest
SHA256 40f67daa40db7bd1aa4fa96b019fbce4a245738276e09c065e62dfb662643f61
MD5 002f4148c9722e03916061e1239eda75
BLAKE2b-256 3de934355e1fe149a82ad4f18964c2b946a4be86c28d5d4aa9eac68855a5dc85

See more details on using hashes here.

File details

Details for the file pyc3dsample-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pyc3dsample-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyc3dsample-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 90588faeb8bf30120a5fa9dfc4827eb2aea688cda1dde82f189254528a15d954
MD5 b805da1965e9799b5a9352401ac88889
BLAKE2b-256 4f4bbe7c1c3f9f58da939c3e3dbd0a800b1dea215ea12f8cd903c7a6b3b15f6d

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