can not remove muscles

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Sepehr Ramezani
Posts: 35
Joined: Tue Nov 05, 2019 2:02 pm

can not remove muscles

Post by Sepehr Ramezani » Wed Sep 22, 2021 7:35 pm

Hi,
I'm trying to remove some muscles from model. It does not give me error and before printing model when I check number of muscles it seems they have been removed however, after printing model, there is no changes. Do I need to finalize or something like that before printing? my code is

Code: Select all

import org.opensim.modeling.*;
Logger.addSink(JavaLogSink());
osismmodel = Model('subject_walk_armless.osim');
osismmodel.finalizeConnections();
SimMusclename=["bflh_r","bfsh_r","gaslat_r"]
c=0;
for m = 0:osismmodel.getMuscles().getSize()-1
        musc = osismmodel.updMuscles().get(c);
        if ~sum(strcmp(char(musc.getName()), SimMusclename))
        osismmodel.updMuscles().remove(c)
        else
            c=c+1;
        end
end
osismmodel.print('subject_walk_armless_DeGroote.osim');

Tags:

User avatar
Najoua Assila
Posts: 34
Joined: Thu Aug 30, 2018 9:24 am

Re: can not remove muscles

Post by Najoua Assila » Thu Sep 23, 2021 12:32 am

Hi,

I had a similar issue, except I work with python, so I am not sure the solution would be the same.
In my case, I had to update the model's ForceSet, instead of the muscle set, to be able to successfully save it in the new osim file.

Hope it helps,

Najoua

User avatar
Sepehr Ramezani
Posts: 35
Joined: Tue Nov 05, 2019 2:02 pm

Re: can not remove muscles

Post by Sepehr Ramezani » Thu Sep 23, 2021 7:56 am

Thanks Najoua, it worked.

POST REPLY