Skip to content

Muscle modeling updates #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Muscle_modeling/_static/intro/image1.jpeg
Binary file not shown.
Binary file added Muscle_modeling/_static/intro/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Muscle_modeling/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
::: {rst-class} break
:::

(MuscleModeling)=
# Muscle Modeling

This tutorial introduces the many facilities for modeling muscles in the
Expand Down
22 changes: 13 additions & 9 deletions Muscle_modeling/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

# Introduction to Muscle Modeling

![Muscles back](_static/intro/image1.jpeg)
```{image} _static/intro/image1.png
:alt: Muscles back
:align: center
:width: 50%
```

Muscles are the actuators of living bodies. They are activated by the
central nervous system (CNS) by a complicated electro-chemical process.
Expand All @@ -15,14 +19,14 @@ the user to the necessary muscle forces in a process known as inverse
dynamics. To do so, the system must know the properties of the muscles
involved, and this is where muscle modeling comes into the picture.

AnyBody contains four different muscle models ranging from simple to
more complicated physiological behavior. The simplest model just assumes
a constant strength of the muscle regardless of its working conditions.
The more complicated models take such conditions as current length,
contraction velocity, fiber length, pennation angle, tendon elasticity,
and stiffness of passive tissues into account. Please refer to the
AnyScript Reference Manual (Find it in AnyBody->Help) for concise
information about the available muscle models:
AnyBody contains four different muscle models ranging from simple to more
complicated physiological behavior. The simplest model just assumes a constant
strength of the muscle regardless of its working conditions. The more
complicated models take such conditions as current length, contraction velocity,
fiber length, pennation angle, tendon elasticity, and stiffness of passive
tissues into account. Please refer to the AnyScript Reference Manual (Find it in
AnyBody->Help->AnyScript Reference) for concise information about the available
muscle models:

1. AnyMuscleModel - assuming constant strength of the muscle
2. AnyMuscleModel3E - a three element model taking serial and parallel
Expand Down
51 changes: 33 additions & 18 deletions Muscle_modeling/lesson1.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ Main = {
When you load the model, open a model view window, and run the
SetInitialConditions operation, you should get the following picture:

![simple model](_static/lesson1/image1.jpeg)
```{image} _static/lesson1/image1.jpeg
:alt: simple model
:align: center
```

The model has a driver, so you can run the kinematic analysis and see
the movement. The arm flexes about the origin of the red reference
Expand All @@ -95,7 +98,10 @@ If you pick the Classes tab in the right-hand side of the window, then
you will get access to the class tree. Expand the tree as shown in the
picture until you get to the AnyMuscleModel.

![class tree](_static/lesson1/image2.png)
```{image} _static/lesson1/image2.png
:alt: class tree
:align: center
```

Notice that this class has three derived classes. These are more
advanced muscle models, and we shall get to those later. However for the
Expand Down Expand Up @@ -185,23 +191,26 @@ Place the cursor right after the end brace of the musle model,
right-click the AnyMuscleViaPoint class in the tree, and insert an
instance of it:

![class tree AnyMuscleViaPoint](_static/lesson1/image3.png)
```{image} _static/lesson1/image3.png
:alt: class tree AnyMuscleViaPoint
:align: center
```

```AnyScriptDoc
AnyMuscleModel SimpleModel = {
      F0 = 100;
//Lf0 = 0;
//Vol0 = 0;
   };

§ AnyMuscleViaPoint <ObjectName> = {
//RefFrames = ;
//Surfaces = ;
AnyMuscleModel &<Insert name0> = <Insert object reference (or full object definition)>;
AnyRefFrame &<Insert name0> = <Insert object reference (or full object definition)>;
AnyRefFrame &<Insert name1> = <Insert object reference (or full object definition)>;
//AnyRefFrame &<Insert name2> = <Insert object reference (or full object definition)>; You can make any number of these objects!
};§
   F0 = 100;
//Lf0 = 0;
//Vol0 = 0;
};

§ AnyMuscleViaPoint <ObjectName> = {
//RefFrames = ;
//Surfaces = ;
AnyMuscleModel &<Insert name0> = <Insert object reference (or full object definition)>;
AnyRefFrame &<Insert name0> = <Insert object reference (or full object definition)>;
AnyRefFrame &<Insert name1> = <Insert object reference (or full object definition)>;
//AnyRefFrame &<Insert name2> = <Insert object reference (or full object definition)>; You can make any number of these objects!
};§
```

Let us start by filling out what we can and removing what we have no use
Expand Down Expand Up @@ -265,13 +274,19 @@ window unless you specifically ask for it. When you load the model and
run the SetInitialConditions study you will get the following picture
(if your model does not load, and you cannot find the error, {download}`clickhere to download a model that works <Downloads/MuscleDemo.1.any>`):

![simple model with muscle](_static/lesson1/image4.jpeg)
```{image} _static/lesson1/image4.jpeg
:alt: simple model with muscle
:align: center
```

Notice that the muscle is now able to balance the gravity, and we are
able to run the InverseDynamicAnalysis. If you try it out and
subsequently open a chart view, you are able to plot the muscle force:

![muscle force](_static/lesson1/image5.png)
```{image} _static/lesson1/image5.png
:alt: muscle force
:align: center
```

The muscle force is the item Fm in the list of properties you can plot
for a muscle. As you can see, lots of other properties are available,
Expand Down
20 changes: 16 additions & 4 deletions Muscle_modeling/lesson2.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ AnyDrawMuscle drw = {};
It obviously does not contain much, so every setting is at its default
value leading to the following display of the muscle:

![simple model with muscle](_static/lesson2/image1.jpeg)
```{image} _static/lesson2/image1.jpeg
:alt: simple model with muscle
:align: center
```

Let us play around with the settings a bit. An easy way to display all
the settings is to discard our manually defined AnyDrawMuscle object and
insert a template from the class tree instead:

![class tree AnyDrawMuscle](_static/lesson2/image2.gif)
```{image} _static/lesson2/image2.gif
:alt: class tree AnyDrawMuscle
:align: center
```

Erase the previous AnyDrawMuscle, right-click the AnyDrawMuscle in the
tree view, and insert an instance:
Expand Down Expand Up @@ -130,7 +136,10 @@ how the muscle force goes up drastically with the reduced moment arm:
Consequently the muscle now bulges more towards the end of the movement
than it does in the beginning:

![Chart view Muscle1.Fm](_static/lesson2/image3.gif)
```{image} _static/lesson2/image3.gif
:alt: Chart view Muscle1.Fm
:align: center
```

The muscle thickness does not have to reflect force. Choosing other
values for the Bulging property will give other results:
Expand Down Expand Up @@ -162,7 +171,10 @@ AnyDrawMuscle drw = {
When you reload and run the InverseDynamicAnalysis, you will notice that
the red shade of the muscle changes as its activity grows:

![Simple model two positions](_static/lesson2/image4.jpeg)
```{image} _static/lesson2/image4.jpeg
:alt: Simple model two positions
:align: center
```

When the activity is zero, the color defaults to a rather pale red. You
can control this "initial" value of the scaled color through the
Expand Down
15 changes: 12 additions & 3 deletions Muscle_modeling/lesson3.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ Anatomically, via point muscles are mostly found in the lower
extremities and in the spine, while the arms and shoulders almost
exclusively have wrapping muscles.

![Old leg Muscle wrapping](_static/lesson3/image1.jpeg)
```{image} _static/lesson3/image1.jpeg
:alt: Old leg Muscle wrapping
:align: center
```

*Most muscles in the legs can be modeled
reasonably with via point muscles.*

![Deltoid muscles](_static/lesson3/image2.jpeg)
```{image} _static/lesson3/image2.jpeg
:alt: Deltoid muscles
:align: center
```

*The deltoid muscle wraps over the head
of the humerus.*
Expand Down Expand Up @@ -125,7 +131,10 @@ AnyMuscleViaPoint Muscle1 = {

The figure below shows the result:

![Simpel model with via point muscle](_static/lesson3/image3.jpeg)
```{image} _static/lesson3/image3.jpeg
:alt: Simple model with via point muscle
:align: center
```

A muscle can pass through an unlimited number of via points, and the
points can be attached to different segments. This can be used to create
Expand Down
25 changes: 20 additions & 5 deletions Muscle_modeling/lesson4.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ insertion point of the cylinder is at {0, 0, 0.2} corresponding exactly
to half of the length of the cylinder of 0.4. This causes the cylinder
to be inserted symmetrically about the xy plane as illustrated below:

![wrapcylinder](_static/lesson4/image1.jpeg)
```{image} _static/lesson4/image1.jpeg
:alt: Wrap cylinder
:align: center
```

The cylinder direction is always z in the coordinate direction of the
object that the cylinder is inserted into. So, if the cylinder does not
Expand All @@ -109,7 +112,10 @@ AnyRefNode CylCenter = {

&#160;Which causes the cylinder to rotate 20 degrees about the y axis.

![wrap cylinder rotated](_static/lesson4/image2.jpeg)
```{image} _static/lesson4/image2.jpeg
:alt: Wrap cylinder rotated
:align: center
```

There are a couple of things to notice about the cylinder: First of all
the graphics looks like the cylinder is faceted. This is not really the
Expand Down Expand Up @@ -242,7 +248,10 @@ It is time to see what we have done. If you load the model and run the
InverseDynamics analysis (and have done everything right), you will see
the model moving through a sequence of positions like this:

![wrap cylinder with via point sequence](_static/lesson4/image3.jpeg)
```{image} _static/lesson4/image3.jpeg
:alt: Wrap cylinder with via point sequence
:align: center
```

As mentioned above, wrapping muscles can also have via points. In fact,
we can easily change the via point muscle, Muscle1,  to wrap over the
Expand All @@ -269,7 +278,10 @@ to change the type from AnyMuscleViaPoint to AnyMuscleShortestPath and
insert the wrapping surface and the StringMesh specification. This gives
us the following result:

![wrap cylinder two muscles](_static/lesson4/image4.jpeg)
```{image} _static/lesson4/image4.jpeg
:alt: Wrap cylinder two muscles
:align: center
```

As you can see, both muscles are now wrapping over the cylinder, and we
can run the InverseDynamics analysis. It seems to work, but the system
Expand Down Expand Up @@ -339,7 +351,10 @@ Step button rather than the run button. This will show you how the
system uses the InitWrapVectors to pull the muscle to the other side of
the cylinder:

![wrap cylinder Init wrap vectors](_static/lesson4/image5.jpeg)
```{image} _static/lesson4/image5.jpeg
:alt: Wrap cylinder Init wrap vectors
:align: center
```

If you keep pressing the step button you will see how the muscle now
wraps on the other side of the cylinder.
Expand Down
Loading