Ejemplo n.º 1
0
def test_crossing_single():
    """This function creates an ematrix of two PulseGen elements and
    another ematrix of two Table elements.

    The two pulsegen elements have same amplitude but opposite phase.

    Table[0] is connected to PulseGen[1] and Table[1] to Pulsegen[0].

    In the plot you should see two square pulses of opposite phase.

    """
    size = 2
    pg = moose.PulseGen('pulsegen', size)
    for ix, ii in enumerate(pg.vec):
        pulse = moose.element(ii)
        pulse.delay[0] = 1.0
        pulse.width[0] = 2.0
        pulse.level[0] = (-1)**ix
    tab = moose.Table('table', size)
    moose.connect(tab.vec[0], 'requestOut', pg.vec[1], 'getOutputValue', 'Single')
    moose.connect(tab.vec[1], 'requestOut', pg.vec[0], 'getOutputValue', 'Single')
    print 'Neighbors:'
    for t in tab.vec:
        print t.path
        for n in moose.element(t).neighbors['requestOut']:
            print 'requestOut <-', n.path
    moose.setClock(0, 0.1)
    moose.useClock(0, '/##', 'process')
    moose.start(5)
    for ii in tab.vec:
        t = moose.Table(ii).vector
        print len(t)
        pylab.plot(t)
    pylab.show()
    def _init_plots(self):
        ExcInhNetBase._init_plots(self)
        if CaPlasticity:
            self.recNCa = 5  # number of synapses for which to record Ca
            #  as range(self.N) is too large
            self.recNwt = 20  # number of synapses for which to record weights

            ## make tables to store weights of recN exc synapses
            self.weightsEq = moose.Table('/plotWeightsEq', self.recNwt)
            wtidx = 0
            for i in range(self.N):
                for j in range(self.excC):
                    if self.excC * i + j not in self.potSyns:
                        moose.connect(
                            self.weightsEq.vec[wtidx], 'requestOut',
                            self.synsEE.vec[i * self.excC + j].synapse[0],
                            'getWeight')
                        wtidx += 1
                        if wtidx >= self.recNwt: break
                ## break only breaks out of one loop, hence repeated here!
                if wtidx >= self.recNwt: break

            self.weightsUp = moose.Table('/plotWeightsUp', self.recNwt)
            for i in range(self.recNwt):  # range(self.N) is too large
                moose.connect(self.weightsUp.vec[i], 'requestOut',
                              self.synsEE.vec[self.potSyns[i]].synapse[0],
                              'getWeight')

            self.CaTables = moose.Table('/plotCa', self.recNCa)
            for i in range(self.recNCa):  # range(self.N) is too large
                moose.connect(self.CaTables.vec[i], 'requestOut',
                              self.synsEE.vec[i * self.excC], 'getCa')
Ejemplo n.º 3
0
def spinetabs(model, neuron, comps='all'):
    if not moose.exists(DATA_NAME):
        moose.Neutral(DATA_NAME)
    # creates tables of calcium and vm for spines
    spcatab = defaultdict(list)
    spvmtab = defaultdict(list)
    for typenum, neurtype in enumerate(neuron.keys()):
        if type(comps) == str and comps in {'*', 'all'}:
            spineHeads = [moose.wildcardFind(neurtype + '/##/#head#[ISA=CompartmentBase]')]
        else:
            spineHeads = [moose.wildcardFind(neurtype + '/' + c + '/#head#[ISA=CompartmentBase]') for c in comps]
        for spinelist in spineHeads:
            for spinenum, spine in enumerate(spinelist):
                compname = spine.parent.name
                sp_num = spine.name.split(NAME_HEAD)[0]
                spvmtab[typenum].append(moose.Table(vm_table_path(neurtype, spine=sp_num, comp=compname)))
                log.debug('{} {} {}', spinenum, spine.path, spvmtab[typenum][-1].path)
                moose.connect(spvmtab[typenum][-1], 'requestOut', spine, 'getVm')
                if model.calYN:
                    for child in spine.children:
                        if child.className == "CaConc" or child.className == "ZombieCaConc":
                            spcatab[typenum].append(
                                moose.Table(DATA_NAME + '/%s_%s%s' % (neurtype, sp_num, compname) + child.name))
                            spcal = moose.element(spine.path + '/' + child.name)
                            moose.connect(spcatab[typenum][-1], 'requestOut', spcal, 'getCa')
                        elif child.className == 'DifShell':
                            spcatab[typenum].append(
                                moose.Table(DATA_NAME + '/%s_%s%s' % (neurtype, sp_num, compname) + child.name))
                            spcal = moose.element(spine.path + '/' + child.name)
                            moose.connect(spcatab[typenum][-1], 'requestOut', spcal, 'getC')
    return spcatab, spvmtab
Ejemplo n.º 4
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))))
Ejemplo n.º 5
0
def setupCurrentStepModel(testId, celltype, pulsearray, dt):
    """Setup a single cell simulation.

    simid - integer identifying the model

    celltype - str cell type
    
    pulsearray - an nx3 array with row[i] = (delay[i], width[i], level[i]) of current injection.
    """
    modelContainer = moose.Neutral('/test%d' % (testId))
    dataContainer = moose.Neutral('/data%d' % (testId))
    cell = TCR('%s/TCR' % (modelContainer.path)) # moose.copy(cells.TCR.prototype, modelContainer.path)#
    pulsegen = moose.PulseGen('%s/pulse' % (modelContainer.path))
    pulsegen.count = len(pulsearray)
    for ii in range(len(pulsearray)):
        pulsegen.delay[ii] = pulsearray[ii][0]
        pulsegen.width[ii] = pulsearray[ii][1]
        pulsegen.level[ii] = pulsearray[ii][2]
    moose.connect(pulsegen, 'output', cell.soma, 'injectMsg')
    somaVm = moose.Table('%s/vm' % (dataContainer.path))
    moose.connect(somaVm, 'requestOut', cell.soma, 'getVm')
    pulseTable = moose.Table('%s/pulse' % (dataContainer.path))
    moose.connect(pulseTable, 'requestOut', pulsegen, 'getOutputValue')
    setupClocks(dt)
    moose.useClock(0, '%s/##[ISA=Compartment]' % (cell.path), 'init')
    moose.useClock(1, '%s/##[ISA=Compartment]' % (cell.path), 'process')
    moose.useClock(7, pulsegen.path, 'process')
    moose.useClock(8, '%s/##' % (dataContainer.path), 'process')
    return {'cell': cell,
            'stimulus': pulsegen,
            'vmTable': somaVm,
            'stimTable': pulseTable
            }
    def _init_plots(self):
        ## make a few tables to store a few Vm-s
        numVms = 10
        self.plots = moose.Table('/plotVms', numVms)
        ## draw numVms out of N neurons
        # not using random.sample() here since Brian version isn't
        #nrnIdxs = random.sample(range(self.N),numVms)
        nrnIdxs = list(range(self.N))
        for i in range(numVms):
            moose.connect( self.network.vec[nrnIdxs[i]], 'VmOut', \
                self.plots.vec[i], 'input')

        ## make self.N tables to store spikes of all neurons
        self.spikes = moose.Table('/plotSpikes', self.N)
        moose.connect( self.network, 'spikeOut', \
            self.spikes, 'input', 'OneToOne' )

        ## make 2 tables to store spikes of all exc and all inh neurons
        self.spikesExc = moose.Table('/plotSpikesAllExc')
        for i in range(self.NmaxExc):
            moose.connect( self.network.vec[i], 'spikeOut', \
                self.spikesExc, 'input' )
        self.spikesInh = moose.Table('/plotSpikesAllInh')
        for i in range(self.NmaxExc, self.N):
            moose.connect( self.network.vec[i], 'spikeOut', \
                self.spikesInh, 'input' )
Ejemplo n.º 7
0
def setup_experiment(presynaptic, postsynaptic, synchan):
    """Setup step current stimulation of presynaptic neuron. Also setup
    recording of pre and postsynaptic Vm, Gk of synchan.

    """
    pulse = moose.PulseGen('/model/pulse')
    pulse.level[0] = 1e-9
    pulse.delay[0] = 0.02  # disable the pulsegen
    pulse.width[0] = 40e-3
    pulse.delay[1] = 1e9
    moose.connect(pulse, 'output', presynaptic, 'injectMsg')
    data = moose.Neutral('/data')
    vm_a = moose.Table('/data/Vm_pre')
    moose.connect(vm_a, 'requestOut', presynaptic, 'getVm')
    vm_b = moose.Table('/data/Vm_post')
    moose.connect(vm_b, 'requestOut', postsynaptic, 'getVm')
    gksyn_b = moose.Table('/data/Gk_syn')
    moose.connect(gksyn_b, 'requestOut', synchan, 'getGk')
    pulsetable = moose.Table('/data/pulse')
    pulsetable.connect('requestOut', pulse, 'getOutputValue')
    return {
        'stimulus': pulsetable,
        'Vm_pre': vm_a,
        'Vm_post': vm_b,
        'Gk_syn': gksyn_b
    }
def single_population(size=2):
    """Example of a single population where each cell is connected to
    every other cell.

    Creates a network of single compartmental cells under /network1 and a pulse generaor

    """
    net = moose.Neutral('network1')
    pop = create_population(moose.Neutral('/network1'), size)
    make_synapses(pop['spikegen'], pop['synchan'])
    pulse = moose.PulseGen('/network1/net1_pulse')
    pulse.firstLevel = 1e-9
    pulse.firstDelay = 0.05
    pulse.firstWidth = 0.02
    moose.connect(pulse, 'output', pop['compartment'][0], 'injectMsg')
    data = moose.Neutral('/data')
    vm = [moose.Table('/data/net1_Vm_%d' % (ii)) for ii in range(size)]
    for tab, comp in zip(vm, pop['compartment']):
        moose.connect(tab, 'requestOut', comp, 'getVm')
    gksyn = [moose.Table('/data/net1_Gk_syn_%d' % (ii)) for ii in range(size)]
    for tab, synchan in zip(gksyn, pop['synchan']):
        moose.connect(tab, 'requestOut', synchan, 'getGk')
    pulsetable = moose.Table('/data/net1_pulse')
    pulsetable.connect('requestOut', pulse, 'getOutputValue')
    return {
        'vm': vm,
        'gksyn': gksyn,
        'pulse': pulsetable,
    }
Ejemplo n.º 9
0
def current_step_test(simtime, simdt, plotdt):
    """Create a single compartment and set it up for applying a step
    current injection.

    We use a PulseGen object to generate a 40 ms wide 1 nA current
    pulse that starts 20 ms after start of simulation.

    """
    model = moose.Neutral('/model')
    comp = create_1comp_neuron('/model/neuron')
    stim = moose.PulseGen('/model/stimulus')
    stim.delay[0] = 20e-3
    stim.level[0] = 1e-9
    stim.width[0] = 40e-3
    stim.delay[1] = 1e9
    moose.connect(stim, 'output', comp, 'injectMsg')
    data = moose.Neutral('/data')
    current_tab = moose.Table('/data/current')
    moose.connect(current_tab, 'requestOut', stim, 'getOutputValue')
    vm_tab = moose.Table('/data/Vm')
    moose.connect(vm_tab, 'requestOut', comp, 'getVm')
    for i in range(10):
        moose.setClock(i, simdt)
    moose.setClock(8, plotdt)
    moose.reinit()
    moose.start(simtime)
    ts = np.linspace(0, simtime, len(vm_tab.vector))
    return ts, current_tab.vector, vm_tab.vector,
Ejemplo n.º 10
0
def test_nml2(nogui=True):
    global SCRIPT_DIR
    filename = os.path.join(SCRIPT_DIR, 'test_files/passiveCell.nml')
    mu.info('Loading: %s' % filename)
    nml = moose.mooseReadNML2(filename)
    if not nml:
        mu.warn("Failed to parse NML2 file")
        return

    assert nml, "Expecting NML2 object"
    msoma = nml.getComp(nml.doc.networks[0].populations[0].id, 0, 0)
    data = moose.Neutral('/data')
    pg = nml.getInput('pulseGen1')

    inj = moose.Table('%s/pulse' % (data.path))
    moose.connect(inj, 'requestOut', pg, 'getOutputValue')

    vm = moose.Table('%s/Vm' % (data.path))
    moose.connect(vm, 'requestOut', msoma, 'getVm')

    simtime = 150e-3
    moose.reinit()
    moose.start(simtime)
    print("Finished simulation!")
    yvec = vm.vector
    injvec = inj.vector * 1e12
    m1, u1 = np.mean(yvec), np.std(yvec)
    m2, u2 = np.mean(injvec), np.std(injvec)
    assert np.isclose(m1, -0.0456943), m1
    assert np.isclose(u1, 0.0121968), u1
    assert np.isclose(m2, 26.64890), m2
    assert np.isclose(u2, 37.70607574), u2
Ejemplo n.º 11
0
def setup_recording(data_path, neuron, syninfo_list):
    """Record Vm from soma and synaptic conductances from synapses in
    syninfo_list

    """
    neuron_path = neuron.path
    data_container = moose.Neutral(data_path)
    soma_vm = moose.Table('%s/Vm_soma' % (data_path))
    soma_path = '%s/soma_1' % (neuron_path)
    print('5555 Soma path', soma_path)
    soma = moose.element(soma_path)
    moose.connect(soma_vm, 'requestOut', soma, 'getVm')
    ampa_data = moose.Neutral('%s/G_AMPA' % (data_path))
    nmda_data = moose.Neutral('%s/G_NMDA' % (data_path))
    ampa_gk = []
    nmda_gk = []

    # Record synaptic conductances
    for syninfo in syninfo_list:
        compname = syninfo['spike'].parent.name
        tab = moose.Table('%s/Gk_nmda_%s' % (nmda_data.path, compname))
        moose.connect(tab, 'requestOut', syninfo['nmda'], 'getGk')
        nmda_gk.append(tab)
        tab = moose.Table('%s/Gk_ampa_%s' % (ampa_data.path, compname))
        moose.connect(tab, 'requestOut', syninfo['ampa'], 'getGk')
        ampa_gk.append(tab)
    return {
        'ampa_gk': ampa_gk,
        'nmda_gk': nmda_gk,
        'soma_vm': soma_vm,
        'data': data_container
    }
Ejemplo n.º 12
0
def create_network(size=2):
    """
    Create a network containing two neuronal populations, pop_A and
    pop_B and connect them up.
    """
    net = moose.Neutral('network')
    pop_a = create_population(moose.Neutral('/network/pop_A'), size)
    print(pop_a)
    pop_b = create_population(moose.Neutral('/network/pop_B'), size)
    make_synapses(pop_a['spikegen'], pop_b['synhandler'])
    pulse = moose.PulseGen('pulse')
    pulse.level[0] = 1e-9
    pulse.delay[0] = 0.02 # disable the pulsegen
    pulse.width[0] = 40e-3
    pulse.delay[1] = 1e9
    data = moose.Neutral('/data')
    vm_a = moose.Table('/data/Vm_A', n=size)
    moose.connect(pulse, 'output', pop_a['compartment'], 'injectMsg', 'OneToAll')
    moose.connect(vm_a, 'requestOut', pop_a['compartment'], 'getVm', 'OneToOne')
    vm_b = moose.Table('/data/Vm_B', size)
    moose.connect(vm_b, 'requestOut', pop_b['compartment'], 'getVm', 'OneToOne')
    gksyn_b = moose.Table('/data/Gk_syn_b', n=size)
    moose.connect(gksyn_b, 'requestOut', pop_b['synchan'], 'getGk', 'OneToOne')
    pulsetable = moose.Table('/data/pulse')
    pulsetable.connect('requestOut', pulse, 'getOutputValue')
    return {'A': pop_a,
            'B': pop_b,
            'Vm_A': vm_a,
            'Vm_B': vm_b,
            'Gsyn_B': gksyn_b
        }
Ejemplo n.º 13
0
def gapjunction_demo():
    model = moose.Neutral('model')
    data = moose.Neutral('data')
    comps = []
    comp1 = make_compartment('%s/comp1' % (model.path))
    comp2 = make_compartment('%s/comp2' % (model.path))
    pulse = moose.PulseGen('%s/pulse' % (model.path))
    pulse.level[0] = 1e-9
    pulse.delay[0] = 50e-3
    pulse.width[0] = 20e-3
    pulse.delay[1] = 1e9
    moose.connect(pulse, 'output', comp1, 'injectMsg')
    gj = moose.GapJunction('%s/gj' % (model.path))
    gj.Gk = 1e-6
    moose.connect(gj, 'channel1', comp1, 'channel')
    moose.connect(gj, 'channel2', comp2, 'channel')
    vm1_tab = moose.Table('%s/Vm1' % (data.path))
    moose.connect(vm1_tab, 'requestOut', comp1, 'getVm')
    vm2_tab = moose.Table('%s/Vm2' % (data.path))
    moose.connect(vm2_tab, 'requestOut', comp2, 'getVm')
    pulse_tab = moose.Table('%s/inject' % (data.path))
    moose.connect(pulse_tab, 'requestOut', pulse, 'getOutputValue')
    utils.setDefaultDt(elecdt=simdt, plotdt2=simdt)
    utils.assignDefaultTicks()
    utils.stepRun(simtime, 10000*simdt)
    # print len(vm1_tab.vector), len(vm2_tab.vector), len(pulse_tab.vector)
    # moose.showmsg(comp1)
    # moose.showmsg(comp2)
    # moose.showmsg(pulse)
    t = pylab.linspace(0, simtime, len(vm1_tab.vector))
    pylab.plot(t, vm1_tab.vector*1000, label='Vm1 (mV)')
    pylab.plot(t, vm2_tab.vector*1000, label='Vm2 (mV)')
    pylab.plot(t, pulse_tab.vector*1e9, label='inject (nA)')
    pylab.legend()
    pylab.show()
Ejemplo n.º 14
0
def loadAndRun(solver=True):
    simtime = 500e-3
    model = moose.loadModel('../data/h10.CNG.swc', '/cell')
    comp = moose.element('/cell/apical_e_177_0')
    soma = moose.element('/cell/soma')
    for i in range(10):
        moose.setClock(i, dt)
    if solver:
        solver = moose.HSolve('/cell/solver')
        solver.target = soma.path
        solver.dt = dt
    stim = moose.PulseGen('/cell/stim')
    stim.delay[0] = 50e-3
    stim.delay[1] = 1e9
    stim.level[0] = 1e-9
    stim.width[0] = 2e-3
    moose.connect(stim, 'output', comp, 'injectMsg')
    tab = moose.Table('/cell/Vm')
    moose.connect(tab, 'requestOut', comp, 'getVm')
    tab_soma = moose.Table('/cell/Vm_soma')
    moose.connect(tab_soma, 'requestOut', soma, 'getVm')
    moose.reinit()
    print('[INFO] Running for %s' % simtime)
    moose.start(simtime )
    vec = tab_soma.vector
    moose.delete( '/cell' )
    return vec
Ejemplo n.º 15
0
def test_synintegration(filename, target_cell, source_type):
    sim = Simulation('synintegration')
    cell = SpinyStellate(SpinyStellate.prototype, 
                         sim.model.path + '/SpinyStellate')
    vm_table = cell.comp[cell.presyn].insertRecorder('Vm', 'Vm', sim.data)
    # Create a common spike gen object
    sp = moose.SpikeGen('spike', sim.model)
    sp.threshold = 0.0
    sp.edgeTriggered = 1
    sptab = moose.Table('spike', sim.data)
    sptab.stepMode = 3
    sptab.connect('inputRequest', sp, 'state')
    (comp_indices, syntype, gbar, tau1, tau2, Ek, ) = \
        get_syninfo(filename, target_cell, source_type)    
    # Set up the synapses
    for ii in range(len(comp_indices)):
        print '%d\t%s\t%g\t%g\t%g\t%g' % (comp_indices[ii], 
                                          syntype[ii], 
                                          gbar[ii], 
                                          tau1[ii], 
                                          tau2[ii], 
                                          Ek[ii])
        comp = cell.comp[comp_indices[ii]]
        weight = 1.0
        if syntype[ii] == 'nmda':
            chan = moose.NMDAChan('nmda_from_%s' % (source_type), comp)
            chan.MgConc = 1.5            
            weight = gbar[ii]
        else:
            chan = moose.SynChan('%s_from_%s' % (syntype[ii], source_type), 
                                 comp)
        chan.Gbar = gbar[ii]
        chan.tau1 = tau1[ii]
        chan.tau2 = tau2[ii]
        chan.Ek = Ek[ii]
        comp.connect('channel', chan, 'channel')
        sp.connect('event', chan, 'synapse')
        count = chan.numSynapses
        if source_type == 'TCR':
            chan.delay[count-1] = 1e-3 # thalamocortical delay
        else:
            chan.delay[count-1] = 0.05e-3 # default delay
        chan.weight[count-1] = weight
        gktable = moose.Table('%s_%s_%s' % (cell.name, comp.name, chan.name), sim.data)
        gktable.stepMode = 3
        gktable.connect('inputRequest', chan, 'Gk')
    pulsegen = moose.PulseGen('pulse', sim.model)
    pulsegen.firstDelay = 3.0
    pulsegen.firstLevel = 1.0
    pulsegen.firstWidth = 1e-3
    pulsegen.trigMode = moose.FREE_RUN
    pulsegen.connect('outputSrc', sp, 'Vm')
    ptable = moose.Table('pulse', sim.data)
    ptable.stepMode = 3
    ptable.connect('inputRequest', pulsegen, 'output')
    sim.schedule(simdt=1e-6, plotdt=1e-6)
    sim.run(10.0)
    sim.save_data_h5(filename.replace('network_', 'synintegration_'))
Ejemplo n.º 16
0
def analogStimTable():
    """Example of using a StimulusTable as an analog signal source in
    a reaction system. It could be used similarly to give other 
    analog inputs to a model, such as a current or voltage clamp signal.

    This demo creates a StimulusTable and assigns it half a sine wave.
    Then we assign the start time and period over which to emit the wave.
    The output of the StimTable is sent to a pool **a**, which participates
    in a trivial reaction::

        table ----> a <===> b

    The output of **a** and **b** are recorded in a regular table 
    for plotting.
    """
    simtime = 150
    simdt = 0.1
    model = moose.Neutral('/model')
    data = moose.Neutral('/data')
    # This is the stimulus generator
    stimtable = moose.StimulusTable('/model/stim')
    a = moose.BufPool( '/model/a' )
    b = moose.Pool( '/model/b' )
    reac = moose.Reac( '/model/reac' )
    reac.Kf = 0.1
    reac.Kb = 0.1
    moose.connect( stimtable, 'output', a, 'setConcInit' )
    moose.connect( reac, 'sub', a, 'reac' )
    moose.connect( reac, 'prd', b, 'reac' )
    aPlot = moose.Table('/data/aPlot')
    moose.connect(aPlot, 'requestOut', a, 'getConc')
    bPlot = moose.Table('/data/bPlot')
    moose.connect(bPlot, 'requestOut', b, 'getConc')
    moose.setClock( stimtable.tick, simdt )
    moose.setClock( a.tick, simdt )
    moose.setClock( aPlot.tick, simdt )

    ####################################################
    # Here we set up the stimulus table. It is half a sine-wave.
    stim = [ np.sin(0.01 * float(i) ) for i in range( 314 )]
    stimtable.vector = stim
    stimtable.stepSize = 0 # This forces use of current time as x value

    # The table will interpolate its contents over the time start to stop:
    # At values less than startTime, it emits the first value in table
    stimtable.startTime = 5
    # At values more than stopTime, it emits the last value in table
    stimtable.stopTime = 60
    stimtable.doLoop = 1 # Enable repeat playbacks.
    stimtable.loopTime = 10 + simtime / 2.0 # Repeat playback over this time

    moose.reinit()
    moose.start(simtime)
    t = [ x * simdt for x in range( len( aPlot.vector ) )]
    pylab.plot( t, aPlot.vector, label='Stimulus waveform' )
    pylab.plot( t, bPlot.vector, label='Reaction product b' )
    pylab.legend()
    pylab.show()
Ejemplo n.º 17
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()
Ejemplo n.º 18
0
def run(nogui):

    reader = NML2Reader(verbose=True)

    filename = 'test_files/passiveCell.nml'
    print('Loading: %s' % filename)
    reader.read(filename)

    msoma = reader.getComp(reader.doc.networks[0].populations[0].id, 0, 0)
    print(msoma)

    data = moose.Neutral('/data')

    pg = reader.getInput('pulseGen1')

    inj = moose.Table('%s/pulse' % (data.path))
    moose.connect(inj, 'requestOut', pg, 'getOutputValue')

    vm = moose.Table('%s/Vm' % (data.path))
    moose.connect(vm, 'requestOut', msoma, 'getVm')

    simdt = 1e-6
    plotdt = 1e-4
    simtime = 150e-3

    if (1):
        #moose.showmsg( '/clock' )
        for i in range(8):
            moose.setClock(i, simdt)
        moose.setClock(8, plotdt)
        moose.reinit()
    else:
        utils.resetSim([model.path, data.path], simdt, plotdt, simmethod='ee')
        moose.showmsg('/clock')

    moose.start(simtime)

    print("Finished simulation!")

    t = np.linspace(0, simtime, len(vm.vector))

    if not nogui:
        import matplotlib.pyplot as plt

        plt.subplot(211)
        plt.plot(t, vm.vector * 1e3, label='Vm (mV)')
        plt.legend()
        plt.title('Vm')
        plt.subplot(212)
        plt.title('Input')
        plt.plot(t, inj.vector * 1e9, label='injected (nA)')
        #plt.plot(t, gK.vector * 1e6, label='K')
        #plt.plot(t, gNa.vector * 1e6, label='Na')
        plt.legend()
        plt.show()
        plt.close()
Ejemplo n.º 19
0
def setup_two_cells():
    """
    Create two cells with leaky integrate and fire compartments. Each
    cell is a single compartment a1 and b2. a1 is stimulated by a step
    current injection.

    The compartment a1 is connected to the compartment b2 through a
    synaptic channel.

    """
    model = moose.Neutral('/model')
    data = moose.Neutral('/data')
    a1 = LIFComp('/model/a1')
    b2 = LIFComp(moose.copy(a1, '/model', 'b2'))
    a1.Vthreshold = 10e-3
    a1.Vreset = 0
    b2.Vthreshold = 10e-3
    b2.Vreset = 0
    syn = moose.SynChan('%s/syn' % (b2.path))
    syn.tau1 = 1e-3
    syn.tau2 = 5e-3
    syn.Ek = 90e-3
    synh = moose.SimpleSynHandler(syn.path + '/synh')
    moose.connect(synh, 'activationOut', syn, 'activation')
    synh.synapse.num += 1
    # syn.numSynapses = 1
    synh.synapse.delay = delayMax
    moose.connect(b2, 'channel', syn, 'channel')
    ## Single message works most of the time but occassionally gives a
    ## core dump

    # m = moose.connect(a1.spikegen, 'spikeOut',
    #                   syn.synapse.vec, 'addSpike')

    ## With Sparse message and random connectivity I did not get core
    ## dump.
    m = moose.connect(a1.spikegen, 'spikeOut', synh.synapse.vec, 'addSpike',
                      'Sparse')
    m.setRandomConnectivity(1.0, 1)
    stim = moose.PulseGen('/model/stim')
    stim.delay[0] = 100e-3
    stim.width[0] = 1e3
    stim.level[0] = 11e-9
    moose.connect(stim, 'output', a1, 'injectMsg')
    tables = []
    data = moose.Neutral('/data')
    for c in moose.wildcardFind('/##[ISA=Compartment]'):
        tab = moose.Table('%s/%s_Vm' % (data.path, c.name))
        moose.connect(tab, 'requestOut', c, 'getVm')
        tables.append(tab)
    syntab = moose.Table('%s/%s' % (data.path, 'Gk'))
    moose.connect(syntab, 'requestOut', syn, 'getGk')
    tables.append(syntab)
    synh.synapse[0].delay = 1e-3
    syn.Gbar = 1e-6
    return tables
Ejemplo n.º 20
0
def graphtables(model, neuron,pltcurr,curmsg, plas=[],compartments='all'):
    print("GRAPH TABLES, of ", neuron.keys(), "plas=",len(plas),"curr=",pltcurr)
    #tables for Vm and calcium in each compartment
    vmtab={}
    catab={key:[] for key in neuron.keys()}
    currtab={}

    # Make sure /data exists
    if not moose.exists(DATA_NAME):
        moose.Neutral(DATA_NAME)

    for typenum,neur_type in enumerate(neuron.keys()):
        if type(compartments)==str and compartments in {'all', '*'}:
                neur_comps = moose.wildcardFind(neur_type + '/#[TYPE=Compartment]')
        else:
            neur_comps=[moose.element(neur_type+'/'+comp) for comp in compartments]
        vmtab[neur_type] = [moose.Table(vm_table_path(neur_type, comp=ii)) for ii in range(len(neur_comps))]

        for ii,comp in enumerate(neur_comps):
            moose.connect(vmtab[neur_type][ii], 'requestOut', comp, 'getVm')

        if model.calYN:
            for ii,comp in enumerate(neur_comps):
                for child in comp.children:
                    if child.className in {"CaConc", "ZombieCaConc"}:
                        catab[neur_type].append(moose.Table(DATA_NAME+'/%s_%d_' % (neur_type,ii)+child.name))
                        cal = moose.element(comp.path+'/'+child.name)
                        moose.connect(catab[neur_type][-1], 'requestOut', cal, 'getCa')
                    elif  child.className == 'DifShell':
                        catab[neur_type].append(moose.Table(DATA_NAME+'/%s_%d_' % (neur_type,ii)+child.name))
                        cal = moose.element(comp.path+'/'+child.name)
                        moose.connect(catab[neur_type][-1], 'requestOut', cal, 'getC')

        if pltcurr:
            currtab[neur_type]={}
            #CHANNEL CURRENTS (Optional)
            for channame in model.Channels:
                tabs = [moose.Table(DATA_NAME+'/chan%s%s_%d' %(channame,neur_type,ii))
                        for ii in range(len(neur_comps))]
                currtab[neur_type][channame] = tabs
                for tab, comp in zip(tabs, neur_comps):
                    path = comp.path+'/'+channame
                    try:
                        chan=moose.element(path)
                        moose.connect(tab, 'requestOut', chan, curmsg)
                    except Exception:
                        log.debug('no channel {}', path)
    #
    # synaptic weight and plasticity (Optional) for one synapse per neuron
    plastab={key:[] for key in neuron.keys()}
    if len(plas):
        for num,neur_type in enumerate(plas.keys()):
            if len(plas[neur_type]):
                for comp_name in plas[neur_type]:
                    plastab[neur_type].append(add_one_table(DATA_NAME,plas[neur_type],comp_name))
    return vmtab,catab,plastab,currtab
Ejemplo n.º 21
0
def setup_stimulation(comp):
    stim = moose.PulseGen('/model/stimulus')
    stim.delay[0], stim.level[0] = 20e-3, 1e-9 #Start injection ar 20ms, with 1nanoAmp.
    stim.width[0], stim.delay[1] = 40e-3, 1e9  #Duration of current is 40ms.
    moose.connect(stim, 'output', comp, 'injectMsg')
    data = moose.Neutral('/data')
    current_tab = moose.Table('/data/current')
    moose.connect(current_tab, 'requestOut', stim, 'getOutputValue')
    vm_tab = moose.Table('/data/Vm')
    moose.connect(vm_tab, 'requestOut', comp, 'getVm')
    return (current_tab, vm_tab)
Ejemplo n.º 22
0
def test_hsolve_calcium():
    for tick in range(0, 7):
        moose.setClock(tick, 10e-6)
    moose.setClock(8, 0.005)

    lib = moose.Neutral('/library')
    model = moose.loadModel(p_file, 'neuron')
    assert model, model
    pulse = moose.PulseGen('/neuron/pulse')
    inject = 100e-10
    chan_proto.chan_proto('/library/SK', param_chan.SK)
    chan_proto.chan_proto('/library/CaL12', param_chan.Cal)
    pulse.delay[0] = 8.
    pulse.width[0] = 500e-12
    pulse.level[0] = inject
    pulse.delay[1] = 1e9

    for comp in moose.wildcardFind('/neuron/#[TYPE=Compartment]'):
        new_comp = moose.element(comp)
        new_comp.initVm = -.08
        difs, difb = td.add_difshells_and_buffers(new_comp, difshell_no,
                                                  difbuf_no)
        for name in cond:
            chan = td.addOneChan(name, cond[name], new_comp)
            if 'Ca' in name:
                moose.connect(chan, "IkOut", difs[0], "influx")

            if 'SK' in name:
                moose.connect(difs[0], 'concentrationOut', chan, 'concen')

    data = moose.Neutral('/data')
    vmtab = moose.Table('/data/Vm')
    shelltab = moose.Table('/data/Ca')
    caltab = moose.Table('/data/CaL_Gk')
    sktab = moose.Table('/data/SK_Gk')
    moose.connect(vmtab, 'requestOut', moose.element('/neuron/soma'), 'getVm')
    moose.connect(shelltab, 'requestOut', difs[0], 'getC')
    moose.connect(caltab, 'requestOut', moose.element('/neuron/soma/CaL12'),
                  'getGk')
    moose.connect(sktab, 'requestOut', moose.element('/neuron/soma/SK'),
                  'getGk')

    hsolve = moose.HSolve('/neuron/hsolve')
    hsolve.dt = 10e-6
    hsolve.target = ('/neuron/soma')
    t_stop = 10.
    moose.reinit()
    moose.start(t_stop)
    vec1 = sktab.vector
    vec2 = shelltab.vector
    assert_stat(vec1, [0.0, 5.102834e-22, 4.79066e-22, 2.08408e-23])
    assert_stat(vec2, [5.0e-5, 5.075007e-5, 5.036985e-5, 2.1950117e-7])
    assert len(np.where(sktab.vector < 1e-19)[0]) == 2001
    assert len(np.where(shelltab.vector > 50e-6)[0]) == 2000
Ejemplo n.º 23
0
def syn_plastabs(connections, model, plas=[]):
    synapse_msg = model.param_sim.plot_synapse_message
    if not moose.exists(DATA_NAME):
        moose.Neutral(DATA_NAME)
    # dictionary of tables with synaptic conductance for all synapses that receive input
    syn_tabs = {ntype: {k: [] for nname in connections[ntype].keys() for k in list(connections[ntype][nname].keys()) if
                        k != 'postsoma_loc'} for ntype in connections.keys()}
    if model.plasYN:
        plas_tabs = {
            ntype: {k: [] for nname in connections[ntype].keys() for k in list(connections[ntype][nname].keys()) if
                    k != 'postsoma_loc'} for ntype in connections.keys()}
    else:
        plas_tabs = []
    if getattr(model, 'stpYN', False):
        stp_tabs = {
            ntype: {k: [] for nname in connections[ntype].keys() for k in list(connections[ntype][nname].keys()) if
                    k != 'postsoma_loc'} for ntype in connections.keys()}
    else:
        stp_tabs = []
    for neur_type in connections.keys():
        for neur_name in connections[neur_type].keys():
            for syntype in list(syn_tabs[neur_type].keys()):
                for precomp in connections[neur_type][neur_name][syntype].keys():
                    if 'extern' in precomp:
                        for comp in connections[neur_type][neur_name][syntype][precomp].keys():
                            synchan = moose.element(neur_name + '/' + comp + '/' + syntype)
                            # print ('##### syn_plastabs',synchan.path,'/'+neur_name.split('/')[-1]+'-'+precomp,comp)
                            syn_tabs[neur_type][syntype].append(moose.Table(DATA_NAME + '/%s' % (
                                        neur_name.split('/')[-1] + '-' + precomp + CONNECT_SEPARATOR + comp.replace('/',
                                                                                                                    '-'))))
                            log.debug('{} {} {} {} {}', neur_name, syntype, synchan.path, precomp,
                                      syn_tabs[neur_type][syntype][-1])
                            moose.connect(syn_tabs[neur_type][syntype][-1], 'requestOut', synchan, 'getGk')
                            if getattr(model, 'stpYN', False):
                                create_plas_tabs(synchan, syn_tabs[neur_type][syntype][-1].name,
                                                 stp_tabs[neur_type][syntype], ['fac', 'dep', 'stp'])
                            if model.plasYN:
                                create_plas_tabs(synchan, syn_tabs[neur_type][syntype][-1].name,
                                                 plas_tabs[neur_type][syntype], ['plas'])
                    else:
                        synchan = moose.element(neur_name + '/' + precomp.split(CONNECT_SEPARATOR)[-1] + '/' + syntype)
                        # print ('###########',synchan.path,'/'+neur_name.split('/')[-1]+'-'+precomp)
                        syn_tabs[neur_type][syntype].append(
                            moose.Table(DATA_NAME + '/%s' % (neur_name.split('/')[-1] + '-' + precomp)))
                        log.debug('neur={} syn={} {} comp={} tab={}', neur_name, syntype, synchan.path, precomp,
                                  syn_tabs[neur_type][syntype][-1], )
                        moose.connect(syn_tabs[neur_type][syntype][-1], 'requestOut', synchan, synapse_message)
                        if getattr(model, 'stpYN', False):
                            create_stp_tabs(synchan, syn_tabs[neur_type][syntype][-1].name,
                                            stp_tabs[neur_type][syntype], ['fac', 'dep', 'stp'])
                        if model.plasYN:
                            create_plas_tabs(synchan, syn_tabs[neur_type][syntype][-1].name,
                                             plas_tabs[neur_type][syntype], ['plas'])
    return syn_tabs, plas_tabs, stp_tabs
def setup_data_recording(neuron, pulse, synapse, spikegen):
    data = moose.Neutral('/data')
    vm_table = moose.Table('/data/Vm')
    moose.connect(vm_table, 'requestOut', neuron, 'getVm')
    inject_table = moose.Table('/data/Inject')
    moose.connect(inject_table, 'requestOut', pulse, 'getOutputValue')
    gk_table = moose.Table('/data/Gk')
    moose.connect(gk_table, 'requestOut', synapse, 'getGk')
    spike_in_table = moose.Table('/data/spike_in')
    moose.connect(spikegen, 'spikeOut', spike_in_table, 'spike')
    return [vm_table, inject_table, gk_table, spike_in_table]
Ejemplo n.º 25
0
def make_model():
    sinePeriod = 50
    maxFiringRate = 10
    refractT = 0.05

    for i in range(20):
        moose.setClock(i, dt)

    ############### Create objects ###############
    stim = moose.StimulusTable('stim')
    spike = moose.RandSpike('spike')
    syn = moose.SimpleSynHandler('syn')
    fire = moose.IntFire('fire')
    stats1 = moose.SpikeStats('stats1')
    stats2 = moose.Stats('stats2')
    plots = moose.Table('plots')
    plot1 = moose.Table('plot1')
    plot2 = moose.Table('plot2')
    plotf = moose.Table('plotf')

    ############### Set up parameters ###############
    stim.vector = [
        maxFiringRate * numpy.sin(x * 2 * numpy.pi / sinePeriod)
        for x in range(sinePeriod)
    ]
    stim.startTime = 0
    stim.stopTime = sinePeriod
    stim.loopTime = sinePeriod
    stim.stepSize = 0
    stim.stepPosition = 0
    stim.doLoop = 1

    spike.refractT = refractT
    syn.synapse.num = 1
    syn.synapse[0].weight = 1
    syn.synapse[0].delay = 0

    fire.thresh = 100  # Don't want it to spike, just to integrate
    fire.tau = 1.0 / maxFiringRate

    stats1.windowLength = int(1 / dt)
    stats2.windowLength = int(1 / dt)

    ############### Connect up circuit ###############
    moose.connect(stim, 'output', spike, 'setRate')
    moose.connect(spike, 'spikeOut', syn.synapse[0], 'addSpike')
    moose.connect(spike, 'spikeOut', stats1, 'addSpike')
    moose.connect(syn, 'activationOut', fire, 'activation')
    moose.connect(stats2, 'requestOut', fire, 'getVm')
    moose.connect(plots, 'requestOut', stim, 'getOutputValue')
    moose.connect(plot1, 'requestOut', stats1, 'getWmean')
    moose.connect(plot2, 'requestOut', stats2, 'getWmean')
    moose.connect(plotf, 'requestOut', fire, 'getVm')
Ejemplo n.º 26
0
 def setUp(self):
     self.testId = uuid.uuid4().int
     self.container = moose.Neutral('test%d' % (self.testId))
     self.model = moose.Neutral('%s/model' % (self.container.path))
     self.data = moose.Neutral('%s/data' % (self.container.path))
     self.soma = create_compartment('%s/soma' % (self.model.path),
                                    **compartment_propeties)
     self.tables = {}
     tab = moose.Table('%s/Vm' % (self.data.path))
     self.tables['Vm'] = tab
     moose.connect(tab, 'requestOut', self.soma, 'getVm')
     for channelname, conductance in channel_density.items():
         chanclass = eval(channelname)
         channel = insert_channel(self.soma,
                                  chanclass,
                                  conductance,
                                  density=True)
         if issubclass(chanclass, KChannel):
             channel.Ek = erev['K']
         elif issubclass(chanclass, NaChannel):
             channel.Ek = erev['Na']
         elif issubclass(chanclass, CaChannel):
             channel.Ek = erev['Ca']
         elif issubclass(chanclass, AR):
             channel.Ek = erev['AR']
         tab = moose.Table('%s/%s' % (self.data.path, channelname))
         moose.connect(tab, 'requestOut', channel, 'getGk')
         self.tables['Gk_' + channel.name] = tab
     archan = moose.HHChannel(self.soma.path + '/AR')
     archan.X = 0.0
     ca = insert_ca(self.soma, 2.6e7, 50e-3)
     tab = moose.Table('%s/Ca' % (self.data.path))
     self.tables['Ca'] = tab
     moose.connect(tab, 'requestOut', ca, 'getCa')
     self.pulsegen = moose.PulseGen('%s/inject' % (self.model.path))
     moose.connect(self.pulsegen, 'output', self.soma, 'injectMsg')
     tab = moose.Table('%s/injection' % (self.data.path))
     moose.connect(tab, 'requestOut', self.pulsegen, 'getOutputValue')
     self.tables['pulsegen'] = tab
     self.pulsegen.count = len(stimulus)
     for ii in range(len(stimulus)):
         self.pulsegen.delay[ii] = stimulus[ii][0]
         self.pulsegen.width[ii] = stimulus[ii][1]
         self.pulsegen.level[ii] = stimulus[ii][2]
     setup_clocks(simdt, plotdt)
     assign_clocks(self.model, self.data)
     moose.reinit()
     start = datetime.now()
     moose.start(simtime)
     end = datetime.now()
     delta = end - start
     print 'Simulation of %g s finished in %g s' % (
         simtime, delta.seconds + delta.microseconds * 1e-6)
Ejemplo n.º 27
0
 def run(self, key):
     try:
         Vm = self.Vm_tables[key]
         u = self.u_tables[key]
     except KeyError, e:
         Vm = moose.Table(self.data_container.path + '/' + key + '_Vm')
         nrn = self.neurons[key]
         moose.connect(Vm, 'requestOut', nrn, 'getVm')
         utable = moose.Table(self.data_container.path + '/' + key + '_u')
         utable.connect('requestOut', self.neurons[key], 'getU')
         self.Vm_tables[key] = Vm
         self.u_tables[key] = utable
Ejemplo n.º 28
0
def setup_current_step_model(model_container, 
                             data_container, 
                             celltype, 
                             pulsearray):
    """Setup a single cell simulation.

    model_container: element to hold the model

    data_container: element to hold data
    

    celltype: str - cell type
    
    pulsearray: nx3 array - with row[i] = (delay[i], width[i],
    level[i]) of current injection.

    simdt: float - simulation time step

    plotdt: float - sampling interval for plotting

    solver: str - numerical method to use, can be `hsolve` or `ee`
    """
    cell_class = eval('cells.%s' % (celltype))
    cell = cell_class('%s/%s' % (model_container.path, celltype))
    print '111111', cell.path
    pulsegen = moose.PulseGen('%s/pulse' % (model_container.path))
    print '121221211', pulsegen.path
    pulsegen.count = len(pulsearray)
    print '7777777', pulsegen.count, pulsegen.id_
    for ii in range(len(pulsearray)):
        print '999999', pulsegen.id_, pulsegen.count
        print '-', pulsegen.delay[ii]
        pulsegen.delay[ii] = pulsearray[ii][0]
        pulsegen.width[ii] = pulsearray[ii][1]
        pulsegen.level[ii] = pulsearray[ii][2]
        print '8888888', ii, pulsegen.delay[ii]
    moose.connect(pulsegen, 'outputOut', cell.soma, 'injectMsg')
    print '22222'
    presyn_vm = moose.Table('%s/presynVm' % (data_container.path))
    print '33333'
    soma_vm =  moose.Table('%s/somaVm' % (data_container.path))
    print '44444'
    moose.connect(presyn_vm, 'requestData', cell.presynaptic, 'get_Vm')
    moose.connect(soma_vm, 'requestData', cell.soma, 'get_Vm')
    pulse_table = moose.Table('%s/injectCurrent' % (data_container.path))
    moose.connect(pulse_table, 'requestData', pulsegen, 'get_output')
    print '55555'
    return {'cell': cell,
            'stimulus': pulsegen,
            'presynVm': presyn_vm,
            'somaVm': soma_vm,
            'injectionCurrent': pulse_table, }
Ejemplo n.º 29
0
def createDataTables(compname, data_hierarchy, pulsename):
    # Create a new path using string manipulation to be used in the creation
    # of a unique data table for each compartment
    comp_path = compname.path.split('/')[-1]
    comp_path = comp_path.strip(']')
    comp_path = comp_path.replace('[', '')
    # Create the unique membrane potential table and connect this to the compartment
    Vmtab = moose.Table(data_hierarchy.path + '/' + comp_path + '_Vm')
    moose.connect(Vmtab, 'requestOut', compname, 'getVm')
    # Create the unique external current table and connect this to the compartment
    current_tab = moose.Table(data_hierarchy.path + '/' + comp_path + '_Iex')
    moose.connect(current_tab, 'requestOut', pulsename, 'getOutputValue')
    return Vmtab, current_tab
Ejemplo n.º 30
0
def add_one_table(DATA_NAME, plas_entry, comp_name):
    if comp_name.find('/') == 0:
        comp_name = comp_name[1:]
    plastab = moose.Table(DATA_NAME + '/plas' + comp_name)
    plasCumtab = moose.Table(DATA_NAME + '/cum' + comp_name)
    syntab = moose.Table(DATA_NAME + '/syn' + comp_name)
    print(plas_entry)
    moose.connect(plastab, 'requestOut', plas_entry['plas'], 'getValue')
    moose.connect(plasCumtab, 'requestOut', plas_entry['cum'], 'getValue')
    shname = plas_entry['syn'].path + '/SH'
    sh = moose.element(shname)
    moose.connect(syntab, 'requestOut', sh.synapse[0], 'getWeight')
    return {'plas': plastab, 'cum': plasCumtab, 'syn': syntab}