Exemple #1
0
def main():
    """
    Example of Interpol object.
    """
    simtime = 1.0
    simdt = 0.001
    model = moose.Neutral('/model')
    data = moose.Neutral('/data')
    interpol = moose.Interpol('/model/sin')
    vec = np.sin(np.linspace(-3.14, 3.14, 100))
    interpol.vector = vec
    interpol.xmax = 3.14
    interpol.xmin = -3.14
    recorded = moose.Table('/data/output')
    moose.connect(recorded, 'requestOut', interpol, 'getY')

    stimtab = moose.StimulusTable('/model/x')
    stimtab.stepSize = 0.0
    # stimtab.startTime = 0.0
    # stimtab.stopTime = simtime
    stimtab.vector = np.linspace(-4, 4, 1000)
    print((stimtab.vector))
    print((interpol.vector))
    moose.connect(stimtab, 'output', interpol, 'input')

    moose.setClock(0, simdt)
    moose.useClock(0, '/data/##,/model/##', 'process')
    moose.reinit()
    moose.start(simtime)
    plt.plot(np.linspace(0, simtime, len(recorded.vector)),
             recorded.vector,
             'b-+',
             label='interpolated')
    plt.plot(np.linspace(0, simtime, len(vec)), vec, 'r-+', label='original')
    plt.show()
    def __init__(self, *args):
        moose.SynChan.__init__(self, *args)
        self.Ek = -80e-3  # V
        # For event based synapses, I had a strength of 5e-6 S
        #    to compensate for event-based,
        # but for the original graded synapses, 5e-9 S is correct.
        self.Gbar = 5e-9  # S # set weight on connecting the network
        self.tau1 = 100e-3  # s # this is Vpre dependent (see below)
        self.tau2 = 0.0  # single first order equation

        Vth = -35e-3  # V
        Delta = 5e-3  # V
        ######## Graded synapse activation
        inhsyntable = moose.Interpol(self.path + "/graded_table")
        graded = moose.Mstring(self.path + '/graded')
        graded.value = 'True'
        mgblock = moose.Mstring(self.path + '/mgblockStr')
        mgblock.value = 'False'
        # also needs a synhandler
        moosesynhandler = moose.SimpleSynHandler(self.path + '/handler')
        # connect the SimpleSynHandler or the STDPSynHandler to the SynChan (double exp)
        moose.connect(moosesynhandler, 'activationOut', self, 'activation')

        # ds/dt = s_inf/tau - s/tau = A - Bs
        # where A=s_inf/tau is activation, B is 1/tau
        # Fill up the activation and tau tables
        # Graded synapse tau
        inhtautable = moose.Interpol(self.path + "/tau_table")
        inhtautable.xmin = -70e-3  # V
        inhtautable.xmax = 0e-3  # V
        tau = [self.tau1]  # at -70 mV
        tau.extend( [self.tau1*(1. - 1./(1+math.exp((Vth-vm)/Delta))) \
            for vm in arange(-70e-3,0.00001e-3,70e-3/1000.)] )
        inhtautable.vector = array(tau)
        inhtautable.connect("lookupOut", self, "setTau1")

        # Graded synapse activation
        inhsyntable.xmin = -70e-3  # V
        inhsyntable.xmax = 0e-3  # V
        act = [0.0]  # at -70 mV
        act.extend( [1/(1+math.exp((Vth-vm)/Delta)) \
            for vm in arange(-70e-3,0.00001e-3,70e-3/1000.)] )
        act = array(act) / array(
            tau)  # element-wise division # NOTE: A = s_inf/tau
        inhsyntable.vector = array(act)
        inhsyntable.connect("lookupOut", self, "activation")
"""Example of Interpol object."""
__author__ = 'Subhasis Ray'

import sys
import math
import numpy as np
from matplotlib import pyplot as plt

sys.path.append('../../python')
import moose

simtime = 1.0
simdt = 0.001
model = moose.Neutral('/model')
data = moose.Neutral('/data')
interpol = moose.Interpol('/model/sin')
vec = np.sin(np.linspace(-3.14, 3.14, 100))
interpol.vector = vec
interpol.xmax = 3.14
interpol.xmin = -3.14
recorded = moose.Table('/data/output')
moose.connect(recorded, 'requestOut', interpol, 'getY')

stimtab = moose.StimulusTable('/model/x')
stimtab.stepSize = 0.0
# stimtab.startTime = 0.0
# stimtab.stopTime = simtime
stimtab.vector = np.linspace(-4, 4, 1000)
print((stimtab.vector))
print((interpol.vector))
moose.connect(stimtab, 'output', interpol, 'input')