Page 1 of 1

MATLAB visualizer- muscle coloration and saving

Posted: Fri Sep 15, 2023 6:11 am
by theresp
Hi all,

Is there a way to visualize the muscle coloration from the activation file in the MATLAB API? I can do it with the kinematics, but also want the muscles to be changing colors in the video. I have looked through the VisualizerUtilities but don't see anything mentioning the coloration or the states/actuation files.

Also, is there a way to automatically save the video displayed from the MATLAB API with the kinematics/muscle activation? I only saw this thread: viewtopicPhpbb.php?f=91&t=12781&p=36578&start=0&view=, but it doesn't seem like it was fully figured out. I'd like to not have to manually do the "View>Save Movie" on the visualizer for automation purposes.

Thanks.
Reese

Re: MATLAB visualizer- muscle coloration and saving

Posted: Sat Oct 07, 2023 2:57 pm
by nbianco
Hi Reese,

If you can create a TimeSeriesTable that contains both the motion of the model and the muscle activations, then you can use VisualizerUtilities to create a visualization of your simulation (note the comments in the code snippet):

Code: Select all

% Whatever model you used to create your simulation.
model = Model('model_file.osim')
model.initSystem();

% This table should contain both coordinates value and speeds and muscle activations. 
% Note that muscle excitations (i.e., columns labeled like '/forceset/soleus_r') will not visualize, because they are not states in the model. 
% If you're constructing a table and adding the muscle activations that you want to visualize, make sure they have the correct column name (i.e., '/forceset/soleus_r/activation').
statesTable = TimeSeriesTable('table_file.sto')

% Create the visualization.
viz = VisualizerUtilities();
viz.showMotion(model, statesTable);
Also, is there a way to automatically save the video displayed from the MATLAB API with the kinematics/muscle activation?
Unfortunately, no. But if you're looking for a way to stitch together the images that get saved from "View > Save Movie", I recommend FFMPEG.

Best,
Nick

Re: MATLAB visualizer- muscle coloration and saving

Posted: Tue Oct 17, 2023 7:53 am
by kernalnet
Hi, I am a Python user and installed OpenSim[moco] via Conda. When I run either

Code: Select all

viz.showModel(model)
or

Code: Select all

viz.showMotion(model, statesTable)
the console crashes and terminates. Any suggestion on how to get it working? Thank you.