Ejemplo n.º 1
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.º 2
0
def threecell_test():
    sim = Simulation('threecell')
    tcr_ix = netdata.celltype.index('TCR')
    ss_ix = netdata.celltype.index('SpinyStellate')
    basket_ix = netdata.celltype.index('DeepBasket')
    ss = SpinyStellate(SpinyStellate.prototype,
                       sim.model.path + '/SpinyStellate')
    tcr = TCR(TCR.prototype, sim.model.path + '/TCR')
    basket = DeepBasket(DeepBasket.prototype, sim.model.path + '/DeepBasket')
    cells = [ss, tcr, basket]
    for postcell in cells:
        for precell in cells:
            if precell == postcell:
                continue
            for syntype in ['ampa', 'nmda', 'gaba']:
                syn = make_synapse(precell, postcell, syntype)
                if syn is not None:
                    tab = record_data(sim.data, 'gk_%s_%s' % (postcell.name, syn.name), syn, 'Gk')
        record_data(sim.data, 'Vm_%s' % (postcell.name), postcell.comp[postcell.presyn], 'Vm')
    pulsegen = moose.PulseGen('pulse', sim.model)
    pulsegen.firstDelay = 3.0
    pulsegen.firstLevel = 1e-9
    pulsegen.firstWidth = 2e-3
    pulsegen.trigMode = moose.FREE_RUN
    pulsegen.connect('outputSrc', tcr.soma, 'injectMsg')
    ptable = moose.Table('pulse', sim.data)
    ptable.stepMode = 3
    ptable.connect('inputRequest', pulsegen, 'output')
    sim.schedule(simdt=25e-6, plotdt=25e-5)
    for t in range(10):
        start = datetime.now()
        sim.run(1.0)
        end = datetime.now()
        delta = end - start
        print 'Ran', t+1, '-th second in', delta.seconds + 1e-6 * delta.microseconds
    sim.save_data_h5('threecells.h5')