Change ligament insertion point in a matlab loop

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Seyyed Hamed Hosseini Nasab
Posts: 18
Joined: Mon Jan 25, 2016 3:32 am

Change ligament insertion point in a matlab loop

Post by Seyyed Hamed Hosseini Nasab » Thu Dec 08, 2016 3:08 am

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

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Change ligament insertion point in a matlab loop

Post by jimmy d » Fri Dec 09, 2016 10:47 am

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)

User avatar
Seyyed Hamed Hosseini Nasab
Posts: 18
Joined: Mon Jan 25, 2016 3:32 am

Re: Change ligament insertion point in a matlab loop

Post by Seyyed Hamed Hosseini Nasab » Mon Dec 12, 2016 1:38 am

Thanks a lot James. I tried the same for a ligament, and it works.
Regards,
Hamed

User avatar
Alicia Blasi-Toccacceli
Posts: 6
Joined: Mon Nov 04, 2019 2:26 am

Re: Change ligament insertion point in a matlab loop

Post by Alicia Blasi-Toccacceli » Thu May 28, 2020 11:21 pm

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

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

Re: Change ligament insertion point in a matlab loop

Post by Ayman Habib » Sat May 30, 2020 11:09 am

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

User avatar
Alicia Blasi-Toccacceli
Posts: 6
Joined: Mon Nov 04, 2019 2:26 am

Re: Change ligament insertion point in a matlab loop

Post by Alicia Blasi-Toccacceli » Mon Jun 01, 2020 7:00 am

Thank you so much for the advice, now it works perfectly!
Regards,
Alicia

POST REPLY