Feedback for the Brain and Body: A New Freely Available Interface Between MATLAB and OpenSim
Even when we simply stand still on two feet, our brains communicate with our muscles—firing them appropriately to keep us upright against gravity. So when scientists simulate simple or complex biomechanical movements, they need to account for that feedback between brain and body. A new, freely available, software interface now makes that possible. It connects MATLAB/Simulink, a mathematical computing and control software package, with OpenSim, a freely available musculoskeletal software package.
“MATLAB is essentially the brain and nervous system, but OpenSim is the person, their bones and muscles, the floor, and gravity pulling them down,” says Jeff Reinbolt, PhD, assistant professor of biomedical engineering at the University of Tennessee. He and , a mechanical engineering graduate student in Reinbolt’s research group, created the interface under a seed grant from Simbios. They published a 2012 paper on the work in the Journal of Biomechanics.
OpenSim’s strengths lie in its musculoskeletal models, Reinbolt says, “It has the bone geometry, muscle forces, how the joints move, and all the dynamics provided by the underlying algorithms, including Simbody.” But until now, OpenSim users have had to load a file of controls that tell the model how to excite specified muscles over a certain period of time. To change controls, the user would create a new file. In addition, OpenSim could only function as an open loop, without feedback; users requiring feedback to close the loop would need to write their own software as a plugin to OpenSim. Without feedback, “you can change the model and do ‘what if’ scenarios, but the model has no brain to automatically compensate for it,” Reinbolt says.
Meanwhile, MATLAB/Simulink provides great control options in the form of templates and blocks of code that are easily changed on the fly, but it lacks the musculoskeletal modeling capability of OpenSim.
Reinbolt and Mansouri’s Simbios seed grant let them bring the two together. “The interface really allows MATLAB to access OpenSim for the muscles and bones it doesn’t have; and allows OpenSim to use MATLAB to control the movement, which OpenSim doesn’t really have built in,” Reinbolt says. “It allows each to get the info needed to create a simulated movement.” And it lets you change things on the fly.
To build the interface, Reinbolt and Mansouri took advantage of the way MATLAB calls functions to connect it with OpenSim through a Simulink block. The interface allows MATLAB to call for the OpenSim model’s state derivatives—the time rate of change in joint positions and velocities of the model, as well as lengths and activations of muscles. MATLAB numerically integrates these derivatives to determine new states for the OpenSim model which allows OpenSim to tell MATLAB how gravity, muscles, and other forces are affecting the model, and then MATLAB uses that information to provide feedback: Are my joint positions at the right place? How should I adjust the controls to correct the movement?
Right now, to use the interface, researchers must join the Simtk.org project. “It's freely available but we want people to use it and give back in return,” Reinbolt says. About 25 people from the US, Canada, UK, Belgium, Poland, Spain, Italy, and Taiwan have already shown interest.
Reinbolt’s research group is already using the interface to simulate posture. They’ve added a stretch reflex controller to allow balancing on two feet. Eventually, they would like to create a controller that will reproduce someone walking with stroke gait so they can then test rehabilitation procedures to predict how the patient might walk better. “The point,” Reinbolt says, “is to keep someone from falling over,” which requires the feedback the interface provides.
The MATLAB/Simulink interface with OpenSim is available to researchers who join the project at http://simtk.org/home/opensim_matlab. The work was published in the Journal of Biomechanics 45:1517-21 (2012).