示例#1
0
 def test_9_postrun_recording_NEURON_voltageclamp(self):
     os.chdir(rootwd)  # move up to load the model
     # pick the model
     sm.prepare_model_NEURON(parameters=self.sec_parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     vstimuli = sm.stimulate_model_NEURON(
         stimparameters=self.sec_stimparam,
         modelsite=self.chosenmodel.cell.soma)
     rec_t, recs, rec_v_stim = rm.prepare_recording_NEURON(
         self.chosenmodel,
         stimuli=vstimuli,
         stimtype=self.sec_stimparam["type"])
     sm.engage_NEURON()
     rec_v_stim = rm.postrun_record_NEURON(
         injectedstimuli=rec_v_stim, stimtype=self.sec_stimparam["type"])
     total_iterations = len(
         range(
             -1,
             int(self.sec_parameters["tstop"] / self.sec_parameters["dt"])))
     self.assertEqual(
         len(rec_t) + len(recs["soma"][0]) + len(rec_v_stim),
         3 * total_iterations)
     os.chdir(pwd)  # reset to the location of this managerRecordTest.py
示例#2
0
 def test_5_stimulus_overall_currents_NEURON(self):
     #os.chdir("..") # this moves you up to ~/managers
     #os.chdir("..") # you are now in parent /cerebmodels
     os.chdir(rootwd)
     parameters = {"dt": 0.1, "celsius": 20, "tstop": 10, "v_init": 65}
     currparameters = {
         "type": ["current", "IClamp"],
         "stimlist": [{
             'amp': 0.5,
             'dur': 10.0,
             'delay': 5.0
         }, {
             'amp': 1.0,
             'dur': 20.0,
             'delay': 5.0 + 10.0
         }],
         "tstop":
         parameters["tstop"]
     }
     sm.prepare_model_NEURON(parameters=parameters,
                             chosenmodel=self.chosenmodel)
     stimuli_list = sm.stimulate_model_NEURON(
         stimparameters=currparameters,
         modelsite=self.chosenmodel.cell.soma)
     rec_i_indivs = rc.stimulus_individual_currents_NEURON(stimuli_list)
     sm.engage_NEURON()
     rec_i = rc.stimulus_overall_current_NEURON(rec_i_indivs)
     # check the length of the rec_v = 0:dt:tstop
     self.assertEqual(
         len(rec_i),
         len(range(-1, int(parameters["tstop"] / parameters["dt"]))))
     os.chdir(pwd)  # reset to the location of this recorderTest.py
示例#3
0
 def test_6_stimulus_overall_voltage_NEURON(self):
     #os.chdir("..") # this moves you up to ~/managers
     #os.chdir("..") # you are now in parent /cerebmodels
     os.chdir(rootwd)
     parameters = {"dt": 0.1, "celsius": 20, "tstop": 10, "v_init": 65}
     voltparameters = {
         "type": ["voltage", "SEClamp"],
         "stimlist": [{
             'amp1': 0.0,
             'dur1': 5.0
         }, {
             'amp2': -70.0,
             'dur2': 10.0
         }],
         "tstop": parameters["tstop"]
     }
     sm.prepare_model_NEURON(parameters=parameters,
                             chosenmodel=self.chosenmodel)
     stimuli = sm.stimulate_model_NEURON(
         stimparameters=voltparameters,
         modelsite=self.chosenmodel.cell.soma)
     sm.engage_NEURON()
     rec_v = rc.stimulus_overall_voltage_NEURON(stimuli)
     # check the length of the rec_v = 0:dt:tstop
     self.assertEqual(
         len(rec_v),
         len(range(-1, int(parameters["tstop"] / parameters["dt"]))))
     os.chdir(pwd)  # reset to the location of this recorderTest.py
示例#4
0
 def test_10_stimulate_model_NEURON_current(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}
     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.prepare_model_NEURON(parameters=parameters, chosenmodel=chosenmodel)
     self.assertEqual(
         len(
             sm.stimulate_model_NEURON(stimparameters=currparameters,
                                       modelsite=chosenmodel.cell.soma)),
         len(currparameters["stimlist"]))
     os.chdir(pwd)  # return to the location of this test file
示例#5
0
 def test_11_stimulate_model_NEURON_voltage(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}
     voltparameters = {
         "type": ["voltage", "SEClamp"],
         "stimlist": [{
             'amp1': 0.,
             'dur1': 100.0
         }, {
             'amp2': 20.,
             'dur2': 150.0
         }]
     }
     sm.prepare_model_NEURON(parameters=parameters, chosenmodel=chosenmodel)
     stimuli = sm.stimulate_model_NEURON(stimparameters=voltparameters,
                                         modelsite=chosenmodel.cell.soma)
     self.assertEqual([stimuli.amp1, stimuli.amp2, stimuli.dur2], [
         voltparameters["stimlist"][0]["amp1"],
         voltparameters["stimlist"][1]["amp2"],
         voltparameters["stimlist"][1]["dur2"]
     ])
     os.chdir(pwd)  # return to the location of this test file
示例#6
0
 def test_6_prepare_recording_NEURON_voltageclamp(self):
     os.chdir(rootwd)  # move up to load the model
     # pick the model
     sm.prepare_model_NEURON(parameters=self.sec_parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     vstimuli = sm.stimulate_model_NEURON(
         stimparameters=self.sec_stimparam,
         modelsite=self.chosenmodel.cell.soma)
     rec_t, recs, rec_v_stim = rm.prepare_recording_NEURON(
         self.chosenmodel,
         stimuli=vstimuli,
         stimtype=self.sec_stimparam["type"])
     sm.engage_NEURON()
     total_iterations = len(
         range(
             -1,
             int(self.sec_parameters["tstop"] / self.sec_parameters["dt"])))
     self.assertEqual([
         len(rec_t) + len(recs["soma"][0]), rec_v_stim.amp1,
         rec_v_stim.dur1, rec_v_stim.amp2, rec_v_stim.dur2
     ], [
         2 * total_iterations, self.sec_stimparam["stimlist"][0]["amp1"],
         self.sec_stimparam["stimlist"][0]["dur1"],
         self.sec_stimparam["stimlist"][1]["amp2"],
         self.sec_stimparam["stimlist"][1]["dur2"]
     ])
     #self.assertEqual( len(rec_t) + len(rec_v["soma"]),#len(rec_v[self.regionslist_str[0]]),
     #                  2*total_iterations )
     os.chdir(pwd)  # reset to the location of this managerRecordTest.py
示例#7
0
 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
示例#8
0
 def test_8_stimulate_model_NEURON_parameter_None(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.stimulate_model_NEURON(),
                      "Model is not stimulated")
     os.chdir(pwd)  # return to the location of this test file
示例#9
0
 def test_7_postrun_recording_NEURON_without_stimulating(self):
     os.chdir(rootwd)  # move up to load the model
     # pick the model
     sm.prepare_model_NEURON(parameters=self.no_parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     stimuli_list = sm.stimulate_model_NEURON()
     rec_t, recs, rec_i_indivs = rm.prepare_recording_NEURON(
         self.chosenmodel, stimuli=stimuli_list)
     sm.engage_NEURON()
     rec_i = rm.postrun_record_NEURON(injectedstimuli=rec_i_indivs)
     self.assertEqual(rm.postrun_record_NEURON(), "Model is not stimulated")
     os.chdir(pwd)  # reset to the location of this managerRecordTest.py
示例#10
0
 def test_1_time_NEURON_without_engaging(self):
     #os.chdir("..") # this moves you up to ~/managers
     #os.chdir("..") # you are now in parent /cerebmodels
     os.chdir(rootwd)
     sm.prepare_model_NEURON(parameters=self.parameters,
                             chosenmodel=self.chosenmodel)
     rec_t = rc.time_NEURON()
     # the length of the rec_time != 0:dt:tstop since recording was not done
     self.assertNotEqual(
         len(rec_t),
         len(range(0, int(
             self.parameters["tstop"] / self.parameters["dt"]))) +
         1  # for the additional dt  step
     )
     os.chdir(pwd)  # reset to the location of this recorderTest.py
 def test_1_transform_signal_None(self):
     os.chdir("..")  # move up to load the model
     # pick the model
     parameters = {"dt": 0.1, "celsius": 30, "tstop": 10, "v_init": 65}
     sm.prepare_model_NEURON(parameters=parameters,
                             chosenmodel=self.chosenmodel)
     rec_t, rec_v, x = rm.prepare_recording_NEURON(self.chosenmodel)
     sm.engage_NEURON()
     total_iterations = len(
         range(-1, int(parameters["tstop"] / parameters["dt"])))
     self.assertRaises(ValueError,
                       sp.transform_signal,
                       chosenmodel=self.chosenmodel,
                       recordings=rec_v[self.regionslist_str[0]])
     os.chdir(pwd)  # reset to the location of this managerRecordTest.py
示例#12
0
 def test_1_recordings_of_cellular_regionbodies_NEURON(self):
     os.chdir(rootwd)  # move up to load the model
     # pick the model
     sm.prepare_model_NEURON(parameters=self.no_parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     recs = rm.recordings_of_cellular_regionbodies_NEURON(self.chosenmodel)
     sm.engage_NEURON()
     total_iterations = len(
         range(-1,
               int(self.no_parameters["tstop"] / self.no_parameters["dt"])))
     a = (Counter(list(recs["soma"][0])) != Counter(list(recs["axon"][0])))
     self.assertEqual([len(recs["soma"][0]), a], [total_iterations, True])
     os.chdir(pwd)  # reset to the location of this managerRecordTest.py
示例#13
0
 def test_3_voltage_to_spiketrain_without_stimulation(self):
     os.chdir("..") # this moves you up to ~/managers
     os.chdir("..") # you are now in parent /cerebmodels
     parameters = {"dt": 0.1, "celsius": 20, "tstop": 10, "v_init": 65}
     sm.prepare_model_NEURON(parameters=parameters, chosenmodel=self.chosenmodel)
     self.rec["time"], self.rec["response"], self.rec["stimulus"] = \
              rm.prepare_recording_NEURON(self.chosenmodel)
     sm.engage_NEURON()
     spikes = co.voltage_to_spiketrain(self.chosenmodel, self.rec)
     ans = \
     len( range(
          int(spikes[self.regionslist_str[0]].t_start.magnitude),
          int(spikes[self.regionslist_str[0]].t_stop.magnitude/parameters["dt"])
           ) ) + 1 # for the additional dt step
     self.assertEqual( ans, len(self.rec["time"]) )
     os.chdir(pwd) # reset to the location of this converterTest.py
示例#14
0
 def test_2_recordings_of_cellular_componenets_NEURON(self):
     os.chdir(rootwd)  # move up to load the model
     # pick the model
     sm.prepare_model_NEURON(parameters=self.no_parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     recs = rm.recordings_of_cellular_components_NEURON(self.chosenmodel)
     sm.engage_NEURON()
     a = (Counter(list(recs["channels"]["soma"]["hh"][0])) != Counter(
         list(recs["channels"]["soma"]["hh"][1])))
     b = (Counter(list(recs["channels"]["soma"]["pas"][0])) != Counter(
         list(recs["channels"]["axon"]["pas"][0])))
     self.assertEqual([a, b], [True, True])
     os.chdir(pwd)  # reset to the location of this managerRecordTest.py
示例#15
0
 def test_9_stimulate_model_NEURON_parameter_error(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}
     #currparameters = {"type": ["current", "IClamp"]} # default
     currparameters = {"type": "current"}  # alternative
     sm.prepare_model_NEURON(parameters=parameters, chosenmodel=chosenmodel)
     self.assertRaises(ValueError,
                       sm.stimulate_model_NEURON,
                       stimparameters=currparameters,
                       modelsite=chosenmodel.cell.soma)
     os.chdir(pwd)  # return to the location of this test file
示例#16
0
 def test_4_response_body_NEURON_tworesponses(self):
     #os.chdir("..") # this moves you up to ~/managers
     #os.chdir("..") # you are now in parent /cerebmodels
     os.chdir(rootwd)
     sm.prepare_model_NEURON(parameters=self.parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {'axon': ['v'], 'soma': ['v', 'i_cap'], 'channels': {'axon': {'pas': ['i']},
     # 'soma': {'hh': ['il', 'el'], 'pas': ['i']}}}
     rec_v = rc.response_body_NEURON(self.chosenmodel.cell.soma, "v")
     rec_i = rc.response_body_NEURON(self.chosenmodel.cell.soma, "i_cap")
     sm.engage_NEURON()
     # check the length of the rec_v = 0:dt:tstop
     a = all(boolean == True
             for boolean in np.array(rec_v) != np.array(rec_i))
     self.assertEqual(a, True)
     os.chdir(pwd)  # reset to the location of this recorderTest.py
示例#17
0
 def test_3_response_body_NEURON(self):
     #os.chdir("..") # this moves you up to ~/managers
     #os.chdir("..") # you are now in parent /cerebmodels
     os.chdir(rootwd)
     sm.prepare_model_NEURON(parameters=self.parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {'axon': ['v'], 'soma': ['v', 'i_cap'], 'channels': {'axon': {'pas': ['i']},
     # 'soma': {'hh': ['il', 'el'], 'pas': ['i']}}}
     rec_v = rc.response_body_NEURON(
         self.chosenmodel.cell.soma,
         self.chosenmodel.regions["soma"][0])  # "v"
     sm.engage_NEURON()
     # check the length of the rec_v = 0:dt:tstop
     self.assertEqual(
         len(rec_v),
         len(range(0, int(
             self.parameters["tstop"] / self.parameters["dt"]))) +
         1  # for the additional dt  step
     )
     os.chdir(pwd)  # reset to the location of this recorderTest.py
示例#18
0
 def test_4_voltage_to_spiketrain_with_stimulation(self):
     os.chdir("..") # this moves you up to ~/managers
     os.chdir("..") # you are now in parent /cerebmodels
     parameters = {"dt": 0.1, "celsius": 20, "tstop": 10, "v_init": 65}
     currparameters = {"type": ["current", "IClamp"],
                       "stimlist": [ {'amp': 0.5, 'dur': 10.0, 'delay': 5.0},
                                     {'amp': 1.0, 'dur': 20.0, 'delay': 5.0+10.0} ],
                       "tstop": parameters["tstop"] }
     sm.prepare_model_NEURON(parameters=parameters, chosenmodel=self.chosenmodel)
     stimuli_list = sm.stimulate_model_NEURON(stimparameters = currparameters,
                                            modelsite = self.chosenmodel.cell.soma)
     self.rec["time"], self.rec["response"], self.rec["stimulus"] = \
              rm.prepare_recording_NEURON(self.chosenmodel)
     sm.engage_NEURON()
     spikes = co.voltage_to_spiketrain(self.chosenmodel, self.rec)
     ans = \
     len( range(
          int(spikes[self.regionslist_str[0]].t_start.magnitude),
          int(spikes[self.regionslist_str[0]].t_stop.magnitude/parameters["dt"])
           ) ) + 1 # for the additional dt step
     self.assertEqual( ans, len(self.rec["time"]) )
     os.chdir(pwd) # reset to the location of this converterTest.py
示例#19
0
 def test_4_prepare_recording_NEURON_without_stimulating_but_evoke_stimulate_model(
         self):
     os.chdir(rootwd)  # move up to load the model
     # pick the modelstimtype = currparameters["type"]
     sm.prepare_model_NEURON(parameters=self.no_parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     stimulate_not = sm.stimulate_model_NEURON()
     rec_t, recs, x = rm.prepare_recording_NEURON(self.chosenmodel,
                                                  stimuli=stimulate_not)
     sm.engage_NEURON()
     a = (Counter(list(recs["soma"][0])) != Counter(
         list(recs["channels"]["soma"]["pas"][0])))
     b = (Counter(list(recs["axon"][0])) != Counter(
         list(recs["channels"]["axon"]["pas"][0])))
     total_iterations = len(
         range(-1,
               int(self.no_parameters["tstop"] / self.no_parameters["dt"])))
     self.assertEqual([len(rec_t), a, b], [total_iterations, True, True])
     os.chdir(pwd)  # reset to the location of this managerRecordTest.py
示例#20
0
 def test_5_prepare_recording_NEURON_currentclamp(self):
     os.chdir(rootwd)  # move up to load the model
     # pick the model
     sm.prepare_model_NEURON(parameters=self.ic_parameters,
                             chosenmodel=self.chosenmodel)
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     stimuli_list = sm.stimulate_model_NEURON(
         stimparameters=self.ic_stimparam,
         modelsite=self.chosenmodel.cell.soma)
     rec_t, recs, rec_i_indivs = rm.prepare_recording_NEURON(
         self.chosenmodel,
         stimuli=stimuli_list,
         stimtype=self.ic_stimparam["type"])
     sm.engage_NEURON()
     total_iterations = len(
         range(-1,
               int(self.ic_parameters["tstop"] / self.ic_parameters["dt"])))
     self.assertEqual(
         len(rec_t) + len(recs["soma"][0]) + len(rec_i_indivs),
         2 * total_iterations + len(self.ic_stimparam["stimlist"]))
     os.chdir(pwd)  # reset to the location of this managerRecordTest.py
示例#21
0
 def test_4_prepare_model_NEURON(self):
     os.chdir(rootwd)  # move up to load the model
     #from utilities import UsefulUtils as uu
     # 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}
     self.assertEqual(
         sm.prepare_model_NEURON(parameters=parameters,
                                 chosenmodel=chosenmodel),
         "NEURON model is ready")
     os.chdir(pwd)  # return to the location of this test file
 def test_2_transform_signal_to_spikes(self):
     os.chdir("..")  # move up to load the model
     # pick the model
     parameters = {"dt": 0.1, "celsius": 30, "tstop": 10, "v_init": 65}
     currparameters = {
         "type": ["current", "IClamp"],
         "stimlist": [{
             'amp': 0.5,
             'dur': 10.0,
             'delay': 5.0
         }, {
             'amp': 1.0,
             'dur': 20.0,
             'delay': 5.0 + 10.0
         }]
     }
     sm.prepare_model_NEURON(parameters=parameters,
                             chosenmodel=self.chosenmodel)
     stimuli_list = sm.stimulate_model_NEURON(
         stimparameters=currparameters,
         modelsite=self.chosenmodel.cell.soma)
     self.rec["time"], self.rec["response"], self.rec["stimulus"] = \
              rm.prepare_recording_NEURON(self.chosenmodel)
     sm.engage_NEURON()
     spikes = sp.transform_signal(chosenmodel=self.chosenmodel,
                                  recordings=self.rec,
                                  tosignal='spikes')
     ans = \
       len( range(
            int(spikes[self.regionslist_str[0]].t_start.magnitude),
            int(spikes[self.regionslist_str[0]].t_stop.magnitude/parameters["dt"])
           ) ) + 1 # for the additional dt step
     self.assertEqual(ans, len(self.rec["time"]))
     os.chdir(
         pwd
     )  # reset to the location of this managerSignalProcessingTest.py
示例#23
0
    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