In [12]:
import sys
sys.path.insert(0, '..')
import time
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
%matplotlib notebook
import numpy as np
from Configuration import Configuration
from MotorUnitPool import MotorUnitPool
from AfferentPool import AfferentPool
from SynapsesFactory import SynapsesFactory
In [13]:
Nsim = 15
FirstStim = 9
LastStim = 20.0
In [14]:
conf = Configuration('confH-ReflexM-WaveCurve.rmto')
In [15]:
print Nsim
print FirstStim
print LastStim
In [16]:
t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)
Mp = np.zeros((int(Nsim), 1))
Hp = np.zeros((int(Nsim), 1))
Stim = np.zeros((int(Nsim), 1))
emg = np.zeros([len(t), int(Nsim)])
pools = dict()
pools[0] = MotorUnitPool(conf, 'SOL')
pools[1] = AfferentPool(conf,'Ia', 'SOL')
pools[2]= AfferentPool(conf,'Ia', 'LG')
Syn = SynapsesFactory(conf, pools)
del Syn
In [17]:
for j in xrange(0, int(Nsim)):
Stim[j] = FirstStim + j * (LastStim - FirstStim) / (Nsim - 1)
conf.changeConfigurationParameter('stimIntensity_PTN', FirstStim + j * (LastStim - FirstStim) / (Nsim - 1),'')
for k in xrange(0, len(pools)):
for i in xrange(0,len(pools[k].unit)):
pools[k].unit[i].createStimulus()
tic = time.time()
for i in xrange(0, len(t)-1):
pools[0].atualizeMotorUnitPool(t[i])
pools[1].atualizeAfferentPool(t[i],0)
pools[2].atualizeAfferentPool(t[i],0)
toc = time.time()
print str(toc - tic) + ' seconds'
pools[0].getMotorUnitPoolEMG()
Mp[j] = np.max(pools[0].emg[t<20]) - np.min(pools[0].emg[t<20])
Hp[j] = np.max(pools[0].emg[t>20]) - np.min(pools[0].emg[t>20])
print Mp[j]
print Hp[j]
emg[:,[j]] = pools[0].emg
pools[0].listSpikes()
pools[1].listSpikes()
pools[2].listSpikes()
sp1 = pools[0].poolTerminalSpikes
sp2 = pools[1].poolTerminalSpikes
sp2 = pools[2].poolTerminalSpikes
for k in xrange(0, len(pools)):
pools[k].reset()
In [18]:
f1 = plt.figure()
plt.plot(Stim, Hp, Stim, Mp)
Out[18]:
In [19]:
np.max(Hp)/np.max(Mp)
Out[19]:
In [20]:
Mp
Out[20]:
In [21]:
f2 = plt.figure()
plt.plot(t, emg[:,14])
Out[21]:
In [22]:
pools[0].listSpikes()
In [23]:
f3 = plt.figure()
plt.plot(sp1[:, 0],
sp1[:, 1]+1, '.')
plt.xlabel('t (ms)')
plt.ylabel('Motor Unit index')
Out[23]:
In [24]:
pools[0].poolTerminalSpikes[:, 1]
Out[24]:
In [ ]:
In [ ]:
In [ ]: