Python c3d to STO force and markers conversion

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
GEORGIY TOKUNOV
Posts: 6
Joined: Fri Feb 15, 2019 11:59 am

Python c3d to STO force and markers conversion

Post by GEORGIY TOKUNOV » Wed Jul 31, 2019 4:32 am

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?

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Python c3d to STO force and markers conversion

Post by Dimitar Stanev » Wed Jul 31, 2019 12:16 pm

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'])).

User avatar
GEORGIY TOKUNOV
Posts: 6
Joined: Fri Feb 15, 2019 11:59 am

Re: Python c3d to STO force and markers conversion

Post by GEORGIY TOKUNOV » Wed Jul 31, 2019 12:39 pm

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

POST REPLY