Using Weight functions in GaitLowerExtremityModel

Hi,

I want to use weight functions to fit gaps in marker data. How can I construct this in the model. If I use
ConstructWeightFunUsingResidualOnOff = Off; i will get this error:
ERROR(OBJ1)
: H:/J.H…ers/C…d/A…n/E…s/G…b/ModelSetup.any : C3DFileData.Points.Markers.LTIB.Weight.Ts : The values in Ts must be monotomically increasing

How can I fix this?

Best regards,

[SIZE=2]Hans
[/SIZE]

Hi Hans,

This error means that the T values of you interpolation function does not increase so in your T data you may have something like this T={0,1,2,1} this would give you this error.

By the way i assume that the ConstructWeightFunUsingResidualOnOff is set to On when you get this error?

It is a bit strange the T vector should in this case automatically be constructed from the same T vector that is used for the markers, so if these data looks ok with this setting set to “Off” it is strange.

Would it possible to upload the C3D so we can have a look at it?

Best regards
Søren

Hi,

I have uploaded the C3D file.

Best regards,

Hans

Hi,

I’m sorry I have zipped the C3D file now.

Best regards,

Hans

Hi Hans,

Thanks for the file, we can reproduce the error.
We will try to run it in a debug version to find out what is the cause.

Best regards
Søren

Hi Hans,

Sorry for keeping you waiting, we have not had time yet to debug it.

Until the problem gets resolved there is actually a way to construct these weight functions manually.

If you set the setting to off the model will load
ConstructWeightFunUsingResidualOnOff =Off

Then you can see the residual values in the C3D file structure for each marker.
Then a weight function can be constructed using the time vector from the markers and the

AnyFunSquareWaveThreshold function which takes in a time vector, a data vector and a threshold value then it creates a smooth wave function for this data that can be used as the weight function. If the setting ConstructWeightFunUsingResidualOnOff had been working on this data set this is exactly what the would have been done automatically.

Please also see
http://www.anybodytech.com/fileadmin/AnyBody/Docs/Tutorials/Making_things_move/lesson6.html

Thanks for your patience…

Best regards
Søren

Hi,

I would like to have an example to construct this function

AnyFunSquareWaveThreshold

Best Regards,

Hans

Hi Hans,

Please find the example attached.

It should have been linked into references manual as one of the script examples in the last release, it will be in the next :wink:

Best regards
Søren

Hi,

I would like to fill in this function what should I state here?

AnyFloat SW3var

Best Regards,

Hans

Hi Hans,

I am not 100% sure what you mean by this question…

AnyFloats are Multi-dimensional floating-point variables so it can be vectors matrices etc…

example:

AnyFloat test={0,0,0,0,1};

In the current example it says:
AnyFloat SW3var = SW3(Main.MyStudy.t);

In this case the SW3Var is vector with three elements because SW3 is a 3 dim interpolation function.

Best regards
Søren

Hi,

I have filled it in now but I do not see any difference in the analysis. It still did not change the weight functions. Do I miss anything?
This is what I have now:

AnyFunSquareWave SW3 =
{
InitialValues = {1.0,1.0,1.0};
Ts = {3.02,4.11};
Values = {{1.0,0.0},{1.0,0.0},{1.0,0.0}};
dT = {0.01,0.02};
};

AnyFunSquareWave SW4 = 
{
  InitialValues = {1.0,1.0,1.0};
  Ts = {3.02,4.11};
  Values = {{1.0,0.0},{1.0,0.0},{1.0,0.0}};
  dT = {0.01,0.02};
}; 


AnyFloat SW3var =SW3(Main.Studies.KinematicStudyForParameterIdentification.t);
AnyFloat  SW4var =SW4(Main.Studies.MotionOptimization.t);

Best regards,

Hans

Hi Hans,

The Values menber is set to make a transition to 1 like the InitialValues, so it may not change the value of the function as you expect. I guess you want it to become zero in the Ts interval and back again to 1 after that. Try this:

Values = {{0.0,1.0},{0.0,1.0},{0.0,1.0}};

Also don’t forget to appliy this function as the weight of the driver in the CreateMarkerClass in replacement of the default one.

Best regards, Sylvain.

Hi,

I do not understand how to apply this weight function in the markerclass. I did not understand this point yet. Could you explain that?

Best regards,

Hans

Hi Hans,

In the marker driver there is a possibility to point at a weigth function.


AnyKinDriverMarker C3Dmotion3 = {
      WeightFun = {&Main.MyModel.C3D.Points.Markers.L002.Weight};
      AnyRefFrame &Marker = .Leg.R3;
      AnyParamFun &Trajectory = Main.MyModel.C3D.Points.Markers.L002.PosInterpol;
      AnyDrawKinMeasure drw = {
        Label = Off;Size = 0.03;Line = Off;
      };

So you will need to make this weight function point at the one you have constructed.

Please also see the tutorial
http://www.anybodytech.com/fileadmin/AnyBody/Docs/Tutorials/Making_things_move/lesson6.html

In the gait models of the repository there is a class which creates the markers and drivers for them see for example the file toolbox/mocap/CreareMarkerClassTD (for TLEM leg markers)

In this file you will find a similar AnyKinDriverMarker object but it has a weight function which has a constant value for the x,y and z directions.

To make use of your weight function in this context(GiatLowerExctremityModel) you will need to modify this constant weigth function and multiply your weight function onto this.

So the best way would be to construct the weight function for all your markers and then point at them in the CreateMakerTDClass

Best regards
Søren

Hi,

Thank you for your explanation but I still did not know how to start in the marker klass. Do you mean that I should make separate weight functions for each separate marker. And What should I construct in the createmarkerclass TD?
This is the current construction in the markerclass:

[SIZE=2]DriverFolder ={

[/SIZE]AnyFolder MarkerName ={

AnyFunConst WeightFun ={Value = {WeightX,WeightY,WeightZ};};

AnyKinDriverMarker Driver = {

AnyDrawKinMeasure Draw = {
Visible = Off;
Opacity = 1;
Label = Off;
Size = 0.01;
Line = Off;
Text = “”;
TextSize = 30;
};

Linear.Ref=0;
AnyRefFrame &ref1 = …InsertionNode1.MarkerName;
AnyParamFun[SIZE=2] &ref2 = Main.ModelSetup.C3DFileData.Points.Markers.MarkerName.PosInterpol;
WeightFun={&.WeightFun};
};

};
};

Best regards,

Hans
[/SIZE]

Hi Hans,

As you can see the code in the CreateMarkerClassTD is generic and is applied to all markers. It is better to keep it this way. The weight function you have to change is the following:

AnyFunConst WeightFun ={Value = {WeightX,WeightY,WeightZ};};

This points at the weight defined individualy for each marker in the ModelSetup file. So the square wave weight funtion should be be defined individualy for each marker as well. I suggest you to do the following. In the CreateMarkerClassTD change the WeightFun to this:

AnyParamFun &WeightFun = Main.ModelSetup.MarkerName.SW3;

Then for each marker in the ModelSetup file add the square wave function that corresponds to it:

CreateMarkerTD <> (
MarkerName=PrefixDef(<>),
MarkerPlacement=Trunk.SegmentsLumbar.PelvisSeg,
OptX=“Off”, OptY=“Off”, OptZ=“On”,
WeightX=1.0,WeightY=1.0,WeightZ=1.0,

Model1=MotionAndParameterOptimizationModel, Model2= InverseDynamicModel
) = {
sRelOpt = {<>};
AnyFunSquareWave SW3 =
{
InitialValues = {<>};
Ts = {<>};
Values = {<>};
dT = {<>};
};
};

If for some of them you still want the constant weight function then add the following function instead:
AnyFunConst SW3 ={Value = {1,1,1};};

That should do what you want.

Best regards, Sylvain.

Hi,

I have changed the code here.

AnyFolder MarkerName ={

AnyFunConst WeightFun ={Value = {WeightX,WeightY,WeightZ};};

AnyKinDriverMarker Driver = {

AnyDrawKinMeasure Draw = {
Visible = Off;
Opacity = 1;
Label = Off;
Size = 0.01;
Line = Off;
Text = “”;
TextSize = 30;
};

Linear.Ref=0;
AnyRefFrame &ref1 = …InsertionNode1.MarkerName;
AnyParamFun &ref2 = Main.ModelSetup.C3DFileData.Points.Markers.MarkerName.PosInterpol;
AnyParamFun &WeightFun = Main.ModelSetup.MarkerName.SW3;

};
};
};

But I receive this errormessage:
[SIZE=1]ERROR(SCR.PRS2)[/SIZE] : [SIZE=1]H:/J.H…ers/C…d/A…n/E…s/G…b/ModelSetup.any[/SIZE] : ‘SW3’ : Object already auto declared by owner : [SIZE=1]Main.Studies.KinematicStudyForParameterIdentification.ModelEnvironmentConnection.Drivers.RTH.Driver
[/SIZE]
What did i do wrong?

Best Regards,

Hans

Hi,

Update of the situation. It is working now. I have filled in all the markernames of the data. And now it is working well.

Best regards,

Hans

Hi,

After adding all functions. It stil follows the gap of the data instead of turning the weight to zero. Why is this?

Best regards,

Hans

Hi Hans,

Well i guess something is still wrong in the code. Regarding to the previous error you should have replaced this line:
AnyFunConst WeightFun ={Value = {WeightX,WeightY,WeightZ};};
by this one:
AnyParamFun &WeightFun = Main.ModelSetup.MarkerName.SW3;
The constant function should be completly removed. Is that what you did?

Best regards, Sylvain.