net.projections.append(Projection(id='projEI', presynaptic=pE.id, postsynaptic=pRS.id, synapse='ampa', delay=2, weight=0.2, random_connectivity=RandomConnectivity(probability=.8))) """ net.inputs.append( Input( id="stim0", input_source=input_source_p0.id, population=pop0.id, percentage=50, weight="weightInput", )) net.inputs.append( Input(id="stim1", input_source=input_source1.id, population=pop1.id, percentage=100)) net.inputs.append( Input(id="stim2", input_source=input_source1.id, population=pop2.id, percentage=50))
net.synapses.append( Synapse(id='gaba', neuroml2_source_file='test_files/gaba.synapse.nml')) net.projections.append( Projection(id='projEI', presynaptic=pE.id, postsynaptic=pRS.id, synapse='ampa', delay=2, weight=0.2, random_connectivity=RandomConnectivity(probability=.8))) net.inputs.append( Input(id='stim', input_source=input_source.id, population=pE.id, percentage=50, weight='weightInput')) print(net) print(net.to_json()) new_file = net.to_json_file('%s.json' % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation(id='SimExample8', network=new_file, duration='1000', dt='0.025', recordTraces={'all': '*'})
net.projections[0].random_connectivity = RandomConnectivity(probability=1) net.projections.append( Projection( id="proj1", presynaptic=p0.id, postsynaptic=p1.id, synapse=nmdaSyn.id, delay=0, weight="weight", )) net.projections[1].random_connectivity = RandomConnectivity(probability=1) net.inputs.append( Input(id="stim", input_source=input_source.id, population=p0.id, percentage=100)) print(net.to_json()) new_file = net.to_json_file("%s.json" % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation( id="SimExample11", network=new_file, duration="1000", dt="0.01", record_traces={"all": "*"}, record_variables={
pynn_receptor_type='inhibitory', pynn_synapse_type='cond_alpha', parameters={'e_rev':-80, 'tau_syn':10})) net.projections.append(Projection(id='proj1', presynaptic=p0.id, postsynaptic=p2.id, synapse='gabaSyn', delay=2, weight=0.01)) net.projections[1].random_connectivity=RandomConnectivity(probability=1)''' net.inputs.append( Input(id="stim", input_source=input_source.id, population=p0.id, cell_ids=[1, 2])) print(net.to_json()) new_file = net.to_json_file("%s.json" % net.id) new_file_yaml = net.to_yaml_file("%s.yaml" % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation( id="Sim%s" % net.id, network=new_file, duration="100", dt="0.01", record_traces={"all": "*"},
def generate(ref, np2=0, np5=0, nb2=0, nb5=0, recordTraces='*'): ################################################################################ ### Build new network net = Network(id=ref) net.notes = 'Example: %s...' % ref net.seed = 7890 net.temperature = 32 net.parameters = { 'np2': np2, 'np5': np5, 'nb2': nb2, 'nb5': nb5, 'offset_curr_l2p': -0.05, 'weight_bkg_l2p': 0.01, 'weight_bkg_l5p': 0.01 } l2p_cell = Cell(id='CELL_HH_reduced_L2Pyr', neuroml2_source_file='../CELL_HH_reduced_L2Pyr.cell.nml') net.cells.append(l2p_cell) l5p_cell = Cell(id='CELL_HH_reduced_L5Pyr', neuroml2_source_file='../CELL_HH_reduced_L5Pyr.cell.nml') net.cells.append(l5p_cell) l2b_cell = Cell(id='CELL_HH_simple_L2Basket', neuroml2_source_file='../CELL_HH_simple_L2Basket.cell.nml') net.cells.append(l2b_cell) l5b_cell = Cell(id='CELL_HH_simple_L5Basket', neuroml2_source_file='../CELL_HH_simple_L5Basket.cell.nml') net.cells.append(l5b_cell) input_source_poisson100 = InputSource(id='poissonFiringSyn100Hz', neuroml2_source_file='../inputs.nml') net.input_sources.append(input_source_poisson100) input_offset_curr_l2p = InputSource(id='input_offset_curr_l2p', pynn_input='DCSource', parameters={ 'amplitude': 'offset_curr_l2p', 'start': 0, 'stop': 1e9 }) net.input_sources.append(input_offset_curr_l2p) l2 = RectangularRegion(id='L2', x=0, y=1000, z=0, width=1000, height=10, depth=1000) net.regions.append(l2) l5 = RectangularRegion(id='L5', x=0, y=0, z=0, width=1000, height=10, depth=1000) net.regions.append(l5) #https://github.com/OpenSourceBrain/OpenCortex import opencortex.utils.color as occ pop_l2p = Population(id='pop_l2p', size='np2', component=l2p_cell.id, properties={'color': occ.L23_PRINCIPAL_CELL}, random_layout=RandomLayout(region=l2.id)) net.populations.append(pop_l2p) pop_l5p = Population(id='pop_l5p', size='np5', component=l5p_cell.id, properties={'color': occ.L5_PRINCIPAL_CELL}, random_layout=RandomLayout(region=l5.id)) net.populations.append(pop_l5p) pop_l2b = Population(id='pop_l2b', size='nb2', component=l2b_cell.id, properties={'color': occ.L23_INTERNEURON}, random_layout=RandomLayout(region=l2.id)) net.populations.append(pop_l2b) pop_l5b = Population(id='pop_l5b', size='nb5', component=l5b_cell.id, properties={'color': occ.L5_INTERNEURON}, random_layout=RandomLayout(region=l5.id)) net.populations.append(pop_l5b) # L2 -> L2 _add_projection(pop_l2p, pop_l2b, 'AMPA', delay=0, weight=0.001, probability=0.8, net=net) _add_projection(pop_l2b, pop_l2p, 'L2Pyr_GABAA', delay=0, weight=0.001, probability=0.8, net=net) _add_projection(pop_l2b, pop_l2p, 'L2Pyr_GABAB', delay=0, weight=0.001, probability=0.8, net=net) # L2 -> L5 _add_projection(pop_l2p, pop_l5p, 'L5Pyr_AMPA', delay=0, weight=0.001, probability=0.8, net=net) _add_projection(pop_l2p, pop_l5b, 'AMPA', delay=0, weight=0.001, probability=0.8, net=net) _add_projection(pop_l2b, pop_l5p, 'L5Pyr_GABAA', delay=0, weight=0.001, probability=0.8, net=net) # L5 -> L5 _add_projection(pop_l5p, pop_l5b, 'AMPA', delay=0, weight=0.001, probability=0.8, net=net) _add_projection(pop_l5b, pop_l5p, 'L5Pyr_GABAA', delay=0, weight=0.001, probability=0.8, net=net) _add_projection(pop_l5b, pop_l5p, 'L5Pyr_GABAB', delay=0, weight=0.001, probability=0.8, net=net) net.inputs.append( Input(id='stim_%s' % pop_l2p.id, input_source=input_source_poisson100.id, population=pop_l2p.id, percentage=100, weight='weight_bkg_l2p')) net.inputs.append( Input(id='stim_%s' % pop_l5p.id, input_source=input_source_poisson100.id, population=pop_l5p.id, percentage=100, weight='weight_bkg_l5p')) print(net.to_json()) new_file = net.to_json_file('%s.json' % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation(id='Sim%s' % net.id, network=new_file, duration='500', seed='1111', dt='0.025', recordTraces={'all': recordTraces}, recordSpikes={'all': '*'}) sim.to_json_file() print(sim.to_json()) return sim, net
weight = W[pops.index(post)][pops.index(pre)] print('Connection %s -> %s weight %s'%(pre.id, post.id, weight)) if weight!=0: net.projections.append(Projection(id='proj_%s_%s'%(pre.id,post.id), presynaptic=pre.id, postsynaptic=post.id, synapse='rs', type='continuousProjection', delay=0, weight=weight, random_connectivity=RandomConnectivity(probability=1))) net.inputs.append(Input(id='modulation', input_source=input_source0.id, population=pE.id, percentage=100)) print(net) print(net.to_json()) new_file = net.to_json_file('%s.json'%net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation(id='Sim%s'%net.id, network=new_file, duration='200', dt='0.025', recordRates={'all':'*'})
'filename':'test_files/cons_locs_pathways_mc0_Column.h5', 'percentage_cells_per_pop':percent, 'DEFAULT_CELL_ID':default_cell.id, 'cell_info':{default_cell.id:default_cell}}) net.cells.append(default_cell) net.synapses.append(Synapse(id='ampa', neuroml2_source_file='test_files/ampa.synapse.nml')) net.synapses.append(Synapse(id='gaba', neuroml2_source_file='test_files/gaba.synapse.nml')) input_source = InputSource(id='poissonFiringSyn', neuroml2_source_file='test_files/inputs.nml') net.input_sources.append(input_source) for pop in ['L4_PC']: net.inputs.append(Input(id='stim_%s'%pop, input_source=input_source.id, population=pop, percentage=80)) new_file = net.to_json_file('%s.json'%net.id) ################################################################################ ### Builds a NeuroML 2 representation, save as XML format_='xml' generate_neuroml2_from_network(net, nml_file_name='%s.net.nml%s'%(net.id, '.h5' if format_=='hdf5' else ''), format=format_) from neuromllite import Simulation
def generate(): ################################################################################ ### Build new network net = Network(id='ExampleK') net.notes = 'Example...' net.parameters = {'pop_size': '8', 'stim_amp': '0.3'} cell = Cell(id='kuramoto1', lems_source_file='CellExamples.xml') net.cells.append(cell) input_source = InputSource(id='iclamp0', neuroml2_input='PulseGeneratorDL', parameters={ 'amplitude': 'stim_amp', 'delay': '100ms', 'duration': '800ms' }) net.input_sources.append(input_source) ''' input_source = InputSource(id='poissonFiringSyn', neuroml2_input='poissonFiringSynapse', parameters={'average_rate':"eta", 'synapse':"ampa", 'spike_target':"./ampa"}) ''' r1 = RectangularRegion(id='region1', x=0, y=0, z=0, width=1000, height=100, depth=1000) net.regions.append(r1) pE = Population(id='Epop', size='pop_size', component=cell.id, properties={'color': '1 0 0'}, random_layout=RandomLayout(region=r1.id)) net.populations.append(pE) ''' net.synapses.append(Synapse(id='ampa', pynn_receptor_type='excitatory', pynn_synapse_type='curr_alpha', parameters={'tau_syn':0.1})) net.projections.append(Projection(id='projEinput', presynaptic=pEpoisson.id, postsynaptic=pE.id, synapse='ampa', delay=2, weight=0.02, one_to_one_connector=OneToOneConnector())) net.projections.append(Projection(id='projEE', presynaptic=pE.id, postsynaptic=pE.id, synapse='ampa', delay=2, weight=0.002, random_connectivity=RandomConnectivity(probability=.5))) net.projections.append(Projection(id='projEI', presynaptic=pE.id, postsynaptic=pI.id, synapse='ampa', delay=2, weight=0.02, random_connectivity=RandomConnectivity(probability=.5))) net.projections.append(Projection(id='projIE', presynaptic=pI.id, postsynaptic=pE.id, synapse='gaba', delay=2, weight=0.02, random_connectivity=RandomConnectivity(probability=.5))) ''' net.inputs.append( Input(id='stim', input_source=input_source.id, population=pE.id, percentage=50)) #print(net) #print(net.to_json()) new_file = net.to_json_file('%s.json' % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation(id='SimExampleK', network=new_file, duration='1000', dt='0.025', seed=123, recordVariables={'sin_theta': { pE.id: '*' }}) sim.to_json_file() return sim, net
syn = Synapse(id='AMPA_preLTP', neuroml2_source_file='fourPathwaySyn.synapse.nml') syn = Synapse(id='AMPA_postLTD', neuroml2_source_file='fourPathwaySyn.synapse.nml') net.synapses.append(syn) net.projections.append(Projection(id='proj0', presynaptic=p0.id, postsynaptic=p1.id, synapse=syn.id, delay=0, weight='weight')) net.projections[0].random_connectivity=RandomConnectivity(probability=1) net.inputs.append(Input(id='i_stim1', input_source=stim1.id, population=p1.id, percentage=100)) net.inputs.append(Input(id='i_stim2', input_source=stim2.id, population=p1.id, percentage=100)) print(net.to_json()) new_file = net.to_json_file('%s.json'%net.id) ################################################################################ ### Build Simulation object & save as JSON recordVariables={} syn_vars = ['g', 'u_bar', 'T', 'N_alpha_bar', 'N_beta_bar', 'N_alpha', 'N_beta', 'N', 'Z', 'X', 'w_pre', 'w_post','w', 'G','C','P']
net.synapses.append(Synapse(id='ampa', neuroml2_source_file='test_files/ampa.synapse.nml')) #net.synapses.append(Synapse(id='gaba', neuroml2_source_file='test_files/gaba.synapse.nml')) net.projections.append(Projection(id='projEI', presynaptic=pE.id, postsynaptic=pRS.id, synapse='ampa', delay=2, weight=0.2, random_connectivity=RandomConnectivity(probability=.8))) ''' net.inputs.append(Input(id='stim0', input_source=input_source_p0.id, population=pop0.id, percentage=50, weight='weightInput')) net.inputs.append(Input(id='stim1', input_source=input_source1.id, population=pop1.id, percentage=100)) net.inputs.append(Input(id='stim2', input_source=input_source1.id, population=pop2.id, percentage=50)) print(net) print(net.to_json())
net.populations[0].component = "hhcell" net.populations[1].component = "hhcell" net.cells.append( Cell(id="hhcell", neuroml2_source_file="test_files/hhcell.cell.nml")) net.synapses.append( Synapse(id="ampa", neuroml2_source_file="test_files/ampa.synapse.nml")) input_source = InputSource(id="poissonFiringSyn", neuroml2_source_file="test_files/inputs.nml") net.input_sources.append(input_source) net.inputs.append( Input( id="stim_%s" % net.populations[0].id, input_source=input_source.id, population=net.populations[0].id, percentage=80, )) print(net.to_json()) new_file = net.to_json_file("%s.json" % net.id) ################################################################################ ### Use a handler which just prints info on positions, etc. def_handler = DefaultNetworkHandler() generate_network(net, def_handler) ################################################################################ ### Export to some formats, e.g. try:
weight=weight)) ''' bkgE = InputSource(id='bkgEstim', pynn_input='DCSource', parameters={'amplitude':2, 'start':0., 'stop':1e6}) net.input_sources.append(bkgE) net.inputs.append(Input(id='bkgE', input_source=bkgE.id, population=pE.id, percentage=100))''' net.inputs.append( Input(id='modulation', input_source=input_source0.id, population=pVIP.id, percentage=100)) print(net) print(net.to_json()) new_file = net.to_json_file('%s.json' % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation(id='SimdelMolinoEtAl', network=new_file, duration='200', dt='0.025', recordTraces={'all': '*'})
net.populations.append(exc_pop) net.populations.append(inh_pop) input_source = InputSource(id='pulseGenerator0', neuroml2_input='PulseGenerator', parameters={ 'amplitude': '0nA', 'delay': '100.0ms', 'duration': '800.0ms' }) net.input_sources.append(input_source) net.inputs.append( Input(id='stim', input_source=input_source.id, population=exc_pop.id, percentage=100)) exc_syn = Synapse(id='rsExc', lems_source_file='Demirtas_Parameters.xml') inh_syn = Synapse(id='rsInh', lems_source_file='Demirtas_Parameters.xml') net.synapses.append(exc_syn) net.synapses.append(inh_syn) syns = {exc_pop.id: exc_syn.id, inh_pop.id: inh_syn.id} W = [['wee', 'wie'], ['wei', 'wii']] # Add internal connections pops = [exc_pop, inh_pop] internal_connections(pops, W) # Save to JSON format
delay=1, weight='Wei', random_connectivity=RandomConnectivity(probability=.8))) net.projections.append(Projection(id='projIE', presynaptic=pI.id, postsynaptic=pE.id, synapse='gabaSyn', delay=1, weight='Wie', random_connectivity=RandomConnectivity(probability=.8))) net.inputs.append(Input(id='stim', input_source=input_source.id, population=pE.id, percentage=100, weight='weightInput')) print(net) print(net.to_json()) new_file = net.to_json_file('%s.json'%net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation(id='Sim%s'%net.id, network=new_file, duration='1000', seed='1111',
id="projEI", presynaptic=pE.id, postsynaptic=pRS.id, synapse="ampa", delay=2, weight=0.2, random_connectivity=RandomConnectivity(probability=0.8), ) ) net.inputs.append( Input( id="stim", input_source=input_source.id, population=pE.id, percentage=50, weight="weightInput", ) ) print(net) print(net.to_json()) new_file = net.to_json_file("%s.json" % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation( id="SimExample8",
net.parameters['input_delay'] = '20ms' net.parameters['input_duration'] = '60ms' #net.parameters['scaling'] = '1nA' input_source_e = InputSource(id='Exc_in', neuroml2_input='PulseGenerator', parameters={ 'amplitude': 'exc_input', 'delay': 'input_delay', 'duration': 'input_duration' }) net.input_sources.append(input_source_e) net.inputs.append( Input(id='Exc_stim', input_source=input_source_e.id, population=exc_pop.id, percentage=100)) input_source_i = InputSource(id='Inh_in', neuroml2_input='PulseGenerator', parameters={ 'amplitude': 'inh_input', 'delay': 'input_delay', 'duration': 'input_duration' }) net.input_sources.append(input_source_i) net.inputs.append( Input(id='Inh_stim', input_source=input_source_i.id, population=inh_pop.id, percentage=100))
def generate(): dt = 0.025 simtime = 1000 ################################################################################ ### Build new network net = Network(id='McCPNet') net.notes = 'Example of simplified McCulloch-Pitts based Network' net.parameters = {'amp': 1.5, 'scale': 3} cell = Cell(id='mccp0', lems_source_file='McCPTest.xml') net.cells.append(cell) silentDL = Synapse(id='silentSyn_proj0', lems_source_file='McCPTest.xml') net.synapses.append(silentDL) rsDL = Synapse(id='rsDL', lems_source_file='McCPTest.xml') net.synapses.append(rsDL) r1 = RectangularRegion(id='region1', x=0, y=0, z=0, width=1000, height=100, depth=1000) net.regions.append(r1) p0 = Population(id='McCPpop0', size='1*scale', component=cell.id, properties={ 'color': '.9 0.9 0', 'radius': 5 }, random_layout=RandomLayout(region=r1.id)) net.populations.append(p0) p1 = Population(id='McCPpop1', size='1*scale', component=cell.id, properties={ 'color': '.9 0 0.9', 'radius': 5 }, random_layout=RandomLayout(region=r1.id)) net.populations.append(p1) net.projections.append( Projection(id='proj0', presynaptic=p0.id, postsynaptic=p1.id, synapse=rsDL.id, pre_synapse=silentDL.id, type='continuousProjection', weight='random()', random_connectivity=RandomConnectivity(probability=0.6))) ''' net.synapses.append(Synapse(id='ampa', pynn_receptor_type='excitatory', pynn_synapse_type='curr_alpha', parameters={'tau_syn':0.1})) net.projections.append(Projection(id='proj1', presynaptic=pEpoisson.id, postsynaptic=pLNP.id, synapse='ampa', delay=0, weight='in_weight', random_connectivity=RandomConnectivity(probability=0.7)))''' input_source0 = InputSource(id='sg0', neuroml2_source_file='inputs.nml') net.input_sources.append(input_source0) input_source1 = InputSource(id='sg1', neuroml2_source_file='inputs.nml') net.input_sources.append(input_source1) for pop in [p0.id]: net.inputs.append( Input(id='stim0_%s' % pop, input_source=input_source0.id, population=pop, percentage=60)) net.inputs.append( Input(id='stim1_%s' % pop, input_source=input_source1.id, population=pop, percentage=60)) #print(net) #print(net.to_json()) new_file = net.to_json_file('%s.json' % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation(id='Sim%s' % net.id, network=new_file, duration=simtime, dt=dt, seed=123, recordVariables={ 'R': { 'all': '*' }, 'ISyn': { 'all': '*' } }) sim.to_json_file() return sim, net
synapse='ampaSyn', delay=2, weight=0.02)) net.projections[0].random_connectivity=RandomConnectivity(probability=1) net.projections.append(Projection(id='proj1', presynaptic=p0.id, postsynaptic=p2.id, synapse='gabaSyn', delay=2, weight=0.01)) net.projections[1].random_connectivity=RandomConnectivity(probability=1)''' net.inputs.append( Input(id='stim', input_source=input_source.id, population=p0.id, percentage=50)) print(net.to_json()) new_file = net.to_json_file('%s.json' % net.id) ################################################################################ ### Build Simulation object & save as JSON sim = Simulation(id='SimSonataExample', network=new_file, duration='1000', dt='0.01', recordTraces={'all': '*'}, recordSpikes={'pop0': '*'})
net.cells.append(default_cell) net.synapses.append( Synapse(id="ampa", neuroml2_source_file="test_files/ampa.synapse.nml")) net.synapses.append( Synapse(id="gaba", neuroml2_source_file="test_files/gaba.synapse.nml")) input_source = InputSource(id="poissonFiringSyn", neuroml2_source_file="test_files/inputs.nml") net.input_sources.append(input_source) for pop in ["L4_PC"]: net.inputs.append( Input( id="stim_%s" % pop, input_source=input_source.id, population=pop, percentage=80, )) new_file = net.to_json_file("%s.json" % net.id) ################################################################################ ### Builds a NeuroML 2 representation, save as XML format_ = "xml" nml_file_name, nml_doc = generate_neuroml2_from_network( net, nml_file_name="%s.net.nml%s" % (net.id, ".h5" if format_ == "hdf5" else ""), format=format_, )
input_sourceI = InputSource(id='noisyCurrentSourceI', lems_source_file='TestNCS.xml', parameters={ 'mean': '0.0nA', 'stdev': str(stdNoiseI) + 'nA', 'noiseDt': '%sms' % dt, 'delay': '0ms', 'duration': '%sms' % duration }) net.input_sources.append(input_sourceE) net.input_sources.append(input_sourceI) net.inputs.append( Input(id='stimE', input_source=input_sourceE.id, population=pE.id, percentage=100)) net.inputs.append( Input(id='stimI', input_source=input_sourceI.id, population=pI.id, percentage=100)) ####################### Save network in json file ############################# print(net.to_json()) new_file = net.to_json_file('%s.json' % net.id) ################################################################################ ### Build Simulation object & save as JSON
net.regions.append(r2) net.populations[0].random_layout = RandomLayout(region=r1.id) net.populations[1].random_layout = RandomLayout(region=r2.id) net.populations[0].component = 'hhcell' net.populations[1].component = 'hhcell' net.cells.append(Cell(id='hhcell', neuroml2_source_file='test_files/hhcell.cell.nml')) net.synapses.append(Synapse(id='ampa', neuroml2_source_file='test_files/ampa.synapse.nml')) input_source = InputSource(id='poissonFiringSyn', neuroml2_source_file='test_files/inputs.nml') net.input_sources.append(input_source) net.inputs.append(Input(id='stim_%s'%net.populations[0].id, input_source=input_source.id, population=net.populations[0].id, percentage=80)) print(net.to_json()) new_file = net.to_json_file('%s.json'%net.id) ################################################################################ ### Use a handler which just prints info on positions, etc. def_handler = DefaultNetworkHandler() generate_network(net, def_handler) ################################################################################