Code Monkey home page Code Monkey logo

muscleforcedirection's Introduction

Overview

The Muscle Force Direction plugin extends the functionalities of OpenSim providing a straighforward interface to extract the muscle lines of action. The source code of the plugin is provided in the main repository and a dll that can be loaded through the main OpenSim user interface is available through the Releases tab. Leveraging the OpenSim Application Programming Interface (API), we also provide MATLAB scripts that replicate the plugin functionalities.

Background

If you are using the internal forces estimated by musculoskeletal models as load sets in finite element models you find that you have few options to compute the direction of each force vector:

  1. use a PointKinematics analysis on the points of interest of your line of action, compute the force versor for the kinematic frame of interest
  2. use the PointForceDirection class and search for the segment of the muscle line of action that you are interested in.

The MuscleForceDirection plugin (MFD plugin for short) tries to streamline this operations and make easier to extract muscle forces and apply them to finite element models.

FE_workflow

"Anatomical" versus "Effective" lines of action

Anatomical muscle lines of actions are those whose attachments are on the bones.

Effective muscle lines of actions are those determining the effective mechanical effect of the muscle action on the equilibrium of the bone when considering its free body diagram.

A typical example is a muscle including via points or wrapping surface, for example the gastronemius, that can alter the muscle lines of action substantially between the first segment of the muscle and the last segment attached to a certain bone. anat_vs_effect

A good explanation of this difference is available in section 5.4.3 of Yamaguchi's book Dynamic Modeling of Musculoskeletal Motion: A Vectorized Approach for Biomechanical Analysis in Three Dimensions entitled EFFECTIVE ORIGIN AND INSERTION POINTS.

Plugin options

Using the plugin setup you can decide:

  1. the body/bodies of interest on which to run the MFD analysis
  2. the reference system in which you want to express the line of actions
  3. choose if you want to extract the "anatomical" lines of action or the "effective" lines of action.

Installation

  • For compiling the C++ plugin, follow the instructions available on the OpenSim Developers' Guide, where you can also find some examples.
  • For installing the MFD plugin for use in the OpenSim GUI follow the same procedure to install other plugins:
    • place the plugin in the plugins folder
    • restart OpenSim
  • For using the MATLAB scripts (OpenSim version ), you need to:
    • ensure that the OpenSim API are correctly installed. Please refer to the OpenSim documentation.
    • include the MATLAB folder in your path.
    • check the provided examples.

[WORK IN PROGRESS] Examples of use

There will be examples of how to call the plugin from Matlab etc.

Publications

The plugin was originally described in the Appendix of this open access publication:

@article{van2013hip,
title={Hip abduction can prevent posterior edge loading of hip replacements},
author={van Arkel, Richard J and Modenese, Luca and Phillips, Andrew TM and Jeffers, Jonathan RT},
journal={Journal of Orthopaedic Research},
volume={31},
number={8},
pages={1172--1179},
year={2013},
publisher={Wiley Online Library}
}

but a better example of use is provided in this other open access paper:

@article{phillips2015femoral,
title={Femoral bone mesoscale structural architecture prediction using musculoskeletal and finite element modelling},
author={Phillips, Andrew TM and Villette, Claire C and Modenese, Luca},
journal={International Biomechanics},
volume={2},
number={1},
pages={43--61},
year={2015},
publisher={Taylor \& Francis}
}

How to contribute

Feel free of contributing as by standard GitHub workflow:

  1. forking this repository
  2. creating your own branch, where you make your modifications and improvements
  3. once you are happy with the new feature you have implemented create a pull request

Resources for learning how to contribute

  • If you want to contribute but you are not familiar with Git, the Software Carpentry Lessons are a perfect place to start with Git and GitHub.
  • If you know how to use git but you are not familiar with GitHub, you can check resources like "First Contributions" to learn how to contribute to existing projects.

Resource on combining finite element and musculoskeletal models

Contributors

Several researchers have contributed to this package:

muscleforcedirection's People

Contributors

cpizzolato avatar ksonggithub avatar modenaxe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

muscleforcedirection's Issues

[MATLAB] Add demo from John Davis (https://gist.github.com/johnjdavisiv)

link: https://gist.github.com/johnjdavisiv/26b17b41afd7555e0c18f8cd84f38123

`% --- Demonstrate using the muscle line of action plugin via the MATLAB API ---
%John Davis
%[email protected]

%The MATLAB path is assumed to be in the Arm26 directory distributed with the plugin
import org.opensim.modeling.*
%Load the custom library - you have to leave the .dll ending off the path to the plugin
opensimCommon.LoadOpenSimLibrary('../MuscleForceDirection');
%After installation you'd usually have the above line look like:
%opensimCommon.LoadOpenSimLibrary('C:/OpenSim 4.2/plugins/MuscleForceDirection');

%Load up an AnalyzeTool instance using the provided config
config_file = 'MySetupFile.xml';
analyze_tool = AnalyzeTool(config_file);

%Access the MuscleForceDirection analysis
muscle_force_direction = analyze_tool.getAnalysisSet.get('MuscleForceDirection');
%You can also get it by index, e.g. analyze_tool.getAnalysisSet.get(0);

%As far as MATLAB knows, muscle_force_direction is an instance of the generic Analysis class
disp(class(muscle_force_direction));
%As a result, we have access to some useful generic methods from that class
%(you can see all of them by doing methodsview(muscle_force_direction);

%Change start/end times and step interval (useful if analyzing CMC results with small timesteps)
muscle_force_direction.setStartTime(0.25);
muscle_force_direction.setEndTime(0.75);
muscle_force_direction.setStepInterval(2);

%We should also change start and end time of analyze_tool
analyze_tool.setStartTime(0.25);
analyze_tool.setFinalTime(0.75); %For some reason the method is called FinalTime instead of EndTime!

%Properties specific to the plugin, like print_muscle_attachments, can be changed using the new
%PropertyHelper class (in Opensim 4.2+)
%See https://simtk-confluence.stanford.edu/display/OpenSim/Scripting+with+Matlab#ScriptingwithMatlab-UsingPropertyHelpertosetPropertyvaluesforpluginclasses
prop = muscle_force_direction.getPropertyByName('print_muscle_attachments');
curr_value = PropertyHelper.getValueBool(prop);
new_value = true;
PropertyHelper.setValueBool(new_value, prop);

%These properties are all set by pointers, so the values in analyze_tool have changed as well.
disp(analyze_tool.getAnalysisSet.get('MuscleForceDirection').getPropertyByName('print_muscle_attachments'));

%Save as a new analysis config
analyze_tool.print('my_new_setup.xml');

%Important! To run the tool with the updated settings, we need a fresh version loaded from the new config file
new_analyze_tool = AnalyzeTool('my_new_setup.xml');
new_analyze_tool.run();`

[CPP] Uniform output format among MATLAB, CPP and the other OpenSim tools

Currently the cpp and Matlab version of the plugin do not output the same vectors.
The CPP plugin (for historical reasons related to some ideas we had) returns versors pointing out from a chosen body and those opposite in direction, coming from the other body where the muscle attaches.
I think we should:

  1. uniform this so that just the muscle versors pointing out of the selected bodies are reported
  2. double check the headers so that they are consistent with the other OpenSim tools, especially for making clear the reference systems where vector and points are expressed.

What do you think @mitkof6 ?

[MATLAB] add equilibrium checker for FE use

It would be useful to functions to check the total dynamic equilibrium given muscle forces JRFs and motion file.
Other people tried, see for example here but I think they did not set the state correctly.

[CPP] implementation of tests

It would be nice to have CPP tests. We can use the same as Matlab, once they are implemented. Hence, Issue #3 must be solved first.

[OpenSim 4.2] Analysis tool crashes if includes MFD

As reported via email by user John Davis:

In OpenSim 4.2, attempting to run an Analysis that includes MuscleForceDirection will immediately result in a crash if the local_ref_system parameter is set to false. The plugin runs fine if local_ref_system is true, and it runs fine either way in OpenSim 4.1.

This is easily reproducible in the demo files distributed with the plugin. This crash occurs both when using the GUI and when calling the tool via the OpenSim API.

I scoured the 4.2 changelogs to see if I could pinpoint anything that would cause this change, but I didn't see anything obvious. When I check the opensim.log file, there are no error messages but the crash seems to occur before the coordinates file is read, because the log ends before the '[info] Loading coordinates from file...' and '[info] Storage: read data...' messages appears as they would in a successful run of the tool.

[CPP] Update to OpenSim 4.0

No rush on this one @mitkof6 I am Issue-ing all the main things I had in mind for the plugin and its development and this is an obvious one requested by many users.

[C++] OpenSim 4.x compatibility issues

Users report issues with loading the plugin I have compiled on my machine: see forum.

@mitkof6 can you help with this? Neither me nor my students nor few other groups I am in contact with had any problem with the shared dll. What do you think the issue could be? The redistributable Microsoft Visual C++ maybe?

[Matlab] requires consolidation of tests

From previous plugin versions there are:

  1. simple model solvable analytically: for transformation tests and wrapping
  2. gait model: to test kinematics
    Need to consolidate these cases (now just manual) and setup the proper tests.

[Docs] documentation needs update before new release

Documentation is (almost) unchanged since first release.
At minimum requires:

  1. add more detailed example of use
  2. better explanation of anatomical vs effective attachment
  3. reflect changes in OpenSim versions
  4. include list of contributors
  5. add section "how to contribute"

[MATLAB] Update to OpenSim 4.0

Time to update to OpenSim 4.0. This requires reviewing the pull request by @KSongGitHub .
Some functions included in the pull request were already available in other packages I developed previously, but the contribution is greatly appreciated. Thank you @KSongGitHub - I might bother you in the next days if I find something I cannot understand.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.