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', _method='yHeelSnap')
lHeelStrike_Time = Test.get_HeelStrike('L', _method='yHeelSnap')
print(f"Right heel strike at : {rHeelStrike_Time}")
print(f"Left heel strike at  : {lHeelStrike_Time}")
Right heel strike at : [0.6, 1.61]
Left heel strike at  : [0.1, 1.09]

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyc3dsample-0.0.5.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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.5.tar.gz
Algorithm Hash digest
SHA256 bfe5d3d7ece5b7ec1cf92190979f03dbfb131a36c0f6330c1adeb8aded1cfe4b
MD5 a52c1a27d75d77a6c94060c2e6176ebc
BLAKE2b-256 22e4a720225c1be38f7849726e757e40cd472cfc2415bfd596be01bbf87e481a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyc3dsample-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 94e161c5e0e6ef7662e96ad5e301691e9938bca2ce2ac2807344e17f6be8166d
MD5 0e83fcf86b089c0f45fa389a934d7936
BLAKE2b-256 02016386c6cfbc9855ce8b10c7c92863e2fae2d15230e9421d66bb904facbff5

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