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 [14]:
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 SynapsesFactory import SynapsesFactory
from jointAnkleForceTask import jointAnkleForceTask
In [15]:
conf = Configuration('confMuscleHillExample.rmto')
conf.simDuration_ms = 5000 # Here I change simulation duration without changing the Configuration file.
In [16]:
pools = dict()
pools[0] = MotorUnitPool(conf, 'SOL')
pools[1] = NeuralTract(conf, 'CMExt')
ankle = jointAnkleForceTask(conf, pools)
Syn = SynapsesFactory(conf, pools)
del Syn
In [17]:
t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)
conf.simDuration_ms = 5000 # Here I change simulation duration without changing the Configuration file.
GammaOrder = 10
FR = 1000/12.0
In [18]:
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])
toc = time.time()
print str(toc - tic) + ' seconds'
In [19]:
pools[0].listSpikes()
pools[1].listSpikes()
The spike times of the MNs along the 5000 ms of simulation are shown in Fig. \ref{fig:spikesMNHill}.
In [20]:
plt.figure()
plt.plot(pools[0].poolTerminalSpikes[:, 0],
pools[0].poolTerminalSpikes[:, 1]+1, '.')
plt.xlabel('t (ms)')
plt.ylabel('Motor Unit index')
Out[20]:
The muscle force produced by the Hill-type model is shown in Fig.\ref{fig:forceHill}.
In [21]:
plt.figure()
plt.plot(t, pools[0].Muscle.force, '-')
plt.xlabel('t (ms)')
plt.ylabel('Muscle Force (N)')
Out[21]:
The muscle length computed with the Hill-type model is shown in Fig.\ref{fig:lengthHill}.
In [22]:
plt.figure()
plt.plot(t, pools[0].Muscle.length_m, '-')
plt.xlabel('t (ms)')
plt.ylabel('Muscle Length (m)')
Out[22]:
The muscle velocity, computed by the Hill-type muscle model, is in Fig.\ref{fig:velocityHill}.
In [23]:
plt.figure()
plt.plot(t, pools[0].Muscle.velocity_m_ms, '-')
plt.xlabel('t (ms)')
plt.ylabel('Muscle Velocity (m/ms)')
Out[23]:
The ankle joint angle is shown in Fig. \ref{fig:ankleAngleHill}.
In [24]:
plt.figure()
plt.plot(t, ankle.ankleAngle_rad*180.0/np.pi, '-')
plt.xlabel('t (ms)')
plt.ylabel('Ankle angle (degree)')
Out[24]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: