STOFileAdapter

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Caitlin Edgar
Posts: 12
Joined: Thu Mar 17, 2022 2:23 am

STOFileAdapter

Post by Caitlin Edgar » Wed Apr 20, 2022 9:25 am

Hi there,

I am currently trying to convert a matlab gait data set from structures into trc and mot files ready to use in opensim.
I have successfully managed to do this with the trc files using TRCFileAdapter however using the same code with STOFileAdapter I am unable to create the mot files as shown in the code and error message below.

I would be extremely grateful for some help on this.

Thanks,
Caitlin



Unsuccessful code

%% Load OpenSim libs
import org.opensim.modeling.*


%Creating opensimtable

opensimTable = osimTableFromStruct(forceStruct_2);


% Define output file name/path
filepath = 'subject_25__walking_4.mot';

% Write the TimeSeriesTableVec3 to file
STOFileAdapter().write(opensimTable, filepath)


error message
Check for incorrect argument data type or missing argument in call to function 'write'.

Error in writing_data_to_mot_from_struct (line 14)
STOFileAdapter().write(opensimTable, filepath)




Successful code
%% Load OpenSim libs
import org.opensim.modeling.*


%Creating opensimtable

opensimTable = osimTableFromStruct(markerStruct_2);

% Add Meta data to the table.
opensimTable.addTableMetaDataString('DataRate','60');
opensimTable.addTableMetaDataString('Units','m');

% Define output file name/path
filepath = 'subject_25__walking_4.trc';

% Write the TimeSeriesTableVec3 to file
TRCFileAdapter().write(opensimTable,filepath)

Tags:

User avatar
Ayman Habib
Posts: 2244
Joined: Fri Apr 01, 2005 12:24 pm

Re: STOFileAdapter

Post by Ayman Habib » Wed Apr 20, 2022 12:01 pm

Hello,

Please use STOFileAdapterVec3 if writing TimeSeriesData of type Vec3, and let us know how it goes.

Best regards,
-Ayman

User avatar
Caitlin Edgar
Posts: 12
Joined: Thu Mar 17, 2022 2:23 am

Re: STOFileAdapter

Post by Caitlin Edgar » Thu Apr 21, 2022 1:16 am

Thank you Ayman, that has worked!

POST REPLY