SimulationManager

class managers.simulation.SimulationManager

Available Methods:

Method name Method type
prepare_model_NEURON() static method
stimulate_model_NEURON() static method
trigger_NEURON() class method
lock_and_load_capability() static method
engage_NEURON() static method
static engage_NEURON()

Starts the NEURON based model WITHOUT implementing capability.

Argument: No argument is passed.

Returned values: Nothing is returned.

static lock_and_load_capability(chosenmodel, modelcapability, **kwargs)

Loads model capability hence running the simulation. This is because a modelcapability is a method attribute of the model.

Arguments:

Argument Value type
first argument instantiated model
second argument string for modelcapability; eg "produces_spike_train"
**kwargs Optional Variable Keyword arguments.

Returned value: Nothing is returned

Use case:

>> modelmodule = importlib.import_module("models.cells.modelPC2015Masoli")

>> pickedmodel = getattr(modelmodule, uu.classesinmodule(modelmodule)[0].__name__)

>> chosenmodel = pickedmodel()

>> sm = SimulationManager()

>> sm.lock_and_load_capability(chosenmodel, modelcapability="produce_spike_train")

static lock_and_load_model_libraries(modelscale=None, modelname=None)

Directs SimInspector to load nmodl libraries if it already exists or else creates them and then loads them.

Keyword Arguments:

Key Value type
modelscale string; eg: "cells"
modelname string; eg: "GrC2001DAngelo"

Returned value: A string message “Model libraries area loaded” letting the user know.

Raised Exceptions: ValueError is there are no model_scale

static prepare_model_NEURON(parameters=None, chosenmodel=None, modelcapability=None, cerebunitcapability=None)

Directs SimInspector to check for compiled nmodl files (library) and optionally for capability, followd by directing the HardwareConfigurator. Then, the SimAssembler is directed to set the run time parameters.

Keyword Arguments:

Key Value type
chosenmodel instantiated NEURON based model
parameters
dictionary with keys: "dt", "celsius",
"tstop", "v_init"
modelcapability (optional) string; eg "produces_spike_train"
cerebunitcapability (optional) imported class, for eg., ProducesSpikeTrain

Returned value: Nothing is returned

NOTE: * although not manadatory it is recommended to use the keyword arguments * also modelcapability and cerebunitcapability is recommended especially if you want to use CerebUnit

Use case:

>> modelmodule = importlib.import_module("models.cells.modelPC2015Masoli")

>> pickedmodel = getattr(modelmodule, uu.classesinmodule(modelmodule)[0].__name__)

>> chosenmodel = pickedmodel()

>> parameters = {"dt": 0.01, "celsius": 30, "tstop": 100, "v_init": 65}

>> sm = SimulationManager()

>> sm.prepare_model_NEURON(parameters=parameters, chosenmodel=chosenmodel)

static stimulate_model_NEURON(stimparameters=None, modelsite=None)

Stimulates the prepared model but before locking & loading the capability lock_and_load_capability() or before engaging the simulator engage_NEURON(). If arguments are passed, i.e, the model is to be stimulated then the Stimulator is directed to stimulate the model with the given parameters.

Keyword Arguments (optional): If not stimulation is required then do not pass any arguments.

Key Value type
stimparameters
  • dictionary with keys "type" and "stimlist"
  • value for ``”type”``is a two element list of strings
  • <stimulus category> <specific type of that category>
  • the first element is ALWAYS <stimulus category>
  • Eg1: for current inject on a cell`` [“current”, “IClamp”]``
  • value for `` “stimlist”`` is a list with elements as

dictionary; like [ {}, {}, … ] - [ {“amp”: 0.5, “dur”: 100.0, “delay”: 10.0}, {“amp”: 1.0, “dur”: 50.0, “delay”: 10.0+100.0} ] - Eg2: for current inject `` [“current”, “IRamp”]`` - [ {“amp_initial”: 0.0, “amp_final”: 0.5, “dur”: 5.0, “delay”: 5.0}, {“amp_initial”: 0.5, “amp_final”: 1.0, “dur”: 5.0, “delay”: 10.0}, {“amp_initial”: 1.0, “amp_final”: 0.5, “dur”: 5.0, “delay”: 15.0}, {“amp_initial”: 0.5, “amp_final”: 0.0, “dur”: 5.0, “delay”: 20.0} ] - Eg3: injecting voltage in a cell ["voltage","SEClamp"] - value for `` “stimlist”`` is a list with elements as dictionary; like [ {}, {}, … ] - [ {“amp1”: 0., “dur1”: 50.}, {“amp2”: 10., “dur2”: 100.}, {“amp3”: 0., “dur3”: 150.} ] - NOTE: unlike current clamps, voltage clamps only support

three levels of voltage change, and since voltage clamp begins
at time 0, off at time dur1+dur2+dur3 if you don’t want to

start simulation with it just set “amp1” 0.0

modelsite section of the instantiated NEURON based model where you would want to stimulate. For eg. chosenmodel.cell.soma

Returned value:

  • if stimparameters are given the returned value is a list of stimuli where each element is a hoc object. For current inject it is h.IClamp, h.IRamp, etc … depending on currenttype, i.e, <specific type of that category>.
  • if no argument is given it returns a string "Model is not stimulated".

NOTE:

  • even if the stimulation does not involve stimulation it is recommended to evoke this function (without the arguments off course).

Use case:

>> modelmodule = importlib.import_module("models.cells.modelPC2015Masoli")

>> pickedmodel = getattr(modelmodule, uu.classesinmodule(modelmodule)[0].__name__)

>> chosenmodel = pickedmodel()

>> runparameters = {"dt": 0.01, "celsius": 30, "tstop": 100, "v_init": 65}

>> currparameters = {"type": ["current", "IClamp"], "stimlist": [ {"amp": 0.5, "dur": 100.0, "delay": 10.0}, {"amp": 1.0, "dur": 50.0, "delay": 10.0+100.0} ]}

>> sm = SimulationManager()

>> sm.prepare_model_NEURON(runparameters, chosenmodel)

>> sm.stimulate_model_NEURON(stimparameters = currparamters, modelsite=chosenmodel.cell.soma)

classmethod trigger_NEURON(chosenmodel, modelcapability=None, **kwargs)

Starts the simulation by calling either lock_and_load_capability() or engage_NEURON().

Arguments:

Arguments Value type
first argument instantiated model
modelcapability key string for eg "produces_spike_train"
**kwargs Optional Variable Keyword arguments.

Returned values: Prints the duration of the simulation run and returns a string saying “model was successfully triggered via NEURON”.