Page 1 of 1

Scaling tool: GUI vs MATLAB API

Posted: Fri May 06, 2022 9:10 am
by jasperverheul
Hi all,

I run into an issue scaling a model. After setting up the ScaleTool in the GUI and saving it as an .xml, I want to run this same scaling setup via the MATLAB API, using a different static trial for each participant. However, the scaling results are different from the GUI (and inappropriate). Does anyone know why the same scaling setup can give a different result when ran in the GUI vs MATLAB?

The MATLAB code I use is.

Code: Select all

% Load the generic scaling setup file
scaleTool = ScaleTool('setupScaling.xml');

% Set up model and (static) marker files
scaleTool.getGenericModelMaker().setModelFileName([folders.models genericModel]);
scaleTool.getModelScaler().setMarkerFileName([folders.data participant '_Static_markers.trc']);
scaleTool.getModelScaler().setOutputModelFileName([folders.models participant '_scaled.osim']);
scaleTool.getMarkerPlacer().setStaticPoseFileName([folders.data participant '_Static_markers.trc']);
scaleTool.getMarkerPlacer().setOutputModelFileName([folders.models participant '_scaled.osim']);

% Set participant mass
scaleTool.setSubjectMass(participantMass);

% Run scaling
scaleTool.run();
Many thanks for any help.

Jasper

Re: Scaling tool: GUI vs MATLAB API

Posted: Mon May 23, 2022 9:54 am
by jobingthampi
Hi, how did you represent that .trc in XML format, kindly help me

Re: Scaling tool: GUI vs MATLAB API

Posted: Mon May 23, 2022 11:38 am
by aymanh
Hi Jasper,

There're many options/knobs in the scale tool that may have values that are different between the GUI and the Matlab sides because you didn't explicitly initialize them. I'd print the Matlab setup to an XML file (using

Code: Select all

scaleTool.print("scaleToolFromMatlab.xml")
and compare the two XML files. In general the GUI and Matlab pathways exercise the same code underneath so it's just a matter of initializing all the options to similar values.

Hope this helps,
-Ayman

Re: Scaling tool: GUI vs MATLAB API

Posted: Tue May 31, 2022 4:44 am
by jasperverheul
Hi Ayman,

Thanks for your reply and suggestions.

When I print the "scaleToolFromMatlab.xml" file and open -> run it via the GUI, the scaling results from the MATLAB API are still different from those in the GUI (see figure attached).

When comparing the setup XML files printed in MATLAB and saved via the GUI, both files are the identical.

Thanks
Jasper

Re: Scaling tool: GUI vs MATLAB API

Posted: Wed Jun 15, 2022 4:55 am
by jasperverheul
The issue seems to be introduced by the saving process. When the model is scaled in the GUI -> saved as a new scaled model -> reopened in the GUI, the same thing happens. In other words, the right model in the image above changes into the left model by saving -> reopening.

Re: Scaling tool: GUI vs MATLAB API

Posted: Wed Jun 15, 2022 6:55 am
by tkuchida
The models appear to be similar but in different poses. You can save the "default pose" of a model (i.e. the pose the model appears in immediately after loading) on the Coordinates panel (please see the "Setting the Default Pose" section on the "Coordinate Controls and Poses" page in the documentation: https://simtk-confluence.stanford.edu:8 ... +and+Poses). Models are also "offset" in the GUI by default; for details, please search for "model offset" on the "Object-Specific Commands" page: https://simtk-confluence.stanford.edu:8 ... c+Commands.