# How to average gait cycles?

Dear AnyBody:

I have a general question regarding using AnyBody to perform musculoskeletal modeling. Typically, the user choose the beginning and the end of a gait cycle, within which all variables (moments/forces) will be calculated. However, as shown in the attachment, there are always substantial cycle-to-cycle variances. Is it possible to let AnyBody run for a few cycles, and then output the average of kinematics/kinetics from those cycles?

thanks,
-Phoebe

Dear Phoebe,

Not out of the box. The question is indeed tricky, because as you say yourself there is some variability even within cycles. You would need to extract start/end time, which may vary as well, and normalize all cycles to, say, 0-50-100 percent phase. This information is not intrinsic and needs to be computed. It is probably easier to do externally through Python/Matlab scripts.

It is also possible to treat these different cycles as new trials and just split all of them (using tStart/tEnd). Then when postprocessing the output - average by the subject/c3d file name.

Kind regards,
Pavel

thanks Pavel. I shall investigate all the available approaches and report what I find to the community.

-Phoebe

Hi Pavel,

Can Anybody determine the start and end of each gait cycles timing and store it in the C3D file? Or those are defined by the user and AnyBody only does kinematic/kinetic calculation based on the selected frame(s)?

Thanks,
-Phoebe

Hi Phoebe,

No, those should be defined by the user at this point.

Kind regards,
Pavel

Hi Pavel,

Can AnyBody read ascii files instead of c3d files, which include trajectory information of the physical markers and FP reaction forces?

Thanks,
-Phoebe

Hi Phoebe,

Yes, of course. But you would need to implement your own soft marker drivers.

Pavel

Hi Pavel,

Thank you for your reply!

As shown in the picture, I calculated the mean and standard deviation of the trajectories of each marker (the figure shows the Z- motion of the LKNE) during multiple cycles. Time was normalized to be between 0 to 100. GRF was processed in a similar way.

I haven’t found a way to rewrite the data (ascii) to c3d so it can be directly read by AnyBody. If AnyBody can read kinematic information of the markers and the kinetic information of the FPs it will be great! Your thoughts are suggestions are greatly appreciated.

-Phoebe

Not sure if I understand what you meant by “soft marker drivers”.

Usually I will pick one cycle of this c3d file to run AnyBody. Now, I would like to use the average of multiple cycles of the same c3d files to drive AnyBody. I can get the kinematic info (i.e., markers’ trajectories) and kinetic info (i.e., GRFs), both of which are in acsii format. If I didn’t specify soft marker drivers when using normal c3d input, is it still necessary to specify them when using an acsii file derived from that same c3d file?

Thanks!
-Phoebe

Hi Phoebe,

It is not a good idea to use average data as input to the analysis in AnyBody, for several reasons:
• For a segment with two markers on, in one trial their distance will be constant, after averaging of data this is no longer the case.
• After doing averaging on marker data the motion will have changed and there is no guarantee it will match the average of the GRF so you may see high residuals.

Best regards
Søren

Agreed. Thanks you Søren!

Hi Søren,

I am trying to use AnyPyTools to perform MS analysis for multiple gait cycles. I have installed AnyPyTools and trying to follow this example. As a new phython user, I am baffled with some (basic) questions. For example:

"
Next, let us run the model from python. First, we import the AnyPyProcess class and create an instance of the class.
In [1]:
from anypytools import AnyPyProcess
app = AnyPyProcess()
"
Am I supposed to type this command? If so, where?

I feel my questions are probably too basic. Is there a video tutorial on running macros in AnyBody to help me with a quick start?

Thanks!
-Phoebe