\chapter{Methods}
\label{ch:methods}

\section{Simulation Software}

Simulation is performed using the OpenSim\footnote{Not to be confused with the 3D virtual world software OpenSimulator, which is sometimes also abbreviated as OpenSim.} software \cite{Delp2007}. OpenSim is an open-source platform for modeling and analyzing neuromusculoskeletal structures and simulating their dynamic movement behavior. It's developed and maintained at the NIH Center for Biomedical Computation at Stanford University and is distributed as part of the Simtk.org repository.

\TODO{Describe working principle (controllers, models etc)}

The software provides an extensive application programming interface (API) in order to develop custom simulation controllers. Additionally it contains a graphical user interface (GUI) used to visualize simulations, edit models and muscle excitation data, as well as to access predefined simulation controllers.

The controllers provided with the OpenSim distribution turned out to require a very specific data collection as its input. These types of data are typically generated during experiments using motion capturing systems and force plates.

In the context of this project, no such data was or is available or could easily be acquired. Instead we rather rely on relatively sparse muscle activation data and have no ground force measurements available. Also we are interested in general principles of movement rather than the detailed analysis of the walking behavior of an individual subject.

Thus a custom controller making use of the provided OpenSIM API was developed which should actuate the model based on the basic activation patterns. This approach also allows to specifically tune the simulation behavior to the requirements of this project and the data available.

For all tasks performed as part of this project, version 3.0 of OpenSim was used as provided on \url{http://www.simtk.org}. The source version was used and built accord

\section{Musculoskeletal Model}

\subsection{Simple Leg Model}

\TODO{Describe SimpleLeg}

\subsection{Two-legged Model}

In the study by Dominici et al. \cite{Dominici2011} EMG activity of the following set of 14 muscles was recorded for each leg of the subject:

\begin{itemize}
	\item Tibialis Anterior (TA)
	\item Gastrocnemius Lateralis (LG)
	\item Gastrocnemius Medialis (MG)
	\item Soleus (Sol)
	\item Vastus Lateralis (VL)
	\item Vastus Medialis (VM)
	\item Rectus Femoris (RF)
	\item Hamstring (HS) -- a group of four muscles, namely Semitendinosus, Semimembranosus, Biceps Femoris-Long Head and Biceps Femoris-Short Head
	\item Adductor Longus (Add)
	\item Tensor Fascia Latae (TFL)
	\item Gluteus Maximus (GM)
	\item Erector Spinae (ES)
	\item External Oblique (OE)
	\item Latissimus Dorsi (LD)
\end{itemize}

The musculoskeletal model to be used thus had to incorporate all these muscles, so the proper activation pattern could be directly applied. Several musculoskeletal models of human legs are already provided with OpenSim 3.0. For this project the Gait2354 model was used as a basis. This is a 23-degree-of-freedom model of the musculoskeletal system of the human leg. By default it contains 54 musculo-tendon actuators and represents a subject with a height of 1.8 m and a mass of 75.16 kg\footnote{More information on the Gait2354 model and its kinematic and dynamic properties as well as references to the studies the model is based on can be found on \url{http://simtk-confluence.stanford.edu:8080/display/OpenSim/Gait+2392+and+2354+Models}}. See figure \ref{fig:screenshot_opensim_gait2354} for a visualization of the model.

\begin{figure}[htb!]
\label{fig:screenshot_opensim_gait2354}
\centering
\includegraphics[width=\textwidth]{images/screenshot_opensim_gait2354.png}
\caption{Screenshot of the Gait2354 model visualized in the OpenSim 3.0 GUI}
\end{figure}

The model was then adapted in order to only in its final version incorporate only the 28 muscles for which data was available. Table \ref{table:muscles_correspondence} shows the muscles from the study and the Gait 2354 musculoskeletal model respectively and how their activation was determined from the study data in the final model. The table shows only the muscles for one leg, the muscles of second leg were handled correspondingly. The leg to which each muscle in the model belongs, is signified by it having a postfix \emph{\_l} for the left leg, or a postfix \emph{\_r} for the right leg.

\begin{center}
\begin{longtable}{llll}
\label{table:muscles_correspondence}
\\
\textbf{Muscle} & \textbf{Name in model} & \textbf{Name in \cite{Dominici2011}} & \textbf{Activation Usage} \\
[1ex] \hline \\ [-1.5ex]
Adductor Longus & add\_long & Add & used directly \\
[1ex] \hline \\ [-1.5ex]
Erector Spinae & ercspn & ES & used directly \\
[1ex] \hline \\ [-1.5ex]
External Oblique & extobl & OE & used directly \\
[1ex] \hline \\ [-1.5ex]
Gastrocnemius Lateralis & lat\_gas & LG & used directly \\
[1ex] \hline \\ [-1.5ex]
Gastrocnemius Medialis & med\_gas & MG & used directly \\
[1ex] \hline \\ [-1.5ex]
Rectus Femoris & rect\_fem & RF & used directly \\
[1ex] \hline \\ [-1.5ex]
Soleus & soleus & Sol & used directly \\
[1ex] \hline \\ [-1.5ex]
Tensor Fasciae Latae & tfl & TFL & used directly \\
[1ex] \hline \\ [-1.5ex]
Tibialis Anterior & tib\_ant & TA & used directly \\
[1ex] \hline \\ [-1.5ex]
Vastus Lateralis & vas\_lat & VL & used directly \\
[1ex] \hline \\ [-1.5ex]
Vastus Medialis & vas\_med & VM & used directly \\
[1ex] \hline \\ [-1.5ex]
Biceps Femoris-Long Head & bifemlh\_r & part of HS & $\frac{1}{4}$ of HS activation \\
[1ex] \hline \\ [-1.5ex]
Biceps Femoris-Short Head & bifemsh\_r & part of HS & $\frac{1}{4}$ of HS activation \\
[1ex] \hline \\ [-1.5ex]
Semimembranosus & semimem & part of HS & $\frac{1}{4}$ of HS activation \\
[1ex] \hline \\ [-1.5ex]
Semitendinosus & semiten & part of HS & $\frac{1}{4}$ of HS activation \\
[1ex] \hline \\ [-1.5ex]
Gluteus Maximus 1 & glut\_max1 & part of GM & $\frac{1}{3}$ of GM activation \\
[1ex] \hline \\ [-1.5ex]
Gluteus Maximus 2 & glut\_max2 & part of GM & $\frac{1}{3}$ of GM activation \\
[1ex] \hline \\ [-1.5ex]
Gluteus Maximus 3 & glut\_max3 & part of GM & $\frac{1}{3}$ of GM activation \\
[1ex] \hline \\ [-1.5ex]
Adductor Magnus 2 & add\_mag2 & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Gluteus Medius 1 & glut\_med1 & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Gluteus Medius 2 & glut\_med2 & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Gluteus Medius 3 & glut\_med3 & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Gracilis & grac & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Iliacus & iliacus & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Inferio gemellus & gem & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Pectineus & pect & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Piriformis & peri & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Psoas Major & psoas & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Quadratus Femoris & quad\_fem & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Sartorius & sar & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Tibialis Posterior & tib\_post & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Vastus Intermedius & vas\_int & - & removed from model \\
[1ex] \hline \\ [-1.5ex]
Latissmus Dorsi & n/a & LD & no data available in \cite{Dominici2011} \\
\caption{Muscles in the Gait2354 model and their correspondents in \cite{Dominici2011}} 
\end{longtable}
\end{center}

Gait model provided with OpenSim (\TODO{Add reference to paper describing model}), muscles removes where no data was available from the paper. Muscles which were measured in combination in the study (hamstring, \dots) needed to be properly accounted for.

\section{Muscle Model}

\subsection{Thelen Muscle Model}

For all muscles in the model, the Thelen muscle model \cite{Thelen2003} was used. This model is the default muscle model used OpenSim 3.0\footnote{\TODO{Add note about deprecated model of same name from previous versions of OpenSim}} and is employed in all muscluloskeletal models provided with OpenSim. The Thelen muscle model is based on the well-known and widely used Hill-type muscle-tendon model \cite{Hill1922,Hill1970,Shadmehr2005}, but incorporates adjustments in order to better account for age-related changes in the muscle properties.

\section{Simulation Controller}

\subsection{Simple Leg Controller}

\TODO{Describe ideas behind it}

\subsection{Locomotor Primitives Controller}

\TODO{Describe ideas behind it}

\section{Data Preparation}

Since the original data from the publication by Dominici et al. \cite{Dominici2011} could not be used, the respective pattern curves had to be extracted from the paper. In order to gather the data from there, a graph digitizer software (GraphClick by Arizona Software) was used. The data was then preprocessed by applying a curve interpolation in order to allow arbitrary, linearly spaced sampling of data points later on in the OpenSim model controller.