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 [1]:
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
from numba import jit, prange
import scipy as sc
from scipy.signal import *
In [2]:
conf = Configuration('confForceVariability.rmto')
conf.simDuration_ms = 5000 # Here I change simulation duration without changing the Configuration file.
t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)
In [3]:
FR = np.array([95.0, 110.0 ,125.0, 140.0, 155.0, 170.0, 185.0, 200.0, 250])
GammaOrder = np.array([7, 5, 4, 4, 4, 3, 2, 2, 1])
condVelS = np.linspace(44/2.0, 44*2.0, 5)
condVelFR = np.linspace(51/2.0, 51*2.0, 5)
condVelFF1 = np.linspace(52/2.0, 52*2.0, 5)
condVelFF2 = np.linspace(53/2.0,53*2, 5)
forceSOL = np.empty((len(t),len(FR), len(condVelS)))
forceMG = np.empty((len(t),len(FR), len(condVelS)))
forceLG = np.empty((len(t),len(FR), len(condVelS)))
torque = np.empty((len(t), len(FR), len(condVelS)))
for m in xrange(1,2):
conf.changeConfigurationParameter('axonDelayCondVel:MG-S',condVelS[m],condVelFR[m])
conf.changeConfigurationParameter('axonDelayCondVel:SOL-S',condVelS[m],condVelFR[m])
conf.changeConfigurationParameter('axonDelayCondVel:LG-S',condVelS[m],condVelFR[m])
conf.changeConfigurationParameter('axonDelayCondVel:MG-FR',condVelFR[m],condVelFF1[m])
conf.changeConfigurationParameter('axonDelayCondVel:SOL-FR',condVelFR[m],condVelFF1[m])
conf.changeConfigurationParameter('axonDelayCondVel:LG-FR',condVelFR[m],condVelFF1[m])
conf.changeConfigurationParameter('axonDelayCondVel:MG-FF',condVelFF1[m],condVelFF2[m])
conf.changeConfigurationParameter('axonDelayCondVel:SOL-FF',condVelFF1[m],condVelFF2[m])
conf.changeConfigurationParameter('axonDelayCondVel:LG-FF',condVelFF1[m],condVelFF2[m])
pools = dict()
pools[0] = MotorUnitPool(conf, 'SOL')
pools[1] = MotorUnitPool(conf, 'MG')
pools[2] = MotorUnitPool(conf, 'LG')
pools[3] = NeuralTract(conf, 'CMExt')
ankle = jointAnkleForceTask(conf, pools)
Syn = SynapsesFactory(conf, pools)
del Syn
for l in xrange(3,4):
print('Firing Rate ' + str(FR[l]))
tic = time.time()
for i in xrange(0,len(t)-1):
pools[3].atualizePool(t[i], FR[l], GammaOrder[l])
ankle.atualizeAnkle(t[i], 0.0)
for j in xrange(3):
pools[j].atualizeMotorUnitPool(t[i])
ankle.computeTorque(t[i])
toc = time.time()
forceSOL[:,l,m] = np.squeeze(pools[0].Muscle.force)
forceMG[:,l,m] = np.squeeze(pools[1].Muscle.force)
forceLG[:,l,m] = np.squeeze(pools[2].Muscle.force)
torque[:,l,m] = np.squeeze(ankle.ankleTorque_Nm)
print str(toc - tic) + ' seconds'
for k in xrange(0, len(pools)):
pools[k].reset()
In [4]:
forceLG.shape
plt.figure()
plt.plot(t, torque[:,:,1])
Out[4]:
In [5]:
plt.figure()
plt.plot(t, forceSOL)
In [ ]:
plt.figure()
plt.plot(t, forceMG)
In [ ]:
plt.figure()
plt.plot(t, forceLG)
In [ ]:
np.save('forceSol',forceSOL,)
np.save('forceMG', forceMG)
np.save('forceLG', forceLG)
np.save('torque', torque)
In [ ]:
X=np.load('forceSol.npy')
In [ ]:
In [ ]: