Batch processing Inverse Dynamics through Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Markus Kurz
Posts: 9
Joined: Mon Jun 01, 2020 10:37 am

Batch processing Inverse Dynamics through Matlab

Post by Markus Kurz » Sat Jun 27, 2020 8:40 am

Dear Forum-Users,

Thanks for the help you provide us here :)
We encouter quite some big problems batch processing Inverse Dynamics with Matlab. I'll try to explain what we are doing and also attach an example file for inverse dynamic setup and grf xml + Matlab command window output + the scaled model.

If we use the Inverse Dynamics Tool in the GUI we get quick okay results but we are getting the same output in the message window as in Matlab. FYI: we have a force plate type 3 and converted it to FP type 2 (regarding forces) and calculated the COP. We checked it and it turned out that the transformed data is correct.

matlab_commandwindow.JPG
matlab_commandwindow.JPG (119.22 KiB) Viewed 498 times

If we now use our Matlab script, which i also attached (there are variables passed to that script, but at least you can see, which parameters we assign), we are getting different results than using OpenSim itself.

Two things are a little bit weird: the command window says, that it encounters an old version storage/motion file. What does that mean? And secondly, in the GRF.xml file, there is a line <data_source_name> and <datafile>. In our script we were only able to assign <datafile>(supposedly a .sto file, but we assigned a .mot file) dynamically and were not able to assign <data_source_name>. But as i read it in the .xml file description, it says that <datafile> will always overwrite <data_source_name> if it is available. I am being a litte clueless about all that.

If it is important, i also attached the datastructure in which our data is arranged. Dummy setup files with the correct weighting etc. are laying in the "Data_sorted" top folder. The adjusted setup files for scaling, IK and ID are laying within each subject folder (Subject_01/ScaleSetup, Subject_01/IKSetup,....)

data_structure.JPG
data_structure.JPG (24.43 KiB) Viewed 498 times
One more side note: What we also see, is that we have moments even when the runner is in the air, but at TD the moment (i.e. knee flexion moment) is zero and shows a plausible curve (compared to inverse kinetic calculations with another program). Does that make any sense?

I hope you can help us with that.

Best regards
/Markus
Attachments
example_files.zip
(64.4 KiB) Downloaded 53 times

Tags:

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

Re: Batch processing Inverse Dynamics through Matlab

Post by Ayman Habib » Mon Jun 29, 2020 9:57 am

Hi Markus,

A couple quick observations:
1. The note regarding the .mot file being old format is just FYI rather than indicating something wrong, so you can safely ignore. Storage files maintain a version in their header so you shouldn't see this if the file is written in the most recent format but you'll always see it for mot files.
2. There's no justification for obtaining different results from Matlab vs GUI, they both exercise the same code. The only explanation is that some wiring done by the GUI was not done in Matlab (for example ground reaction forces were not applied). If that's the case the issue is likely due to your directory structure. I'd suggest you rearrange the data files/setup files in the same folder similar to how we do it in the distribution, see if you get the correct behavior than troubleshoot what breaks. The GUI jumps through lots of hoops to get this working because of having files refer internally to other files using relative paths (or no path at all/filename) is quite error prone.

Hope this helps,
-Ayman

User avatar
Markus Kurz
Posts: 9
Joined: Mon Jun 01, 2020 10:37 am

Re: Batch processing Inverse Dynamics through Matlab

Post by Markus Kurz » Mon Jun 29, 2020 1:41 pm

Hej Ayman,

Thanks a lot for your reply.

1. Okay, we were just worried that there is a problem, but if it is just an indication for us, than it is okay. One thing to add to that: we observed a file being written to our main_function folder. I'll attach it to this post. It is called externalforce_NewDataSource_TransformedP.sto, even though it is not used for Inverse Dynamics (as it seems).

2. We figured out, that if we leave the <data_source_name></data_source_name> part of the GRF.xml file empty, than we get the right output as we are getting through clicking through the GUI. So it seems as we fixed that problem.

Have you any suggestions regarding the moments during flight phase?

Thanks again for your help.

Best regards
/Markus
Attachments
externalforce_NewDataSource_TransformedP.zip
(9.05 KiB) Downloaded 39 times

POST REPLY