Simulating unilateral transtibial gait

Hi, I am trying to simulate a walking model where the subject is a transtibial amputee and has an ESAR foot on the right foot.
I am using the MoCap Lower body model with my own C3D file and I also have my own Force Plates included.
I have already removed muscle groups from the model which are inactive in the subject‘s right leg because of the amputition, using „MechObjectExclude“. I put an include file in the Inverse Dynamic study which I named „MusExclude“.
The muscle groups I removed are: [SIZE=1]Soleus, Gastrocnemius, Tibialis, Peroneus, Extensor.[/SIZE]

Now, when I try to run the Inverse dynamic analysis, I get the following error: “ERROR(OBJ.MCH.MUS4) : C:/P…s/A…y/A…0/AMMR/A…n/E…s/TTA0/M…l/M…l/InverseDynamics.any(29) : InverseDynamicStudy.InverseDynamics : Muscle recruitment solver : solver aborted due to singular KKT matrix“

I understand why I get this error, because now the software cannot find a solution how the model is able to carry out the motion without all these muscles.

I’ve been trying to constrain the model, using the FDK method. I‘m not sure if I am doing it correctly. I’ve added Constraints to the SubTalar and Ankle Joint, making the reaction types in y and z direction FDK-dependent.
The Z direction is the vertical direction in my case.
Aslo I have added stiffness to both SubTalar and the Ankle joint.

Here is the code which I’ve edited in the Jnt file, for the right leg:

AnyRevoluteJoint Ankle = {
Axis = z; //flexion extension
//Axis2 = x; //abduction adduction
AnyRefNode &ShankNode = …Seg.Shank.AnkleJoint;
AnyRefNode &FootNode = …Seg.Talus.AnkleJoint;
//ShankNode ={AnyDrawRefFrame drw={RGB={0,1,0};};};
//AnyDrawStdJoint Ankle = { };

    Constraints = {
      CType = {Hard, ForceDep, ForceDep, Hard, Hard};
      Reaction.Type={On,Off,Off,On,On};
    };

};

  AnyForce AnkleStiffness = {
    AnyKinLinear &lin = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.Ankle.Linear;

// //F={Fx,Fy,Fz}, Pos: pos property ur AnyKinLinear maelingunni
F = {-1000lin.Pos[0],0,-5000lin.Pos[1]};
};

AnyRevoluteJoint SubTalar = {
//Axis1 = z; //flexion extension
Axis = z; //inversion eversion
AnyRefNode &TalusNode = …Seg.Talus.SubTalarJoint;
AnyRefNode &FootNode = …Seg.Foot.SubTalarJoint;
//TalusNode ={AnyDrawRefFrame drw={RGB={1,0,0};};};
//AnyDrawStdJoint SubTalar = { };
Constraints = {
CType = {Hard, ForceDep, ForceDep, Hard, Hard};
Reaction.Type={On,Off,Off,On,On};
};
};

  AnyForce SubTalarStiffness = {
    AnyKinLinear &lin = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.SubTalar.Linear;

// //F={Fx,Fy,Fz}, Pos: pos property ur AnyKinLinear maelingunni
F = {-1000lin.Pos[0],0,-5000lin.Pos[1]};
};

Am I using the FDK method correctly?

Might I need to change something else than just how the Ankle and SubTalar Joints work?

And just to clarify, the values I use in the Forces above are just arbitrary values.

Thank you in advance for your help!

Best regards,
Hrefna

Hi Hrefna,

I have taken a quick look at the model.

First of all i think your use of FDK is not correct :wink: for what you want to obtain.

You are right that the model does not run inverse analysis because some dof in the model can not be balanced.

I suggest taking the modeling work in these steps

[ol]
[li]Exclude the muscles[/li][li]Add an artifical engine to the ankle and subtalar joints to enable the model to run. Simply add and AnyReacForce to the two joints, this will create a very strong engine.[/li][li]Make sure the model runs inverse dynamic analysis[/li][li]Add springs to the two joints ankle and subtalar using something like this for the ankle joint same for the subtalar[/li][/ol]
AnyForce AnkleStiffness = {
AnyKinMeasure [COLOR=black]&ref = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.Ankle;[/COLOR]
// //F={Fx,Fy,Fz}, Pos: pos property ur AnyKinLinear maelingunni
F = {-1000*lin.Pos[0]};
};

[ol]
[li]Remove the engine added in step 2[/li][li]Remove the drivers for the ankle and subtalar joints these are now FDK driven. This is done in file JointAndDriversOptimized.any here you need to alter the driver JntDriverRightLegTD so that it is FDK driven. So i think it should look something like this Constraints.CType = {Hard, Hard… ForceDep,ForceDep}; since the last two dof in the driver are the ankle and subtalar joint.[/li][/ol]
Then the model should be ready to run, i recommend doing it one dof at the time, and start with a high stiffness to make it run.

To summarize: What i describe above will remove the muscles and add a stiffness to the two joints in the ankle. Then it will change the driver of the ankle to be FDK, and it should make the model run with possible some tweaks to the stiffness function.

What you tried to do in the script would have altered the joint type so that certain dof in the joint would have been FDK driven so the joint would no longer act as a revolute joint but start to give away on certain dofs, i guess this is not what you wanted?

Best regards
Søren

Hi Soren and thank you for your advice.

I´ve been trying to add “AnyReacForce” to the two joints but I keep on getting errors. I am not quite sure how the format is on AnyReacForce when adding it to a joint and I haven’t found any examples on how to do it.

Could you give me a quick example of how you would add AnyReacForce to a RevoluteJoint?

Also, I have another question. I seems to me that when I change the function of the joints in the right leg, it will also change in the left leg. How can I avoid this? I just want to change the right leg.

Best Regards,

Hrefna

Hi Hrefna,

To apply an AnyReacForce to a joint simple write something like this:

AnyReacForce MyForce={
AnyKinMeasure &ref=.MyJoint; // here you need to make a reference to the ankle joint or subtalar

};

Concerning the right and left side question:

All the changes you did before with FDK looks like they was done inside the “jnt.any” file please return the Jnt.any file to the original state.

Please create a new file containing all your modifications and include the file in your study.

In this file you can write something like this to add the reaction force above.

// make a pointer to the folder you would like to add something to
AnyFolder &MyJointModifications = Main.XX.XX.Right.Leg.Jnt;

MyJointModifications ={

AnyReacForce MyForce={
AnyKinMeasure &ref=.MyJoint; // here you need to make a reference to the ankle joint or subtalar

};

//here you should also add the stiffness functions…

};

in this way you will only modify the right side

Best regards
Søren

Hi Soren,

Thanks for your help.

I can now run the inverse dynamic analysis with no problems by using your method.
What concerns me though is that making the ankle and subtalar joint Force Dependent and excluding muscles in the foot and shank doesn’t seem to have any effect on the force output in the remaining muscles in the leg, it remains constant.
I’ve compared the results to the model where I do not exclude any muscles. Also I’ve tried changing the stiffness in the ankle and subtalar ankle but I still I get the same results.
I would assume that by removing muscles in the shank and foot the remaining muscles in the leg would have to compensate for the loss of muscles.

Do you know why it remains constant?

Best regards,
Hrefna

Hi Hrefna,

For the leg which you do the changes on the results should not be constant.

For the other leg the results will not change because the same GRF is still applied on the same muscle config.

Did you do the comparison on same side as you modified?

The model has a reaction force in the hip to the world that takes up residuals, this is why the models runs also with no arms on.

If you did the comparison on the same side as you did the modifications, then the only reason i can think of is that the modifcations is somehow not effective.

Please ensure that these modifications are included in the study you are looking at, beaware that files can be loaded but still be either used or not used by a study.

Locate the study in the ModelTree and look at the object description of the study, then make sure the muscles you have excluded are not listed and alos that the other items/modification you have added can be seen. You can also check that the muscle activities of the excluded muscles are zero in the output?

Best regards
Søren

Hi Soren,

A few days ago we followed your instructions on how to correctly apply the FDK method.
For the sake of making sure that we are not making any mistakes, below is a quick summary of how we apply the FDK method:

1: We add the following lines of code to the MoCap_LowerBody.main.any file;

AnyFolder &MyJointChanges = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt;
MyJointChanges ={

//Start of block 1:
//The lines below are commented out in step 2.

AnyReacForce ReactionAnkle={
  AnyKinMeasure &ref1 = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.Ankle;
};

AnyReacForce ReactionSubTalar={
  AnyKinMeasure &ref2 = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.SubTalar;
};

//End of block 1

//Start of block 2
//The lines below are commented out in step 1.

AnyForce AnkleStiffness = {
  AnyKinMeasure &lin = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.Ankle;
  // //F={Fx,Fy,Fz}, Pos: pos property ur AnyKinLinear maelingunni
  F = {-2*lin.Pos[0]};
};

AnyForce SubTalarStiffness = {
  AnyKinMeasure &lin = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.SubTalar;
  // //F={Fx,Fy,Fz}, Pos: pos property ur AnyKinLinear maelingunni
  F = {-2*lin.Pos[0]};
};

};
//End of block 2

};

Furthermore, the following line of code is added in the right leg driver in the …Model/JointsAndDriversOptimized.any file

CType = {Hard, Hard, Hard, Hard, ForceDep, ForceDep};

2: We run the motion and parameter optimization of our model, with all of the lines of code above commented out.

3: We run the inverse dynamic analysis with block 2 commented out, as well as the CType = {Hard, Hard, Hard, Hard, ForceDep, ForceDep}; line commented out. We do not comment out block 1.

4: Then, we run the inverse dynamic analysis with block 1 commented out. We do not comment out block 2 and the CType = {Hard, Hard, Hard, Hard, ForceDep, ForceDep}; line.

After that, we open up a new 2D chart, and compare some of the muscles in the right thigh between a model where the muscles in the shank are taken out with a model where the muscles in the shank are not taken out. We do not find any differences. Furthermore, in the model where we have subtracted the muscles in the shank, no force output is displayed in those muscles, which means we must have been successful at removing those muscles.

We are not sure on what we could do next. Do you have any suggestions?

Thanks in advance,
Hrefna

Hi Hrefna

Here are some comments.

Step 3 is not needed at all, the reason why i mentioned the reacforces was just to be able to remove the muscles and still see the model running, so like a debug stage you could say.

Did you swicth on the forcedependent solver in the study you are running?

It sounds strange that you can see muscles has become zero and the others did not change? are you sure you looked at enough muscles and on the same side of the leg?

Please try the following:

[ol]
[li]In a normal gait model remove a muscle and make sure you can see the effect of this on other muscles. note that depending on which one it is you may not see big changes in all other muscles. Alternatively try run the simplearm example from the tutorials with similar changes. [/li][li]In the FDK model you have how does the ankle joint move? is it different than before? it should be . [/li][li]If you change the stiffness does it change anything in the model?[/li][/ol]
Note that you can have anyscript code loaded but not automatically used by a study. So make sure that when you alter the model it is included or referred to by the study you are running.

Best regards
Søren

Thank you for your advice, it has been very helpful.

I am able to run the model with the ankle joint being force dependent but if I also make the subtalar joint force dependent I keep getting an error saying that I have too few constraints.

What I’ve been trying to do now is to change the subtalar joint so it has zero degrees of freedom because the prosthetic foot allows very little eversion/inversion of the subtalar joint.

How can I change this function of the joint?

Best Regards,

Hrefna

Hi Hrefna,

I do not really understand why it says there are too few constraints when you have FDK on the subtalar joint, that is a bit strange, are you sure you handle this dof like the ankle flexion? it should be the same procedure to add fdk to this joint.

Here is howto avoid motion in the subtalar joint.

1 in the kinematic optimization add a driver for this angle and set it to be the value you would like it to be, this is a hard driver so it will not allow it t move, just use an AnyKinEqSimpleDriver on the subtalar joint for this.

2 rerun the optimization of the motion having now with the subtalar joint locked.

3 in the inverse dynamic model you now have no motion in this joint.

Best regards
Søren

Hi Soren,

yes I did exactly the same for the ankle flexion and the subtalar joint when making it force dependent and I am still receiving the same error message: Muscle recruitment solver : solver aborted due to singular KKT matrix.
I have constrained the subtalar joint by adding:

AnyKinEqSimpleDriver RSubTalarConstraint ={
 AnyRevoluteJoint &Jnt = Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.SubTalar;
 MeasureOrganizer = {0};  
 DriverPos = {0.0};
 DriverVel = {0};
 Reaction.Type = {Off};   
 };

To the „ExtraDrivers.any“ file which is located in the Kinematics file.
When I examine the chart view after the Kinematic study then the chart for “Main.Studies.KinematicStudyForParameterIdentification.Output.BodyModel.Interface.Right.SubTalarEversion.Pos” shows zero, so I think I’ve successfully stopped the Eversion motion in the right subtalar joint.

I‘ve tried changing the value of stiffness but as I increase the value of stiffness on the ankle joint then I start getting a different kind of a error message: Muscle recruitment solver : solver aborted after maximum number of iterations.
For example, if I put in the force :
AnyForceAnkleStiffness={
AnyKinMeasure&lin=Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.Ankle;
F={-1500lin.Pos[0]};
};
Then I receive the error Muscle recruitment solver : solver aborted after maximum number of iterations.
But if I change the value to:
AnyForceAnkleStiffness={
AnyKinMeasure&lin=Main.Studies.HumanModel.BodyModel.Right.Leg.Jnt.Ankle;
F={-1000
lin.Pos[0]};
};

Then I receive the error Muscle recruitment solver : solver aborted due to singular KKT matrix.

In Joint and drivers optimized, for the right leg, I changed the following:

#if RIGHT_LEG_TD == 1
AnyKinEqInterPolDriver JntDriverRightLegTD =  {
  FileErrorContinueOnOff = On;
  Type = Bspline;
  BsplineOrder = 4;
  FileName = "../Input/"+OutputFileNamePrefix+Main.ModelSetup.C3DFileData.NameOfFile+"-euler-rightlegtd.txt";
  AnyKinMeasureOrg &HipFlexion = ...BodyModel.Interface.Right.HipFlexion;
  AnyKinMeasureOrg &HipAbduction = ...BodyModel.Interface.Right.HipAbduction;
  AnyKinMeasureOrg &HipExternalRotation = ...BodyModel.Interface.Right.HipExternalRotation;
  AnyKinMeasureOrg &KneeFlexion = ...BodyModel.Interface.Right.KneeFlexion;
  AnyKinMeasureOrg &AnklePlantarFlexion = ...BodyModel.Interface.Right.AnklePlantarFlexion;
  AnyKinMeasureOrg &SubTalarEversion = ...BodyModel.Interface.Right.SubTalarEversion;
  Reaction.Type={Off,Off,Off,Off,Off,Off};
  CType = {Hard, Hard, Hard, Hard, ForceDep, Hard};
  };
#endif

In my attempts to debug this model, I have also tried to remove only two muscle group, namely the Soleus and Gastrocnemius muscles. Then I am able to run the Inverse Dynamic Analysis, however I get the warning “Overloaded muscle configuration.“

Any thoughts on what might be wrong?

Am I correct in thinking that I should not have to make the subtalar joint FDK as I have already constrained him?

And one last thing, don’t I have to exclude the muscles also from the calibration file or is it sufficient to use MechObjectExclude in the inverse dynamic study ?

Hi Hrefna,

Sorry for the slow reply

[ol]
[li]It sounds as the extra drivers are applied correctly and the subtalar motion is initially now driven to be zero. [/li][li]When you run the inverse study this driver needs to be taken out of the study, otherwise you still have a hard driver on the subtalar joint which will not allow the FDK to find the static equilibrium of this DOF. Se more about the assumption on the FDK and it limitations here http://www.anybodytech.com/fileadmin/AnyBody/Docs/Tutorials/chapX_ForceDependentKinematics/lesson3.html [/li][li]So the FDK works by ensuring Static (not dynamic) equilibrium around the dof in question, and to be able to do this it needs to be able to actually move to balance the external moment applied. [/li][li]Just an idea to debug the model maybee try to exclude the forceplates, to see if this makes it run [/li][li]The two different error messages on the recruitment are essentially meaning the same thing, basically the solver did not succeed in creating equilibrium [/li][li]In the file “***euler-rightlegtd.txt” Check that the position of the subtalar joint is indeed zero as you would expect it to be. [/li][li]The setting for the subtalar joint should FDk so CType = {Hard, Hard, Hard, Hard, ForceDep, ForceDep};[/li]Otherwise the joint is driven to a fixed position and not allowed to move away from this pos, and since there are no reactions on the dof and no muscles anymore, just a spring it has no means to make a balance, because the position would be prescribed to a fixed value.
[li]The stiffness you list the last posting relates to the ankle joint not subtalar joint, you need the same type of spring on this joint.[/li][/ol]
I hope some of these item may allow you to move on otherwise please write again.

Best regards
Søren