Beispiel #1
0
def makeSpine(model, parentComp, compName, index, frac, SpineParams):
    #frac is where along the compartment the spine is attached
    #unfortunately, these values specified in the .p file are not accessible
    neck_path = '{}/{}{}{}'.format(parentComp.path, compName, index, NAME_NECK)
    neck = moose.Compartment(neck_path)
    log.debug('{} at {} x,y,z={},{},{}', neck.path, frac, parentComp.x,
              parentComp.y, parentComp.z)
    moose.connect(parentComp, 'raxial', neck, 'axial', 'Single')
    #evenly distribute the spines along the parent compartment
    x = parentComp.x0 + frac * (parentComp.x - parentComp.x0)
    y = parentComp.y0 + frac * (parentComp.y - parentComp.y0)
    z = parentComp.z0 + frac * (parentComp.z - parentComp.z0)
    neck.x0, neck.y0, neck.z0 = x, y, z
    #could pass in an angle and use cos and sin to set y and z
    neck.x, neck.y, neck.z = x, y + SpineParams.necklen, z
    setSpineCompParams(model, neck, SpineParams.neckdia, SpineParams.necklen,
                       SpineParams.neckRA, SpineParams.spineRM,
                       SpineParams.spineCM)

    head_path = '{}/{}{}{}'.format(parentComp.path, compName, index, NAME_HEAD)
    head = moose.Compartment(head_path)
    moose.connect(neck, 'raxial', head, 'axial', 'Single')
    head.x0, head.y0, head.z0 = neck.x, neck.y, neck.z
    head.x, head.y, head.z = head.x0, head.y0 + SpineParams.headlen, head.z0

    setSpineCompParams(model, head, SpineParams.headdia, SpineParams.headlen,
                       SpineParams.headRA, SpineParams.spineRM,
                       SpineParams.spineCM)

    return head, neck
Beispiel #2
0
def makePassiveSoma( name, length, diameter):
    print("length: ", length)
    print("diameter: ", diameter)
    numComp = 10
    x = length/float(numComp)
    # x = length
    elecid = moose.Neuron( '/library/' + name )
    soma = moose.Compartment( elecid.path + '/soma' )
    soma.diameter = diameter
    soma.length = length
    soma.x0 = 0
    soma.x = x

    ls = x
    n = 2.0
    dendList = []
    for i in range(numComp -1):
        dendList.append(moose.Compartment( elecid.path + '/dend' + str(i) ))
        dend = dendList[-1]
        dend.diameter = diameter/n
        # dl = ls + x
        dend.x0 = ls
        dend.x = ls + x
        dend.length = x
        ls += x
        n += 1.0
        if i == 0:
            moose.connect( soma, 'axial', dendList[i], 'raxial')
        else:
            moose.connect( dendList[i-1], 'axial', dendList[i], 'raxial')
    return elecid
def loadGran98NeuroML_L123(filename, params):
    neuromlR = NeuroML()
    populationDict, projectionDict = \
        neuromlR.readNeuroMLFromFile(filename,params=params)
    print "Number of compartments =",\
        len(moose.Neuron(populationDict['CA1group'][1][0].path).children)
    soma_path = populationDict['CA1group'][1][0].path + '/Seg0_soma_0_0'
    somaVm = setupTable('somaVm', moose.Compartment(soma_path), 'Vm')
    #somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/Gran_CaPool_98'),'Ca')
    #somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/Gran_KCa_98'),'Gk')
    #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X')
    soma = moose.Compartment(soma_path)

    print "Reinit MOOSE ... "
    resetSim(['/elec', '/cells'], simdt, plotdt,
             simmethod='hsolve')  # from moose.utils
    print "Running ... "
    moose.start(runtime)
    tvec = arange(0.0, runtime, simdt)
    plot(tvec, somaVm.vector[1:])
    title('Soma Vm')
    xlabel('time (s)')
    ylabel('Voltage (V)')
    print "Showing plots ..."
    show()
def loadGran98NeuroML_L123(filename):
    neuromlR = NeuroML()
    populationDict, projectionDict = \
        neuromlR.readNeuroMLFromFile(filename)
    soma_path = populationDict['Gran'][1][0].path + '/Soma_0'
    somaVm = setupTable('somaVm', moose.Compartment(soma_path), 'Vm')
    somaCa = setupTable('somaCa', moose.CaConc(soma_path + '/Gran_CaPool_98'),
                        'Ca')
    somaIKCa = setupTable('somaIKCa',
                          moose.HHChannel(soma_path + '/Gran_KCa_98'), 'Gk')
    #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X')
    soma = moose.Compartment(soma_path)
    print("Reinit MOOSE ... ")
    resetSim(['/elec', '/cells'], simdt, plotdt,
             simmethod='ee')  # from moose.utils
    print("Running ... ")
    moose.start(runtime)
    tvec = arange(0.0, runtime, plotdt)
    plot(tvec, somaVm.vector[1:])
    title('Soma Vm')
    xlabel('time (s)')
    ylabel('Voltage (V)')
    figure()
    plot(tvec, somaCa.vector[1:])
    title('Soma Ca')
    xlabel('time (s)')
    ylabel('Ca conc (mol/m^3)')
    figure()
    plot(tvec, somaIKCa.vector[1:])
    title('KCa current (A)')
    xlabel('time (s)')
    ylabel('')
    print("Showing plots ...")
    show()
Beispiel #5
0
def makeSpine(model,
              parentComp,
              compName,
              index,
              frac,
              SpineParams,
              randomAngles=True):
    # frac is where along the compartment the spine is attached
    # unfortunately, these values specified in the .p file are not accessible
    neck_path = '{}/{}{}{}'.format(parentComp.path, compName, index, NAME_NECK)
    neck = moose.Compartment(neck_path)
    log.debug('{} at {} x,y,z={},{},{}', neck.path, frac, parentComp.x,
              parentComp.y, parentComp.z)
    moose.connect(parentComp, 'raxial', neck, 'axial', 'Single')
    # evenly distribute the spines along the parent compartment
    x = parentComp.x0 + frac * (parentComp.x - parentComp.x0)
    y = parentComp.y0 + frac * (parentComp.y - parentComp.y0)
    z = parentComp.z0 + frac * (parentComp.z - parentComp.z0)
    neck.x0, neck.y0, neck.z0 = x, y, z
    from scipy.linalg import norm

    if randomAngles:
        # random angles for visualization
        dendvect = np.array([
            parentComp.x, parentComp.y, parentComp.z
        ]) - np.array([parentComp.x0, parentComp.y0, parentComp.z0])
        dendvmag = norm(dendvect)
        dendunitvec = dendvect / dendvmag
        not_v = np.random.random(3)
        not_v /= norm(not_v)
        while (dendunitvec == not_v).all():
            not_v = np.random.random(3)
            not_v /= norm(not_v)
        # make vector perpendicular to v
        n1 = np.cross(dendunitvec, not_v)
        # normalize n1
        n1 /= norm(n1)
        neck.x, neck.y, neck.z = SpineParams.necklen * n1
        # print(neck.x, neck.y, neck.z)
    else:
        # could pass in an angle and use cos and sin to set y and z
        neck.x, neck.y, neck.z = x, y + SpineParams.necklen, z
    setSpineCompParams(model, neck, SpineParams.neckdia, SpineParams.necklen,
                       SpineParams.neckRA, SpineParams.spineRM,
                       SpineParams.spineCM)

    head_path = '{}/{}{}{}'.format(parentComp.path, compName, index, NAME_HEAD)
    head = moose.Compartment(head_path)
    moose.connect(neck, 'raxial', head, 'axial', 'Single')
    head.x0, head.y0, head.z0 = neck.x, neck.y, neck.z
    head.x, head.y, head.z = SpineParams.headlen * np.array([
        head.x0, head.y0, head.z0
    ]) / norm(np.array([head.x0, head.y0, head.z0]))
    # head.x0, head.y0 + SpineParams.headlen, head.z0

    setSpineCompParams(model, head, SpineParams.headdia, SpineParams.headlen,
                       SpineParams.headRA, SpineParams.spineRM,
                       SpineParams.spineCM)
    return head, neck
 def loadCell(self):
     self.context.readCell('gran_aditya_migliore.p',self.path)
     self._gran = moose.Cell(self.path)
     self._granSoma = moose.Compartment(self.path+'/soma')
     self._granSomaKA = moose.Compartment(self.path+'/soma/KA_ms')
     self._granPeri = moose.Compartment(self.path+'/periphery')
     self._granPeriNa = moose.HHChannel(self.path+'/periphery/Na_rat_ms')
     self._granPeriKA = moose.HHChannel(self.path+'/periphery/KA_ms')
Beispiel #7
0
 def setUp(self):
     cell = moose.Neutral('/n')
     comp1 = moose.Compartment('/n/c1')
     chan = moose.HHChannel('/n/c1/ch')
     moose.connect(comp1, 'channel', chan, 'channel')
     comp2 = moose.Compartment('/n/c2')
     comp2.connect('raxial', comp1, 'axial')
     self.graph = moosegraph('/n')
Beispiel #8
0
def loadGran98NeuroML_L123(filename):
    neuromlR = NeuroML()
    populationDict, projectionDict = \
        neuromlR.readNeuroMLFromFile(filename)
    soma_path = populationDict['CA1group'][1][0].path + '/Seg0_soma_0_0'
    somaVm = setupTable('somaVm', moose.Compartment(soma_path), 'Vm')
    soma = moose.Compartment(soma_path)
    moose.reinit()
    moose.start(runtime)
    tvec = np.arange(0.0, runtime, simdt)
    res = count.spike_train_simple_stat(somaVm.vector)
    return res['number of spikes']
Beispiel #9
0
def create_spine(parentCompt, parentObj, index, frac, length, dia, theta):
    """Create spine of specified dimensions and index"""
    RA = 1.0
    RM = 1.0
    CM = 0.01
    sname = 'shaft' + str(index)
    hname = 'head' + str(index)
    shaft = moose.Compartment(parentObj.path + '/' + sname)
    moose.connect(parentCompt, 'raxial', shaft, 'axial', 'single')
    x = parentCompt.x0 + frac * (parentCompt.x - parentCompt.x0)
    y = parentCompt.y0 + frac * (parentCompt.y - parentCompt.y0)
    z = parentCompt.z0 + frac * (parentCompt.z - parentCompt.z0)
    shaft.x0 = x
    shaft.y0 = y
    shaft.z0 = z
    sy = y + length * math.cos(theta * math.pi / 180.0)
    sz = z + length * math.sin(theta * math.pi / 180.0)
    shaft.x = x
    shaft.y = sy
    shaft.z = sz
    shaft.diameter = dia / 10.0
    shaft.length = length
    xa = math.pi * dia * dia / 400.0
    circumference = math.pi * dia / 10.0
    shaft.Ra = RA * length / xa
    shaft.Rm = RM / (length * circumference)
    shaft.Cm = CM * length * circumference
    shaft.Em = EREST_ACT
    shaft.initVm = EREST_ACT

    head = moose.Compartment(parentObj.path + '/' + hname)
    moose.connect(shaft, 'raxial', head, 'axial', 'single')
    head.x0 = x
    head.y0 = sy
    head.z0 = sz
    hy = sy + length * math.cos(theta * math.pi / 180.0)
    hz = sz + length * math.sin(theta * math.pi / 180.0)
    head.x = x
    head.y = hy
    head.z = hz
    head.diameter = dia
    head.length = length
    xa = math.pi * dia * dia / 4.0
    circumference = math.pi * dia
    head.Ra = RA * length / xa
    head.Rm = RM / (length * circumference)
    head.Cm = CM * length * circumference
    head.Em = EREST_ACT
    head.initVm = EREST_ACT
    return head
Beispiel #10
0
def add_synchans(model, container):
    #synchans is 2D array, where each row has a single channel type
    #at the end they are concatenated into a dictionary
    synchans = []
    comp_list = moose.wildcardFind(container + '/#[TYPE=Compartment]')
    SynPerCompList = np.zeros((len(comp_list), len(model.NumSyn)), dtype=int)
    #Create 2D array to store all the synapses.  Rows=num synapse types, columns=num comps
    for key in model.SYNAPSE_TYPES:
        synchans.append([])
    allkeys = sorted(model.SYNAPSE_TYPES)

    # i indexes compartment for array that stores number of synapses
    for i, comp in enumerate(comp_list):

        #create each type of synchan in each compartment.  Add to 2D array
        for key in DendSynChans(model):
            keynum = allkeys.index(key)
            Gbar = model.SYNAPSE_TYPES[key].Gbar
            Gbarvar = model.SYNAPSE_TYPES[key].var
            synchans[keynum].append(
                addoneSynChan(key, comp, Gbar, model.calYN, Gbarvar))

        for key in SpineSynChans(model):
            keynum = allkeys.index(key)
            Gbar = model.SYNAPSE_TYPES[key].Gbar
            Gbarvar = model.SYNAPSE_TYPES[key].var
            for spcomp in moose.wildcardFind(comp.path +
                                             '/#[ISA=Compartment]'):
                if NAME_HEAD in spcomp.path:
                    synchans[keynum].append(
                        addoneSynChan(key, spcomp, Gbar, model.calYN, Gbarvar))

        ########### delete from here to allsynchans= once pop_funcs debugged ################

        #calculate distance from soma
        xloc = moose.Compartment(comp).x
        yloc = moose.Compartment(comp).y
        dist = np.sqrt(xloc * xloc + yloc * yloc)
        #create array of number of synapses per compartment based on distance
        #possibly replace NumGlu[] with number of spines, or eliminate this if using real morph
        #Check in ExtConn - how is SynPerComp used
    #end of iterating over compartments
    #now, transform the synchans into a dictionary

    allsynchans = {
        key: synchans[keynum]
        for keynum, key in enumerate(sorted(model.SYNAPSE_TYPES))
    }

    return allsynchans
Beispiel #11
0
 def setUp(self):
     self.test_id = uuid.uuid4()
     self.model_container = moose.Neutral('test%s' % (self.test_id))
     self.neuron = moose.Neuron('%s/cell' % (self.model_container.path))
     self.soma = moose.Compartment('%s/soma' % (self.neuron.path))
     self.soma.diameter = 20e-6
     self.soma.length = 0.0
     parent = self.soma
     comps = []
     for ii in range(100):
         comp = moose.Compartment('%s/comp_%d' % (self.neuron.path, ii))
         comp.diameter = 10e-6
         comp.length = 100e-6
         moose.connect(parent, 'raxial', comp, 'axial')
         comps.append(comp)
         parent = comp
Beispiel #12
0
 def loadCell(self):
     self.context.readCell('mit_aditya_davison_reduced.p', self.path)
     self._mitral = moose.Cell(self.path)
     self._mitralSoma = moose.Compartment(self.path + '/soma')
     self._mitralGlom = moose.Compartment(self.path + '/glom')
     self._mitralDend = moose.Compartment(self.path + '/dend')
     self._mitralDendNa = moose.HHChannel(self.path + '/dend/Na_mit_usb')
     self._mitralSomaNa = moose.HHChannel(self.path + '/soma/Na_mit_usb')
     self._mitralSomaCaPool = moose.CaConc(self.path + '/soma/Ca_mit_conc')
     self._mitralSomaLCa = moose.HHChannel(self.path + '/soma/LCa3_mit_usb')
     self._mitralSomaKCa = moose.HHChannel(self.path + '/soma/Kca_mit_usb')
     # Connect the LCa current to the Ca Pool
     self._mitralSomaLCa.connect('IkSrc', self._mitralSomaCaPool, 'current')
     # Connect the KCa channel to the Ca concentration of Ca Pool
     self._mitralSomaCaPool.connect('concSrc', self._mitralSomaKCa,
                                    'concen')
Beispiel #13
0
def makePassiveSoma(name, length, diameter):
    elecid = moose.Neuron('/library/' + name)
    dend = moose.Compartment(elecid.path + '/soma')
    dend.diameter = diameter
    dend.length = length
    dend.x = length
    return elecid
Beispiel #14
0
def makeCompt(name, parent, dx, dy, dia):
    RM = 1.0
    RA = 1.0
    CM = 0.01
    EM = -0.065
    pax = 0
    pay = 0
    if (parent.className == "Compartment"):
        pax = parent.x
        pay = parent.y
    compt = moose.Compartment(name)
    compt.x0 = pax
    compt.y0 = pay
    compt.z0 = 0
    compt.x = pax + dx
    compt.y = pay + dy
    compt.z = 0
    compt.diameter = dia
    clen = numpy.sqrt(dx * dx + dy * dy)
    compt.length = clen
    compt.Rm = RM / (numpy.pi * dia * clen)
    compt.Ra = RA * 4.0 * numpy.pi * clen / (dia * dia)
    compt.Cm = CM * numpy.pi * dia * clen
    if (parent.className == "Compartment"):
        moose.connect(parent, 'raxial', compt, 'axial')
    return compt
Beispiel #15
0
def makePassiveSoma(name, length, diamater):
    elecid = moose.Neuron('/library/' + name)
    dend = moose.Compartment(elecid.path + '/soma')
    dend.diameter = params['dendDia']
    dend.length = params['dendL']
    dend.x = params['dendL']
    return elecid
Beispiel #16
0
def loadGran98NeuroML_L123(filename):
    neuromlR = NeuroML()
    populationDict, projectionDict = \
        neuromlR.readNeuroMLFromFile(filename)
    soma_path = populationDict['Gran'][1][0].path+'/Soma_0'
    somaVm = setupTable('somaVm',moose.Compartment(soma_path),'Vm')
    somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/Gran_CaPool_98'),'Ca')
    somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/Gran_KCa_98'),'Gk')
    ## Am not able to plot KDr gating variable X when running under hsolve
    #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X')

    print "Reinit MOOSE ... "
    resetSim(['/elec',cells_path], simdt, plotdt, simmethod='hsolve')

    print "Running ... "
    moose.start(runtime)
    tvec = arange(0.0,runtime*2.0,plotdt)
    tvec = tvec[ : somaVm.vector.size ]
    plot(tvec,somaVm.vector)
    title('Soma Vm')
    xlabel('time (s)')
    ylabel('Voltage (V)')
    figure()
    plot(tvec,somaCa.vector)
    title('Soma Ca')
    xlabel('time (s)')
    ylabel('Ca conc (mol/m^3)')
    figure()
    plot(tvec,somaIKCa.vector)
    title('soma KCa current')
    xlabel('time (s)')
    ylabel('KCa current (A)')
    print "Showing plots ..."
    show()
Beispiel #17
0
def buildCompt(pa,
               name,
               RM=1.0,
               RA=1.0,
               CM=0.01,
               dia=1.0e-6,
               x=0.0,
               y=0.0,
               z=0.0,
               dx=10e-6,
               dy=0.0,
               dz=0.0,
               Em=-0.065,
               initVm=-0.065):
    length = np.sqrt(dx * dx + dy * dy + dz * dz)
    compt = moose.Compartment(pa.path + '/' + name)
    compt.x0 = x
    compt.y0 = y
    compt.z0 = z
    compt.x = dx + x
    compt.y = dy + y
    compt.z = dz + z
    compt.diameter = dia
    compt.length = length
    xa = dia * dia * PI / 4.0
    sa = length * dia * PI
    compt.Ra = length * RA / xa
    compt.Rm = RM / sa
    compt.Cm = CM * sa
    compt.Em = Em
    compt.initVm = initVm
    return compt
Beispiel #18
0
    def __init__(self, path, length, diameter, args):
        """ Initialize moose-compartment """
        self.mc_ = None
        self.path = path
        # Following values are taken from Upi's chapter on Rallpacks
        self.RM = args.get('RM', 4.0)
        self.RA = args.get('RA', 1.0)
        self.CM = args.get('CM', 0.01)
        self.Em = args.get('Em', -0.065)
        self.diameter = diameter
        self.compLength = length
        self.computeParams()

        try:
            self.mc_ = moose.Compartment(self.path)
            self.mc_.length = self.compLength
            self.mc_.diameter = self.diameter
            self.mc_.Ra = self.Ra
            self.mc_.Rm = self.Rm
            self.mc_.Cm = self.Cm
            self.mc_.Em = self.Em
            self.mc_.initVm = self.Em

        except Exception as e:
            utils.dump("ERROR", [
                "Can't create compartment with path %s " % path,
                "Failed with error %s " % e
            ])
            sys.exit(0)
Beispiel #19
0
def testNMDAChan(simtime=1.0, simdt=1e-5, plotdt=1e-5):
    context = moose.PyMooseBase.getContext()
    container = moose.Neutral('test_NMDA')

    soma_b = moose.Compartment('B', container)
    soma_b.Rm = 5.3e9 # GM = 2e-5 S/cm^2
    soma_b.Cm = 8.4823001646924426e-12 # CM = 0.9 uF/cm^2
    soma_b.Em = -65e-3 
    soma_b.initVm = -65e-3
    soma_b.Ra = 282942.12 # RA = 250 Ohm-cm
    
    nmda = moose.NMDAChan('nmda', container)
    nmda.tau2 = 5e-3
    nmda.tau1 = 130e-3
    nmda.Gbar = 1e-9
    nmda.saturation = 1e10
    nmda.connect('channel', soma_b, 'channel')
    spikegen = moose.SpikeGen('spike', container)
    spikegen.threshold = 0.5
    spikegen.connect('event', nmda, 'synapse')
    spikegen.refractT = 0.0
    nmda.delay[0] = 1e-3
    nmda.weight[0] = 1.0
    
    pulsegen = moose.PulseGen('pulse', container)
    pulsegen.setCount(3)
    pulsegen.level[0] = 1.0
    pulsegen.delay[0] = 10e-3
    pulsegen.width[0] = 1e-3
    pulsegen.level[1] = 1.0
    pulsegen.delay[1] = 2e-3
    pulsegen.width[1] = 1e-3    
    pulsegen.delay[2] = 1e9
    pulsegen.connect('outputSrc', spikegen, 'Vm')

    data = moose.Neutral('data')
    vmB = moose.Table('Vm_B', data)
    vmB.stepMode = 3
    vmB.connect('inputRequest', soma_b, 'Vm')
    pulse = moose.Table('pulse', data)
    pulse.stepMode = 3
    pulse.connect('inputRequest', pulsegen, 'output')
    gNMDA = moose.Table('G', data)
    gNMDA.stepMode = 3
    gNMDA.connect('inputRequest', nmda, 'Gk')

    context.setClock(0, simdt)
    context.setClock(1, simdt)
    context.setClock(2, simdt)
    context.setClock(3, plotdt)
    context.reset()
    context.step(simtime)
    # gNMDA.dumpFile('gNMDA.dat', False)
    # vmA.dumpFile('Va.dat', False)
    # vmB.dumpFile('Vb.dat', False)
    ts = np.linspace(0, simtime, len(gNMDA))
    pylab.plot(ts, pulse)
    pylab.plot(ts, np.asarray(gNMDA) * 1e9, label='gNMDA')
    pylab.show()
    np.savetxt('../data/two_comp_nmda.plot', np.transpose(np.vstack((ts, vmB, gNMDA))))
def create_compartment(path):
    comp = moose.Compartment(path)
    comp.diameter = soma_dia
    comp.Em = EREST_ACT + 10.613e-3
    comp.initVm = EREST_ACT
    sarea = np.pi * soma_dia * soma_dia
    comp.Rm = 1/(0.3e-3 * 1e4 * sarea)
    comp.Cm = 1e-6 * 1e4 * sarea
    if moose.exists('/library/na'):
        nachan = moose.element(moose.copy('/library/na', comp, 'na'))
    else:
        nachan = create_na_chan(comp.path)
    nachan.Gbar = 120e-3 * sarea * 1e4
    moose.showfield(nachan)
    moose.connect(nachan, 'channel', comp, 'channel')
    if moose.exists('/library/k'):
        kchan = moose.element(moose.copy('/library/k', comp, 'k'))
    else:
        kchan = create_k_chan(comp.path)
    kchan.Gbar = 36e-3 * sarea * 1e4
    moose.connect(kchan, 'channel', comp, 'channel')
    synchan = moose.SynChan(comp.path + '/synchan')
    synchan.Gbar = 1e-8
    synchan.tau1 = 2e-3
    synchan.tau2 = 2e-3
    synchan.Ek = 0.0
    m = moose.connect(comp, 'channel', synchan, 'channel')
    spikegen = moose.SpikeGen(comp.path + '/spikegen')
    spikegen.threshold = 0.0
    m = moose.connect(comp, 'VmOut', spikegen, 'Vm')
    return comp
Beispiel #21
0
 def translate_rotate(
         self, obj, x, y, z,
         ztheta):  # recursively translate all compartments under obj
     for childId in obj.children:
         try:
             childobj = moose.element(childId)
             if childobj.className in ['Compartment', 'SymCompartment']:
                 ## SymCompartment inherits from Compartment,
                 ## so below wrapping by Compartment() is fine for both Compartment and SymCompartment
                 child = moose.Compartment(childId)
                 x0 = child.x0
                 y0 = child.y0
                 x0new = x0 * cos(ztheta) - y0 * sin(ztheta)
                 y0new = x0 * sin(ztheta) + y0 * cos(ztheta)
                 child.x0 = x0new + x
                 child.y0 = y0new + y
                 child.z0 += z
                 x1 = child.x
                 y1 = child.y
                 x1new = x1 * cos(ztheta) - y1 * sin(ztheta)
                 y1new = x1 * sin(ztheta) + y1 * cos(ztheta)
                 child.x = x1new + x
                 child.y = y1new + y
                 child.z += z
             if len(childobj.children) > 0:
                 self.translate_rotate(
                     childobj, x, y, z,
                     ztheta)  # recursive translation+rotation
         except TypeError:  # in async13, gates which have not been created still 'exist'
             # i.e. show up as a child, but cannot be wrapped.
             pass
Beispiel #22
0
 def translate_rotate(
         self, obj, x, y, z,
         ztheta):  # recursively translate all compartments under obj
     for childId in obj.children():
         childobj = moose.Neutral(childId)
         if childobj.className in [
                 'Compartment', 'SymCompartment'
         ]:  # if childobj is a compartment or symcompartment translate, else skip it
             child = moose.Compartment(
                 childId
             )  # SymCompartment inherits from Compartment, so this is fine for both Compartment and SymCompartment
             x0 = child.x0
             y0 = child.y0
             x0new = x0 * cos(ztheta) - y0 * sin(ztheta)
             y0new = x0 * sin(ztheta) + y0 * cos(ztheta)
             child.x0 = x0new + x
             child.y0 = y0new + y
             child.z0 += z
             x1 = child.x
             y1 = child.y
             x1new = x1 * cos(ztheta) - y1 * sin(ztheta)
             y1new = x1 * sin(ztheta) + y1 * cos(ztheta)
             child.x = x1new + x
             child.y = y1new + y
             child.z += z
         if len(childobj.children()) > 0:
             self.translate_rotate(childobj, x, y, z,
                                   ztheta)  # recursive translation+rotation
Beispiel #23
0
 def translate_rotate(self, obj, x, y, z, ztheta):
     for childId in obj.children:
         childobj = moose.Neutral(childId)
         # if childobj is a compartment or symcompartment translate, else
         # skip it
         if childobj.className in ['Compartment', 'SymCompartment']:
             # SymCompartment inherits from Compartment, so below wrapping by
             # Compartment() is fine for both Compartment and SymCompartment
             child = moose.Compartment(childId)
             x0 = child.x0
             y0 = child.y0
             x0new = x0 * cos(ztheta) - y0 * sin(ztheta)
             y0new = x0 * sin(ztheta) + y0 * cos(ztheta)
             child.x0 = x0new + x
             child.y0 = y0new + y
             child.z0 += z
             x1 = child.x
             y1 = child.y
             x1new = x1 * cos(ztheta) - y1 * sin(ztheta)
             y1new = x1 * sin(ztheta) + y1 * cos(ztheta)
             child.x = x1new + x
             child.y = y1new + y
             child.z += z
         if len(childobj.children) > 0:
             # recursive translation+rotation
             self.translate_rotate(childobj, x, y, z, ztheta)
Beispiel #24
0
def make_compartment(path):
    comp = moose.Compartment(path)
    comp.Em = -70e-3
    comp.initVm = -70e-3
    comp.Cm = 1e-12
    comp.Rm = 1e9
    return comp
Beispiel #25
0
def create_squid():
    """Create a single compartment squid model."""
    parent = moose.Neutral('/n')
    compt = moose.Compartment('/n/compt')
    Em = EREST_ACT + 10.613e-3
    compt.Em = Em
    compt.initVm = EREST_ACT
    compt.Cm = 7.85e-9
    compt.Rm = 4.2e5
    compt.Ra = 7639.44e3
    nachan = moose.HHChannel('/n/compt/Na')
    nachan.Xpower = 3
    xGate = moose.HHGate(nachan.path + '/gateX')
    xGate.setupAlpha(Na_m_params + [VDIVS, VMIN, VMAX])
    nachan.Ypower = 1
    yGate = moose.HHGate(nachan.path + '/gateY')
    yGate.setupAlpha(Na_h_params + [VDIVS, VMIN, VMAX])
    nachan.Gbar = 0.942e-3
    nachan.Ek = 115e-3 + EREST_ACT
    moose.connect(nachan, 'channel', compt, 'channel', 'OneToOne')

    kchan = moose.HHChannel('/n/compt/K')
    kchan.Xpower = 4.0
    xGate = moose.HHGate(kchan.path + '/gateX')
    xGate.setupAlpha(K_n_params + [VDIVS, VMIN, VMAX])
    kchan.Gbar = 0.2836e-3
    kchan.Ek = -12e-3 + EREST_ACT
    moose.connect(kchan, 'channel', compt, 'channel', 'OneToOne')
    return compt
Beispiel #26
0
def run_model():
    model = moose.Neutral('/model')
    data = moose.Neutral('/data')
    cell = TuftedIB('/model/TuftedIB')
    stim = alpha_stimulus('/model/stim', 1.0e-9, 15e-3, 20e-3, simtime, simdt)
    stim.startTime = 1e9
    p1 = cell.path + '/' + d1
    p2 = cell.path + '/' + d2
    comp_d1 = moose.element(p1) if moose.exists(p1) else moose.Compartment(p1)
    comp_d2 = moose.element(p2) if moose.exists(p2) else moose.Compartment(p2)
    s = '%s/%s' % (cell.path, 'comp_1')
    comp_soma = moose.element(s) if moose.exists(s) else moose.Compartment(s)
    comp_soma.inject = -0.2e-9
    moose.connect(stim, 'output', comp_d1, 'injectMsg')
    tab_d1 = moose.Table('%s/d1_Vm' % (data.path))
    tab_d2 = moose.Table('%s/d2_Vm' % (data.path))
    tab_soma = moose.Table('%s/soma_Vm' % (data.path))
    tab_stim = moose.Table('%s/stim' % (data.path))
    moose.connect(tab_d1, 'requestOut', comp_d1, 'getVm')
    moose.connect(tab_d2, 'requestOut', comp_d2, 'getVm')
    moose.connect(tab_soma, 'requestOut', comp_soma, 'getVm')
    moose.connect(stim, 'output', tab_stim, 'input')
    solver = moose.HSolve('%s/solver' % (cell.path))
    solver.dt = simdt
    solver.target = cell.path
    utils.setDefaultDt(elecdt=simdt, plotdt2=plotdt)
    utils.assignDefaultTicks()
    moose.reinit()
    utils.stepRun(simtime, 1e5 * simdt, logger=config.logger)
    pylab.subplot(211)
    pylab.plot(np.linspace(0, simtime, len(tab_d1.vector)),
               tab_d1.vector * 1e3,
               label='D1 Vm (mV)')
    pylab.plot(np.linspace(0, simtime, len(tab_d2.vector)),
               tab_d2.vector * 1e3,
               label='D2 Vm (mV)')
    pylab.plot(np.linspace(0, simtime, len(tab_soma.vector)),
               tab_soma.vector * 1e3,
               label='SOMA Vm (mV)')
    pylab.legend()
    pylab.subplot(212)
    pylab.plot(np.linspace(0, simtime, len(tab_stim.vector)),
               tab_stim.vector * 1e9,
               label='Stimulus (nA)')
    pylab.legend()
    pylab.savefig('fig_a4c.png')
    pylab.show()
Beispiel #27
0
def make_testcomp(containerpath):
    comp = moose.Compartment('%s/testcomp' % (containerpath))
    comp.Em = -65e-3
    comp.initVm = -65e-3
    comp.Cm = 1e-12
    comp.Rm = 1e9
    comp.Ra = 1e5
    return comp
Beispiel #28
0
def timetable_demo():
    tt_array, sp_array = timetable_nparray()
    tt_file, sp_file = timetable_file()
    # Create a synchan inside a compartment to demonstrate how to use
    # TimeTable to send artificial spike events to a synapse.
    comp = moose.Compartment('/model/comp')
    comp.Em = -60e-3
    comp.Rm = 1e9
    comp.Cm = 1e-12
    synchan = moose.SynChan('/model/comp/synchan')
    synchan.Gbar = 1e-6
    synchan.Ek = 0.0
    moose.connect(synchan, 'channel', comp, 'channel')
    synh = moose.SimpleSynHandler('/model/comp/synchan/synh')
    moose.connect(synh, 'activationOut', synchan, 'activation')
    synh.synapse.num = 1
    moose.connect(tt_file, 'eventOut', moose.element(synh.path + '/synapse'),
                  'addSpike')
    # Data recording: record the `state` of the time table filled
    # using array.
    data = moose.Neutral('/data')
    tab_array = moose.Table('/data/tab_array')
    moose.connect(tab_array, 'requestOut', tt_array, 'getState')
    # Record the synaptic conductance for the other time table, which
    # is filled from a text file and sends spike events to a synchan.
    tab_file = moose.Table('/data/tab_file')
    moose.connect(tab_file, 'requestOut', synchan, 'getGk')

    # Scheduling
    moose.setClock(0, simdt)
    moose.setClock(1, simdt)
    moose.useClock(1, '/model/##[ISA=Compartment]', 'init')
    moose.useClock(1, '/model/##,/data/##', 'process')
    moose.reinit()
    moose.start(simtime)

    # Plotting
    pylab.subplot(2, 1, 1)
    pylab.plot(sp_array,
               np.ones(len(sp_array)),
               'rx',
               label='spike times from numpy array')
    pylab.plot(np.linspace(0, simtime, len(tab_array.vector)),
               tab_array.vector,
               'b-',
               label='TimeTable state')
    pylab.legend()
    pylab.subplot(2, 1, 2)
    pylab.plot(sp_file,
               np.ones(len(sp_file)),
               'rx',
               label='spike times from file')
    pylab.plot(np.linspace(0, simtime, len(tab_file.vector)),
               tab_file.vector * 1e6,
               'b-',
               label='Syn Gk (uS)')
    pylab.legend()
    pylab.show()
def buildModel():
    global model
    global soma
    model = moose.Neutral('/model')
    soma = moose.Compartment('/model/soma')
    soma.Em = -60e-3
    soma.Rm = 1e10
    soma.Cm = 1e-10
    return model
Beispiel #30
0
def loadGran98NeuroML_L123(filename):
    neuromlR = NeuroML()
    populationDict, projectionDict = \
        neuromlR.readNeuroMLFromFile(filename)
    soma_path = populationDict['Gran'][1][0].path + '/Soma_0'
    somaVm = setupTable('somaVm', moose.Compartment(soma_path), 'Vm')
    somaCa = setupTable('somaCa', moose.CaConc(soma_path + '/Gran_CaPool_98'),
                        'Ca')
    somaIKCa = setupTable('somaIKCa',
                          moose.HHChannel(soma_path + '/Gran_KCa_98'), 'Gk')
    #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X')
    soma = moose.Compartment(soma_path)
    print "Reinit MOOSE ... "
    resetSim(['/elec', '/cells'], simdt, plotdt,
             simmethod='ee')  # from moose.utils
    print "Running ... "
    moose.start(runtime)
    print 'Finished simulation for', runtime, 'seconds'