Page 1 of 1

Python c3d to STO force and markers conversion

Posted: Wed Jul 31, 2019 4:32 am
by frstrtr
Hi!

I tried to force python script from here (https://simtk-confluence.stanford.edu:8 ... c3d)+Files) to work with no success.

Fixed some minor bugs (here - https://github.com/IISCI/c3d_2_sto), but stuck on markers.flatten() method of AbstractDataTable, it is not implemented in that class.

Any suggestions?

Re: Python c3d to STO force and markers conversion

Posted: Wed Jul 31, 2019 12:16 pm
by mitkof6
I haven't tried your script, but maybe you can get a copy of the immutable data structure (e.g., import copy, copy.copy(table['markers'])).

Re: Python c3d to STO force and markers conversion

Posted: Wed Jul 31, 2019 12:39 pm
by frstrtr
Thanks for the advice, but we found a solution.

It seems that in the original script from https://simtk-confluence.stanford.edu:8 ... d%29+Files) used the wrong method for file read - fileRead(), taken from the parent class FileAdapter, it should be replaced with read() method from C3DFileAdpter class as follows:

import opensim as osim

# WRONG:
# tables = C3DFileAdapter.readFile(os.path.join(test_dir, 'walking2.c3d'), 1)
# CORRECT:
tables = osim.C3DFileAdapter().read(os.path.join(test_dir, 'walking2.c3d'), 1)

Fixed all errors now, and c3d were successfully imported to two separate .sto files (forces and markers)

Resulting code in my repo:
https://github.com/IISCI/c3d_2_sto