Wiki

Clone wiki

musclemodelR / Home

Introduction

musclemodelR is an R package that is used to simulate the dynamic interaction between Hill-type muscle models and linear elastic elements. The basic code was originally developed to simulate fixed-end contractions (i.e., no change in muscle-tendon unit length), but since has been expanded to study active lengthening of muscles. Currently, the models are used to simulate the effect of tendons on 1) deceleration of mass and 2) direct lengthening of the muscle-tendon unit during muscle activation.


Installation

The easiest way to install this package is to use the install_bitbucket() function from the devtools package.

Installing devtools

To install devtools:

install.packages("devtools")
If you have problems installing devtools, you can find more information at its github page.

Installing musclemodelR

To install musclemodelR after successful installation of devtools:

devtools::install_bitbucket(repo = "michaelvrosario/musclemodelR")
This may take a while because it will install musclemodelR as well as any dependencies.


Examples

The following example demonstrates the framework for simulating the effect of muscle activation in conjunction with a constant rate of muscle-tendon unit elongation.

# load package
library(musclemodelR)

#############################
### single simulation test ##
#############################
constants <- list(
  useFV = T,
  useLT = T,
  type = "MTU_ramp",
  k = 35,
  dt = 1/1000,
  Fmax = 250,
  v_mus_max = 13,
  l0_mus = 70,
  x_mus_0 = 70,
  m_mus = 0.025,
  lengthenRate = -120,
  lengthenDuration = 0.100)

constants <- as.data.frame(constants)

inputList <- makeInputList(constants = constants)
singleRun <- SimulateMTUlengthening_PSO(inputList = inputList)


########################
### batch simulation ###
########################

constants <- list(
  useFV = T,
  useLT = T,
  type = "MTU_ramp",
  k = c(35, Inf, 40),
  dt = 1/1000,
  Fmax = 250,
  v_mus_max = 13,
  l0_mus = 70,
  x_mus_0 = 70,
  m_mus = 0.025,
  lengthenRate = -120,
  lengthenDuration = 0.100)

constants <- expand.grid(constants)


# run simulation and export to *.JSON
RunMultipleSimulations(inputs = constants, file = "data.JSON", previousResults = F)


# import results back to R
data <- importJSON(file = "data.JSON")

# plot time series data
# data[[1]] is a summary of all simulations included in data
# first set of results saved in data[[2]]

PlotTimeSeries(data=data[[2]], pdf=TRUE)


Todo

Coding

  • create simulation of direct lengthening
  • generalize deceleration code for recycling
  • setup lengthening simulations after experimental data
  • create script to analyze lengthening results
  • modify deceleration analysis to investigate effect of mass
  • include installation and usage in wiki
  • create documentation of functions using oxygen
  • generalize functions to include stimulation parameters
  • simulate deactivation with activation, split data into lengthening and not
  • fix lengthening unit tests
  • add indexing parameter for analysis fxns (DIY query)
  • add r package documentation
  • look up how to document package and make manual
  • implement intermediate unit testing
  • genarilize code to take time-varying L_MTU and activation

Model parameters

  • iterate though tendon stiffness?
  • get a good estimate of combined FMax of all muscles connected to spring
  • calculate tendon stiffness from lengthening experimental data 829Mpa -> 378N/mm

Updated