コード例 #1
0
def setup(param_sim, model):
    if param_sim.calcium is not None:
        model.calYN = param_sim.calcium
    if param_sim.spines is not None:
        model.spineYN = param_sim.spines

    condset = getattr(model.Condset, param_sim.neuron_type)

    if param_sim.Kir_offset is not None:
        model.Channels.Kir.X.A_vhalf += param_sim.Kir_offset
        model.Channels.Kir.X.B_vhalf += param_sim.Kir_offset

    for cond in sorted(param_sim.cond):
        name, comp, value = cond
        print('cond:', name, comp, value)
        setup_conductance(condset, name, comp, value)

    new_file = morph_morph_file(model,
                                param_sim.neuron_type,
                                param_sim.morph_file,
                                RA=param_sim.RA, RM=param_sim.RM, CM=param_sim.CM,
                                Erest=param_sim.Erest, Eleak=param_sim.Eleak)
    model.morph_file[param_sim.neuron_type] = new_file.name

    MSNsyn, neurons = cell_proto.neuronclasses(model)
    neuron_paths = {ntype:[neuron.path]
                    for ntype, neuron in neurons.items()}
    pg = inject_func.setupinj(model, param_sim.injection_delay, param_sim.injection_width, neuron_paths)
    tables.graphtables(model, neurons,
                       param_sim.plot_current,
                       param_sim.plot_current_message)
    writer = tables.setup_hdf5_output(model, neurons, compartments=['soma'], filename='d1d2_bs.h5')

    simpaths=['/'+param_sim.neuron_type]
    clocks.assign_clocks(simpaths, param_sim.simdt, param_sim.plotdt, param_sim.hsolve,
                         model.param_cond.NAME_SOMA)

    if param_sim.hsolve and model.calYN:
        calcium.fix_calcium(model.neurontypes(), model)

    return pg, writer
コード例 #2
0
def test_net_injection(calcium, synapses, spines, single, ghk, plasticity):
    "Create the neuron and run a very short simulation"

    # pytest.skip("skipping network tests")

    if ghk and not hasattr(moose, 'GHK'):
        pytest.skip("GHK is missing")

    if spines and not single:
        pytest.skip("spines are too much with multiple neurons")

    d1d2.calYN = bool(calcium)
    d1d2.plasYN = bool(plasticity)
    d1d2.ghkYN = bool(ghk)
    d1d2.spineYN = bool(spines)
    d1d2.synYN = bool(synapses)
    str_net.single = bool(single)

    MSNsyn, neurons = cell_proto.neuronclasses(d1d2)

    population, connection, plas = create_network.create_network(
        d1d2, str_net, neurons)

    pg = inject_func.setupinj(d1d2, 0.02, 0.01, population['pop'])
    pg.firstLevel = 1e-9

    data = moose.Neutral('/data')

    vmtab, catab, plastab, currtab = tables.graphtables(
        d1d2, neurons, False, 'getGk')

    moose.reinit()
    moose.start(0.05)

    vm1 = vmtab[0][0].vector
    vm2 = vmtab[1][0].vector

    # Quick sanity check that the values are not outlandish.
    # We do not check at the beginning because of the initial fluctuation.
    assert -0.01 < vm1[250] < 0.05
    assert -0.01 < vm2[250] < 0.05
    assert -0.01 < vm1[499] < 0.05
    assert -0.01 < vm2[499] < 0.05
    return vm1, vm2
コード例 #3
0
def test_net_injection(calcium, synapses, spines, single, ghk, plasticity):
    "Create the neuron and run a very short simulation"

    #pytest.skip("skipping network tests")

    if ghk and not hasattr(moose, 'GHK'):
        pytest.skip("GHK is missing")

    if spines and not single:
        pytest.skip("spines are too much with multiple neurons")

    d1d2.calYN = bool(calcium)
    d1d2.plasYN = bool(plasticity)
    d1d2.ghkYN = bool(ghk)
    d1d2.spineYN = bool(spines)
    d1d2.synYN = bool(synapses)
    str_net.single = bool(single)

    MSNsyn, neurons = cell_proto.neuronclasses(d1d2)

    population,connection, plas = create_network.create_network(d1d2, str_net, neurons)

    pg = inject_func.setupinj(d1d2, 0.02, 0.01, population['pop'])
    pg.firstLevel = 1e-9

    data = moose.Neutral('/data')

    vmtab, catab, plastab, currtab = tables.graphtables(d1d2, neurons, False, 'getGk')

    moose.reinit()
    moose.start(0.05)

    vm1 = vmtab[0][0].vector
    vm2 = vmtab[1][0].vector

    # Quick sanity check that the values are not outlandish.
    # We do not check at the beginning because of the initial fluctuation.
    assert -0.01 < vm1[250] < 0.05
    assert -0.01 < vm2[250] < 0.05
    assert -0.01 < vm1[499] < 0.05
    assert -0.01 < vm2[499] < 0.05
    return vm1, vm2
コード例 #4
0
def test_single_injection(calcium, synapses, spines, ghk, plasticity):
    "Create the neuron and run a very short simulation"

    if ghk and not hasattr(moose, 'GHK'):
        pytest.skip("GHK is missing")

    d1d2.calYN = bool(calcium)
    d1d2.plasYN = bool(plasticity)
    d1d2.ghkYN = bool(ghk)
    d1d2.spineYN = bool(spines)
    d1d2.synYN = bool(synapses)

    MSNsyn, neurons = cell_proto.neuronclasses(d1d2)
    neuron_paths = {ntype:[neuron.path]
                    for ntype, neuron in neurons.items()}
    pg = inject_func.setupinj(d1d2, 0.02, 0.01, neuron_paths)
    pg.firstLevel = 1e-8

    data = moose.Neutral('/data')

    vmtab, catab, plastab, currtab = tables.graphtables(d1d2, neurons, False, 'getGk')

    moose.reinit()
    moose.start(0.05)

    vm1 = vmtab[0][0].vector
    vm2 = vmtab[1][0].vector

    # Quick sanity check that the values are not outlandish.
    # We do not check at the beginning because of the initial fluctuation.
    exp = (0.174
           - 0.025 * bool(spines)
           - 0.043 * bool(calcium))

    assert exp - 0.01 < vm1[250] < exp + 0.02
    assert exp - 0.01 < vm2[250] < exp + 0.02

    assert -0.01 < vm1[499] < 0.05
    assert -0.01 < vm2[499] < 0.05
コード例 #5
0
def test_single_injection(calcium, synapses, spines, ghk, plasticity):
    "Create the neuron and run a very short simulation"

    if ghk and not hasattr(moose, 'GHK'):
        pytest.skip("GHK is missing")

    d1d2.calYN = bool(calcium)
    d1d2.plasYN = bool(plasticity)
    d1d2.ghkYN = bool(ghk)
    d1d2.spineYN = bool(spines)
    d1d2.synYN = bool(synapses)

    MSNsyn, neurons = cell_proto.neuronclasses(d1d2)
    neuron_paths = {ntype: [neuron.path] for ntype, neuron in neurons.items()}
    pg = inject_func.setupinj(d1d2, 0.02, 0.01, neuron_paths)
    pg.firstLevel = 1e-8

    data = moose.Neutral('/data')

    vmtab, catab, plastab, currtab = tables.graphtables(
        d1d2, neurons, False, 'getGk')

    moose.reinit()
    moose.start(0.05)

    vm1 = vmtab[0][0].vector
    vm2 = vmtab[1][0].vector

    # Quick sanity check that the values are not outlandish.
    # We do not check at the beginning because of the initial fluctuation.
    exp = (0.174 - 0.025 * bool(spines) - 0.043 * bool(calcium))

    assert exp - 0.01 < vm1[250] < exp + 0.02
    assert exp - 0.01 < vm2[250] < exp + 0.02

    assert -0.01 < vm1[499] < 0.05
    assert -0.01 < vm2[499] < 0.05
コード例 #6
0
#Need to debug this since eliminated param_sim.stimtimes
#See what else needs to be changed in plasticity_test.
if ca1.plasYN:
    plas, stimtab = plasticity_test.plasticity_test(ca1, param_sim.syncomp,
                                                    MSNsyn,
                                                    param_sim.stimtimes)

###############--------------output elements
if param_sim.plot_channels:
    for chan in ca1.Channels.keys():
        libchan = moose.element('/library/' + chan)
        plot_channel.plot_gate_params(libchan, param_sim.plot_activation,
                                      ca1.VMIN, ca1.VMAX, ca1.CAMIN, ca1.CAMAX)

vmtab, catab, plastab, currtab = tables.graphtables(
    ca1, neuron, param_sim.plot_current, param_sim.plot_current_message, plas,
    plotcomps)
if param_sim.save:
    fname = ca1.param_stim.Stimulation.Paradigm.name + '_' + ca1.param_stim.location.stim_dendrites[
        0]
#    tables.setup_hdf5_output(ca1, neuron, param_sim.save)

if ca1.spineYN:
    spinecatab, spinevmtab = tables.spinetabs(ca1, neuron, plotcomps)
else:
    spinevmtab = []
########## clocks are critical. assign_clocks also sets up the hsolver
simpaths = ['/' + neurotype for neurotype in ca1.neurontypes()]
clocks.assign_clocks(simpaths, param_sim.simdt, param_sim.plotdt,
                     param_sim.hsolve, ca1.param_cond.NAME_SOMA)
コード例 #7
0
def setup(param_sim, model):
    #these next two overrides are not used in optimization as they are not passed in from optimize
    #they could be used if running basic_simulation directly
    '''
    if param_sim.calcium is not None:
        model.calYN = param_sim.calcium
    if param_sim.spines is not None:
        model.spineYN = param_sim.spines
     '''
    '''
    if model.type = nml:
        this block of code updates neuroml files
        write a bunch of new  code
    else:
        #this block of code updates moose_nerp foramt files
    '''
    condset = getattr(
        model.Condset,
        param_sim.neuron_type)  # Fetch reference for model condutances.
    chanset = model.Channels  # Fetch reference for model channels.

    for cond in sorted(param_sim.cond):
        name, comp, value = cond
        if logger.level == logging.DEBUG:
            print('cond:', name, comp, value)
        setup_conductance(condset, name, comp, value)

    for chan in param_sim.chan:
        chan_name, opt, gate, value = chan
        if logger.level == logging.DEBUG:
            print('chan:', chan_name, opt, gate, value)
        if opt == 'taumul':
            scale_voltage_dependents_tau_muliplier(chanset, chan_name, gate,
                                                   value)
        elif opt == 'vshift':
            offset_voltage_dependents_vshift(chanset, chan_name, gate, value)

    new_file = morph_morph_file(model,
                                param_sim.neuron_type,
                                param_sim.morph_file,
                                RA=param_sim.RA,
                                RM=param_sim.RM,
                                CM=param_sim.CM,
                                Erest=param_sim.Erest,
                                Eleak=param_sim.Eleak)
    logger.info('morph_file: {}'.format(new_file.name))
    model.morph_file[param_sim.neuron_type] = new_file.name
    #end of code that updates moose_nerp files

    plotcomps = [model.param_cond.NAME_SOMA]
    fname = param_sim.neuron_type + '.h5'
    param_sim.save = 1
    #create neuron model and set up output
    model.param_sim = param_sim
    setup_CaPool(param_sim, model)
    #syn,neurons,writer,tables=create_model_sim.create_model_sim(model,fname,param_sim,plotcomps)
    create_model_sim.setupNeurons(model)
    #set up current injection
    neuron_paths = {
        ntype: [neuron.path]
        for ntype, neuron in model.neurons.items()
    }
    pg = inject_func.setupinj(model, param_sim.injection_delay,
                              param_sim.injection_width, neuron_paths)
    writer = tables.setup_hdf5_output(model,
                                      model.neurons,
                                      filename=fname,
                                      compartments=plotcomps)
    tables.graphtables(model, model.neurons, model.param_sim.plot_current,
                       model.param_sim.plot_current_message, model.plas,
                       plotcomps)
    if logger.level == logging.DEBUG:
        print_params.print_elem_params(model, param_sim.neuron_type, param_sim)
    return pg, writer
コード例 #8
0
ファイル: __main__.py プロジェクト: ModelDBRepository/245563
all_neur_types=neuron
#create network and plasticity
population,connections,plas=create_network.create_network(gp, gp_net, all_neur_types)

###------------------Current Injection
if gp_net.num_inject<np.inf and not gp_net.single :
    inject_pop=inject_func.inject_pop(population['pop'],gp_net.num_inject)
else:
    inject_pop=population['pop']
pg=inject_func.setupinj(gp, param_sim.injection_delay,param_sim.injection_width,inject_pop)
moose.showmsg(pg)
##############--------------output elements
if gp_net.single:
    vmtab, catab, plastab, currtab = tables.graphtables(gp, all_neur_types,
                                                        param_sim.plot_current,
                                                        param_sim.plot_current_message,
                                                        [])
    if gp.synYN:
        #overwrite plastab above, since it is empty
        syntab, plastab=tables.syn_plastabs(connections,plas)
    if gp.spineYN:
        spinecatab,spinevmtab=tables.spinetabs(gp,neuron)
else:
    spiketab, vmtab, plastab, catab = net_output.SpikeTables(gp, population['pop'], gp_net.plot_netvm, plas, gp_net.plots_per_neur)

########## clocks are critical
## these function needs to be tailored for each simulation
## if things are not working, you've probably messed up here.
if gp_net.single:
    simpath=['/'+neurotype for neurotype in all_neur_types]
else:
コード例 #9
0
ファイル: create_model_sim.py プロジェクト: neurord/spspine
def setupOutput(model, **kwargs):
    ###############--------------output elements
    (vmtab,
     catab,
     plastab,
     currtab) = tables.graphtables(model, model.neurons,
                                   model.param_sim.plot_current,
                                   model.param_sim.plot_current_message,
                                   model.plas,
                                   model.param_sim.plotcomps)

    if model.param_sim.save:
        writer=tables.setup_hdf5_output(model, model.neurons,
                                        filename=model.param_sim.fname,
                                        compartments=model.param_sim.plotcomps)
    else:
        writer=None
    model.writer = writer
    # Add tables to model namespace to simplify passing/returning
    model.vmtab = vmtab
    model.catab = catab
    model.plastab = plastab
    model.currtab = currtab

    if model.log.logger.getEffectiveLevel() == logging.DEBUG:
        for neur in model.neurons.keys():
            print_params.print_elem_params(model, neur, model.param_sim)

    if model.param_sim.plot_channels:
        plt.ion()
        if type(model.param_sim.plot_channels) is str:
            useChans = [model.param_sim.plot_channels] #Convert to list of len 1
        elif type(model.param_sim.plot_channels) is list:
            useChans = model.param_sim.plot_channels # Use the list of channel name strings
        else:
            useChans = model.Channels.keys() # Use all channels
        for chan in useChans:
            libchan = moose.element('/library/'+chan)
            plot_channel.plot_gate_params(libchan,
                                          model.param_sim.plot_activation,
                                          model.VMIN, model.VMAX,
                                          model.CAMIN, model.CAMAX)

    if model.spineYN:
        model.spinecatab, model.spinevmtab = tables.spinetabs(model,
                                                              model.neurons,
                                                              #model.param_sim.plotcomps,
                                                              )
    else:
        model.spinevmtab = []

    model.spiketab=tables.spiketables(model.neurons, model.param_cond)

    if getattr(model.param_sim,'plotgate',None):
        plotgate = model.param_sim.plotgate
        gatepath = list(model.neurons.values())[0].path+'/'+model.NAME_SOMA+'/'+plotgate
        gate = moose.element(gatepath)
        model.gatetables = {}
        gatextab=moose.Table('/data/gatex')
        moose.connect(gatextab, 'requestOut', gate, 'getX')
        model.gatetables['gatextab']=gatextab
        gateytab=moose.Table('/data/gatey')
        moose.connect(gateytab, 'requestOut', gate, 'getY')
        model.gatetables['gateytab']=gateytab
        if model.Channels[plotgate][0][2]==1:
            gateztab=moose.Table('/data/gatez')
            moose.connect(gateztab, 'requestOut', gate, 'getZ')
            model.gatetables['gateztab']=gateztab
    return