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

Python - No data in output file #300

Closed michael-lbm closed 8 months ago

michael-lbm commented 10 months ago

Hello,

I'm not sure if this is the right place to ask, but I have encountered a problem while trying to use ezc3d with python. I am trying to adapt the position of the corners of the force plates in my .c3d-File.

This is my code:

import os
import numpy as np
import ezc3d

PathC3D = 'R:/Data'
PathOutput = 'R:/NewFiles'

FileName = '417351_laq_k.c3d'

File =  ezc3d.c3d(os.path.join(PathC3D, FileName))

Position = File['parameters']['FORCE_PLATFORM']['CORNERS']['value']

PositionNew = np.flip(Position, axis=2)

File['parameters']['FORCE_PLATFORM']['CORNERS']['value'] = PositionNew

File.write(os.path.join(PathOutput, FileName))

The code runs without error however the file in R:/NewFiles seems is only 2KB large compared to the 1200 KB of the original file. Also when I open the file with Mokka I can see the force plates but there seems to be no data in the file.

Furthermore if I run the following code and just load and then save the file again it is also empty?

import os
import numpy as np
import ezc3d

PathC3D = 'R:/Data'
PathOutput = 'R:/NewFiles'

FileName = '417351_laq_k.c3d'

File =  ezc3d.c3d(os.path.join(PathC3D, FileName))

File.write(os.path.join(PathOutput, FileName))

I would greatly appreciate any help on the matter :)

Many thanks in advance!

Attached here are the original file and the copy: File.zip

pariterre commented 10 months ago

Dear @michael-lbm

When looking at your original file, it seems corrupted, i.e. the problem does not occur when writing is used, but when reading the original file. Indeed, File['header']['points']['last_frame'] returns 18446744073709551615 (which is -1 interpreted as unsigned int). This means that for some reason, the data header of your original file tells ezc3d that there is no data in your file.

I suspect the c3d was created without points and instead of properly declaring the header, the manufacturor did not declare the number of frames. This means ezc3d skips entirely the analog reading part as well.

Do you know the company this c3d is from? I can make a fix, but I would need to specify the manufacturor in the source code for reference

michael-lbm commented 10 months ago

Hi @pariterre

thanks for the quick reply.

The file was created from the recordings of two type 3 force plates from kistler (model 9260AA6). The file was exported from the BioWare software from Kistler. Since for this recording only the force plates were used without any motion capture system I guess you are right and the c3d was created without any points.

If you need any further information on the file or recording setup please feel free to ask.

michael-lbm commented 10 months ago

Hi,

I just wanted to ask it there any updates regarding this issue?

pariterre commented 10 months ago

Hi @michael-lbm! Sorry I haven't had the time to work on this lately. I'll try to have a look this weeken! Thanks for the reminder!

pariterre commented 9 months ago

Fixed in #302 :)

I am pushing a new release on conda soon :)

pariterre commented 9 months ago

@michael-lbm Done, version 1.5.6 should do the trick :)

michael-lbm commented 9 months ago

Hi @pariterre ,

thank you for the new version, I really appreciate your effort.

I'm sorry to bother you again, but unfortunately I still can't seem to get it to work.

Now when I run the same code with my file I get an error:

Number of frames in the data set must match the analog rate X point frame

Unfortunately I don't understand the .c3d format quite well so don't really know what might be the problem here.

pariterre commented 9 months ago

@michael-lbm Hello there! Sorry again for the time since my last response... I've had the time to look at this error. It should now be fixed thanks to #304 I'll push the 1.5.7 version during the day!

michael-lbm commented 8 months ago

Hi @pariterre,

I just tried it with version 1.5.7 and now it works :)

Thanks again for your time and effort!