opencortex core Package

This is the main module for user interaction with OpenCortex.

opencortex.core Package

opencortex.core.add_exp_one_syn(nml_doc, id, gbase, erev, tau_decay)

Adds an <expOneSynapse> element to the document. See the definition of the behaviour of this here: https://www.neuroml.org/NeuroML2CoreTypes/Synapses.html#expOneSynapse

Returns the class created.

opencortex.core.add_exp_two_syn(nml_doc, id, gbase, erev, tau_rise, tau_decay)

Adds an <expTwoSynapse> element to the document. See the definition of the behaviour of this here: https://www.neuroml.org/NeuroML2CoreTypes/Synapses.html#expTwoSynapse

Returns the class created.

opencortex.core.add_gap_junction_synapse(nml_doc, id, conductance)

Adds a <gapJunction> element to the document. See the definition of the behaviour of this here: https://www.neuroml.org/NeuroML2CoreTypes/Synapses.html#gapJunction

Returns the class created.

opencortex.core.add_inputs_to_population(net, id, population, input_comp_id, number_per_cell=1, all_cells=False, only_cells=None, segment_ids=[0], fraction_alongs=[0.5], weights=1)

Add current input to the specified population. Attributes:

net
reference to the network object previously created
id
id of the <inputList> to be created
population
the <population> to be targeted
input_comp_id
id of the component to be used for the input (e.g. added with add_pulse_generator())
number_per_cell
how many inputs to apply to each cell of the population. Default 1
all_cells
Whether to target all cells. Default False
only_cells
Which specific cells to target. List of ids. Default None
segment_ids
List of segment ids to place inputs onto on each cell. Either list of 1 value or list of number_per_cell entries. Default [0]
fraction_alongs
List of fractions along the specified segments to place inputs onto on each cell. Either list of 1 value or list of number_per_cell entries. Default [0.5]
weights
Either a scalar value (all weights set to this for all inputs), or a function to pick a (random) value per input. Default 1
opencortex.core.add_poisson_firing_synapse(nml_doc, id, average_rate, synapse_id)

Adds a <poissonFiringSynapse> element to the document. See the definition of the behaviour of this here: https://www.neuroml.org/NeuroML2CoreTypes/Inputs.html#poissonFiringSynapse

Returns the class created.

opencortex.core.add_population_in_rectangular_region(net, pop_id, cell_id, size, x_min, y_min, z_min, x_size, y_size, z_size, cell_bodies_overlap=True, store_soma=False, population_dictionary=None, cell_diameter_dict=None, color=None)

Method which creates a cell population in the NeuroML2 network and distributes these cells in the rectangular region. Input arguments are:

net
reference to the network object previously created
pop_id
population id
cell_id
cell component id
size
size of a population
x_min
lower x bound of a rectangular region
y_min
lower y bound of a rectangular region
z_min
lower z bound of a rectangular region
x_size
width of a rectangular region along x axis
y_size
width of a rectangular region along y axis
z_size
width of a rectangular region along z axis
cell_bodies_overlap
boolean value which defines whether cell somata can overlap; default is set to True
store_soma
boolean value which specifies whether soma positions have to be returned in the output array; default is set to False
population_dictionary
optional argument in the format returned by opencortex.utils.add_populations_in_rectangular_layers; default value is None but it must be specified when cell_bodies_overlap is set to False
cell_diameter_dict
optional argument in the format {‘cell_id1’: soma diameter of type ‘float’, ‘cell_id2’: soma diameter of type ‘float’}; default is None but it must be specified when cell_bodies_overlap is set to False
color
optional color (which will be put through to annotation in generated NeuroML); RGB format, 3 floats 0->1, e.g. 1 0 0 for red; default is None
opencortex.core.add_probabilistic_projection(net, prefix, presynaptic_population, postsynaptic_population, synapse_id, connection_probability, delay=0, weight=1)

Add a projection between presynaptic_population and postsynaptic_population with probability of connection between each pre & post pair of cells given by connection_probability. Attributes:

net
reference to the network object previously created
prefix
prefix to use in the id of the projection
presynaptic_population
presynaptic population e.g. added via add_population_in_rectangular_region()
postsynaptic_population
postsynaptic population e.g. added via add_population_in_rectangular_region()
synapse_id
id of synapse previously added, e.g. added with add_exp_two_syn()
connection_probability
For each pre syn cell i and post syn cell j, where i!=j, the chance they will be connected is given by this
delay
optional delay for each connection, default 0 ms
weight
optional weight for each connection, default 1
opencortex.core.add_pulse_generator(nml_doc, id, delay, duration, amplitude)

Adds a <pulseGenerator> element to the document. See the definition of the behaviour of this here: https://www.neuroml.org/NeuroML2CoreTypes/Inputs.html#pulseGenerator

Returns the class created.

opencortex.core.add_single_cell_population(net, pop_id, cell_id, x=0, y=0, z=0, color=None)

Add a population with id pop_id containing a single instance of cell cell_id. Optionally specify (x,`y`,`z`) and the population color.

opencortex.core.add_spike_source_poisson(nml_doc, id, start, duration, rate)

Adds a <SpikeSourcePoisson> element to the document. See the definition of the behaviour of this here: https://www.neuroml.org/NeuroML2CoreTypes/PyNN.html#SpikeSourcePoisson

Returns the class created.

opencortex.core.add_targeted_electrical_projection(nml_doc, net, prefix, presynaptic_population, postsynaptic_population, targeting_mode, synapse_list, number_conns_per_cell, pre_segment_group, post_segment_group)

Adds (electrical, gap junction mediated) projection from presynaptic_population to postsynaptic_population, specifically limiting connections presynaptically to pre_segment_group and postsynaptically to post_segment_group.

opencortex.core.add_targeted_inputs_to_population(net, id, population, input_comp_id, segment_group, number_per_cell=1, all_cells=False, only_cells=None, weights=1)

Add current input to the specified population. Attributes:

net
reference to the network object previously created
id
id of the <inputList> to be created
population
the <population> to be targeted
input_comp_id
id of the component to be used for the input (e.g. added with add_pulse_generator())
segment_group
which segment group on the target cells to limit input locations to
number_per_cell
How many inputs to apply to each cell of the population. Default 1
all_cells
whether to target all cells. Default False
only_cells
which specific cells to target. List of ids. Default None
weights
Either a scalar value (all weights set to this for all inputs), or a function to pick a (random) value per input. Default 1
opencortex.core.add_targeted_projection(net, prefix, presynaptic_population, postsynaptic_population, targeting_mode, synapse_list, number_conns_per_cell, pre_segment_group=None, post_segment_group=None, delays_dict=None, weights_dict=None)

Adds (chemical, event based) projection from presynaptic_population to postsynaptic_population, specifically limiting connections presynaptically to pre_segment_group and postsynaptically to post_segment_group.

net
reference to the network object previously created
prefix
prefix to use in the id of the projection
presynaptic_population
presynaptic population e.g. added via add_population_in_rectangular_region()
postsynaptic_population
postsynaptic population e.g. added via add_population_in_rectangular_region()
targeting_mode
a string that specifies the targeting mode: ‘convergent’ or ‘divergent’
synapse_list
the list of synapse ids that correspond to the individual receptor components on the physical synapse, e.g. the first element is the id of the AMPA synapse and the second element is the id of the NMDA synapse; these synapse components will be mapped onto the same location of the target segment
number_conns_per_cell
number of connections to make on each cell in the postsynaptic population (when targeting_mode=’convergent’) or from each cell in the presynaptic population (when targeting_mode=’divergent’)
pre_segment_group
which segment_group to target connennections from on the presynaptic population, e.g. axon_group. This can be left out or set to None if the presynaptic component has no morphology
post_segment_group
which segment_group to target connennections from on the postsynaptic population, e.g. dendrite_group. This can be left out or set to None if the postsynaptic component has no morphology
delays_dict
optional dictionary that specifies the delays (in ms) for individual synapse components, e.g. {‘NMDA’:5.0} or {‘AMPA’:3.0,’NMDA’:5}
weights_dict
optional dictionary that specifies the weights for individual synapse components, e.g. {‘NMDA’:1} or {‘NMDA’:1,’AMPA’:2}
opencortex.core.add_transient_poisson_firing_synapse(nml_doc, id, average_rate, delay, duration, synapse_id)

Adds a <transientPoissonFiringSynapse> element to the document. See the definition of the behaviour of this here: https://www.neuroml.org/NeuroML2CoreTypes/Inputs.html#transientPoissonFiringSynapse

Returns the class created.

opencortex.core.add_voltage_clamp_triple(nml_doc, id, delay, duration, conditioning_voltage, testing_voltage, return_voltage, simple_series_resistance, active='1')

Adds a <voltageClampTriple> element to the document. See the definition of the behaviour of this here: https://github.com/NeuroML/NeuroML2/blob/development/Schemas/NeuroML2/NeuroML_v2beta5.xsd

Returns the class created.

opencortex.core.generate_lems_simulation(nml_doc, network, nml_file_name, duration, dt, target_dir='.', include_extra_lems_files=[], gen_plots_for_all_v=True, plot_all_segments=False, gen_plots_for_quantities={}, gen_plots_for_only_populations=[], gen_saves_for_all_v=True, save_all_segments=False, gen_saves_for_only_populations=[], gen_saves_for_quantities={}, gen_spike_saves_for_all_somas=False, gen_spike_saves_for_only_populations=[], gen_spike_saves_for_cells={}, spike_time_format='ID_TIME', report_file_name=None, lems_file_name=None, lems_file_generate_seed=12345, simulation_seed=12345, verbose=False)

Generate a LEMS simulation file with which to run simulations of the network. Generated LEMS files can be run with jNeuroML (or converted to simulator specific formats, e.g. NEURON, and run)

opencortex.core.generate_network(reference, network_seed=1234, temperature='32degC')

Generate a network which will contain populations, projections, etc. Arguments:

reference
the reference to use as the id for the network
network_seed
optional, will be used for random elements of the network, e.g. placement of cells in 3D
temperature
optional, will be specified in network and used in temperature dependent elements, e.g. ion channels with Q10. Default: 32degC
opencortex.core.include_cell_prototype(nml_doc, cell_nml2_path)

Add a NeuroML2 file containing a cell definition

opencortex.core.include_neuroml2_cell(nml_doc, cell_nml2_path, cell_id, channels_also=True)

Add a cell with id cell_id which is in cell_nml2_path to the build document, along with all its channels (if channels_also==True)

opencortex.core.include_neuroml2_cell_and_channels(nml_doc, cell_nml2_path, cell_id)

DEPRECATED TODO: remove, due to include_neuroml2_cell Add a cell with id cell_id which is in cell_nml2_path to the build document, along with all its channels

opencortex.core.include_neuroml2_file(nml_doc, nml2_file_path)

Add a NeuroML2 file containing definitions of elements which can be used in the network

opencortex.core.include_opencortex_cell(nml_doc, reference)

Include a cell from the standard set of NeuroML2 cells included with OpenCortex. See https://github.com/OpenSourceBrain/OpenCortex/tree/master/NeuroML2/prototypes.

opencortex.core.save_network(nml_doc, nml_file_name, validate=True, format='xml', max_memory=None, target_dir='./', use_subfolder=True)

Save the contents of the built NeuroML document, including the network to the file specified by nml_file_name, optionally specifying the target_dir

opencortex.core.simulate_network(lems_file_name, simulator, max_memory='400M', nogui=True, load_saved_data=False, reload_events=False, plot=False, verbose=True, num_processors=1)

Run a simulation of the LEMS file lems_file_name using target platform simulator