Change scapulothoracic joint properties in the Thoracoscapular model

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Alicia Blasi-Toccacceli
Posts: 6
Joined: Mon Nov 04, 2019 2:26 am

Change scapulothoracic joint properties in the Thoracoscapular model

Post by Alicia Blasi-Toccacceli » Wed Jun 10, 2020 8:40 am

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 1883 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

Tags:

User avatar
Carmichael Ong
Posts: 401
Joined: Fri Feb 24, 2012 11:50 am

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Carmichael Ong » Thu Jun 11, 2020 3:39 pm

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).

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

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Alicia Blasi-Toccacceli » Fri Jun 12, 2020 5:08 am

Thanks for the explanation and the suggestion, I will try this!

Regards,
Alicia

User avatar
Marcel Rossi
Posts: 8
Joined: Sat Aug 25, 2018 1:02 am

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Marcel Rossi » Fri Jul 10, 2020 1:55 am

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

User avatar
Félix Lefebvre
Posts: 16
Joined: Fri Oct 05, 2018 5:41 am

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Félix Lefebvre » Thu Feb 17, 2022 3:42 am

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,

User avatar
Colin Smith
Posts: 53
Joined: Fri Feb 24, 2012 11:50 am

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Colin Smith » 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()

User avatar
Félix Lefebvre
Posts: 16
Joined: Fri Oct 05, 2018 5:41 am

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Félix Lefebvre » Tue Feb 22, 2022 2:01 am

Hi Colin,

It worked, thank you for your help !

User avatar
Kaiwen Yang
Posts: 45
Joined: Mon Sep 03, 2018 11:25 am

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Kaiwen Yang » Wed Jun 01, 2022 12:05 am

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);

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

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Ayman Habib » Wed Jun 01, 2022 9:35 am

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

User avatar
Kaiwen Yang
Posts: 45
Joined: Mon Sep 03, 2018 11:25 am

Re: Change scapulothoracic joint properties in the Thoracoscapular model

Post by Kaiwen Yang » Fri Jun 10, 2022 12:04 am

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

POST REPLY