This notebook presents a simulation of 5000 ms of 400 descending commands and 800 motoneurons from soleus. The force is prduced by a Hill-type muscle model.


In [4]:
import sys
sys.path.insert(0, '..')
import time
import matplotlib.pyplot as plt
%matplotlib notebook 
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('pdf', 'png')
plt.rcParams['savefig.dpi'] = 75

plt.rcParams['figure.autolayout'] = False
plt.rcParams['figure.figsize'] = 10, 6
plt.rcParams['axes.labelsize'] = 18
plt.rcParams['axes.titlesize'] = 20
plt.rcParams['font.size'] = 16
plt.rcParams['lines.linewidth'] = 2.0
plt.rcParams['lines.markersize'] = 8
plt.rcParams['legend.fontsize'] = 14

plt.rcParams['text.usetex'] = True
plt.rcParams['font.family'] = "serif"
plt.rcParams['font.serif'] = "cm"
plt.rcParams['text.latex.preamble'] = "\usepackage{subdepth}, \usepackage{type1cm}"


import numpy as np

from Configuration import Configuration
from MotorUnitPool import MotorUnitPool
from NeuralTract import NeuralTract
from AfferentPool import AfferentPool
from SynapsesFactory import SynapsesFactory
from jointAnkleForceTask import jointAnkleForceTask

In [8]:
conf = Configuration('confIsometricClosedLoop.rmto')
conf.simDuration_ms = 2000 # Here I change simulation duration without changing the Configuration file.
t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)
GammaOrder = 10
FR = 1000/12.0

In [9]:
pools = dict()
pools[0] = MotorUnitPool(conf, 'SOL')
pools[1] = NeuralTract(conf, 'CMExt')
pools[2] = AfferentPool(conf,'Ia', 'SOL')
ankle = jointAnkleForceTask(conf, pools)
Syn = SynapsesFactory(conf, pools)
del Syn


[ 4526.19985237]
Hill muscle of the SOL muscle with maximum force of 3586.0 N  built.
Muscle spindle from muscle SOL built.
Motor Unit Pool SOL built
Descending Command CMExt built
Afferent Pool Ia of muscle SOL built
Ankle joint for Force Task built
All the 431958 synapses were built
All the 0 synaptic noises were built

In [10]:
IaFR = np.zeros([len(t), 1])
tic = time.time()
for i in xrange(0,len(t)-1): 
    ankle.atualizeAnkle(t[i], 0.1 * np.sin(2*np.pi*t[i]/1000.0))
    pools[1].atualizePool(t[i], FR, GammaOrder)
    pools[0].atualizeMotorUnitPool(t[i])
    pools[2].atualizeAfferentPool(t[i], pools[0].spindle.IaFR_Hz)
    ankle.computeTorque(t[i])
    IaFR[i] = pools[0].spindle.IaFR_Hz
toc = time.time()
print str(toc - tic) + ' seconds'


3986.817662 seconds

In [11]:
pools[0].listSpikes()
pools[1].listSpikes()
pools[2].listSpikes()

The spike times of the MNs along the 5000 ms of simulation are shown in Fig. \ref{fig:spikesMNHill}.


In [12]:
plt.figure()
plt.plot(pools[0].poolTerminalSpikes[:, 0],
    pools[0].poolTerminalSpikes[:, 1]+1, '.')
plt.xlabel('t (ms)')
plt.ylabel('Motor Unit index')


Out[12]:
<matplotlib.text.Text at 0x7f8d77120d90>

In [13]:
plt.figure()
plt.plot(pools[2].poolTerminalSpikes[:, 0],
    pools[2].poolTerminalSpikes[:, 1]+1, '.')
plt.xlabel('t (ms)')
plt.ylabel('Afferent index')


Out[13]:
<matplotlib.text.Text at 0x7f8d6e8e64d0>

The muscle force produced by the Hill-type model is shown in Fig.\ref{fig:forceHill}.


In [14]:
plt.figure()
plt.plot(t, pools[0].Muscle.force, '-')
plt.xlabel('t (ms)')
plt.ylabel('Muscle Force (N)')


Out[14]:
<matplotlib.text.Text at 0x7f8d6e74dc10>

The muscle length computed with the Hill-type model is shown in Fig.\ref{fig:lengthHill}.


In [15]:
plt.figure()
plt.plot(t, pools[0].Muscle.length_m/pools[0].Muscle.optimalLength_m, '-')
plt.xlabel('t (ms)')
plt.ylabel('Muscle Length (m)')


Out[15]:
<matplotlib.text.Text at 0x7f8d6eb01290>

The muscle velocity, computed by the Hill-type muscle model, is in Fig.\ref{fig:velocityHill}.


In [16]:
plt.figure()
plt.plot(t, pools[0].Muscle.velocity_m_ms/pools[0].Muscle.optimalLength_m, '-')
plt.xlabel('t (ms)')
plt.ylabel('Muscle Velocity (m/ms)')


Out[16]:
<matplotlib.text.Text at 0x7f8d6cd973d0>

The ankle joint angle is shown in Fig. \ref{fig:ankleAngleHill}.


In [17]:
plt.figure()
plt.plot(t, ankle.ankleAngle_rad*180.0/np.pi, '-')
plt.xlabel('t (ms)')
plt.ylabel('Ankle angle (degree)')


Out[17]:
<matplotlib.text.Text at 0x7f8d6cd7ff50>

In [18]:
plt.figure()
plt.plot(t, IaFR, '-')
plt.xlabel('t (ms)')
plt.ylabel('Ankle angle (degree)')


Out[18]:
<matplotlib.text.Text at 0x7f8d6cc9cf10>

In [19]:
plt.figure()
plt.plot(t, ankle.ankleTorque_Nm, '-')
plt.xlabel('t (ms)')
plt.ylabel('Ankle angle (degree)')


Out[19]:
<matplotlib.text.Text at 0x7f8d6cc2d250>

In [ ]:


In [ ]:


In [ ]:


In [ ]: