Ejemplo n.º 1
0
def simulator():

    conf = Configuration('confpython.rmto')

    pools = dict()
    pools[0] = MotorUnitPool(conf, 'SOL')
    pools[1] = InterneuronPool(conf, 'RC', 'ext')

    Syn = SynapsesFactory(conf, pools)

    t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)

    tic = time.clock()
    for i in xrange(0, len(t)):
        # Corrent injectada no soma dos MNs
        for j in xrange(1, len(pools[0].iInjected), 2):
            pools[0].iInjected[j] = 10
        pools[0].atualizeMotorUnitPool(t[i])  # MN pool
        pools[2].atualizePool(t[i])  # RC synaptic Noise
        pools[1].atualizeInterneuronPool(t[i])  # RC pool
    toc = time.clock()
    print str(toc - tic) + ' seconds'

    pools[0].listSpikes()

    plt.figure()
    plt.plot(pools[0].poolSomaSpikes[:, 0], pools[0].poolSomaSpikes[:, 1] + 1,
             '.')

    plt.figure()
    plt.plot(t, pools[0].Muscle.force, '-')
    plt.xlabel('t (ms)')
    plt.ylabel('Muscle Force (N)')
Ejemplo n.º 2
0
def simulator():

    conf = Configuration('confMNRC.rmto')

    pools = dict()
    pools[0] = MotorUnitPool(conf, 'SOL')
    pools[1] = InterneuronPool(conf, 'RC', 'ext')

    Syn = SynapsesFactory(conf, pools)

    t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)

    RC_mV = np.zeros_like(t)
    MN_mV = np.zeros_like(t)

    for i in xrange(0, len(t)):
        # t=step*i [ms]
        # Current in nA, adjusted to reproduce approximately the experimental 3mV
        pools[0].iInjected[1] = 13
        pools[0].atualizeMotorUnitPool(t[i])  # MN pool
        pools[2].atualizePool(t[i])  # RC synaptic Noise
        pools[1].atualizeInterneuronPool(t[i])  # RC pool
        RC_mV[i] = pools[1].unit[0].v_mV[0]
        MN_mV[i] = pools[0].unit[0].v_mV[1]

    fs = 1 / (conf.timeStep_ms * 1e-3)
    window = 1000
    f, Cxy = signal.coherence(MN_mV, RC_mV, fs, nperseg=window)

    plt.figure()
    plt.plot(f, Cxy)
    plt.xlabel('f (Hz)')
    plt.ylabel('Coherence')
    plt.xlim((0, 500))
Ejemplo n.º 3
0
def simulator():

    conf = Configuration('confTest.rmto')

    #idx = np.where(conf.confArray['f0']=='MUnumber_SOL-S')[0][0]
    #conf.confArray['f1'][idx] = nMN

    pools = dict()
    pools[0] = MotorUnitPool(conf, 'SOL')
    pools[1] = NeuralTract(conf, 'CMExt')
    #pools[2] = InterneuronPool(conf, 'RC', 'ext')

    #ankle = jointAnkleForceTask(conf, pools)
    Syn = SynapsesFactory(conf, pools)
    del Syn

    #conf.simDuration_ms = duration
    t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)

    tic = time.time()
    for i in xrange(0, len(t)):
        pools[1].atualizePool(t[i])
        pools[0].atualizeMotorUnitPool(t[i])
        #pools[3].atualizePool(t[i]) # RC synaptic Noise
        #pools[2].atualizeInterneuronPool(t[i]) # RC pool
    toc = time.time()
    print str(toc - tic) + ' seconds'

    pools[0].listSpikes()
    pools[1].listSpikes()
    '''
Ejemplo n.º 4
0
def simulator1():

    conf = Configuration('confGH.rmto')

    pools = dict()
    pools[0] = MotorUnitPool(conf, 'SOL')
    pools[1] = InterneuronPool(conf, 'RC', 'ext')
    pools[2] = NeuralTract(conf, 'CMExt')

    Syn = SynapsesFactory(conf, pools)

    t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)

    RC_mV = np.zeros_like(t)
    MN_mV = np.zeros_like(t)

    for i in xrange(0, len(t)):
        pools[2].atualizePool(t[i])  # Neural tract
        pools[0].atualizeMotorUnitPool(t[i])  # MN pool
        pools[3].atualizePool(t[i])  # RC synaptic Noise
        pools[1].atualizeInterneuronPool(t[i])  # RC pool
        RC_mV[i] = pools[1].unit[0].v_mV[0]
        MN_mV[i] = pools[0].unit[0].v_mV[1]

    pools[0].listSpikes()
    pools[1].listSpikes()
    pools[2].listSpikes()

    # Calculate feedback gain
    ## Calculate number of spikes
    numRecruitedUnits = int(max(pools[0].poolSomaSpikes[:, 1]))
    numberSpikes = [None] * numRecruitedUnits
    firingRate = [None] * numRecruitedUnits
    for i in xrange(numRecruitedUnits):
        # Count number of spikes for each recruited unit
        numberSpikes[i] = pools[0].poolSomaSpikes[:, 1].tolist().count(i)
        firingRate[i] = numberSpikes[i] / conf.simDuration_ms
    ## Calcultate average MN activity
    activity = np.mean(firingRate) * numRecruitedUnits

    plt.figure()
    plt.plot(pools[0].poolSomaSpikes[:, 0], pools[0].poolSomaSpikes[:, 1] + 1,
             '.')

    plt.figure()
    plt.plot(t, MN_mV)

    print '{} recruited units, with average activity of {}'.format(
        numRecruitedUnits, activity)
Ejemplo n.º 5
0
def initialize():
    conf = Configuration('confTest.rmto')

    pools = dict()
    pools[0] = MotorUnitPool(conf, 'SOL')
    pools[1] = NeuralTract(conf, 'CMExt')
    pools[2] = InterneuronPool(conf, 'RC', 'ext')

    for i in xrange(0, len(pools[0].unit)):
        pools[0].unit[i].createStimulus()

    Syn = SynapsesFactory(conf, pools)

    t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)

    return pools, t
Ejemplo n.º 6
0
def simulator():

    conf = Configuration('confnlinIO.rmto')

    pools = dict()
    pools[0] = MotorUnitPool(conf, 'SOL')
    pools[1] = InterneuronPool(conf, 'RC', 'ext')

    for i in xrange(0, len(pools[0].unit)):
        pools[0].unit[i].createStimulus()

    Syn = SynapsesFactory(conf, pools)

    t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)

    RC_mV = np.zeros_like(t)
    MN_mV = np.zeros_like(t)

    tic = time.clock()
    for i in xrange(0, len(t)):
        pools[0].atualizeMotorUnitPool(t[i])  # MN pool
        pools[2].atualizePool(t[i])  # RC synaptic Noise
        pools[1].atualizeInterneuronPool(t[i])  # RC pool
        RC_mV[i] = pools[1].v_mV[0]
        MN_mV[i] = pools[0].v_mV[1]
    toc = time.clock()
    print str(toc - tic) + ' seconds'

    pools[0].listSpikes()

    plt.figure()
    plt.plot(t, pools[0].unit[0].nerveStimulus_mA)

    plt.figure()
    plt.plot(t, MN_mV, '-')

    #plt.figure()
    #plt.plot(pools[0].poolSomaSpikes[:, 0],
    #    pools[0].poolSomaSpikes[:, 1]+1, '.')

    plt.figure()
    plt.plot(t, RC_mV, '-')
Ejemplo n.º 7
0
def simulator():

    conf = Configuration('confTest.rmto')

    pools = dict()
    pools[0] = MotorUnitPool(conf, 'SOL')
    pools[1] = NeuralTract(conf, 'CMExt')

    #pools.append(InterneuronPool(conf, 'RC'))

    #ankle = jointAnkleForceTask(conf, pools)
    Syn = SynapsesFactory(conf, pools)
    del Syn

    t = np.arange(0.0, conf.simDuration_ms, conf.timeStep_ms)

    dendV = np.zeros_like(t)
    somaV = np.zeros_like(t)
    internodeV = np.zeros_like(t)
    nodeV = np.zeros_like(t)

    FR_neuralTract = 80
    GammaOrder_neuralTract = 10

    tic = time.time()
    for i in xrange(0, len(t)):
        #for j in xrange(len(pools[0].unit)):
        #    pools[0].unit[j].iInjected[1] = 10
        pools[1].atualizePool(t[i], FR_neuralTract, GammaOrder_neuralTract)
        pools[0].atualizeMotorUnitPool(t[i])
        dendV[i] = pools[0].unit[2].v_mV[0]
        somaV[i] = pools[0].unit[2].v_mV[1]
    toc = time.time()
    print str(toc - tic) + ' seconds'

    pools[0].listSpikes()
    pools[1].listSpikes()
    '''