In the GaitLowerExtremityModel it’s possible to generate a csv file to save the output, but I want to save the raw marker points as a csv file too. How can I do this? Because if I try to save marker coordinates now it will not be stored.
Markerpos will simply write the entire matrix in one cell. Markerpos2 will write the usual line with time, x component, y component, z component for each time step.
I was looking for a method to save all the muscle activity after performing Inverse dynamics in a CSV file.
I searched a bit in the forum and repositories and figured out a way to save individual muscles in the same CSV file. Below is the sample of my code to save it:
AnyOutputFile FileOutput = {
// Write output to a csv file with the number of steps in filename
FileName = "vOutput/TestOutput_"+Main.TrialSpecificData.NameOfFile+ ".csv";
Header = {
TitleSectionOnOff = Off;
ConstSectionOnOff = Off;
VarSectionOnOff = Off;
ColumnNamesOnOff = On;
};
AnyFloat SoleusMedialis_Fm = Main.Studies.HumanModel.BodyModel.Right.Leg.Mus.SoleusMedialis1.Fm;
AnyFloat SoleusMedialis_Activity = Main.Studies.HumanModel.BodyModel.Right.Leg.Mus.SoleusMedialis1.Activity;
};
I would like to know if there is a way to save all the muscle activity in a single csv file. In the above method we have to define AnyFloat variables for every single muscle in the body. Is there any work around?
The following solution should work. Include this code in your AnyBodyStudy. The only limitation is that you would have to create individual output files for the right and left legs. The AnySearchFun will scan the model tree and collect the values in the Activity field for all muscle objects in the right leg. Please change this code to reflect the correct model tree path for leg muscles in your model.
//This will search the model tree for muscle activations
AnySearchFun sf_mus_activity = {
Search = "Main.HumanModel.BodyModel.Right.Leg.Mus.*.Activity";
};
AnyOutputFile SaveMuscleActivations={
FileName = "Activations.txt";
SepSign = " ";
Header.TitleSectionOnOff = Off;
Header.ConstSectionOnOff = Off;
Header.ColumnNamesOnOff = On;
Header.VarSectionOnOff = Off;
Search=.sf_mus_activity.Search;
};