Spine models in AMMRV1.2 and 1.3

Damon,

You should put in one of the *Study class folders. For example if you look at the example in the reference manual - it looks like:

 
 AnyParamStudy SimpleParamStudy_3param = {
    ... // something else here

    AnyOutputFile OFile1 = {
      FileName = "AnyOutputFile.OFile1.txt";
      AnyVar out0 = .out0.Val;
    };
 };

I am not sure that it will be picked up from the HumanModel folder (it may be ignored since this way it may appear in many different studies and overwrite the output file). So try using it inside of AnyBodyStudy/AnyParamStudy/AnyOptStudy objects.

I tried on a simpler example and it seems to be the case.

Best regards,
Pavel

Hi Pavel
I did not find AnyParamStudy in the GaitFullBody.main. But I did find serveraly studies in the GaitFullBody.main file, I put the code near the end of the study section shown in the code below. The model ran in ā€œMotionAndParameterOptimizatinModelā€, but skipped when I tried to run ā€œInverseDynamicModelā€. What do you think I should do?

Also, once the model runs completely, where do I get the output files of the data I am looking for?

Sincerely thanks
Damon

Here below is the sectin in GaitFullBody.main file…

[SIZE=3]//This study is used for running the inverse dynamic analysis of the optimized motion
[/SIZE][SIZE=3]//***********************************************************************************
[/SIZE]HumanModel={
[SIZE=3]AnyFolder[/SIZE] &Mannequin=.InverseDynamicStudy.Mannequin;
[SIZE=3]#include[/SIZE] ā€œBodyPartsSetup.anyā€
};
[SIZE=3]#include[/SIZE] ā€œHumanModel.anyā€

[SIZE=3]AnyBodyStudy[/SIZE] InverseDynamicStudy = {
[SIZE=3]AnyFolder[/SIZE] &C3DData=…ModelSetup.C3DFileData ;
[SIZE=3]AnyFolder[/SIZE] &HumanModel=.HumanModel.BodyModel;
[SIZE=3]#include[/SIZE] ā€œMannequin.anyā€

[SIZE=3]//Environment around the human
[/SIZE][SIZE=3]AnyFolder[/SIZE] EnvironmentModel ={

[SIZE=3]AnyFolder[/SIZE] DrawC3DMarkers = {};
[SIZE=3]//Model of the floor and force plates this is where the force plates are defined
[/SIZE][SIZE=3]AnyFolder[/SIZE] &HumanModelRef=…HumanModel.BodyModel;
[SIZE=3]//This environment file makes use of automatic detecteion of which foot are incontact with which plate
[/SIZE][SIZE=3]#include[/SIZE] ā€œEnvironmentAutoDetection.anyā€
[SIZE=3]//This environment file has no automatic detecteion of which foot are incontact with which plate it has to be set manually
[/SIZE][SIZE=3]//#include ā€œEnvironment.anyā€
[/SIZE]};

[SIZE=3]//Connection between environment and the human
[/SIZE][SIZE=3]AnyFolder[/SIZE] ModelEnvironmentConnection = {
[SIZE=3]//Drivers for the model
[/SIZE][SIZE=3]#include[/SIZE] ā€œJointsAndDriversOptimized.anyā€
};

InverseDynamics.Criterion.UpperBoundOnOff=Off;
nStep=Main.ModelSetup.nStep;
Gravity ={0,0,-9.81};
tStart = Main.TrialSpecificData.tStart+2Kinematics.ApproxVelAccPerturb;
tEnd = Main.TrialSpecificData.tEnd-2
Kinematics.ApproxVelAccPerturb;

[SIZE=3]//this will give these ouputs
[/SIZE]
AnyOutputFileOutputFile={
FileName=ā€œResults.txtā€;
AnyFloatMA1=Main.LTptT6S1.MA1;
AnyFloatMA3=Main.L5SacrumMedioLateralForce.MA3;
SepSign=Main.GeneralSettings.OutputSepSign;
};

[SIZE=3]//#include ā€œGCDOutput.anyā€
[/SIZE]};

[SIZE=3]//This study is only used for loading the optimized parameters
[/SIZE][SIZE=3]AnyOptKinStudy[/SIZE] LoadParametersOptimizationResults = {
[SIZE=3]AnyFolder[/SIZE] &Study = .InverseDynamicStudy;
ParameterOptimization.ConvergenceTol=1e-3;
Analysis = {
[SIZE=3]AnyOperation[/SIZE] &ref = .Study.Kinematics;
};
};

[SIZE=3]#endif
[/SIZE]};

Hi Damon,

What I meant was that it should be in one of such studies (not necessary AnyParamStudy). You need to find exactly which study is being used and insert this output block there. So let us look deeper.

You mentioned that you ran ā€˜MotionAndParameterOptimizationSequnce’, but your output is in the InverseDynamicsStudy. If you want run the InverseDynamicsStudy case you need to switch the flags in the beginning of GaitFullBody.main.any to be:


#define MotionAndParameterOptimizationModel 0
...
#define InverseDynamicModel 1

But this has to be done after you performed the optimization study (with 1,0 flags). This way the InverseDynamicsStudy will pick up optimized values and use them.

I think this minor change will help.

Regards,
Pavel

Pavel

I ran the 'MotionAndParameterOptimizationSequnce 1' to build the bones. Then I tried to run InverseDynamicModel 1 to build the muscles on the bones, and that is when the program skipped and stopped running.

So what your saying is i need to find the right study, put the code there and run the 1,0 and then the 0,1.

Are all the studies in the main file, or is there other files with studies that I need to try?

Sincerely thanks
Damon

Damon,

What I said was that you may have many different studies in your model for different purpose, like it is right now. But there is just one important, which reports required value and you are supposed to know which one it is.

For example, I can see that you are requesting something force-related - it means that it has to be an inverse dynamics study. So the output should be placed in the inverse dynamics study. But in case of the Gait applications the procedure requires to run the model twice: first time to optimize motion and parameters, reload with ā€˜0,1’ flags and run second to perform the inverse dynamics analysis. So nothing will happen when you run the optimization step, but the output will appear next to the main file when you run the second step, i.e. the inverse dynamics study.

So the steps are:

  1. place the output code in the appropriate study object/folder
  2. run optimization study with 1,0 flags (#define statements from my previous post)
  3. change the flags to be 0, 1
  4. run inverse dynamics study
  5. enjoy your results.

(steps 2,3 are not needed if you have already run the optimization step).

Hope this helps,
Pavel

Hi Pavel

From your response, I’m starting to wonder if the code I’m using will do what I need it to do.

With the model the way it is, I can already get to the data in ChartFX 2D, "Text files (data only).

But to download those "Text files (data only) from ChartFX 2D, for 31 muscles I’m looking at, will take a long time to download all the files. I have over 600 captures and i really need to get the data more quickly than downloading one muscle at a time. Doing it one at a tim is 600x31 downloads. So I’m trying to find a way to export the data more quickly, i.e 32 muscles data files all at once.

What do you think, is the code going to do this, if not can you help me with this problemm please.

Sincerely
Thanks

Hi Damon,

Of course, this is possible. AnyScript is a script language - thus, the beauty is that you can automated something like that. You just need to organize the output for your muscle forces properly.

From what I see - the output looks somewhat strange. I wouldn’t except this code to access the correct values: to get right values you should use a long path like ā€œAnyFloat MA1 = Main.Studies.HumanModel.BodyModel.Trunk.MusclesSpineLeft.ErectorSpinae.LTptT6S1.Activity;ā€

If you can access needed object in the model tree view - right click and use copy complete name.

And as I said before - 1) construct correct output block 2) use this block in the inverse dynamics study.

Regards,
Pavel

Thanks Pavel
I tried this below code in the study[SIZE=3] ā€œused for running the inverse dynamic analysis of the optimized motionā€ [COLOR=#000000] and the model skipped in 0/1. What do you think is wrong?
[/COLOR][/SIZE]
AnyOutputFileOutputFile={
FileName=ā€œResults.txtā€;
AnyFloatMA1=Main.Studies.HumanModel.BodyModel.SelectedOutput.Trunk.JointReactionForce.L5SacrumMedioLateralForce;[SIZE=3]
[/SIZE]SepSign=Main.GeneralSettings.OutputSepSign;
};

Also, with a different capture not related to above problem, I’m having problem with tollerances. I am wondering if there was a way to adjust the tolerances, and how to do this (1)? And if i do this what affect will this have on my kinetic L5/S1 values. i.e. how much will relaxing the tollerances affect the L5/S1 kinetic data output (2)?

Here is my error mesage.

[SIZE=1]NOTICE(OBJ.DES3)[/SIZE] : [SIZE=1]//data/rf/E…n/D…s/1…n/A…3/A…n/29/7…B/ModelSetup.any[/SIZE] : [SIZE=1]LWRBY[/SIZE] : Design initialization : Design variable’s value was updated

Macro command > operation Main.Studies.InverseDynamicStudy.InitialConditions

Macro command > run


3.0) InitialConditions (Operation: Main.Studies.InverseDynamicStudy.InitialConditions):
3.0) …Design variables have been updated.
3.1) …Load time positions have been re-established.
Failed to resolve kinematic constraints (final kin. error = 1.551556E+001)
…
had to remove some code to submit this reply

…

ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverTrunk’ above error tolerance 0.000001, error = 0.000551.
Constraint no. #4 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverTrunk’ above error tolerance 0.000001, error = 0.000028.
Constraint no. #5 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverTrunk’ above error tolerance 0.000001, error = 0.000181.
Constraint no. #6 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverTrunk’ above error tolerance 0.000001, error = 0.000211.
Constraint no. #7 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverTrunk’ above error tolerance 0.000001, error = 0.000460.
Constraint no. #8 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverTrunk’ above error tolerance 0.000001, error = 0.001600.
Constraint no. #0 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftLegTD’ above error tolerance 0.000001, error = 0.001106.
Constraint no. #1 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftLegTD’ above error tolerance 0.000001, error = 0.000380.
Constraint no. #2 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftLegTD’ above error tolerance 0.000001, error = 0.000137.
Constraint no. #3 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftLegTD’ above error tolerance 0.000001, error = 0.000061.
Constraint no. #4 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftLegTD’ above error tolerance 0.000001, error = 0.000691.
Constraint no. #5 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftLegTD’ above error tolerance 0.000001, error = 0.000076.
Constraint no. #0 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightLegTD’ above error tolerance 0.000001, error = 0.000273.
Constraint no. #1 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightLegTD’ above error tolerance 0.000001, error = 0.000608.
Constraint no. #2 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightLegTD’ above error tolerance 0.000001, error = 0.000125.
Constraint no. #3 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightLegTD’ above error tolerance 0.000001, error = 0.000048.
Constraint no. #4 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightLegTD’ above error tolerance 0.000001, error = 0.000453.
Constraint no. #5 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightLegTD’ above error tolerance 0.000001, error = 0.000268.
Constraint no. #0 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.SCDriverLeft’ above error tolerance 0.000001, error = 0.000257.
Constraint no. #1 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.SCDriverLeft’ above error tolerance 0.000001, error = 0.001496.
Constraint no. #2 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.SCDriverLeft’ above error tolerance 0.000001, error = 0.000369.
Constraint no. #0 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftArm’ above error tolerance 0.000001, error = 0.009485.
Constraint no. #1 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftArm’ above error tolerance 0.000001, error = 0.010278.
Constraint no. #2 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftArm’ above error tolerance 0.000001, error = 0.016598.
Constraint no. #3 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftArm’ above error tolerance 0.000001, error = 0.000336.
Constraint no. #4 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftArm’ above error tolerance 0.000001, error = 0.000861.
Constraint no. #5 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftArm’ above error tolerance 0.000001, error = 0.061595.
Constraint no. #6 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverLeftArm’ above error tolerance 0.000001, error = 0.026652.
Constraint no. #0 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.SCDriverRight’ above error tolerance 0.000001, error = 0.001033.
Constraint no. #1 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.SCDriverRight’ above error tolerance 0.000001, error = 0.000606.
Constraint no. #2 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.SCDriverRight’ above error tolerance 0.000001, error = 0.000482.
Constraint no. #0 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightArm’ above error tolerance 0.000001, error = 0.007880.
Constraint no. #1 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightArm’ above error tolerance 0.000001, error = 0.005890.
Constraint no. #2 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightArm’ above error tolerance 0.000001, error = 0.012349.
Constraint no. #3 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightArm’ above error tolerance 0.000001, error = 0.014979.
Constraint no. #4 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightArm’ above error tolerance 0.000001, error = 0.000180.
Constraint no. #5 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightArm’ above error tolerance 0.000001, error = 0.096247.
Constraint no. #6 in ā€˜Main.Studies.InverseDynamicStudy.ModelEnvironmentConnection.JointsAndDrivers.JntDriverRightArm’ above error tolerance 0.000001, error = 0.018172.
[SIZE=1]ERROR(OBJ.MCH.KIN3)[/SIZE] : [SIZE=1]//data/rf/E…n/D…s/1…n/A…3/A…n/29/7…B/GaitFullBody.main.any[/SIZE] : [SIZE=1]InverseDynamicStudy.InitialConditions[/SIZE] : Kinematic analysis failed in time step 0

Macro command > operation Main.Studies.HumanModel.Calibration.CalibrationSequence

Error : Main.Studies.HumanModel.Calibration.CalibrationSequence : object is not AnyOperation.

Sincerely thanks
Damon

Hi Damon,

From the description it looks good to me. It’s hard to tell what is wrong, but most likely it is still a wrong place to insert the output block. Do I understand it correct that the output is simply not being generated, but you can see the results otherwise (which contradicts with your second problem - if you cannot run it, you will, of course, not get the output)? I would recommend to get a fresh clean copy of the same model (GaitFullBody) from the repository and check that it works there. Just the output - check what the differences are.

Regarding the tolerances - you can change them in the solver settings in AnyBodyStudy object. But that does not seem to be the problem in your case. You are doing something wrong elsewhere. If you managed to run the motion and parameter optimization study - you should not be seeing this problem. It may happen in the optimization study, but that would mean that you got the initial conditions wrong and would require to modify the input parameters/position, etc. You can assess it visually in the model view - you should see both sets of markers: target and source.

My suggestion for solving your problems is to ā€˜divide & conquer’ - get a fresh copy of the GFB model and try the output code there (if it works - do the same in your model). And another tip would be to get familiar with the original example, to make sure that you can get something similar or exactly what you want.

Regards,
Pavel

Pavel
I put in a very short C3D file, and tested it with 1/0 and 0/1. And it ran for both. When I put in the code then this is what happens.

[LEFT][LEFT] [/LEFT]
[LEFT]***************************************************************************************[/LEFT]
[LEFT]5.0) Kinematics (Operation: Main.Studies.MotionOptimization.Kinematics): [/LEFT]
[LEFT]0) PreOperation (Operation: Main.Studies.MotionOptimization.Kinematics.PreOperation): [/LEFT]
[LEFT].0) InitialConditions (Operation: Main.Studies.MotionOptimization.InitialConditions): [/LEFT]
[LEFT].0) …Design variables have been updated.[/LEFT]
[LEFT].1) …Load time positions have been re-established.[/LEFT]
[LEFT].2) …Kinematic analysis completed. The kinematic constraints have been resolved.[/LEFT]
[LEFT].3) …Initial conditions are fully updated.[/LEFT]
[LEFT]5.0) Kinematic analysis…[/LEFT]
[LEFT]5.54) …Kinematic analysis completed[/LEFT]
[LEFT]Total simulation time: 56.925[/LEFT]
[LEFT] [/LEFT]
[LEFT]***************************************************************************************[/LEFT]
[LEFT] [/LEFT]
[LEFT]Closing model…[/LEFT]
[LEFT]Saving modified values…[/LEFT]
[LEFT]Deleting last loaded model…[/LEFT]
[LEFT]…Model deleted.[/LEFT]
[LEFT]Loading Main : ā€œ\data\rf\ENG_d.stambolian\Documents\1-AnyScripts_Damon\AMMRV1.3\Application\1 - Test_For_Data\TDO\GaitFullBody.main.anyā€[/LEFT]
[LEFT]Scanning…[/LEFT]
[LEFT]Parsing…[/LEFT]
[LEFT]Constructing model tree…[/LEFT]
[LEFT]ERROR(SCR.PRS9) : //data/rf/E…n/D…s/1…n/A…3/A…n/1…a/TDO/GaitFullBody.main.any : ā€˜AnyOutputFileOutputFile’ : Unresolved object[/LEFT]
[LEFT] [/LEFT]
[LEFT]Closing model…[/LEFT]
[LEFT]Deleting last loaded model…[/LEFT]
[LEFT]…Model deleted.[/LEFT]
[LEFT]Model loading skipped[/LEFT]
[LEFT] [/LEFT][/LEFT]

I am still wondering if I am explaining what I need. Below is the output that I can save by going to Chart FX(2D) new. Basically I want to export many of this kind of data. Is that what the code are working on will do?

XY
Main.Studies.InverseDynamicStudy.Output.HumanModel.SelectedOutput.Trunk.JointReactionForce.L5SacrumMedioLateralForce
5.73 1.67e+001
5.74 1.74e+001
5.74 1.64e+001
5.75 1.47e+001
5.76 1.30e+001
5.77 1.20e+001
5.78 1.18e+001
5.78 1.14e+001
ETC……

Hi Damon,

Ok, that’s a completely different story :slight_smile: When you said ā€˜skipped’ - I presumed that it worked without errors, but did not generate the output file despite proper definition. But now I can see that you have a syntax error (i saw this typo before, but thought that it happened due to copying code into a message).

Change ā€˜AnyOutputFileOutputFile’ to ā€˜AnyOutputFile OutputFile’ (with a space).

And yes - this code will do the same thing.

Regards,
Pavel

Hi Pavel

Its working :), also added a space between AnyFloat and MA1. And it skipped, so I commented out SepSign=… Now the file "Results is generated in the model folder.

So, what is the ā€œSepSignā€ for?

[SIZE=3]AnyOutputFile[/SIZE] OutputFile={
FileName=ā€œResults.txtā€;
[SIZE=3]AnyFloat[/SIZE] MA1=Main.Studies.HumanModel.BodyModel.SelectedOutput.Trunk.JointReactionForce.L5SacrumMedioLateralForce;
[SIZE=3]//SepSign=Main.GeneralSettings.OutputSepSign;
[/SIZE]};

Here is the outputs, the top one is from ChartFX, and the lower is from the Results file, the results file has a few more decimal places.

ChartFX

XY
Main.Studies.InverseDynamicStudy.Output.HumanModel.SelectedOutput.Trunk.JointReactionForce.L5SacrumMedioLateralForce
8.23 1.15e+001
8.23 8.47e+000
8.24 8.18e+000
8.25 6.99e+000
8.25 7.01e+000
8.26 6.98e+000
8.26 6.85e+000
8.27 6.62e+000
8.28 6.38e+000
8.28 6.21e+000
8.29 6.02e+000
8.29 5.77e+000
8.30 5.51e+000
8.30 5.25e+000
8.31 5.00e+000
8.32 4.75e+000
8.32 4.53e+000
8.33 4.33e+000
8.33 4.18e+000
8.34 4.02e+000
8.35 3.89e+000
8.35 3.80e+000
8.36 3.76e+000
8.36 3.77e+000
8.37 3.80e+000
8.38 3.82e+000
8.38 3.84e+000
8.39 3.86e+000
8.39 3.98e+000
8.40 4.13e+000
8.41 4.34e+000
8.41 4.54e+000
8.42 4.70e+000
8.42 4.83e+000
8.43 4.92e+000
8.43 4.96e+000
8.44 4.96e+000
8.45 4.86e+000
8.45 4.71e+000
8.46 4.51e+000
8.46 4.27e+000
8.47 3.99e+000
8.48 3.71e+000
8.48 3.46e+000
8.49 3.39e+000
8.49 3.34e+000
8.50 3.28e+000
8.51 3.22e+000
8.51 3.18e+000
8.52 3.16e+000
8.52 3.12e+000
8.53 3.05e+000
8.53 2.94e+000
8.54 2.81e+000
8.55 2.20e+000

From Results File

---- AnyBody Output File ---------------------------------
Study: Main.Studies.InverseDynamicStudy
Operation: Main.Studies.InverseDynamicStudy.InverseDynamics

Constants (Name = Value):
Main.Studies.InverseDynamicStudy.OutputFile.FileName = ā€œResults.txtā€
Main.Studies.InverseDynamicStudy.OutputFile.NumberFormat.Digits = 15
Main.Studies.InverseDynamicStudy.OutputFile.NumberFormat.Width = 22
Main.Studies.InverseDynamicStudy.OutputFile.NumberFormat.Style = ScientificNumber
Main.Studies.InverseDynamicStudy.OutputFile.NumberFormat.FormatStr = ā€œ%22.15eā€
Main.Studies.InverseDynamicStudy.OutputFile.Search =
Main.Studies.InverseDynamicStudy.OutputFile.SepSign = ā€œ,ā€
Main.Studies.InverseDynamicStudy.OutputFile.LineSepSign = ā€œā€
Main.Studies.InverseDynamicStudy.OutputFile.Header.TitleSectionOnOff = On
Main.Studies.InverseDynamicStudy.OutputFile.Header.ConstSectionOnOff = On
Main.Studies.InverseDynamicStudy.OutputFile.Header.VarSectionOnOff = On
Main.Studies.InverseDynamicStudy.OutputFile.Header.ColumnNamesOnOff = On
Main.Studies.InverseDynamicStudy.OutputFile.Header.LinePrefix = ā€œā€

Variables (Column# Name):
col0 Main.Studies.InverseDynamicStudy.t
col1 Main.Studies.InverseDynamicStudy.OutputFile.MA1

Main.Studies.InverseDynamicStudy.t,Main.Studies.InverseDynamicStudy.OutputFile.MA1
8.228333333333334e+000,1.152279162175040e+001
8.234228395061729e+000,8.472963274934349e+000
8.240123456790125e+000,8.179536053784805e+000
8.246018518518520e+000,6.989168447676880e+000
8.251913580246916e+000,7.011439054734605e+000
8.257808641975311e+000,6.979570805405915e+000
8.263703703703706e+000,6.849119799833286e+000
8.269598765432102e+000,6.619917102000356e+000
8.275493827160497e+000,6.379963407977425e+000
8.281388888888893e+000,6.209861820982646e+000
8.287283950617288e+000,6.015577015561753e+000
8.293179012345684e+000,5.773693579202980e+000
8.299074074074079e+000,5.510538800697851e+000
8.304969135802475e+000,5.250166707578463e+000
8.310864197530870e+000,4.996318032141873e+000
8.316759259259266e+000,4.750429233072103e+000
8.322654320987661e+000,4.532733427929192e+000
8.328549382716057e+000,4.332888877174591e+000
8.334444444444452e+000,4.176748984960437e+000
8.340339506172848e+000,4.021825783500026e+000
8.346234567901243e+000,3.889899056118300e+000
8.352129629629639e+000,3.804636958513490e+000
8.358024691358034e+000,3.760812433458339e+000
8.363919753086430e+000,3.774021288179860e+000
8.369814814814825e+000,3.802249186841907e+000
8.375709876543221e+000,3.818056787170664e+000
8.381604938271616e+000,3.838771273279872e+000
8.387500000000012e+000,3.857854456665980e+000
8.393395061728407e+000,3.981725816407132e+000
8.399290123456803e+000,4.130307372772506e+000
8.405185185185198e+000,4.341112643002932e+000
8.411080246913594e+000,4.543857633221432e+000
8.416975308641989e+000,4.704837578772247e+000
8.422870370370385e+000,4.826912852810338e+000
8.428765432098780e+000,4.916899376062960e+000
8.434660493827176e+000,4.964103294583757e+000
8.440555555555571e+000,4.956434423294273e+000
8.446450617283967e+000,4.864077374675356e+000
8.452345679012362e+000,4.706669556813004e+000
8.458240740740758e+000,4.505345796247612e+000
8.464135802469153e+000,4.265898947564399e+000
8.470030864197549e+000,3.991969842518053e+000
8.475925925925944e+000,3.705093105935839e+000
8.481820987654340e+000,3.458654393892088e+000
8.487716049382735e+000,3.388556916910625e+000
8.493611111111131e+000,3.337545177662601e+000
8.499506172839526e+000,3.275143328749369e+000
8.505401234567922e+000,3.224129064711963e+000
8.511296296296317e+000,3.181825025195265e+000
8.517191358024713e+000,3.157559169309657e+000
8.523086419753108e+000,3.123200985551668e+000
8.528981481481504e+000,3.052793194001214e+000
8.534876543209899e+000,2.941252509902689e+000
8.540771604938295e+000,2.809929718883913e+000
8.546666666666690e+000,2.202127372247476e+000

That’s good to hear.

SepSign is used to define how you want the values to be separated. For example it can be a comma or a tab or etc. If you press F1 on the ā€˜AnyOutputFile’ it will bring you to the help on this class and all options.

You can also control the number format by adjusting the following values:

Main.Studies.InverseDynamicStudy.OutputFile.Number Format.Digits = 15
Main.Studies.InverseDynamicStudy.OutputFile.Number Format.Width = 22
Main.Studies.InverseDynamicStudy.OutputFile.Number Format.Style = ScientificNumber
Main.Studies.InverseDynamicStudy.OutputFile.Number Format.FormatStr = "%22.15e"

Regarding more muscles - you can simply add more values like you did for MA1.

Regards,
Pavel

Pavel

I’m running the full model and the data file is being generated step by step. This is great! Thank you very much.

I was curious how did you get this code? Main.Studies.InverseDynamicStudy.OutputFile.Number Format.Digits = 15

When I hit F1 as you suggested, i only found this information, but not any recommendations for code.

[LEFT]AnyIntVarNumberFormat.Digits Const Number of digits in output. Disregarded if smaller than one. 15[/LEFT]

2 -----------------------------

Pavel

There is another area that I was looking at about 6 months ago. This was to generate a data file of the external forces and moments on the L5/S1. That is the forces and moments if there were no muscle forces acting on the joints. The solution then was to turn off all the muscles in one of the AB files. The problem with this solution is that would require running the model twice for the research i’m doing. Once to get the ouputs with the muscles, and the second time to get the outputs without the muscles. Like I mentioned before there are over 600 trails, and running them twice is over 1200 times.

So I was wondering if we can take a look at this and see if ther is a way this could be done in the code to run the model once and get both outputs, (1) the forces and moments on the L5/S1 that includes the forces of the muscles, and (2) the L5/S1 forces and moments that do not include the muscle forces on the joints.

3------------

Another thing that takes a lot of time is to try to adjust the intitial joint angles, and sometimes move the green markers closer to the blue markers. Do you have any recommendations how this can be done faster. When I run ā€œinitial conditionsā€ the bones move to the right spot, but when I run the model it still doesn’t complete. So this is why I adjust the joint angles and sometimes move markers.

So I was thinking since running initial conditions puts the bones in the initial position, is there a way those joint angle values could be placed in these folders
[SIZE=3]#include[/SIZE] ā€œModelSetup.anyā€
[SIZE=3]#include[/SIZE] ā€œTrialSpecificData.anyā€
automatically instead of adjusting the joint angles and markers by hand.

Or maybe I’m just doing things the hard way?

Sincerely thanks
Damon

Hi Damon,

Glad to hear that it is running.

  1. I just copied this block from the output that you posted. Essentially this part is up to you - try changing it to suit your needs or just leave it to be default. You can always try playing around with it on a very small example from the reference manual and see what it does and what fits best.

  2. As I mentioned before - the beauty of AnyScript that you can automate almost anything you want. You can use AnyBodyCon.exe to run AnyBody model externally, say from Matlab, and supply parameters programmatically. Please check it in the tutorials: Interface Features->The command line application.
    Secondly, you can use pre-processor commands to change your model configuration by adding just one line like #define MyConfig 1. You are already familiar with this technique from 0/1, 1/0 configs in the GFB model, but the next step to add conditional checks (getting a bit more advanced).

I’ll post a small example here and you’ll need to develop on that yourself.


#ifndef MusclesOff
  #define TRUNK_SIMPLE_MUSCLES 1
#else
  #define TRUNK_SIMPLE_MUSCLES 0
#endif

By replacing normal trunk muscle definition with this block in the BodyPartsSetup.any you can simply run your model twice externally by supplying MusclesOff or not supplying it. This way you can process all your models in a batch mode.

  1. You could probably develop a script to get these initial conditions automatically from the positions of your markers. That would require a fixed set of them for all trials and a little bit of programming.

You would need to overwrite a TrialSpecificData.any from your script or make an include file that would contain computed values.

If you have that - you can return to answer 2 and run everything at once.

Another option is to go quickly through your trials and update TrialSpecificData.any for each of them. Then use ā€˜2’ to run everything automatically from the console application. (that it probably the quickest option and easiest for you).

So what you need for now is:
a) well structured folders with unique trialspecificdata.any
b) anymacro file that runs all studies and trials (or a matlab script that writes such file and calls the console applicatin).

Then it can be done rather quickly and left, for example, overnight or for the weekend.

Maybe the explanation is a bit cumbersome, but I hope you get the idea (let me know what you do not understand from this quick answer). And please take a look at the tutorial.

Best regards,
Pavel

[LEFT]Hi Pavel[/LEFT]

[LEFT]Thanks this is great to hear of the possibility of speeding this processing up. I looked at the turtorial, ā€œInterface Features->The command line application.ā€ I don’t see how this allows me to run a batch, several C3D files in series, or to run the same C3D file with muscles on and then with muscles off?[/LEFT]

[LEFT][COLOR=black][FONT=Verdana]a) I think I already have this trialspecificdata.any, since I started with the GaitFullBody model.
b) [FONT=Verdana][COLOR=black]Im not sure where to start with this? ā€œdevelop the [/FONT][/COLOR]anymacro file that runs all studies and trialsā€[/LEFT]
[/COLOR][/FONT]

LEFT I tried to turn off the trunk muscles, by changing theTRUNK_SIMPLE_MUSCLES[SIZE=3] to ā€œ0ā€[/SIZE] BodyPartsSetup, and the program skipped.[/LEFT]

From this code:

[SIZE=3]// Trunk: 1 included, 0 not included
// *********************************
[/SIZE][SIZE=3]#define[/SIZE] TRUNK 1
[SIZE=3]// This is just the bones,
// Choose one of the following options to add muscles
[/SIZE][SIZE=3]#define[/SIZE]TRUNK_SIMPLE_MUSCLES1
[SIZE=3]// Additional stiffness in the lumbar joints can be added.
[/SIZE][SIZE=3]#define[/SIZE] TRUNK_DISC_STIFFNESS_NORMAL 0

To this code:

// Trunk: 1 included, 0 not included
// *********************************
[SIZE=3]#define[/SIZE] TRUNK 1
[SIZE=3]// This is just the bones,
// Choose one of the following options to add muscles
[/SIZE][SIZE=3]#define[/SIZE]TRUNK_SIMPLE_MUSCLES 0
[SIZE=3]// Additional stiffness in the lumbar joints can be added.
[/SIZE][SIZE=3]#define[/SIZE] TRUNK_DISC_STIFFNESS_NORMAL 0

[LEFT]For (3) The way I have been starting the trails, is to go to TrialSpecificData.any and adjust the joints as best I can, and then upload the model to see how well the bones fit. Then I run the ā€œInitial Conditionsā€ . Then I run the model. [/LEFT]
All of this takes some time to adjust all these joints . Is there was a way to change the TrailSpecificData.any values by using the Intial Conditions values. What do you think? {Pavel, scratch this, or better said ignor this itch, since once initial conditions has run i think the model is in the correct starting frame to start the ā€œMotionAndParameterOptimizationModelā€}

[LEFT]4) This is another area which also causing the process of the trails to be very slow. When I import the C3D files from Vicon, sometimes there is vibration type noise in the markers that cause the AnyBody model to run slow or sometimes stop running. To solve this I’m thinking to use the Vicon Nexus Butterworth Filter for Trajectories after labeling the trail. The Vicon capability has a Fourth Order (Zero Lag), and a Second Order (With Lag), and for both of these the Cut-Off-Frequency can be adjusted from .01 to 1000. I want to be careful not to over filter the true trajectory data, but also need to remove the noise. So what would you recommend, the Fourth Order (Zero Lag), or the Second Order (With Lag)? And at what Cut-Off-Frequency would you recommend?[/LEFT]

Sincerely thanks
Damon

Hi Damon,

AnyMacro file may look like (that’s just an example, you would need to create your own):

load "bikemodel.main.any"
operation Main.Bike2D.Study.InverseDynamicAnalysis
runmacro   "SaveMacroOperation-Save.anymcr"
run
exit

So for your example you can run the inverse dynamics analysis for all trials by using something like:


load "..\Folder1\Model1.main.any"
operation Main.Long_Path_Here.InverseDynamicAnalysis
run
load "..\Folder2\Model2.main.any"
operation Main.Long_Path_Here.InverseDynamicAnalysis
run
...
load "..\FolderN\ModelN.main.any"
operation Main.Long_Path_Here.InverseDynamicAnalysis
run
exit

Where N is the number of trials and each Folder(1…N) contains TrialSpecificData.any and the optimized motion. All the trials can contain shared configuration #include file that would be one level up in the folders and, therefore, controlled simultaneously.

What I mean is that you can replace a block:

//**************************************************
#ifndef MotionAndParameterOptimizationModel

#define MotionAndParameterOptimizationModel 0  

#endif
//Set this to 1 if you want to run the inverse dynamic analysis
#ifndef InverseDynamicModel

#define InverseDynamicModel 1

#endif

by

#include "../config.any"

, which, in turn, will be shared by all trials. (that probably explains a bit the ā€˜well structured folders’)

Another way is to include a shared configuration file, which will overwrite the values. Basically this way is better because you will localize possible problems in your shared file. It would need to use an #undef pre-processor command:


#undef MotionAndParameterOptimizationModel
#define MotionAndParameterOptimizationModel 0  

#undef InverseDynamicModel
#define InverseDynamicModel 1

This block will force your models to run in the inverse dynamics mode. Similarly you can control the body parts. But please note that such #include file needs to come after the definition of values.

So the description is a probably a bit cumbersome if you haven’t done something like that. So let us start with a simple homework example (that will be self-explainable).
Task:
a) Create 2 models, which share a configuration file: (i) body part, e.g. TRUNK_SIMPLE_MUSCLES - sets to 0 and 1, (ii) InverseDynamicsModel switch.
b) Write an AnyMacro file that can be run from the AnyBody console application and execute both of the inverse dynamics studies.
c) Try running it.

Regarding the filters: You would need to test it yourself as the Cut-Off frequency will be experiment-specific. The easiest way is to try different settings and see whether you are happy or not.

Best regards,
Pavel

Hi Pavel

For each trail I have a seperate folder with a GaitFullModel in each folder with a trail specific C3D file. I’ve been doing this way for these reasons:
-There are 31 subjects so the subject heights and weights are different, so that makes 31 different folders,
-Then for each subject there are 24 similar but different activities, so now that is 31x24 different ā€œmodelā€ folders. Once I do the MotionParameterOptimizationModel, I want to keep the bone model for each unique trial, so I won’t need to spend time to re-run the MotionParameterOptimizationModel if I want to run the Optiization again.

  • I do this is so I can for example make chanes to the polynomial value for optimization and then re-run the InverseDynamic Model model without having to re-run the MotionParameterOptimizationModel.
    -Also by haveing a folder for each trial I think it is easier for me to keep track of the different trails.
    -doing this does take some extra storage space, but this is not a problem.

So I’m wondering how/if this would work with the methods you just explained?

I still would like to have a separate model file for each trail, and be able to automatically run several trails automatically in a batch over the weekend or for ever short it takes to run the over 600 trails, which I would also like to run the model with and without muscles during that batch (1200 trails??), and save the L5/S1 kinetics with muscles and without muscles during that batch run. What do you think, does my single model file approach interfer with improving the processing efficiency?

a) Or can I, Create 2 models by using two of my trails, which share a configuration file: (i) body part, e.g. TRUNK_SIMPLE_MUSCLES - sets to 0 and 1, (ii) InverseDynamicsModel switch?
b) And by using two of my GaitFull models can I, Write an AnyMacro file that can be run from the AnyBody console application and execute both of the inverse dynamics studies?
d) or is constructing this way not the best way?
e) Also, what is ā€œconsole applicationsā€, is there a turtorial or webcast that explains this?

Sincerely thanks
Damon

Hi Damon,

it is a yes for a.) and b.) and for e.) there is a tutorial in ā€œInterface Features Lesson 5: Command Line Application (=console)ā€

for your structure, can I ask you some questions?
Have you managed to run all models already once? Do you only want to run them again in one batch?

About the function of a C3D driven model:
in the MotionAndParameterOPti you use the C3D file, you scale the model and optimize the motion, all the results are then saved in text files. The optimized Parameters as segment lengths and information for the joint axis and centers are saved in the ā€œxxx-processed-OPtimizedParamters.txtā€. The joint angles of the left leg are saved in the ā€œxxx-precessed-leftlegtd.txtā€ā€¦
Once you have done the MotionAndParameterOpti once and the model created the txt files, there is no need to do it again.
The InverseDynamics Study will then use only the data from the txt files. When loading, it will scale the model according to the segment lengths from the text file and drive/move the body model using the joint angles from the text files.
So you need C3D file, those text files, height and weight and the initial guess on the position of the model for each different trial, there is no need to have the complete model copied into 31*24=744 folders. But that is not a big problem, usually the C3D requires most of the space.

Hi Pavel, Amir

Thread 1 of 2.
I re-wrote this, I hope this will make more sense,

This is what I plan to do;

For each subject, I adjust the initial joint angles for two trails, one trail the body is at a lower position at a lower shelf, and the other trail the body is at a higher position for the placement of the box on the upper shelf. Once I do this an run the optimization for the bones and muscles I know I have two good models for the two different body positions. Then i use these two template models to create model files for the other 22 trails for that subject (i.e. each subject did 24 trails). The 24 differnt files are created by copying the model file, and changing the C3D file. This process is done for each of the 31 subjects. At the end I have a total of 744 unique model files, 24x31. Two trails from each subject have been completed (bones and muscles), and 22 trails from each subect have not been ran yet. So I still need to run 682 trails

So with these 682 trails (model files) I’d like to:

  1. Batch run all of them to create the bones.
  2. Then batch run them using the optimization polynomial 3 critera to create all of the muscles and the L5/S1 data.
  3. Then batch run them again with a different optimization criteria to re-create all the muscles and the L5/S1 data.
  4. Then batch run them to derive the external kinetics only (no muscles on the joints).

So how do you suggest I start developing the programming for this?

Sincerely thanks
Damon