pyomeca / ezc3d

Easy to use C3D reader/writer for C++, Python and Matlab
https://pyomeca.github.io/Documentation/ezc3d/index.html
MIT License
145 stars 46 forks source link

Convert csv / pickle to c3d #275

Closed mfalv closed 1 year ago

mfalv commented 1 year ago

Is there a way to convert a csv / pickle file to c3d?

pariterre commented 1 year ago

Hi @mfalv

There is no automated way to do that, however, creating a brand new c3d and pushing data to it actually not complicated.

If you have a look in the readme section Python (if you are in Python) or Matlab (if you are in Matlab) you can see how creating and adding data to a c3d https://github.com/pyomeca/ezc3d#python-3 The relevant part is:

import ezc3d

c3d = ezc3d.c3d()

c3d['parameters']['POINT']['RATE']['value'] = [100]
c3d['parameters']['POINT']['LABELS']['value'] = ('point1', 'point2', 'point3', 'point4', 'point5')
c3d['data']['points'] = np.random.rand(4, 5, 100)

c3d.write("path_to_c3d.c3d")

Since POINT:RATE and POINT:LABELS must be supplied along with the actual data in order to produce a valid C3D.

I hope this helps!

mfalv commented 1 year ago

It does help! Thanks @pariterre .