list all muscle forces

Hi,

i wonder what would be the best way to export all muscles forces/activities included in (an arbitrary) model.

Is there an easy way to create as csv file without having to create a list of all muscles?

Or how can i ensure that i did not forget a muscle when i created a list?

Thanks,

Thomaz

Hi Thomaz,

for example you could have a look at the LegMoments.any. There you can find the command AnyForceMomentMeasure2 which is what you are looking for (at least I think so). There is also a list which ensures that all muscles are included: #include “LegMuscleNames.any”.
Through this file the XXXNetMomentMuscle-variables are created and I think these include the muscle forces for a joint.

Best regards

Patrick

as far as i understand, AnyForceMomentMeasure2 can be used to summarize forces using a list of muscles. Correct? I don’t like to create a muscle list (e. g. because the list must be updated if i remove some muscles).

The LegMuscleNames.any does only include leg muscles for this specific model.

I thought, as AnyBody is primarily a program to calculate muscle forces, there should be a comfortable way to export them?

A simplified wish in a nutshell:

I would like to create a list of all instances of the AnyMuscle class including subclasses (AnyGeneralMuscle, AnyShortestPathMuscle, …).

(hope the terminology is correct.) i. e. a list of all muscles which are optimized during muscle recruitment.

Is this possible in version 5.2?

Thanks,

Thomaz

Hello Thomaz,

to answer your question, if it is possible to export a list of all muscles in AMS version 5.2: Yes and No.

First the No: Unfortunately there is no one-click-solution for the export of all muscles, neither for reaction forces, segment positions and all the other things you could think of when you see the model.

But if you there is a possibility to create a list of all muscles from the output you can generate from AMS and which we already used a couple of times (and this works also for earlier versions than 5.2).
One way to create a list of all muscles is to export the output of a study in the h5 format and read this output with a small python script which parses through the h5 tree looking for groups in the tree which contain a dataset with a name specific for an instance of an AnyMuscle like class, e.g. the dataset “Activity”. Then the names of these groups can easily be written to a text file.

I hope this helps solving your problem.

Best regards
Daniel

Hi Daniel,

that sounds interesting. What do you mean with: “export the output of a study in the h5 format”?
Would you share the python script?

Thanks and kind regards,

Thomaz

Thomaz,

to export the results of a study no script is needed: You just have to find the “Output” folder in the model tree and then chose “save data” after right clicking it. Then chose the “deep structure” to get the h5-file.

Best regards,

Patrick

Hi Thomaz,

sorry, I can’t share the complete script which also does some other things.
But I can give you a short example that does these things:


import h5py
    
######################################################
def check_entry(checkname):
    i = checkname.rfind('/')
    if checkname[i+1:] == 'Activity':
        print 'found muscle \"' + checkname[:i] + '\"'
######################################################

h5tree = h5py.File('output.anydata.h5','r')
h5tree.visit(check_entry)
h5tree.close()

For questions how to make it work please look at python tutorials other help pages.

Best regards
Daniel

Hi Daniel, hi Patrick,

thanks a lot! Great,

Thomaz