示例#1
0
def creat_moose_tables():
    soma_v_table = create_output_table(table_element='/output',
                                       table_name='somaVm')
    soma_i_table = create_output_table(table_element='/output',
                                       table_name='somIm')
    soma_i_table1 = create_output_table(table_element='/output',
                                        table_name='somIm1')
    soma_i_table2 = create_output_table(table_element='/output',
                                        table_name='somIm2')
    soma_i_table3 = create_output_table(table_element='/output',
                                        table_name='somIm3')
    soma_i_table4 = create_output_table(table_element='/output',
                                        table_name='somIm4')

    moose.connect(soma_v_table, 'requestOut', moose.element('/soma'), 'getVm')
    moose.connect(soma_i_table, 'requestOut', moose.element('/soma/Ca_V2'),
                  'getIk')
    moose.connect(soma_i_table1, 'requestOut', moose.element('/soma/Ca_V1'),
                  'getIk')
    moose.connect(soma_i_table2, 'requestOut', moose.element('/soma/K'),
                  'getIk')
    moose.connect(soma_i_table3, 'requestOut', moose.element('/soma/ca_cc'),
                  'getIk')
    moose.connect(soma_i_table4, 'requestOut', moose.element('/soma/CaPool'),
                  'getCa')
    return {
        'vm': [soma_v_table],
        'internal_currents': [
            soma_i_table, soma_i_table1, soma_i_table2, soma_i_table3,
            soma_i_table4
        ]
    }
def main():
    # Simulation information.
    simtime = 0.1
    simdt = 0.25e-5
    plotdt = 0.25e-3

    # Cell Compartment infromation
    diameter = 30e-6
    length = 50e-6
    Em = EREST_ACT + 10.613e-3
    CM = 1e-6 * 1e4
    RM = 1 / (0.3E-3 * 1e4)
    RA = 4

    # Stimulus information
    inj_delay = 20E-3
    inj_amp = 1E-9
    inj_width = 40E-3

    # Create cell
    chicken_model = create_swc_model(
        root_name='E19',
        file_name='E19-cell_filling-caudal.CNG.swc',
        RM=RM,
        CM=CM,
        RA=RA,
        ELEAK=Em,
        initVM=Em)
    soma = moose.element('/E19[0]/soma')

    # Create channels
    channels_set = create_set_of_channels(channel_settings, VDIVS, VMIN, VMAX)

    # Fetch all compartment paths.
    moose_paths = []
    for comp in moose.wildcardFind(chicken_model.path +
                                   '/#[TYPE=Compartment]'):
        moose_paths.append(comp.path)

    # Copy all channels to compartments.
    for channel_name, channel_obj in channels_set.items():
        copy_connect_channel_moose_paths(channel_obj, channel_name,
                                         moose_paths)

    # connect pulse gen
    pulse_inject = create_pulse_generator(soma,
                                          inj_width,
                                          inj_amp,
                                          delay=inj_delay)

    # Output table
    soma_v_table = create_output_table(table_element='/output',
                                       table_name='somaVm')
    soma_i_table = create_output_table(table_element='/output',
                                       table_name='somaIm')
    chicken_dend_table = create_output_table(table_element='/output',
                                             table_name='chkdend')

    # Connect output tables
    moose.connect(soma_v_table, 'requestOut', soma, 'getVm')
    moose.connect(soma_i_table, 'requestOut', pulse_inject, 'getOutputValue')
    moose.connect(chicken_dend_table, 'requestOut',
                  moose.element('/E19[0]/dend_36_0'), 'getVm')

    # Set moose simulation clocks
    for lable in range(7):
        moose.setClock(lable, simdt)
    moose.setClock(8, plotdt)

    # Run simulation
    moose.reinit()
    moose.start(simtime)

    # Plot output tables.
    v_plot = plot_vm_table(simtime,
                           soma_v_table,
                           soma_i_table,
                           chicken_dend_table,
                           title="soma vs dend new k1 chan g_bar = 0.05")
    v_plot.legend(['soma_v', 'i', 'dend_v'])
    plt.grid(True)
    plt.show()
示例#3
0
def main(inj_amp, outfile):
    # Simulation information.
    simtime = 0.1
    simdt = 0.25e-5
    plotdt = 0.25e-3

    # Cell Compartment infromation
    diameter = 30e-6
    length = 50e-6
    Em = EREST_ACT + 10.613e-3
    CM = 1e-6 * 1e4
    RM = 1 / (0.3E-3 * 1e4)

    # Channel information.
    sa, x_sa = compute_comp_area(diameter, length)
    na_g = 120E-3 * sa * 1E4
    na_ek = 115E-3 + EREST_ACT
    k_g = 36e-3 * sa * 1E4
    k_ek = -12E-3 + EREST_ACT

    # Stimulus information
    inj_delay = 20E-3
    inj_amp = float(inj_amp)
    inj_width = 40E-3

    # Create cell
    soma = create_compartment('soma',
                              length,
                              diameter,
                              RM,
                              CM,
                              initVM=EREST_ACT,
                              ELEAK=Em)

    # Create channels
    K_chan = create_channel(chan_name='K',
                            vdivs=VDIVS,
                            vmin=VMIN,
                            vmax=VMAX,
                            x_params=K_n_params,
                            xpow=4)

    Na_chan = create_channel(chan_name='Na',
                             vdivs=VDIVS,
                             vmin=VMIN,
                             vmax=VMAX,
                             x_params=Na_m_params,
                             xpow=3,
                             y_params=Na_h_params,
                             ypow=1)

    # Set conductances
    nachan = moose.copy(Na_chan, soma.path, 'Na', 1)
    kchan = moose.copy(K_chan, soma.path, 'K', 1)
    nachan = set_channel_conductance(nachan, na_g, na_ek)
    kchan = set_channel_conductance(kchan, k_g, k_ek)

    # Add channels to soma
    moose.connect(nachan, 'channel', soma, 'channel', 'OneToOne')
    moose.connect(kchan, 'channel', soma, 'channel', 'OneToOne')

    # connect pulse gen
    pulse_inject = create_pulse_generator(soma,
                                          inj_width,
                                          inj_amp,
                                          delay=inj_delay)

    # Output table
    soma_v_table = create_output_table(table_element='/output',
                                       table_name='somaVm')
    soma_i_table = create_output_table(table_element='/output',
                                       table_name='somaIm')

    # Connect output tables
    moose.connect(soma_v_table, 'requestOut', soma, 'getVm')
    moose.connect(soma_i_table, 'requestOut', pulse_inject, 'getOutputValue')

    # Set moose simulation clocks
    for lable in range(7):
        moose.setClock(lable, simdt)
    moose.setClock(8, plotdt)

    # Run simulation
    moose.reinit()
    moose.start(simtime)

    #save
    np.save(outfile, soma_v_table.vector)
示例#4
0
def main(experiment_title):
    # Simulation information.
    simtime = 0.1
    simdt = 0.25e-6
    plotdt = 0.25E-3

    # Cell Compartment infromation
    diameter = 30e-6
    length = 50e-6
    Em = EREST_ACT + 10.613e-3
    CM = 1e-6 * 1e4
    RM = 1 / (0.3E-3 * 1e4)

    # Stimulus information
    inj_delay = 20E-3
    inj_amp = 1E-9
    inj_width = 40E-3

    # Create cell
    soma = create_compartment('soma',
                              length,
                              diameter,
                              RM,
                              CM,
                              initVM=EREST_ACT,
                              ELEAK=Em)

    # Create channels
    channels_set = create_set_of_channels(channel_settings, VDIVS, VMIN, VMAX,
                                          CADIVS, CAMIN, CAMAX)

    moose_paths = [soma.path]
    for channel_name, channel_obj in channels_set.items():
        copy_connect_channel_moose_paths(channel_obj, channel_name,
                                         moose_paths)

    # Create calcium pools in library.
    ca_pool = create_ca_conc_pool(ca_params)

    # copy calcium pools to all compartments.
    copy_ca_pools_moose_paths(ca_pool, 'CaPool', moose_paths)

    # Connect calciums pools to channels in compartments.
    connect_ca_pool_to_chan(chan_name='SKca',
                            chan_type='ca_dependent',
                            calname='CaPool',
                            moose_paths=moose_paths)
    connect_ca_pool_to_chan(chan_name='CaL',
                            chan_type='ca_permeable',
                            calname='CaPool',
                            moose_paths=moose_paths)

    # connect pulse gen.
    pulse_inject = create_pulse_generator(soma,
                                          inj_width,
                                          inj_amp,
                                          delay=inj_delay)

    # Output table.
    soma_v_table = create_output_table(table_element='/output',
                                       table_name='somaVm')
    soma_i_table = create_output_table(table_element='/output',
                                       table_name='somaIm')

    # Connect output tables.
    moose.connect(soma_v_table, 'requestOut', soma, 'getVm')
    moose.connect(soma_i_table, 'requestOut', pulse_inject, 'getOutputValue')

    # Set moose simulation clocks.
    for lable in range(10):
        moose.setClock(lable, simdt)
    moose.setClock(8, plotdt)

    # Run simulation
    moose.reinit()
    moose.start(simtime)

    # Plot output tables.
    v_plot = plot_vm_table(simtime,
                           soma_v_table,
                           soma_i_table,
                           title=experiment_title)
    plt.grid(True)
    plt.legend(['v', 'i'])
    plt.show()
示例#5
0
def main():
    # Simulation information.
    simtime = 0.1
    simdt = 0.25e-5
    plotdt = 0.25e-3

    # Cell Compartment infromation
    diameter = 30e-6
    length = 50e-6
    Em = EREST_ACT + 10.613e-3
    CM = 1e-6 * 1e4
    RM = 1 / (0.3E-3 * 1e4)

    # Stimulus information
    inj_delay = 20E-3
    inj_amp = 1E-9
    inj_width = 40E-3

    # Create cell
    soma = create_compartment('soma',
                              length,
                              diameter,
                              RM,
                              CM,
                              initVM=EREST_ACT,
                              ELEAK=Em)

    # Create channels
    channels_set = create_set_of_channels(channel_settings, VDIVS, VMIN, VMAX)

    moose_paths = [soma.path]
    for channel_name, channel_obj in channels_set.items():
        copy_connect_channel_moose_paths(channel_obj, channel_name,
                                         moose_paths)

    # connect pulse gen
    pulse_inject = create_pulse_generator(soma,
                                          inj_width,
                                          inj_amp,
                                          delay=inj_delay)

    # Output table
    soma_v_table = create_output_table(table_element='/output',
                                       table_name='somaVm')
    soma_i_table = create_output_table(table_element='/output',
                                       table_name='somaIm')

    # Connect output tables
    moose.connect(soma_v_table, 'requestOut', soma, 'getVm')
    moose.connect(soma_i_table, 'requestOut', pulse_inject, 'getOutputValue')

    # Set moose simulation clocks
    for lable in range(7):
        moose.setClock(lable, simdt)
    moose.setClock(8, plotdt)

    # Run simulation
    moose.reinit()
    moose.start(simtime)

    # Plot output tables.
    v_plot = plot_vm_table(simtime,
                           soma_v_table,
                           soma_i_table,
                           title="soma voltage")
    plt.grid(True)
    plt.legend(['v', 'i'])
    plt.show()
示例#6
0
def main(experiment_title, _rate, syn_g_max):
    # Simulation information.
    simtime = 1
    simdt = 0.25e-6
    plotdt = 0.25E-3

    # Cell Compartment infromation
    diameter = 30e-6
    length = 50e-6
    Em = EREST_ACT + 10.613e-3
    CM = 1e-6 * 1e4
    RM = 1 / (0.3E-3 * 1e4)
    RA = 4
    dend_n = 5

    # Create two compartmental model.
    soma = create_compartment('soma',
                              length,
                              diameter,
                              RM,
                              CM,
                              initVM=EREST_ACT,
                              ELEAK=Em)  # Soma creation
    bunch = create_n_dends('dend_', dend_n, length, diameter, RM, CM,
                           RA)  # Dend creation
    for item in bunch.values():
        item.Em = Em
        item.initVm = EREST_ACT

    bunch = connect_n_serial(bunch)
    moose.connect(soma, 'axial', list(bunch.values())[0], 'raxial')

    # Create channels
    channels_set = create_set_of_channels(channel_settings, VDIVS, VMIN, VMAX,
                                          CADIVS, CAMIN, CAMAX)

    # Create synaptic channel
    synapses_and_handles = [
        create_synaptic_channel(setting.syn_name, syn_g_max, setting.tau1,
                                setting.tau2, setting.ek,
                                setting.synapse_count, setting.delay)
        for setting in synapse_settings
    ]

    # Copy the synaptic channels to moose compartments.
    moose_paths = [moose.element('/dend_2').path]
    for syn, syn_handle in synapses_and_handles:
        copy_syn_channel_moose_paths(syn, syn.name, moose_paths)

    # create pre-synaptic input
    spikegen_1 = create_spikegen(name='spikegen_1',
                                 type='random',
                                 refractory_period=1E-3,
                                 rate=_rate)

    moose.connect(spikegen_1, 'spikeOut',
                  moose.element('/dend_2[0]/syn[0]/synhandler').synapse[0],
                  'addSpike')

    # connect channels to compartments.
    for channel_name, channel_obj in channels_set.items(
    ):  # Copy channels to soma.
        copy_connect_channel_moose_paths(channel_obj, channel_name,
                                         moose_paths)

    # Output table.
    soma_v_table = create_output_table(table_element='/output',
                                       table_name='somaVm')
    dend1_v_table = create_output_table(table_element='/output',
                                        table_name='dend1Vm')

    # Connect output tables.
    moose.connect(soma_v_table, 'requestOut', soma, 'getVm')
    moose.connect(dend1_v_table, 'requestOut', moose.element('/dend_2'),
                  'getVm')

    # Set moose simulation clocks.
    for lable in range(10):
        moose.setClock(lable, simdt)
    moose.setClock(8, plotdt)

    # Run simulation
    moose.reinit()
    moose.start(simtime)

    # Plot output tables.
    v_plot = plot_vm_table(simtime,
                           soma_v_table,
                           dend1_v_table,
                           title=experiment_title.format(_rate, syn_g_max),
                           xlab='Time',
                           ylab='voltage')
    plt.grid(True)
    plt.legend(['soma', 'dend'])
    plt.show()