def run(): ######################## Build the network #################################### nml_doc = NeuroMLDocument(id="IafNet") IaFCell0 = IaFCell(id="iaf0", C="1.0 nF", thresh = "-50mV", reset="-65mV", leak_conductance="10 nS", leak_reversal="-65mV") nml_doc.iaf_cells.append(IaFCell0) IaFCell1 = IaFCell(id="iaf1", C="1.0 nF", thresh = "-50mV", reset="-65mV", leak_conductance="20 nS", leak_reversal="-65mV") nml_doc.iaf_cells.append(IaFCell1) syn0 = ExpOneSynapse(id="syn0", gbase="65nS", erev="0mV", tau_decay="3ms") nml_doc.exp_one_synapses.append(syn0) net = Network(id="IafNet") nml_doc.networks.append(net) size0 = 5 pop0 = Population(id="IafPop0", component=IaFCell0.id, size=size0) net.populations.append(pop0) size1 = 5 pop1 = Population(id="IafPop1", component=IaFCell0.id, size=size1) net.populations.append(pop1) prob_connection = 0.5 for pre in range(0,size0): pg = PulseGenerator(id="pulseGen_%i"%pre, delay="0ms", duration="100ms", amplitude="%f nA"%(0.1*random())) nml_doc.pulse_generators.append(pg) net.explicit_inputs.append(ExplicitInput(target="%s[%i]"%(pop0.id,pre), input=pg.id)) for post in range(0,size1): # fromxx is used since from is Python keyword if random() <= prob_connection: net.synaptic_connections.append(SynapticConnection(from_="%s[%i]"%(pop0.id,pre), synapse=syn0.id, to="%s[%i]"%(pop1.id,post))) nml_file = 'tmp/testnet.nml' writers.NeuroMLWriter.write(nml_doc, nml_file) print("Written network file to: "+nml_file) ###### Validate the NeuroML ###### from utils import validateNeuroML2 validateNeuroML2(nml_file)
axon_segment = neuroml.Segment(proximal = p, distal = d, parent = parent) axon_segment.id = seg_id axon_segment.name = 'axon_segment_' + str(axon_segment.id) #now reset everything: parent = neuroml.SegmentParent(segments=axon_segment.id) parent_segment = axon_segment seg_id += 1 axon_segments.append(axon_segment) doc.cells[0].morphology.segments += axon_segments nml_file = './tmp/modified_morphology.nml' writers.NeuroMLWriter.write(doc,nml_file) print("Saved modified morphology file to: "+nml_file) ###### Validate the NeuroML ###### from utils import validateNeuroML2 validateNeuroML2(nml_file)
nml_doc = NeuroMLDocument(id="SomeSynapses") expOneSyn0 = ExpOneSynapse(id="ampa", tau_decay="5ms", gbase="1nS", erev="0mV") nml_doc.exp_one_synapses.append(expOneSyn0) expTwoSyn0 = ExpTwoSynapse(id="gaba", tau_decay="12ms", tau_rise="3ms", gbase="1nS", erev="-70mV") nml_doc.exp_two_synapses.append(expTwoSyn0) bpSyn = BlockingPlasticSynapse(id="blockStpSynDep", gbase="1nS", erev="0mV", tau_rise="0.1ms", tau_decay="2ms") bpSyn.notes = "This is a note" bpSyn.plasticity_mechanism = PlasticityMechanism(type="tsodyksMarkramDepMechanism", init_release_prob="0.5", tau_rec="120 ms") bpSyn.block_mechanism = BlockMechanism(type="voltageConcDepBlockMechanism", species="mg", block_concentration="1.2 mM", scaling_conc="1.920544 mM", scaling_volt="16.129 mV") nml_doc.blocking_plastic_synapses.append(bpSyn) nml_file = 'tmp/synapses.xml' writers.NeuroMLWriter.write(nml_doc, nml_file) print("Saved to: "+nml_file) ###### Validate the NeuroML ###### from utils import validateNeuroML2 validateNeuroML2(nml_file)
def run(): cell_num = 10 x_size = 500 y_size = 500 z_size = 500 nml_doc = NeuroMLDocument(id="Net3DExample") syn0 = ExpOneSynapse(id="syn0", gbase="65nS", erev="0mV", tau_decay="3ms") nml_doc.exp_one_synapses.append(syn0) net = Network(id="Net3D") nml_doc.networks.append(net) proj_count = 0 #conn_count = 0 for cell_id in range(0, cell_num): cell = Cell(id="Cell_%i" % cell_id) cell.morphology = generateRandomMorphology() nml_doc.cells.append(cell) pop = Population(id="Pop_%i" % cell_id, component=cell.id, type="populationList") net.populations.append(pop) inst = Instance(id="0") pop.instances.append(inst) inst.location = Location(x=str(x_size * random()), y=str(y_size * random()), z=str(z_size * random())) prob_connection = 0.5 for post in range(0, cell_num): if post is not cell_id and random() <= prob_connection: from_pop = "Pop_%i" % cell_id to_pop = "Pop_%i" % post pre_seg_id = 0 post_seg_id = 1 projection = Projection(id="Proj_%i" % proj_count, presynaptic_population=from_pop, postsynaptic_population=to_pop, synapse=syn0.id) net.projections.append(projection) connection = Connection(id=proj_count, \ pre_cell_id="%s[%i]"%(from_pop,0), \ pre_segment_id=pre_seg_id, \ pre_fraction_along=random(), post_cell_id="%s[%i]"%(to_pop,0), \ post_segment_id=post_seg_id, post_fraction_along=random()) projection.connections.append(connection) proj_count += 1 #net.synaptic_connections.append(SynapticConnection(from_="%s[%i]"%(from_pop,0), to="%s[%i]"%(to_pop,0))) ####### Write to file ###### nml_file = 'tmp/net3d.nml' writers.NeuroMLWriter.write(nml_doc, nml_file) print("Written network file to: " + nml_file) ###### Validate the NeuroML ###### from utils import validateNeuroML2 validateNeuroML2(nml_file)
def run(): cell_num = 10 x_size = 500 y_size = 500 z_size = 500 nml_doc = NeuroMLDocument(id="Net3DExample") syn0 = ExpOneSynapse(id="syn0", gbase="65nS", erev="0mV", tau_decay="3ms") nml_doc.exp_one_synapses.append(syn0) net = Network(id="Net3D") nml_doc.networks.append(net) proj_count = 0 #conn_count = 0 for cell_id in range(0,cell_num): cell = Cell(id="Cell_%i"%cell_id) cell.morphology = generateRandomMorphology() nml_doc.cells.append(cell) pop = Population(id="Pop_%i"%cell_id, component=cell.id, type="populationList") net.populations.append(pop) inst = Instance(id="0") pop.instances.append(inst) inst.location = Location(x=str(x_size*random()), y=str(y_size*random()), z=str(z_size*random())) prob_connection = 0.5 for post in range(0,cell_num): if post is not cell_id and random() <= prob_connection: from_pop = "Pop_%i"%cell_id to_pop = "Pop_%i"%post pre_seg_id = 0 post_seg_id = 1 projection = Projection(id="Proj_%i"%proj_count, presynaptic_population=from_pop, postsynaptic_population=to_pop, synapse=syn0.id) net.projections.append(projection) connection = Connection(id=proj_count, \ pre_cell_id="%s[%i]"%(from_pop,0), \ pre_segment_id=pre_seg_id, \ pre_fraction_along=random(), post_cell_id="%s[%i]"%(to_pop,0), \ post_segment_id=post_seg_id, post_fraction_along=random()) projection.connections.append(connection) proj_count += 1 #net.synaptic_connections.append(SynapticConnection(from_="%s[%i]"%(from_pop,0), to="%s[%i]"%(to_pop,0))) ####### Write to file ###### nml_file = 'tmp/net3d.nml' writers.NeuroMLWriter.write(nml_doc, nml_file) print("Written network file to: "+nml_file) ###### Validate the NeuroML ###### from utils import validateNeuroML2 validateNeuroML2(nml_file)