Update Muscle Path

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Ekaterina Stansfield
Posts: 9
Joined: Mon Jul 03, 2017 5:37 am

Update Muscle Path

Post by Ekaterina Stansfield » Tue Jul 18, 2023 4:18 am

Hi, this question is related to my question in viewtopic.php?f=91&t=16752

I am updating muscle paths in a model.

The problem is that stating

"state = model.initSystem()"

before "loc=model.getMuscles().get(muscle).getGeometryPath().getPathPointSet().get(point).getLocation(state)",

does not allow for an automatic update of the model.

What do I need to do to update the default model state so that I can export the updated model to a .osim file?

Tags:

User avatar
Nicos Haralabidis
Posts: 197
Joined: Tue Aug 16, 2016 1:46 am

Re: Update Muscle Path

Post by Nicos Haralabidis » Thu Jul 20, 2023 8:43 am

Hello Ekaterina!

I just did some exploring and maybe this works (Matlab):
import org.opensim.modeling.*
mod = Model('gait2392_simbody.osim');
state = mod.initSystem();
musc0 = mod.getMuscles().get(0)
gp0=musc0.getGeometryPath();
cp0 = gp0.getCurrentPath(state);
cp0_0 = cp0.get(0); %0th pathpoint, returns abstract pathpoint
pathpoint0 = PathPoint.safeDownCast(cp0_0); % need to downcast to concrete class to edit
pathpoint0.set_location(Vec3(1,2,3)); % 1,2,3 the new locations of the path points
state = mod.initSystem(); % Reinitialize state for changes to take effect
mod.print('test.osim'); % Print to model file to see if changes worked

Hope that works!

Thanks,

Nicos

User avatar
Ekaterina Stansfield
Posts: 9
Joined: Mon Jul 03, 2017 5:37 am

Re: Update Muscle Path

Post by Ekaterina Stansfield » Fri Jul 21, 2023 9:59 pm

Thank you -- I will give it a go!

POST REPLY