Scaling tool: GUI vs MATLAB API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Jasper Verheul
Posts: 7
Joined: Thu Jan 26, 2017 5:46 am

Scaling tool: GUI vs MATLAB API

Post by Jasper Verheul » Fri May 06, 2022 9:10 am

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

Tags:

User avatar
Jobin Geevarghese ThampI
Posts: 32
Joined: Sat Apr 30, 2022 10:42 am

Re: Scaling tool: GUI vs MATLAB API

Post by Jobin Geevarghese ThampI » Mon May 23, 2022 9:54 am

Hi, how did you represent that .trc in XML format, kindly help me

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

Re: Scaling tool: GUI vs MATLAB API

Post by Ayman Habib » Mon May 23, 2022 11:38 am

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

User avatar
Jasper Verheul
Posts: 7
Joined: Thu Jan 26, 2017 5:46 am

Re: Scaling tool: GUI vs MATLAB API

Post by Jasper Verheul » Tue May 31, 2022 4:44 am

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
Attachments
GUIvsAPI2.png
GUIvsAPI2.png (297.79 KiB) Viewed 531 times

User avatar
Jasper Verheul
Posts: 7
Joined: Thu Jan 26, 2017 5:46 am

Re: Scaling tool: GUI vs MATLAB API

Post by Jasper Verheul » Wed Jun 15, 2022 4:55 am

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.

User avatar
Thomas Uchida
Posts: 1794
Joined: Wed May 16, 2012 11:40 am

Re: Scaling tool: GUI vs MATLAB API

Post by Thomas Uchida » Wed Jun 15, 2022 6:55 am

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.

POST REPLY