def create_GoC_network( duration, dt, seed, runid, run=False): ### ---------- Load Params noPar = True pfile = Path('params_file.pkl') if pfile.exists(): print('Reading parameters from file:') file = open('params_file.pkl','rb') params_list = pkl.load(file) if len(params_list)>runid: p = params_list[runid] file.close() if noPar: p = inp.get_simulation_params( runid ) ### ---------- Component types goc_filename = 'GoC.cell.nml' # Golgi cell with channels goc_file = pynml.read_neuroml2_file( goc_filename ) goc_type = goc_file.cells[0] goc_ref = nml.IncludeType( href=goc_filename ) MFSyn_filename = 'MF_GoC_Syn.nml' # small conductance synapse for background inputs mfsyn_file = pynml.read_neuroml2_file( MFSyn_filename ) MFSyn_type = mfsyn_file.exp_three_synapses[0] mfsyn_ref = nml.IncludeType( href=MFSyn_filename ) MF20Syn_filename = 'MF_GoC_SynMult.nml' # multi-syn conductance for strong/coincident transient input mf20syn_file = pynml.read_neuroml2_file( MF20Syn_filename ) MF20Syn_type = mf20syn_file.exp_three_synapses[0] mf20syn_ref = nml.IncludeType( href=MF20Syn_filename ) mf_type2 = 'spikeGeneratorPoisson' # Spike source for background inputs mf_poisson = nml.SpikeGeneratorPoisson( id = "MF_Poisson", average_rate="5 Hz" ) # Not tuned to any data - qqq ! mf_bursttype = 'transientPoissonFiringSynapse' # Burst of MF input (as explicit input) mf_burst = nml.TransientPoissonFiringSynapse( id="MF_Burst", average_rate="100 Hz", delay="2000 ms", duration="500 ms", synapse=MF20Syn_type.id, spike_target='./{}'.format(MF20Syn_type.id) ) gj = nml.GapJunction( id="GJ_0", conductance="426pS" ) # GoC synapse ### --------- Populations # Build network to specify cells and connectivity net = nml.Network( id="gocNetwork", type="networkWithTemperature" , temperature="23 degC" ) # Create GoC population goc_pop = nml.Population( id=goc_type.id+"Pop", component = goc_type.id, type="populationList", size=p["nGoC"] ) for goc in range( p["nGoC"] ): inst = nml.Instance( id=goc ) goc_pop.instances.append( inst ) inst.location = nml.Location( x=p["GoC_pos"][goc,0], y=p["GoC_pos"][goc,1], z=p["GoC_pos"][goc,2] ) net.populations.append( goc_pop ) ### MF population MF_Poisson_pop = nml.Population(id=mf_poisson.id+"_pop", component=mf_poisson.id, type="populationList", size=p["nMF"]) for mf in range( p["nMF"] ): inst = nml.Instance(id=mf) MF_Poisson_pop.instances.append( inst ) inst.location = nml.Location( x=p["MF_pos"][mf,0], y=p["MF_pos"][mf,1], z=p["MF_pos"][mf,2] ) net.populations.append( MF_Poisson_pop ) # Create NML document for network specification net_doc = nml.NeuroMLDocument( id=net.id ) net_doc.networks.append( net ) net_doc.includes.append( goc_ref ) net_doc.includes.append( mfsyn_ref ) net_doc.includes.append( mf20syn_ref ) net_doc.spike_generator_poissons.append( mf_poisson ) net_doc.transient_poisson_firing_synapses.append( mf_burst ) net_doc.gap_junctions.append(gj) ### ------------ Connectivity ### 1. Background excitatory inputs: MF to GoC populations MFProjection = nml.Projection(id="MFtoGoC", presynaptic_population=MF_Poisson_pop.id, postsynaptic_population=goc_pop.id, synapse=MFSyn_type.id) net.projections.append(MFProjection) # MF_> GoC synapses (with syn_count equivalent to integer scaling of Mf synapse strength) nMFSyn = p["MF_GoC_pairs"].shape[1] ctr=0 for syn in range( nMFSyn ): mf, goc = p["MF_GoC_pairs"][:, syn] for syn_count in range(p["MF_GoC_wt"][ctr]): conn2 = nml.Connection(id=ctr, pre_cell_id='../{}/{}/{}'.format(MF_Poisson_pop.id, mf, mf_poisson.id), post_cell_id='../{}/{}/{}'.format(goc_pop.id, goc, goc_type.id), post_segment_id='0', post_fraction_along="0.5") #on soma MFProjection.connections.append(conn2) ctr+=1 ### 2. Perturbation as High Freq MF Inputs ctr=0 for goc in p["Burst_GoC"]: for jj in range( p["nBurst"] ): # Each Perturbed GoC gets nBurst random Burst sources inst = nml.ExplicitInput( id=ctr, target='../{}/{}/{}'.format(goc_pop.id, goc, goc_type.id), input=mf_burst.id, synapse=MF20Syn_type.id, spikeTarget='./{}'.format(MF20Syn_type.id)) net.explicit_inputs.append( inst ) ctr += 1 ### 3. Electrical coupling between GoCs GoCCoupling = nml.ElectricalProjection( id="gocGJ", presynaptic_population=goc_pop.id, postsynaptic_population=goc_pop.id ) net.electrical_projections.append( GoCCoupling ) dend_id = [1,2,5] for jj in range( p["GJ_pairs"].shape[0] ): conn = nml.ElectricalConnectionInstanceW( id=jj, pre_cell='../{}/{}/{}'.format(goc_pop.id, p["GJ_pairs"][jj,0], goc_type.id), pre_segment=dend_id[p["GJ_loc"][jj,0]], pre_fraction_along='0.5', post_cell='../{}/{}/{}'.format(goc_pop.id, p["GJ_pairs"][jj,1], goc_type.id), post_segment=dend_id[p["GJ_loc"][jj,1]], post_fraction_along='0.5', synapse=gj.id, weight=p["GJ_wt"][jj] ) GoCCoupling.electrical_connection_instance_ws.append( conn ) ### -------------- Write files net_filename = 'gocNetwork.nml' pynml.write_neuroml2_file( net_doc, net_filename ) simid = 'sim_gocnet_'+goc_type.id+'_run_{}'.format(runid) ls = LEMSSimulation( simid, duration=duration, dt=dt, simulation_seed=seed ) ls.assign_simulation_target( net.id ) ls.include_neuroml2_file( net_filename) ls.include_neuroml2_file( goc_filename) ls.include_neuroml2_file( MFSyn_filename) ls.include_neuroml2_file( MF20Syn_filename) # Specify outputs eof0 = 'Events_file' ls.create_event_output_file(eof0, "%s.v.spikes"%simid,format='ID_TIME') for jj in range( goc_pop.size): ls.add_selection_to_event_output_file( eof0, jj, '{}/{}/{}'.format( goc_pop.id, jj, goc_type.id), 'spike' ) of0 = 'Volts_file' ls.create_output_file(of0, "%s.v.dat"%simid) for jj in range( goc_pop.size ): ls.add_column_to_output_file(of0, jj, '{}/{}/{}/v'.format( goc_pop.id, jj, goc_type.id)) #Create Lems file to run lems_simfile = ls.save_to_file() if run: res = pynml.run_lems_with_jneuroml_neuron( lems_simfile, max_memory="2G", nogui=True, plot=False) else: res = pynml.run_lems_with_jneuroml_neuron( lems_simfile, max_memory="2G", only_generate_scripts = True, compile_mods = False, nogui=True, plot=False) return res
yDim = 100 zDim = 500 offset = 0 ##### Cells #oc.add_cell_prototype(nml_doc, 'izhikevich/Izh_471141261.cell.nml') oc.include_opencortex_cell(nml_doc, 'izhikevich/RS.cell.nml') oc.include_opencortex_cell(nml_doc, 'iaf/iaf.cell.nml') oc.include_opencortex_cell(nml_doc, 'iaf/iafRef.cell.nml') oc.include_opencortex_cell(nml_doc, 'acnet2/pyr_4_sym_soma.cell.nml') oc.include_opencortex_cell(nml_doc, 'acnet2/pyr_4_sym.cell.nml') # TODO: add method oc.add_spike_generator_poisson(...) spike_gen = neuroml.SpikeGeneratorPoisson(id="poissonInput", average_rate="50Hz") nml_doc.spike_generator_poissons.append(spike_gen) ##### Synapses synAmpa1 = oc.add_exp_two_syn(nml_doc, id="synAmpa1", gbase="1nS", erev="0mV", tau_rise="0.5ms", tau_decay="5ms") synAmpa2 = oc.add_exp_two_syn(nml_doc, id="synAmpa2", gbase="2nS", erev="0mV", tau_rise="0.5ms", tau_decay="8ms") synGaba1 = oc.add_exp_two_syn(nml_doc, id="synGaba1", gbase="1nS", erev="-70mV", tau_rise="2ms", tau_decay="20ms")
def create_GoC_network( duration, dt, seed, N_goc=0, run=False, prob_type='Boltzmann', GJw_type='Vervaeke2010' ): goc_filename = 'GoC.cell.nml' goc_file = pynml.read_neuroml2_file( goc_filename ) goc_type = goc_file.cells[0] GJ_filename = 'GapJuncCML.nml' GJ_file = pynml.read_neuroml2_file( GJ_filename ) GJ_type = GJ_file.gap_junctions[0] MFSyn_filename = 'MF_GoC_Syn.nml' mfsyn_file = pynml.read_neuroml2_file( MFSyn_filename ) MFSyn_type = mfsyn_file.exp_three_synapses[0] MF20Syn_filename = 'MF_GoC_SynMult.nml' mf20syn_file = pynml.read_neuroml2_file( MF20Syn_filename ) MF20Syn_type = mf20syn_file.exp_three_synapses[0] # Distribute cells in 3D if N_goc>0: GoC_pos = nu.GoC_locate(N_goc) else: GoC_pos = nu.GoC_density_locate() N_goc = GoC_pos.shape[0] # get GJ connectivity GJ_pairs, GJWt = nu.GJ_conn( GoC_pos, prob_type, GJw_type ) tmp1, tmp2 = valnet.gapJuncAnalysis( GJ_pairs, GJWt ) print("Number of gap junctions per cell: ", tmp1) print("Net GJ conductance per cell:", tmp2) # Create pop List goc_pop = nml.Population( id=goc_type.id+"Pop", component = goc_type.id, type="populationList", size=N_goc ) # Create NML document for network specification net = nml.Network( id="gocNetwork", type="networkWithTemperature" , temperature="23 degC" ) net_doc = nml.NeuroMLDocument( id=net.id ) net_doc.networks.append( net ) net_doc.includes.append( goc_type ) net.populations.append( goc_pop ) #Add locations for GoC instances in the population: for goc in range(N_goc): inst = nml.Instance( id=goc ) goc_pop.instances.append( inst ) inst.location = nml.Location( x=GoC_pos[goc,0], y=GoC_pos[goc,1], z=GoC_pos[goc,2] ) # Define input spiketrains input_type = 'spikeGenerator'#'spikeGeneratorPoisson' lems_inst_doc = lems.Model() mf_inputs = lems.Component( "MF_Input", input_type) mf_inputs.set_parameter("period", "2000 ms" ) #mf_inputs.set_parameter("averageRate", "50 Hz") lems_inst_doc.add( mf_inputs ) #synapse_type = 'alphaCurrentSynapse' #alpha_syn = lems.Component( "AlphaSyn", synapse_type) #alpha_syn.set_parameter("tau", "30 ms" ) #alpha_syn.set_parameter("ibase", "200 pA") #lems_inst_doc.add( alpha_syn ) # Define MF input population N_mf = 15 #MF_pop = nml.Population(id=mf_inputs.id+"_pop", component=mf_inputs.id, type="populationList", size=N_mf) #net.populations.append( MF_pop ) mf_type2 = 'spikeGeneratorPoisson' #mf_poisson = lems.Component( "MF_Poisson", mf_type2) #mf_poisson.set_parameter("averageRate", "5 Hz") #lems_inst_doc.add( mf_poisson ) # adding in neuroml document instead of mf_poisson mf_poisson = nml.SpikeGeneratorPoisson( id = "MF_Poisson", average_rate="5 Hz" ) net_doc.spike_generator_poissons.append( mf_poisson ) net_doc.includes.append( goc_type ) MF_Poisson_pop = nml.Population(id=mf_poisson.id+"_pop", component=mf_poisson.id, type="populationList", size=N_mf) net.populations.append( MF_Poisson_pop ) MF_pos = nu.GoC_locate( N_mf ) for mf in range( N_mf ): inst = nml.Instance(id=mf) MF_Poisson_pop.instances.append( inst ) inst.location = nml.Location( x=MF_pos[mf,0], y=MF_pos[mf,1], z=MF_pos[mf,2] ) # Setup Mf->GoC synapses #MFprojection = nml.Projection(id="MFtoGoC", presynaptic_population=MF_pop.id, postsynaptic_population=goc_pop.id, synapse=alpha_syn.id) #net.projections.append(MFprojection) MF2projection = nml.Projection(id="MF2toGoC", presynaptic_population=MF_Poisson_pop.id, postsynaptic_population=goc_pop.id, synapse=MFSyn_type.id)#alpha_syn.id net.projections.append(MF2projection) #Get list of MF->GoC synapse mf_synlist = nu.randdist_MF_syn( N_mf, N_goc, pConn=0.3) nMFSyn = mf_synlist.shape[1] for syn in range( nMFSyn ): mf, goc = mf_synlist[:, syn] conn2 = nml.Connection(id=syn, pre_cell_id='../{}/{}/{}'.format(MF_Poisson_pop.id, mf, mf_poisson.id), post_cell_id='../{}/{}/{}'.format(goc_pop.id, goc, goc_type.id), post_segment_id='0', post_fraction_along="0.5") MF2projection.connections.append(conn2) # Burst of MF input (as explicit input) mf_bursttype = 'transientPoissonFiringSynapse' mf_burst = lems.Component( "MF_Burst", mf_bursttype) mf_burst.set_parameter( "averageRate", "100 Hz" ) mf_burst.set_parameter( "delay", "2000 ms" ) mf_burst.set_parameter( "duration", "500 ms" ) mf_burst.set_parameter( "synapse", MF20Syn_type.id ) mf_burst.set_parameter( "spikeTarget", './{}'.format(MF20Syn_type.id) ) lems_inst_doc.add( mf_burst ) # Add few burst inputs n_bursts = 4 gocPerm = np.random.permutation( N_goc ) ctr = 0 for gg in range(4): goc = gocPerm[gg] for jj in range( n_bursts ): inst = nml.ExplicitInput( id=ctr, target='../{}/{}/{}'.format(goc_pop.id, goc, goc_type.id), input=mf_burst.id, synapse=MF20Syn_type.id, spikeTarget='./{}'.format(MF20Syn_type.id)) net.explicit_inputs.append( inst ) ctr += 1 ''' one-to-one pairing of MF and GoC -> no shared inputs for goc in range(N_mf): #inst = nml.Instance(id=goc) #MF_pop.instances.append( inst ) #inst.location = nml.Location( x=GoC_pos[goc,0], y=GoC_pos[goc,1], z=GoC_pos[goc,2]+100 ) #conn = nml.Connection(id=goc, pre_cell_id='../{}/{}/{}'.format(MF_pop.id, goc, mf_inputs.id), post_cell_id='../{}/{}/{}'.format(goc_pop.id, goc, goc_type.id), post_segment_id='0', post_fraction_along="0.5") #MFprojection.connections.append(conn) goc2 = N_goc-goc-1 inst2 = nml.Instance(id=goc) MF_Poisson_pop.instances.append( inst2 ) inst2.location = nml.Location( x=GoC_pos[goc2,0], y=GoC_pos[goc2,1], z=GoC_pos[goc2,2]+100 ) conn2 = nml.Connection(id=goc, pre_cell_id='../{}/{}/{}'.format(MF_Poisson_pop.id, goc, mf_poisson.id), post_cell_id='../{}/{}/{}'.format(goc_pop.id, goc2, goc_type.id), post_segment_id='0', post_fraction_along="0.5") MF2projection.connections.append(conn2) ''' # Add electrical synapses GoCCoupling = nml.ElectricalProjection( id="gocGJ", presynaptic_population=goc_pop.id, postsynaptic_population=goc_pop.id ) #print(GJ_pairs) gj = nml.GapJunction( id="GJ_0", conductance="426pS" ) net_doc.gap_junctions.append(gj) nGJ = GJ_pairs.shape[0] for jj in range( nGJ ): #gj.append( lems.Component( "GJ_%d"%jj, 'gapJunction') ) #gj[jj].set_parameter( "conductance", "%fnS"%(GJWt[jj]) ) #gj = nml.GapJunction(id="GJ_%d"%jj, conductance="%fnS"%(GJWt[jj])) #net_doc.gap_junctions.append(gj) #lems_inst_doc.add( gj[jj] ) #print("%fnS"%(GJWt[jj]*0.426)) conn = nml.ElectricalConnectionInstanceW( id=jj, pre_cell='../{}/{}/{}'.format(goc_pop.id, GJ_pairs[jj,0], goc_type.id), pre_segment='1', pre_fraction_along='0.5', post_cell='../{}/{}/{}'.format(goc_pop.id, GJ_pairs[jj,1], goc_type.id), post_segment='1', post_fraction_along='0.5', synapse=gj.id, weight=GJWt[jj] )#synapse="GapJuncCML" synapse=gj.id , conductance="100E-9mS" # ------------ need to create GJ component GoCCoupling.electrical_connection_instance_ws.append( conn ) net.electrical_projections.append( GoCCoupling ) net_filename = 'gocNetwork.nml' pynml.write_neuroml2_file( net_doc, net_filename ) lems_filename = 'instances.xml' pynml.write_lems_file( lems_inst_doc, lems_filename, validate=False ) simid = 'sim_gocnet'+goc_type.id ls = LEMSSimulation( simid, duration=duration, dt=dt, simulation_seed=seed ) ls.assign_simulation_target( net.id ) #ls.include_lems_file( 'Synapses.xml', include_included=False) #ls.include_lems_file( 'Inputs.xml', include_included=False) ls.include_neuroml2_file( net_filename) ls.include_neuroml2_file( goc_filename) ls.include_neuroml2_file( GJ_filename) ls.include_neuroml2_file( MFSyn_filename) ls.include_neuroml2_file( MF20Syn_filename) ls.include_lems_file( lems_filename, include_included=False) # Specify outputs eof0 = 'Events_file' ls.create_event_output_file(eof0, "%s.v.spikes"%simid,format='ID_TIME') for jj in range( goc_pop.size): ls.add_selection_to_event_output_file( eof0, jj, '{}/{}/{}'.format( goc_pop.id, jj, goc_type.id), 'spike' ) of0 = 'Volts_file' ls.create_output_file(of0, "%s.v.dat"%simid) for jj in range( goc_pop.size ): ls.add_column_to_output_file(of0, jj, '{}/{}/{}/v'.format( goc_pop.id, jj, goc_type.id)) #Create Lems file to run lems_simfile = ls.save_to_file() #res = pynml.run_lems_with_jneuroml( lems_simfile, max_memory="1G",nogui=True, plot=False) #res = pynml.run_lems_with_jneuroml_neuron( lems_simfile, max_memory="2G", only_generate_scripts = True, compile_mods = False, nogui=True, plot=False) res = pynml.run_lems_with_jneuroml_neuron( lems_simfile, max_memory="2G", compile_mods = False,nogui=True, plot=False) #res=True return res
def create_GoC_network(duration, dt, seed, N_goc=0, N_mf=15, run=False, prob_type='Boltzmann', GJw_type='Vervaeke2010'): ### ---------- Component types goc_filename = 'GoC.cell.nml' # Golgi cell with channels goc_file = pynml.read_neuroml2_file(goc_filename) goc_type = goc_file.cells[0] goc_ref = nml.IncludeType(href=goc_filename) MFSyn_filename = 'MF_GoC_Syn.nml' # small conductance synapse for background inputs mfsyn_file = pynml.read_neuroml2_file(MFSyn_filename) MFSyn_type = mfsyn_file.exp_three_synapses[0] mfsyn_ref = nml.IncludeType(href=MFSyn_filename) MF20Syn_filename = 'MF_GoC_SynMult.nml' # multi-syn conductance for strong/coincident transient input mf20syn_file = pynml.read_neuroml2_file(MF20Syn_filename) MF20Syn_type = mf20syn_file.exp_three_synapses[0] mf20syn_ref = nml.IncludeType(href=MF20Syn_filename) mf_type2 = 'spikeGeneratorPoisson' # Spike source for background inputs mf_poisson = nml.SpikeGeneratorPoisson( id="MF_Poisson", average_rate="5 Hz") # Not tuned to any data - qqq ! mf_bursttype = 'transientPoissonFiringSynapse' # Burst of MF input (as explicit input) mf_burst = nml.TransientPoissonFiringSynapse(id="MF_Burst", average_rate="100 Hz", delay="2000 ms", duration="500 ms", synapse=MF20Syn_type.id, spike_target='./{}'.format( MF20Syn_type.id)) gj = nml.GapJunction(id="GJ_0", conductance="426pS") # GoC synapse ### --------- Populations # Build network to specify cells and connectivity net = nml.Network(id="gocNetwork", type="networkWithTemperature", temperature="23 degC") ### Golgi cells if N_goc > 0: GoC_pos = nu.GoC_locate(N_goc) else: GoC_pos = nu.GoC_density_locate() N_goc = GoC_pos.shape[0] # Create GoC population goc_pop = nml.Population(id=goc_type.id + "Pop", component=goc_type.id, type="populationList", size=N_goc) for goc in range(N_goc): inst = nml.Instance(id=goc) goc_pop.instances.append(inst) inst.location = nml.Location(x=GoC_pos[goc, 0], y=GoC_pos[goc, 1], z=GoC_pos[goc, 2]) net.populations.append(goc_pop) ### MF population MF_Poisson_pop = nml.Population(id=mf_poisson.id + "_pop", component=mf_poisson.id, type="populationList", size=N_mf) MF_pos = nu.GoC_locate(N_mf) for mf in range(N_mf): inst = nml.Instance(id=mf) MF_Poisson_pop.instances.append(inst) inst.location = nml.Location(x=MF_pos[mf, 0], y=MF_pos[mf, 1], z=MF_pos[mf, 2]) net.populations.append(MF_Poisson_pop) # Create NML document for network specification net_doc = nml.NeuroMLDocument(id=net.id) net_doc.networks.append(net) net_doc.includes.append(goc_ref) net_doc.includes.append(mfsyn_ref) net_doc.includes.append(mf20syn_ref) net_doc.spike_generator_poissons.append(mf_poisson) net_doc.transient_poisson_firing_synapses.append(mf_burst) net_doc.gap_junctions.append(gj) ### ------------ Connectivity ### background excitatory inputs: MF to GoC populations MFProjection = nml.Projection(id="MFtoGoC", presynaptic_population=MF_Poisson_pop.id, postsynaptic_population=goc_pop.id, synapse=MFSyn_type.id) net.projections.append(MFProjection) #Get list of MF->GoC synapse mf_synlist = nu.randdist_MF_syn(N_mf, N_goc, pConn=0.3) # Not tuned to any data - qqq! nMFSyn = mf_synlist.shape[1] for syn in range(nMFSyn): mf, goc = mf_synlist[:, syn] conn2 = nml.Connection( id=syn, pre_cell_id='../{}/{}/{}'.format(MF_Poisson_pop.id, mf, mf_poisson.id), post_cell_id='../{}/{}/{}'.format(goc_pop.id, goc, goc_type.id), post_segment_id='0', post_fraction_along="0.5") #on soma MFProjection.connections.append(conn2) ### Add few burst inputs n_bursts = 4 gocPerm = np.random.permutation( N_goc) # change to central neurons later -qqq !!! ctr = 0 for gg in range(4): goc = gocPerm[gg] for jj in range(n_bursts): inst = nml.ExplicitInput( id=ctr, target='../{}/{}/{}'.format(goc_pop.id, goc, goc_type.id), input=mf_burst.id, synapse=MF20Syn_type.id, spikeTarget='./{}'.format(MF20Syn_type.id)) net.explicit_inputs.append(inst) ctr += 1 ### Electrical coupling between GoCs # get GJ connectivity GJ_pairs, GJWt = nu.GJ_conn(GoC_pos, prob_type, GJw_type) #tmp1, tmp2 = valnet.gapJuncAnalysis( GJ_pairs, GJWt ) #print("Number of gap junctions per cell: ", tmp1) #print("Net GJ conductance per cell:", tmp2) # Add electrical synapses GoCCoupling = nml.ElectricalProjection(id="gocGJ", presynaptic_population=goc_pop.id, postsynaptic_population=goc_pop.id) nGJ = GJ_pairs.shape[0] for jj in range(nGJ): conn = nml.ElectricalConnectionInstanceW( id=jj, pre_cell='../{}/{}/{}'.format(goc_pop.id, GJ_pairs[jj, 0], goc_type.id), pre_segment='1', pre_fraction_along='0.5', post_cell='../{}/{}/{}'.format(goc_pop.id, GJ_pairs[jj, 1], goc_type.id), post_segment='1', post_fraction_along='0.5', synapse=gj.id, weight=GJWt[jj]) GoCCoupling.electrical_connection_instance_ws.append(conn) net.electrical_projections.append(GoCCoupling) ### -------------- Write files net_filename = 'gocNetwork.nml' pynml.write_neuroml2_file(net_doc, net_filename) #lems_filename = 'instances.xml' #pynml.write_lems_file( lems_inst_doc, lems_filename, validate=False ) simid = 'sim_gocnet' + goc_type.id ls = LEMSSimulation(simid, duration=duration, dt=dt, simulation_seed=seed) ls.assign_simulation_target(net.id) ls.include_neuroml2_file(net_filename) ls.include_neuroml2_file(goc_filename) ls.include_neuroml2_file(MFSyn_filename) ls.include_neuroml2_file(MF20Syn_filename) #ls.include_lems_file( lems_filename, include_included=False) # Specify outputs eof0 = 'Events_file' ls.create_event_output_file(eof0, "%s.v.spikes" % simid, format='ID_TIME') for jj in range(goc_pop.size): ls.add_selection_to_event_output_file( eof0, jj, '{}/{}/{}'.format(goc_pop.id, jj, goc_type.id), 'spike') of0 = 'Volts_file' ls.create_output_file(of0, "%s.v.dat" % simid) for jj in range(goc_pop.size): ls.add_column_to_output_file( of0, jj, '{}/{}/{}/v'.format(goc_pop.id, jj, goc_type.id)) #Create Lems file to run lems_simfile = ls.save_to_file() if run: res = pynml.run_lems_with_jneuroml_neuron(lems_simfile, max_memory="2G", nogui=True, plot=False) else: res = pynml.run_lems_with_jneuroml_neuron(lems_simfile, max_memory="2G", only_generate_scripts=True, compile_mods=False, nogui=True, plot=False) return res
erev="0mV", tau_rise="2ms", tau_decay="10ms") nml_doc.exp_two_synapses.append(syn1) # Define Poisson spiking input pfs = neuroml.PoissonFiringSynapse(id="poissonFiringSyn", average_rate="150 Hz", synapse=syn0.id, spike_target="./%s" % syn0.id) nml_doc.poisson_firing_synapses.append(pfs) # Define Poisson spike generator sgp = neuroml.SpikeGeneratorPoisson(id="spikeGenPoisson", average_rate="150 Hz") nml_doc.spike_generator_poissons.append(sgp) # Define Spike array sa = neuroml.SpikeArray(id="spikeArray") sa.spikes.append(neuroml.Spike(id="0", time="100ms")) sa.spikes.append(neuroml.Spike(id="1", time="500ms")) sa.spikes.append(neuroml.Spike(id="2", time="700ms")) sa.spikes.append(neuroml.Spike(id="3", time="705ms")) nml_doc.spike_arrays.append(sa) # Define timedSynapticInput tsi = neuroml.TimedSynapticInput(id="timedSynapticInput", synapse=syn1.id,