Hi,
thanks for your fast respsonse to my mail. Here is the full conversation for other people that might have a similar problem:
My original question:
Hi pariterre,
I am trying to use the ezc3d package in Python (version 1.6.0) to merge two c3d files containing marker data and force plate data from the same trial. Unfortunately I am having some troubles/questions and thought maybe you could help me out.
Is there a way to access the raw analog data from a file? Using file['header']['analogs'] returns an array that appears to be downsampled to the point frame_rate.
When I artificially increase the number of samples in the analog data to fit the frame rate of the analog data collection there are no forces in the resulting file? Is this because the data is not real or do I need to define some more parameters even when using the raw analog data?
Please find attached my files and the code I am using.
Thank you!
Best regards
And your answer:
Thanks for reaching out. If possible, I would appreciate if you could copy-paste our conversation to "https://github.com/pyomeca/ezc3d/issues" so everyone else can benefit from what we discuss :)
In the meantime, I am answering here your questions so far:
- Is there a way to access the raw analog data from a file? Using file['header']['analogs'] returns an array that appears to be downsampled to the point frame_rate.
I assume you meant file['data']['analogs']? If so, that is correct. These are the actual unmodified data. However, the provided sampling ratio between points and analogs must be sound, that is, ANALOG:RATE / POINT:RATE must be an integer. Otherwise, the data won't be stored properly. Apart from that, file['data']['analogs'] is the raw data.
- When I artificially increase the number of samples in the analog data to fit the frame rate of the analog data collection there are no forces in the resulting file? Is this because the data is not real or do I need to define some more parameters even when using the raw analog data?
The "force" data are not stored in a C3D file, only analogs. Analyses must be applied to get the force data. Depending on if the analog data are of type TYPE-2, TYPE-4, TYPE-7 and TYPE-20 (I may be misremembering the accepted format), analogs must be stored accordingly. Changing the "force" field of the data will not change anything as they are computed values. If you want to merge data, you must append them to the file['data']['analogs'] field (meaning you must provide the corrected formatting which may or may not be possible).
Additional note : "header" field is NEVER read by ezc3d, it is always generated. If you want to modify something, you MUST do it in the PARAMETER field. That is because all information in "header" are redundant with either the parameters or the data themselves. So changing frame_rate in heading will be discarded to match the one in parameter when writing the new C3D file
So specifically for you case, you can drop anything related to header. I also had a quick look at your data and your POINT:RATE is 60.00239944 which is not ideal to create a nice and neat ratio, and you ANALOG:RATE (in the other file) is 1200. So we expect 20X more data in the second file, but we get:
file_forceplate.data.analogs.shape => (1, 16, 1922)
file_marker.data.points.shape => (4, 84, 2104)
which obvious does not make sense (for 2104 frames of points, there should be 42080 frames of analogs). So combining these file don't really make sense anyway...
Hope this helps! Again, please copy-paste this conversation in a Github issue
Have a nice day
Thanks again, this already helps me a lot. But I still have some follow up questions:
Some additional information regarding the number of frames in the files. Yes they dont match because the recordings are not synchronized but I know the offset between the files and the relevant part of the recordings so I can just crop my data accordingly and then combine the relevant parts.
Regarding the first point, yes I meant file['data']['analogs']. I dont quite understand the thing about the frame rate though. If I open FileForcePlate.c3d in Mokka it shows 1922 frames. If I export FileForcePlate.c3d to a csv file using Mokka, the csv file contains 38440 (1922 * 20) analog samples, which makes sense since the analog data was sampled at 1200 Hz, 20 times the marker data at 60 Hz. So I am assuming Mokka only shows data for each point frame and not for each analog frame? Regardless the data is in the file otherwise I couldnt see it in the csv export right?
When I use the data from the csv export and create a new c3d file that contains this data in file['data']['analogs'] and use the marker data from FileMarker.c3d in file['data']['points'] and declare the parameters from FileForcePlate.c3d in file['parameters']['FORCE_PLATFORM'] and file['parameters']['ANALOG'] and the parameters from FileMarker.c3d in file['parameters']['POINT'] I actuall get the wanted result. The new file contains the marker trajectories, the analog data and computed force data. And the analog data is sampled at 1200 Hz (even though I only see that in the csv export, in Mokka directly it again only shows data at 60 Hz).
The problem here is that I have several trials and would need to manually export the c3d files to csv files for each trial. So using a script to access the analog data from FileForcePlate.c3d would of course be nicer, but I am still facing the issue that I only get 1922 frames of analog data and not the full 38440 frames using file_forceplate['data']['analogs']. Am I still missing something obvious here?
c3d and csv files:
MergeC3D.zip
Hi,
thanks for your fast respsonse to my mail. Here is the full conversation for other people that might have a similar problem:
My original question:
And your answer:
Thanks again, this already helps me a lot. But I still have some follow up questions:
Some additional information regarding the number of frames in the files. Yes they dont match because the recordings are not synchronized but I know the offset between the files and the relevant part of the recordings so I can just crop my data accordingly and then combine the relevant parts.
Regarding the first point, yes I meant
file['data']['analogs']. I dont quite understand the thing about the frame rate though. If I open FileForcePlate.c3d in Mokka it shows 1922 frames. If I export FileForcePlate.c3d to a csv file using Mokka, the csv file contains 38440 (1922 * 20) analog samples, which makes sense since the analog data was sampled at 1200 Hz, 20 times the marker data at 60 Hz. So I am assuming Mokka only shows data for each point frame and not for each analog frame? Regardless the data is in the file otherwise I couldnt see it in the csv export right?When I use the data from the csv export and create a new c3d file that contains this data in
file['data']['analogs']and use the marker data from FileMarker.c3d infile['data']['points']and declare the parameters from FileForcePlate.c3d infile['parameters']['FORCE_PLATFORM']andfile['parameters']['ANALOG']and the parameters from FileMarker.c3d infile['parameters']['POINT']I actuall get the wanted result. The new file contains the marker trajectories, the analog data and computed force data. And the analog data is sampled at 1200 Hz (even though I only see that in the csv export, in Mokka directly it again only shows data at 60 Hz).The problem here is that I have several trials and would need to manually export the c3d files to csv files for each trial. So using a script to access the analog data from FileForcePlate.c3d would of course be nicer, but I am still facing the issue that I only get 1922 frames of analog data and not the full 38440 frames using
file_forceplate['data']['analogs']. Am I still missing something obvious here?c3d and csv files:
MergeC3D.zip