pyomeca / ezc3d

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

Problem with COP calculations #194

Closed mrrezaie closed 3 years ago

mrrezaie commented 3 years ago

Hi Pariterre,

Sorry for opening another issue. There is a problem with COP calculations for this c3d file. The results are around zero. I used the following scripts for plotting the COP of the 1st force plate:

c = c3d('gait.c3d', extract_forceplat_data=True) cop = c["data"]["platform"][0]['center_of_pressure']

image image image

But in MOKKA, I have these data: image

I attached the file. Would you please take a look? Gait.zip

Thank you in advance.

pariterre commented 3 years ago

Hi @mrrezaie !

First you have to make sure you remove data where forces are too small (i.e., no forces on force platform). because it does not make sense to compute center of pressure where there is no pressure (this is why you get such values). Your BTK graphs ranges from 5.0 to 6.0 second, while the ezc3d one ranges from 0 to the end of the trial. You can set a threshold on force norm. For instance:

import numpy as np
[...]
idx = np.linalg.norm(forces, axis=0) > 50

With that you get values within a normal range.

Still they are not strictly equal, it is because BTK are not using the same way to compute the geometrical center for the force plate. BTK is using the mean from the corners 0 and 2, while I use the mean of all 4 corners

mrrezaie commented 3 years ago

Thanks @pariterre for the response.

You are right. I cropped the MOKKA data just for better observation. But at the time of each foot contact on each force plate, the COP data is absolute zero. I created a MOT file for OpenSim and the COPs stop over the lab origin. There was no such problem with other c3d files.

Anyway, It might not be an important issue. I was testing my script for c3d to OpenSim files conversion over several c3d files and I though you might be interested in this file.

Have a great time.

Regards, Mohammadreza

pariterre commented 3 years ago

That is weird.. Using the file you provided me, I get the same values (when cropped using the snippet I gave you), I get the same results as the figure you provided..

pariterre commented 3 years ago

@mrrezaie Should I close this issue?

mrrezaie commented 3 years ago

Thanks for your time.