Skip to content

Commit

Permalink
Adding pyb script for generating stimulations
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Apr 19, 2017
1 parent a514caf commit 48507a1
Show file tree
Hide file tree
Showing 5 changed files with 403 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NeuroML2/GenerateIV.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import opencortex.build as oc
import opencortex.core as oc
import numpy as np

def generate(cell_id, duration, reference, iRange):
Expand Down
94 changes: 94 additions & 0 deletions NeuroML2/GenerateStims.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import sys

import opencortex.core as oc

import numpy as np

def generate(cell_id, duration, reference, bEnsyn):

bInsyn = int(bEnsyn * 0.2)

cell_file = '%s.cell.nml'%cell_id

nml_doc, network = oc.generate_network(reference, temperature='35degC')

oc.include_neuroml2_cell_and_channels(nml_doc,cell_file,cell_id)

oc.include_neuroml2_file(nml_doc,'AMPA.synapse.nml')
oc.include_neuroml2_file(nml_doc,'GABA.synapse.nml')
oc.include_neuroml2_file(nml_doc,'NMDA.synapse.nml')

ampa1 = oc.add_poisson_firing_synapse(nml_doc,
id="ampa1",
average_rate="50 Hz",
synapse_id='AMPA')

gaba1 = oc.add_poisson_firing_synapse(nml_doc,
id="gaba1",
average_rate="50 Hz",
synapse_id='GABA')

nmda1 = oc.add_poisson_firing_synapse(nml_doc,
id="nmda1",
average_rate="50 Hz",
synapse_id='NMDA')


pop = oc.add_single_cell_population(network,
'L23_pop',
cell_id)




oc.add_targeted_inputs_to_population(network, "bEsyn_a",
pop, ampa1.id,
segment_group='dendrite_group',
number_per_cell = bEnsyn,
all_cells=True)

oc.add_targeted_inputs_to_population(network, "bEsyn_n",
pop, nmda1.id,
segment_group='dendrite_group',
number_per_cell = bEnsyn,
all_cells=True)

oc.add_targeted_inputs_to_population(network, "bIsyn",
pop, gaba1.id,
segment_group='dendrite_group',
number_per_cell = bInsyn,
all_cells=True)


nml_file_name = '%s.net.nml'%network.id
oc.save_network(nml_doc, nml_file_name, validate=True)

interesting_seg_ids = [0,200,1000,2000,2500,2949]

to_plot = {'Some_voltages':[]}
to_save = {'%s_voltages.dat'%cell_id:[]}

for seg_id in interesting_seg_ids:
to_plot.values()[0].append('%s/0/%s/%s/v'%(pop.id, pop.component,seg_id))
to_save.values()[0].append('%s/0/%s/%s/v'%(pop.id, pop.component,seg_id))

oc.generate_lems_simulation(nml_doc,
network,
nml_file_name,
duration,
dt = 0.025,
gen_plots_for_all_v = False,
plot_all_segments = False,
gen_plots_for_quantities = to_plot, # Dict with displays vs lists of quantity paths
gen_saves_for_all_v = False,
save_all_segments = False,
gen_saves_for_quantities = to_save) # Dict with file names vs lists of quantity paths)


if __name__ == "__main__":

cell_id = 'L23_NoHotSpot'
reference = "L23_Stim"
duration = 200

generate(cell_id, duration, reference, 100)
4 changes: 2 additions & 2 deletions NeuroML2/L23_IV.net.nml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2beta5.xsd" id="L23_IV">
<notes>

This NeuroML 2 file was generated by OpenCortex v0.0.8 using:
This NeuroML 2 file was generated by OpenCortex v0.1.0 using:
libNeuroML v0.2.29
pyNeuroML v0.2.10

</notes>
<property tag="Python random seed" value="1234"/>
<property tag="Network seed" value="1234"/>
<include href="L23_NoHotSpot.cell.nml"></include>
<include href="ca.channel.nml"></include>
<include href="it.channel.nml"></include>
Expand Down
Loading

0 comments on commit 48507a1

Please sign in to comment.