MATLAB visualizer- muscle coloration and saving

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Therese Parr
Posts: 9
Joined: Mon Dec 02, 2019 9:47 am

MATLAB visualizer- muscle coloration and saving

Post by Therese Parr » Fri Sep 15, 2023 6:11 am

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

Tags:

User avatar
Nicholas Bianco
Posts: 988
Joined: Thu Oct 04, 2012 8:09 pm

Re: MATLAB visualizer- muscle coloration and saving

Post by Nicholas Bianco » Sat Oct 07, 2023 2:57 pm

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

User avatar
Mohammadreza Rezaie
Posts: 386
Joined: Fri Nov 24, 2017 12:48 am

Re: MATLAB visualizer- muscle coloration and saving

Post by Mohammadreza Rezaie » Tue Oct 17, 2023 7:53 am

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.

POST REPLY