Page 1 of 1

ScaleTool API does not assign correct model file path

Posted: Sun Sep 30, 2018 10:54 am
by paldauf
Hi Guys,

I could not find a solution in the forum, so I would be happy if someone can held me:

I am trying to specify the path of the model I want to use for the ScaleTool via MATLAB.

Code: Select all

scaleTool = ScaleTool('C:\...\OSMATLAB_Batch_Walk\Subject01\ScaleSetup'\svegor_Setup_Scale.xml');
scaleTool.getGenericModelMaker().setModelFileName('C:\...\OSMATLAB_Batch_Walk\modelfile.osim');
scaleTool.getGenericModelMaker().setMarkerSetFileName('C:\...\OSMATLAB_Batch_Walk\Subject01\ScaleSetup\svegor_MarkerSet.xml');
scaleTool.run();
Important: *Note that the Model file is two hierarchical levels above the Scaletool setup file!*

What I get is following:

Code: Select all

Step 1: Loading generic model

Exception:
  Object: Cannot not open file
  C:\...\OSMATLAB_Batch_Walk\Subject01\ScaleSetup\C:\...\MATLAB\OSMATLAB_Batch_Walk\modelfile.osim.
  It may not exist or you do not have permission to read it.
  Thrown at object.cpp:104 in Object().
  line= 2632
If I set the modelfile, the path is incorrect since it adds the path I assigned to the path where the setupfile is located.

If I would store the model file in the setup file folder, it works, but this is what I'm trying to avoid.

I also tries to type in the setup file "Unassigned", but this also does not work.

I hope you understand my problem and would be happy for any help or idea.

Yours, Sven

Re: ScaleTool API does not assign correct model file path

Posted: Sun Sep 30, 2018 12:31 pm
by tkuchida
Note that the Model file is two hierarchical levels above the Scaletool setup file!
Have you tried '..\..\OSMATLAB_Batch_Walk\modelfile.osim'?

Re: ScaleTool API does not assign correct model file path

Posted: Fri Oct 05, 2018 8:49 am
by paldauf
Hey Thomas,

thanks for your fast and sorry for my delayed reply.

I tried to do what you recommended, but there is still no difference to recognize. I still get the same error message because both paths are merged.

Can't explain to myself why such an issue occurs because I do the same with the IKTool and it sets the right path even if the files are in another folder.

I would appreciate if there are other ways or ideas to manage this. Otherwise I will save the model file and scale setup file in the same folder but this is rather a suboptimal solution for my purposes.

Thank you in advance,

Sven

Re: ScaleTool API does not assign correct model file path

Posted: Fri Oct 05, 2018 11:17 am
by tkuchida
The first line of your code is scaleTool = ScaleTool('C:\...\OSMATLAB_Batch_Walk\Subject01\ScaleSetup'\svegor_Setup_Scale.xml'); which looks like it contains 2 issues:
1. I don't think 3 periods ("...") is meaningful: if you want to use a relative path, I don't think the path string should begin with "C:\".
2. There's an extra quotation mark between "ScaleSetup" and "\svegor" which may have unexpected consequences.
You might want to look through the example scripts as well.

Re: ScaleTool API does not assign correct model file path

Posted: Sun Oct 07, 2018 5:49 am
by paldauf
In my actual code, the three dots in the path do not exist(it was only for simplification purposes to shorten the path, sorry for that).
And also the extra quotation mark between "ScaleSetup" and "\svegor" was only a mistake here since I use another variable name instead of '\svegor_Setup_Scale.xml'.

This is what I do:

scaleTool = ScaleTool('C:\Users\Sven\Documents\OSMATLAB_Batch_Walk\Subject01\ScaleSetup\svegor_Setup_Scale.xml');

The path for my scaleTool is right, but I still have the problem that an error occurs because of the merge of the paths (e.g.: path\path\filename) when setting the ModelFilePathName.

But I solved my problem by storing the model file in the same folder than the Setup file.

Nevertheless, thank you very much. Maybe I can come up with my issue at the next OpenSim workshop in Belgium in 4 weeks.