-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ktk.write_c3d generates an error if file doesn't end by .c3d #233
Comments
Hi @felixchenier , Thanks for looking into this. As a matter of fact, I am on MacOs (Sonoma 14.2, with M1 chip). I looked into the ezc3d issue you referred to, but since I am on mac the UTF-8 encoding should not be a problem. Furhtermore, you can see I am saving a file called Some environment info:
For sake of completeness here: import numpy as np
import ezc3d
# Load an empty c3d structure
c3d = ezc3d.c3d()
# Adjust some mandatory values of the parameters and fill the data with random values
c3d["parameters"]["POINT"]["RATE"]["value"] = [100]
c3d["parameters"]["POINT"]["LABELS"]["value"] = ("point1", "point2", "point3", "point4", "point5")
c3d["data"]["points"] = np.random.rand(3, 5, 100)
c3d["parameters"]["ANALOG"]["RATE"]["value"] = [1000]
c3d["parameters"]["ANALOG"]["LABELS"]["value"] = ("analog1", "analog2", "analog3", "analog4", "analog5", "analog6")
c3d["data"]["analogs"] = np.random.rand(1, 6, 1000)
# Create a custom parameter to the POINT group
c3d.add_parameter("POINT", "NewParam", [1, 2, 3])
# Create a custom parameter a new group
c3d.add_parameter("NewGroup", "NewParam", ["MyParam1", "MyParam2"])
# Write a new modified C3D and read back the data
c3d.write("temporary.c3d") Similarly, the example of import kineticstoolkit.lab as ktk
import numpy as np
points = ktk.TimeSeries()
points.time = np.linspace(0, 10, 10*240, endpoint=False)
points.data["Marker1"] = np.ones((2400, 4))
points.data["Marker2"] = np.ones((2400, 4))
analogs = ktk.TimeSeries()
analogs.time = np.linspace(0, 10, 10*2400, endpoint=False)
analogs.data["Signal1"] = np.sin(analogs.time)
analogs.data["Signal2"] = np.cos(analogs.time)
rotations = ktk.TimeSeries()
rotations.time = np.linspace(0, 10, 10*480, endpoint=False)
rotations.data["Rotation1"] = np.ones((4800, 4, 4))
rotations.data["Rotation2"] = np.ones((4800, 4, 4))
ktk.write_c3d("testfile.c3d", rotations=rotations)
ktk.write_c3d("testfile.c3d", points=points)
ktk.write_c3d("testfile.c3d", analogs=analogs)
ktk.write_c3d("testfile.c3d", points=points, analogs=analogs, rotations=rotations) I am not really sure why it does not work since |
As an additional information, I am quite sure this is generated not when writing the C3D, but when we read it again to add the events, something that has been done as a workaround for pyomeca/ezc3d#263 This has not been reproduced by @pariterre and I forgot about it. I'll revisit it when I'll investigate this issue more deeply. |
Hi @Alek050 OK I think I got it :-) In your original bug description:
You didn't put ".c3d" in the file name. If you do, it's ok. Let's simply add
just after the first check_param calls. |
Works as a charm, sorry for the inconvenience, will add it in the pull request as well. |
Done in branch PR232 |
Initially discussed in #229
Describe the bug
generates a correct file, but with this error message.
Python version
3.12
Waiting for @Alek050 to know this information:
Python installation
Select: python.org, Anaconda, conda-forge, etc.
Operating system
The text was updated successfully, but these errors were encountered: