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.3.tar.gz (1.3 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.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyc3dsample-0.0.3.tar.gz
  • Upload date:
  • Size: 1.3 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.3.tar.gz
Algorithm Hash digest
SHA256 aa5e2b94251143be513b1decbb54c222a275717f4e9025cad457bedcb8f45d44
MD5 f31b685b80ffa37668ffeab8f9320ece
BLAKE2b-256 581b3f112a109e1b2ead076ec4a0e1513383c6443cc2e8c63d170d15d7f55448

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyc3dsample-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b45ae94ee93ebed6e3a7ab1e7441ce92c39313c8b4f855f1b9920a5ecd8f4cba
MD5 7fb8064fa707a7ea864c0c2e9544da6e
BLAKE2b-256 eb49fff56f3cf5ba73dd762c17782ffaf35acfb9850dd877b4b97e8f4373251d

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