Page 1 of 1

STOFileAdapter

Posted: Wed Apr 20, 2022 9:25 am
by caitlinedgar
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)

Re: STOFileAdapter

Posted: Wed Apr 20, 2022 12:01 pm
by aymanh
Hello,

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

Best regards,
-Ayman

Re: STOFileAdapter

Posted: Thu Apr 21, 2022 1:16 am
by caitlinedgar
Thank you Ayman, that has worked!