Coordinate Speed Calculation & SOpt frame 1 applied speed

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Jacob J. Banks
Posts: 97
Joined: Tue Jul 15, 2014 5:17 am

Coordinate Speed Calculation & SOpt frame 1 applied speed

Post by Jacob J. Banks » Fri Apr 15, 2022 1:52 pm

I have 2 semi related questions/I have been struggling with... hopefully 1 post is appropriate.

1) How are the state speeds calculated? Is this just a simple 3pt (central?) method form the coordinates? If so, why can't I match them EXACTLY from the state coordinates?

2) Does the static optimization (SOpt) tool make any corrections to the first and last frames 'states'? It appears that the speed from the first frame is generally quite a bit different from the following (and the same for the last frame with the previous ones), as one would expect since it doesn't have the same amount of data points to work with as other frames would. This is of particular concern when trying to match a custom SOpt (MATLAB fmincon) result with the SOpt Tool result. I can't seem to get the first frame to have a similar 'Optimal Forces' (predicted force divided by predicted activation from SOpt Tool) and corresponding Activations. It would appear that the first frame speed used by the SOpt Tool is not what is calculated from the States Tool and is instead closer to the speeds found in the following frames.

Please advise, as I can't seem to find an answer to either in the source code, documentation, or in this forum.
Jake Banks

Tags:

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

Re: Coordinate Speed Calculation & SOpt frame 1 applied speed

Post by Nicos Haralabidis » Fri Apr 15, 2022 2:09 pm

Hello Jake,

I think the positional data is fitted with a spline (https://github.com/opensim-org/opensim- ... zation.cpp) (Line 338), a GCV spline specifically I think (https://github.com/opensim-org/opensim- ... plineSet.h). Hope that helps!

Cheers,

Nicos

User avatar
Jacob J. Banks
Posts: 97
Joined: Tue Jul 15, 2014 5:17 am

Re: Coordinate Speed Calculation & SOpt frame 1 applied speed

Post by Jacob J. Banks » Sat Apr 16, 2022 6:47 am

Nicos,
Thank you for the prompt and clear reply. I was sort of thinking that may be the case, but for whatever reason I overlooked that portion of the code.
I suppose it is spline fit to smooth a bit and more easily take a derivative. Still a bit confusing to have speeds and coordinates you can generate with the Analysis Tool that do not align with what is being used for SOpt, but for now I will chalk up the predicted MTA optimal forces differences (which are relatively small) I'm getting for my custom SOpt and the ones you can calculate from the SOpt Tool results to the spline fitting. May try fitting a spline and calculating my own speeds for grins to just see if I can reproduce things, but probably not that big of a deal in the long run.
At any rate, thanks again,
Jake Banks

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

Re: Coordinate Speed Calculation & SOpt frame 1 applied speed

Post by Carmichael Ong » Wed Apr 20, 2022 6:46 pm

Since you seem to be using your own custom static optimization too, one thing to note is that the static optimization within OpenSim does not consider passive muscle forces. This can lead to bigger discrepancies than one might expect, and also a plus often for using a custom static optimization framework if this may affect your problems greatly.

POST REPLY