def test_7_trigger_NEURON_raw(self): os.chdir(rootwd) # move up to load the model # pick the model modelmodule = importlib.import_module("models.cells.modelDummyTest") pickedmodel = getattr(modelmodule, uu.classesinmodule(modelmodule)[0].__name__) chosenmodel = pickedmodel() # parameters = {"dt": 0.01, "celsius": 30, "tstop": 100, "v_init": 65} sm.prepare_model_NEURON(parameters=parameters, chosenmodel=chosenmodel) self.assertEqual(sm.trigger_NEURON(chosenmodel), "model was successfully triggered via NEURON") os.chdir(pwd) # return to the location of this test file
def launch_model(self, parameters=None, onmodel=None, stimparameters=None, stimloc=None, capabilities={ 'model': None, 'vtest': None }, mode="raw"): """Directs the :ref:`SimulationManager` to launch simulation on an instantiated model. **Keyword Arguments:** +-------------------------------+----------------------------------------------+ | Key | Value type | +===============================+==============================================+ | ``parameters`` | dictionary | +-------------------------------+----------------------------------------------+ | ``onmodel`` | instantiated model | +-------------------------------+----------------------------------------------+ | ``stimparameters`` (optional) | dictionary | +-------------------------------+----------------------------------------------+ | ``stimloc`` (optional) | string; attribute name of instantiated model | +-------------------------------+----------------------------------------------+ | ``capabilities`` (optional) | dictionary | +-------------------------------+----------------------------------------------+ | ``mode`` (optional) | string; | | |- "raw" (default), "capability" | +-------------------------------+----------------------------------------------+ * ``parameters``- *mandatory* whose value is a dictionary. For example, ``parameters = {"dt": 0.01, "celsius": 30, "tstop": 100, "v_init": 65}`` * ``onmodel``- *mandatory* whose value is the instantiated model using :py:meth:`.choose_model()`. For example, ``onmodel = <instance>.choose_model(modelscale="a_chosen_scale", modelname="a_chosen_name")``. * ``stimparameters``- optional whose value is a dictionary. For example, ``{"type": ["current", "IClamp"], "stimlist": [ {'amp': 0.5, 'dur': 100.0, 'delay': 10.0}, {'amp': 1.0, 'dur': 50.0, 'delay': 10.0+100.0} ] }``. * ``stimloc``- optional (mandatory only if ``stimparameters`` argument is provided). Its value is string representing the namse of an attribute of the instantiated model. Note that this instantiated model is the value for the mandatory keyword argument ``onmodel``. * ``capabilties``- optional whose value is a dictionary. The dictionary **must** have the keys ``model`` and ``vtest``. The value for ``model`` key is a string representing the models method. For example, ``model: "produce_voltage_response"``. The value for ``vtest`` key is a class imported from the installed ``CerebUnit``. *NOTE*: Calling this function returns the model as the attribute ``ExecutiveControl.chosenmodel``. """ # NOTE: although it is convenient to use self.chosenmodel # to the user having explicitly choose onmodel as an argument is clearer uu.check_not_None_in_arg({ 'parameters': parameters, 'onmodel': onmodel }) get_stimtype = (lambda stimpar: None if stimpar is None else stimpar["type"]) self.simtime = datetime.datetime.now() if onmodel.modelscale is "cells": get_stimloc = ( lambda stimloc: None if stimloc is None else getattr(onmodel.cell, stimloc)) sm.prepare_model_NEURON(parameters=parameters, chosenmodel=onmodel, modelcapability=capabilities['model'], cerebunitcapability=capabilities['vtest']) stimuli_clamp = sm.stimulate_model_NEURON( stimparameters=stimparameters, modelsite=get_stimloc(stimloc)) self.recordings["time"], self.recordings["response"], rec_clamp_indivs = \ rm.prepare_recording_NEURON( onmodel, stimuli = stimuli_clamp, stimtype = get_stimtype(stimparameters) ) if mode == "raw": sm.trigger_NEURON(onmodel) elif mode == "capability": sm.trigger_NEURON( onmodel, modelcapability=capabilities['model'], # Below are the **kwargs for lock_and_load_capability parameters=parameters, stimparameters=stimparameters, stimloc=stimloc, onmodel=onmodel, mode="capability") self.recordings["stimulus"] = \ rm.postrun_record_NEURON( injectedstimuli = rec_clamp_indivs, stimtype = get_stimtype(stimparameters) ) # save the parameters as attributes self.chosenmodel = onmodel self.parameters = parameters self.stimparameters = stimparameters return self.chosenmodel