Page 1 of 2

Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Wed Jun 10, 2020 8:40 am
by gudrun
Dear all,

I am using the Thoracoscapular model (Seth et al. 2019) and I would like to change the thoracic ellipsoid radii (the highlighted line in the attached .osim file screenshot). The aim is to carry out a kind of sensitivity analysis, so I want to automatize the process through Python API.
ThoracoscapularModel.PNG
ThoracoscapularModel.PNG (65.88 KiB) Viewed 1301 times
I can access the joint (like a classic one):

Code: Select all

Joint = model.getJointSet().get("scapulothoracic")
But then, I want to access the ellipsoid radii with a command which look like this (obviously, it is too specific, and it does not exist):

Code: Select all

Radii_ellisp = joint.get_thoracic_ellipsoid_radii_x_y_z()
Is there a way to achieve this with an oriented object method like above? Or should I try this with a code which select the line like a str sequence and change it?

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

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Thu Jun 11, 2020 3:39 pm
by ongcf
Since the ScapulothoracicJoint class is not in OpenSim's core libraries, it's not as straightforward to edit properties specific to that joint type through the Python API. A couple of ways to do this:

1. Load the XML file, edit, and write out the adjusted XML file using Python utilities (without OpenSim). Then continue with the OpenSim API.
2. Use the PropertyHelper class. Unfortunately for Python users, this will be reintroduced in 4.2 (but can be used in MATLAB). This is also already available if you build the master branch of OpenSim on github (https://github.com/opensim-org/opensim-core).

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Fri Jun 12, 2020 5:08 am
by gudrun
Thanks for the explanation and the suggestion, I will try this!

Regards,
Alicia

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Fri Jul 10, 2020 1:55 am
by marcel_ssi
Hi Carmichael,

I have exactly the same issue as Alicia, I would like to get access to and set new values for the scapulothoracic joint radii, (<thoracic_ellipsoid_radii_x_y_z>), and in may case I am using Matlab instead of Python. Nevertheless, I am not familiar with the use of the PropertyHelper, and couldn't find any info about this specific class on the website as well (https://simtk.org/api_docs/opensim/api_ ... enSim.html).

I got as far as Alicia and was also able to get the position and orientation of the joint frame, it is only the radii of the ellipsoid that I am missing. Would you please give me an example on how to use this PropertyHelper class to get these values and also to set new values to this line of the *.osim file? More specifically, how to proceed from this line onwards:

Joint = model.getJointSet().get("scapulothoracic")

Thanks Carmichael, it will be much appreciated!

Marcel

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Thu Feb 17, 2022 3:42 am
by felix.lefebvre
Hi,

I have the same issue, trying to access scapulothoracic joint properties through Python API with OpenSim 4.3.

Is there a simpler way to do it now ?

Something like:

scap = myModel.getJointSet().get("scapulothoracic")
scap.get_thoracic_ellipsoid_radii_x_y_z()


Thanks,

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Fri Feb 18, 2022 12:29 pm
by clnsmith
Hi Felix,

scap = myModel.getJointSet().get("scapulothoracic")

returns a generic object of type "Joint"

you can downcast this to the specific type of joint, since you know the type from the model file.

scap_joint = ScapulothoracicJoint.safeDownCast(scap);

now there will be all the ScapulothoracicJoint methods available so you can access the command you want.

scap_joint.get_thoracic_ellipsoid_radii_x_y_z()

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Tue Feb 22, 2022 2:01 am
by felix.lefebvre
Hi Colin,

It worked, thank you for your help !

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Wed Jun 01, 2022 12:05 am
by yangkaiwen
clnsmith wrote:
Fri Feb 18, 2022 12:29 pm
Hi Felix,

scap = myModel.getJointSet().get("scapulothoracic")

returns a generic object of type "Joint"

you can downcast this to the specific type of joint, since you know the type from the model file.

scap_joint = ScapulothoracicJoint.safeDownCast(scap);

now there will be all the ScapulothoracicJoint methods available so you can access the command you want.

scap_joint.get_thoracic_ellipsoid_radii_x_y_z()
Hmmm, I tried this code in Matlab with OpenSim 4.1, resulting an error

Code: Select all

import org.opensim.modeling.*
opensimCommon.LoadOpenSimLibrary('ScapulothoracicJointPlugin41_WinX64');
osimModel = Model('testModel.osim');
clc
osimModel.setUseVisualizer(true);
scap = osimModel.getJointSet().get("scapulothoracic");
scap_joint = ScapulothoracicJoint.safeDownCast(scap);
scap_joint.get_thoracic_ellipsoid_radii_x_y_z()

Code: Select all

Unable to resolve the name
ScapulothoracicJoint.safeDownCast.

Error in shoulderVisual (line 14)
scap_joint =
ScapulothoracicJoint.safeDownCast(scap);

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Wed Jun 01, 2022 9:35 am
by aymanh
Hello,

The Scapulothoracic Joint was integrated into core OpenSim libraries in version 4.2, so you'll have to upgrade or use the PropertyHelper mechanism which operates on any type of object including those defined in plugins.

Hope this helps,
-Ayman

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Posted: Fri Jun 10, 2022 12:04 am
by yangkaiwen
Thanks Ayman,

Another quick question I have is why the Thoracoscapular model has state.getNQ =18 while state.getNU = 17? I realize there is an extra "Q" between "scapula_winging" and "scapular_upward_rotation" but this does not quite make sense..

Kaiwen