Page 1 of 1

Change ligament insertion point in a matlab loop

Posted: Thu Dec 08, 2016 3:08 am
by hamed-hn
Dear all,

I am trying to change insertion point of a ligament and see the effect on ligament load. As I have to do this for 100 runs, I am trying to do this as batch process in matlab. The problem is that, I do not want to create 100 models, save them with different names and then run IK for them. I just want to change a single parameter (the attachment point) of the model and run IK without saving the new model somewhere. How can I access to this parameter in matlab, change it dynamically and run IK in a loop?
Any information is highly appreciated.

Kind regards,
Hamed

Re: Change ligament insertion point in a matlab loop

Posted: Fri Dec 09, 2016 10:47 am
by jimmy
You can drill down to the pathpoints of a muscle. Looks something like

Code: Select all

model = Mode(pathtomodel)

s = model.initSystem()

gpath = model.getMuscles().get('rect_fem_r').getGeometryPath()

pathpoint = gpath.getPathPointSet().get(0)

location = Vec3(0.1, 0.1, 0.1)

pathpoint.setLocation(s, location)

Re: Change ligament insertion point in a matlab loop

Posted: Mon Dec 12, 2016 1:38 am
by hamed-hn
Thanks a lot James. I tried the same for a ligament, and it works.
Regards,
Hamed

Re: Change ligament insertion point in a matlab loop

Posted: Thu May 28, 2020 11:21 pm
by gudrun
Hello,

Sorry for reopening this old topic, but I am trying to change muscle insertion with Python and it does not work.

In fact, the code above proposed by jimmy does in theory exactly what I want but when I run a similar code, I got an error for the last line with the setLocation function.
AttributeError: AbstractPathPoint object has no attribute setLocation.
I saw in the doxygen API documentation that the function setLocation is usable with the PathPoint class, but not with AbstractPathPoint class like here. Is there a way to use PathPoint object to achieve the desired goal? Or any other solution?

Thank you in advance for any advice or tips.
Alicia Blasi-Toccaceli

Re: Change ligament insertion point in a matlab loop

Posted: Sat May 30, 2020 11:09 am
by aymanh
Hello,

The API has changed in version 4.0 after the code snippet was shared, you should use the documentation for the version you have, accessible from the application/GUI. A guide to use doxygen is here https://simtk-confluence.stanford.edu/d ... ng+Doxygen

For this specific situation, the method setLocation is not available to the base class AbstractPathPoint, however if you know the exact type of PathPoint you're dealing with (PathPoint, ConditionalPathPoint, ....) you can use "safedowncast" method to the proper type to use it, for example:

Code: Select all

ppt = PathPoint.safeDownCast(abstractPathPoint)
then ppt will have access to the method setLocation.

Hope this helps,
-Ayman

Re: Change ligament insertion point in a matlab loop

Posted: Mon Jun 01, 2020 7:00 am
by gudrun
Thank you so much for the advice, now it works perfectly!
Regards,
Alicia