Forums Anyscript.org  

Go Back   Forums Anyscript.org > Professional Forum > Debug model

Notices

Reply
 
Thread Tools Display Modes
  #21  
Old 08-02-2017, 12:01 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default GM Foot Model

Hi Søren, thank you for your reply,

Does the timestep refer the the time of the starting frame, or the duration of the tStart to tEnd divided by the number of steps?

I see the repo model uses tStart as the initial heel contact at the starting point and runs for 685ms, but the pressure data has only 650ms of data.

Also, in the Environment.any..

Code:
#if FirstRun == 1
    AnyFunEx PressureFun = 
    {
      AnyVector Return = .FootPressureNodeCoeffVecInitial;
      AnyFunExMonoPy PressureFunction =
      {
        ModuleFile = "Final2.py";
        ArgList = 
        {
          AnyMatrix Mat = ...FootPressureNodeMatInitial;
          AnyFloat Time = 0;
          AnyString path = " ";
        };
      };
    };
  
    AnyVector FootPressureNodeCoeffVec =  PressureFun(FootPressureNodeMat, Main.Studies.InverseDynamicStudy.t - Main.Studies.InverseDynamicStudy.tStart, Main.FootPrintFolderPath + "/Input/" + Main.TrialSpecificData.NameOfFile + "-PressureData.txt");
what does the Time in ArgList refer to? does it allow me to off set the start time of the pressure data by say 0.001 or 1 ms so it reads 11ms 21ms 31ms instead of 10ms 20ms 30ms?

Lastly, for some of the vectors/nodes in anybody - they seem to have an offset in the python scripting which is consistent throughout which effects location of, for example the StrikeNode in the Environment.any file

The offset is either
Code:
0.049+(Rb+0.5+i)*CellL
or
Code:
0.4 -0.049 -64*CellW + (Rl+0.5+i)*CellW
Which in final2.py is also applied to
Code:
cell0 = [0.4 -0.049 -64*CellW + (Rl+0.5)*CellW, 0.049 + (Rb+0.5)*CellL, 0] #theoretical value
In the Environment.any I've rotated each of the location nodes, as the foot location was facing the wrong way on the platform like so:

Code:
 AnyFolder &GlobalRef = .GlobalRef;
    GlobalRef = {
      AnyRefNode StrikeFootRef = {
        sRel = {..FootLocationCooVec[0] -0.65, ..FootLocationCooVec[1] -0.88, 0}*RotMat(-pi,y)*RotMat(-pi,x);
        AnyDrawNode Draw = {ScaleXYZ=0.005*{1,1,1}; RGB={1,0,0};};
      };
As these foot location nodes have the offset of
Code:
 #First time step CoP, correspond to heel strike location
    #******************************************************* Step1Vec = Data[0][1:]
    
    LongWeightedStep1Vec = []
    for i in range(Rh):
        LongCoo = 0.049+(Rb+0.5+i)*CellL
        for j in range(Rw):
            LongWeightedStep1Vec.append(Step1Vec[i*Rw+j]*LongCoo)
    
    LongCooStrike = sum(LongWeightedStep1Vec)/sum(Step1Vec)
    
    LatWeightedStep1Vec = []
    for i in range(Rw):
        LatCoo = 0.4 -0.049 -64*CellW + (Rl+0.5+i)*CellW
        for j in range(Rh):
            LatWeightedStep1Vec.append(Step1Vec[j*Rw+i]*LatCoo)
    
    LatCooStrike = sum(LatWeightedStep1Vec)/sum(Step1Vec)
So i was wondering how i can apply the same logic to

Final2.py..

Code:
 # Create the matrix of pressure cells global coordinates (size [i][3])
    #*********************************************************************
    cell = []
    cell0 = [0.4 -0.049 -64*CellW + (Rl+0.5)*CellW, 0.049 + (Rb+0.5)*CellL, 0] #theoretical value
    #cell0 = [0.4 -0.049 -64*CellW + (Rl+0.5)*CellW, 0.049 -0.01 + (Rb+0.5)*CellL, 0] #with offset
    for h in range(Rh):
        for w in range(Rw):
            cell.append([cell0[0] + CellW*w, cell0[1] + CellL*h, cell0[2]])
and rotate/translate this to match the rotation and translation i've applied to the location nodes, but I am not quite sure how.

I am able to run a complete inverse dynamics simulation, but again the pressure nodes are not visible. to do this I change:

Code:
 # Create the matrix of pressure cells global coordinates (size [i][3])
    #*********************************************************************
    cell = []
    cell0 = [0.4 -0.049 -64*CellW + (Rl+0.5)*CellW, 0.049 + (Rb+0.5)*CellL, 0] #theoretical value
    #cell0 = [0.4 -0.049 -64*CellW + (Rl+0.5)*CellW, 0.049 -0.01 + (Rb+0.5)*CellL, 0] #with offset
    for h in range(Rh):
        for w in range(Rw):
            cell.append([cell0[0] -0.2 + CellW*w, cell0[1] - 0.3 + CellL*h, cell0[2]])

Thank you very much for your time Søren, I feel like I am getting close to a working model...

Best Regards,
Zach
Reply With Quote
  #22  
Old 08-03-2017, 11:40 AM
toerholm's Avatar
toerholm toerholm is offline
AnyBody Support
 
Join Date: Feb 2009
Posts: 865
Default

Hi Zach,

As i recall it the timestep is the time obtained from from the study, so the study ask the python code to return the loads associated with the current time value of the study.

In the experimental data there could be differences in the starting time between pressure and mocap. The pressure data always has first data at heel strike so there could sometimes be a need to adjust the starting time to macth the data.

The

Code:
AnyFloat Time =0;
is the initial value of the timestep argument it needs to be provided... it could also have been written as
Code:
AnyFloat timestep  =0;
it would have been the same.


The demo model has the following time settings:

C3D data: starts at 0.85 to 1.62 sec (0.77 sec total)
Pressure data: starts at 0 and goes to 0.65 sec (0.65 sec total)
Study: starts art 0.955 and goes to 1.6 sec (0.645 total ) (see the tstart and tend in modeltree of the loaded model)

The starting time of the study has been adjusted so that the analysis starts at heel strike, since this is when pressure data is availble... and it has been cut in the end since swing phase has no pressure.

The offsets you find in the files relates to the location of the pressure plate in the lab so it needs to be changed accordingly to match your settings.


I am not eaxtly sure how to do this in your case but i would think changing the offsets values in the same way in the .any and .py files should have been enough. Possibly it could be easier to make it in the same way in .any and .py if you avoided using the rotmat it is basically a grid layout, which needs to be located correctly ;-)


Best regards
Søren
__________________
TIP: How to save and load results.
http://wiki.anyscript.org/index.php/All_about_AnyBody_Modeling_System#Save_Load_and_Re play_Results

Subscribe to the forums, click the 'Forum Tools' link above the list of threads then select 'Subscribe to Forum'. You will then have the option to choose the subscription mode for this forum and get an email automatically.

Last edited by toerholm; 08-03-2017 at 11:50 AM.
Reply With Quote
  #23  
Old 08-14-2017, 10:46 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default GM MoCap Model

Hi Soren, thank you very much for your knowledge.

It seems I have got the model reading the Pressure data per time step in the inverse dynamic study, with only one slight problem...

The pressure data is being distributed backwards in that the posterior foot strike (from the pressure file) is starting at the toe and then the toe off (from the pressure file) is ending at the foot.

When I invert the file so that the heel is at the bottom of the pressure matrix this does not work.

I was wondering if you could maybe explain how to rotate the C3D and force platform so that they are pointing in the same direction as the pressure matrix?

Or how to rotate the pressure matrix in the AMS? Although, I have wrestled with this for some months now.

This is obviously not ideal, but will be an interim solution until I am able to collect a new trial with GM marker set up in the gait lab.

Many Thanks,
Zach
Reply With Quote
  #24  
Old 08-15-2017, 10:35 AM
toerholm's Avatar
toerholm toerholm is offline
AnyBody Support
 
Join Date: Feb 2009
Posts: 865
Default

Hi Zach,

To change the layout of the force plate you will need to alter the forceplate class and rotate the plate in there by changing the corner nodes.

The maker data is more difficult to change since the marker driver is essentially a distance measure between a local coordinate system in the marker and the 3d trajectory data. So the only option would be to actually change the c3d file data which is not so easy i guess.

To rotate the pressure plate you will need to modify the .py files as you already know.

This will have to be done in the Final2.py in these lines

Code:
# Create the matrix of pressure cells global coordinates (size [i][3])
    #*********************************************************************
    cell = []
    cell0 = [0.4 -0.049 -64*CellW + (Rl+0.5)*CellW, 0.049 + (Rb+0.5)*CellL, 0] #theoretical value
    #cell0 = [0.4 -0.049 -64*CellW + (Rl+0.5)*CellW, 0.049 -0.01 + (Rb+0.5)*CellL, 0] #with offset
    for h in range(Rh):
        for w in range(Rw):
            cell.append([cell0[0] + CellW*w, cell0[1] + CellL*h, cell0[2]])
    
    #print cell
Maybe in your case it should be

Code:
    
           cell.append([cell0[0] + CellW*w, cell0[1] - CellL*h, cell0[2]])
I can not remember all details anymore but there could other .py files where the same change would have to be done.

Best regards
Søren
__________________
TIP: How to save and load results.
http://wiki.anyscript.org/index.php/All_about_AnyBody_Modeling_System#Save_Load_and_Re play_Results

Subscribe to the forums, click the 'Forum Tools' link above the list of threads then select 'Subscribe to Forum'. You will then have the option to choose the subscription mode for this forum and get an email automatically.
Reply With Quote
  #25  
Old 10-16-2017, 06:09 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default Force Platform and Pressure platform integration - sampling rate query

Hi Søren,
It's been a while since we last spoke.

After your reccomendations and insights to study times, I've successfully run the GM model scaling most of the bones individually (from MR images segmented with a shape model), using the GM marker protocol. Also i've used an AMTI force plate and also using EMED pressure inputs (this required me to construct a Type2Pressure plate + a few extra python scripts to fomat data from EMED to a text file readable by Anybody... Because the GM model didn't have enough python scripts already...

I believe the combination of these three inputs is different from the original model - which scales based on surface scans, collects gait and force information using a kistler platform and uses RSScan for the pressure inputs as a Type3Pressure plate

One question I have is on the sampling rates of the force and pressure data. Could you maybe explain how the anybody system accounts for differences in sampling rates between the pressure data and the gait/force data? If it does at all?

Thank you for your time and reccomendations Søren, the model development seems to be progressing well.

Thanks,
Zach

Last edited by Zach_Welshman; 10-16-2017 at 06:19 PM. Reason: Clarification
Reply With Quote
  #26  
Old 10-17-2017, 10:57 AM
toerholm's Avatar
toerholm toerholm is offline
AnyBody Support
 
Join Date: Feb 2009
Posts: 865
Default

Hi Zach,

Sounds really good that the modelling is progressing well, i know this is not an easy task.

Concerning the sampling rate, this is handled using interpolation functions all data are read into interpolation functions and when AnyBody is running it can be done with many or few nStep's, independently of the sampling freq.

Best regards
Søren
__________________
TIP: How to save and load results.
http://wiki.anyscript.org/index.php/All_about_AnyBody_Modeling_System#Save_Load_and_Re play_Results

Subscribe to the forums, click the 'Forum Tools' link above the list of threads then select 'Subscribe to Forum'. You will then have the option to choose the subscription mode for this forum and get an email automatically.
Reply With Quote
  #27  
Old 10-17-2017, 01:23 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default Force Platform and Pressure platform integration - sampling rate query

Hi Søren,

It has been a challenging model to work with and I have a deep appreciation for the work that went into this model initially. It's been fun integrating the inputs into the model - even with the accompanying headaches.

Do you mean that the force data and pressure data are interpolated? And when it is interpolated, how many points are generated? Does the model control for upsampling and /or downsampling?

I hope this makes sense.

Many Thanks,
Zach
Reply With Quote
  #28  
Old 10-23-2017, 11:30 AM
toerholm's Avatar
toerholm toerholm is offline
AnyBody Support
 
Join Date: Feb 2009
Posts: 865
Default

Hi Zach,

In all AnyBody models the data are being used though interpolation functions.

Normally the interpolation functions will be constructed using the full number of data points recorded.

When running a study you will set the nStep you can choose to use the full number of nStep fromt he recoding, but normally we will choose to downsample the by using a lower nStep value. Note that the time steps in AnyBody are independent so the results for a given time value does not depend on the previous steps, though there is lower limit of nStep if the motion is large... because the previous positions are used as initial guesses for the starting position.

Best regards
Søren
__________________
TIP: How to save and load results.
http://wiki.anyscript.org/index.php/All_about_AnyBody_Modeling_System#Save_Load_and_Re play_Results

Subscribe to the forums, click the 'Forum Tools' link above the list of threads then select 'Subscribe to Forum'. You will then have the option to choose the subscription mode for this forum and get an email automatically.
Reply With Quote
  #29  
Old 11-18-2017, 11:23 PM
basialys2 basialys2 is offline
Junior Member
 
Join Date: Oct 2017
Posts: 5
Default altering Foot location and Final2 functions

Dear Zach and Soren,

thanks to your conversation I was able to solve many problems I had on the way to make my GM foot model run. I am already able to load my model with #define InverseDynamicModel and #define FirstRun switched to 1. However I still need to work on reading pressure data. I was trying to analyze Footlocation and Final2 python files but there are some places when I am not sure how to change the code to work nicely with my data. The biggest concerns are about the line

LongCoo = 0.049+(Rb+0.5+i)*CellL
and
LatCoo = 0.4 -0.049 -64*CellW + (Rl+0.5+i)*CellW

I know the numbers in expressions concern foot location offset but do you have any hints how to set this numbers no work on my model? Does any number mean something exactly?
Reply With Quote
  #30  
Old 11-20-2017, 04:31 PM
toerholm's Avatar
toerholm toerholm is offline
AnyBody Support
 
Join Date: Feb 2009
Posts: 865
Default

Hi Claire,

I will try explain though it is far away in mind ...

The data expected is not all cells but a square, which covers the footprint...

The location of this square wrt to the full plate is given by Rb which stands for rectangle bottom, and Rl which is retangle left. these number are cell numbers... so an integer counted from the lower left corner of the plate.

CellW and CellL are cell dimensions.

The other values are some numbers which must be related to the specific setup in the lab, those you most likely need to change.

It is important that these locations are correct so i would try to visualize the data you create inside AnyBody together with the foot to see if it makes sense.

Hope it helped.

Best regards
Søren
__________________
TIP: How to save and load results.
http://wiki.anyscript.org/index.php/All_about_AnyBody_Modeling_System#Save_Load_and_Re play_Results

Subscribe to the forums, click the 'Forum Tools' link above the list of threads then select 'Subscribe to Forum'. You will then have the option to choose the subscription mode for this forum and get an email automatically.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:56 PM.