-
Nora Abi Akar authored
Remove `gid` attribute of target of a connection, and local gap-junction site of a gap-junction connection (#1467) * Change the type of the target of a `connection` from `cell_member_type` to `cell_lid_type`. The target cell's gid is always known in both the recipe and simulation. * Change the type of the local site of a `gap_junction_connection` from `cell_member_type` to `cell_lid_type`, and make it such that the first argument of the connection is the peer site, and the second the local site. The local cell's gid is always known in both the recipe and simulation. * Change the type of the target of an `event_generator` from `cell_member_type` to `cell_lid_type`. The target cell's gid is always known in both the recipe and simulation. * New `cell_spike_events` and `cse_vector` for `simulation::inject_events`. * Simplify recipe sanity checks and remove associated exception types. * Fix unit tests, examples, docs
Unverifieddb0041a5
Recipes
The :class:`recipe` class documentation is below.
A recipe describes neuron models in a cell-oriented manner and supplies methods to provide cell information. Details on why Arbor uses recipes and general best practices can be found in :ref:`modelrecipe`.
Recipe
Describe a model by describing the cells and network, without any information about how the model is to be represented or executed.
All recipes derive from this abstract base class.
Recipes provide a cell-centric interface for describing a model.
This means that model properties, such as connections, are queried using the global identifier (:attr:`arbor.cell_member.gid`) of a cell.
In the description below, the term gid
is used as shorthand for the cell with global identifier.
Required Member Functions
The following member functions (besides a constructor) must be implemented by every recipe:
Optional Member Functions
Cells
See :ref:`pycell`.
Synapses
See :ref:`pyinterconnectivity`.
Event generator and schedules
Describes a regular schedule with multiples of :attr:`dt` within the interval [:attr:`tstart`, :attr:`tstop`).
Describes an explicit schedule at a predetermined (sorted) sequence of :attr:`times`.
Describes a schedule according to a Poisson process.
An example of an event generator reads as follows:
import arbor
# define a Poisson schedule with start time 1 ms, expected frequency of 5 Hz,
# and the target cell's gid as seed
def event_generators(gid):
target = 0 # index of the synapse on target cell gid
seed = gid
tstart = 1
freq = 0.005
sched = arbor.poisson_schedule(tstart, freq, seed)
# construct an event generator with this schedule on target cell and weight 0.1
w = 0.1
return [arbor.event_generator(target, w, sched)]
Example
Below is an example of a recipe construction of a ring network of multi-compartmental cells. Because the interface for specifying cable morphology cells is under construction, the temporary helpers in cell_parameters and make_cable_cell for building cells are used.
import sys
import arbor
class ring_recipe (arbor.recipe):
def __init__(self, n=4):
# The base C++ class constructor must be called first, to ensure that
# all memory in the C++ class is initialized correctly.
arbor.recipe.__init__(self)
self.ncells = n
self.params = arbor.cell_parameters()
# The num_cells method that returns the total number of cells in the model
# must be implemented.
def num_cells(self):
return self.ncells
# The cell_description method returns a cell.
def cell_description(self, gid):
return make_cable_cell(gid, self.params)
def num_targets(self, gid):
return 1
def num_sources(self, gid):
return 1
# The kind method returns the type of cell with gid.
# Note: this must agree with the type returned by cell_description.
def cell_kind(self, gid):
return arbor.cell_kind.cable
# Make a ring network
def connections_on(self, gid):
src = (gid-1)%self.ncells
w = 0.01
d = 10
return [arbor.connection(arbor.cell_member(src,0), 0, w, d)]
# Attach a generator to the first cell in the ring.
def event_generators(self, gid):
if gid==0:
sched = arbor.explicit_schedule([1])
return [arbor.event_generator(0, 0.1, sched)]
return []
def get_probes(self, id):
# Probe just the membrane voltage at a location on the soma.
return [arbor.cable_probe_membrane_voltage('(location 0 0)')]