Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
0
 def load_model(self):
     """method called by __init__
     """
     modelmodule = importlib.import_module("models." + self.modelscale +
                                           ".model" + self.modelname)
     pickedmodel = getattr(modelmodule,
                           uu.classesinmodule(modelmodule)[0].__name__)
     self.chosenmodel = pickedmodel()
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
0
 def test_5_lock_and_load_capability(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()
     #
     self.assertEqual(
         sm.lock_and_load_capability(chosenmodel,
                                     modelcapability="produce_spike_train"),
         "DummyTest model just finished run for produce_spike_train")
     os.chdir(pwd)  # return to the location of this test file
Ejemplo n.º 7
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
Ejemplo n.º 8
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
Ejemplo n.º 9
0
    def choose_model(modelscale=None, modelname=None):
        """Returns instantiated model for a desired model name available in the specified model scale.

        **Keyword Arguments:**

        +----------------+-------------+
        | Key            | Value type  |
        +================+=============+
        | ``modelscale`` | string      |
        +----------------+-------------+
        | ``modelname``  | string      |
        +----------------+-------------+

        *NOTE*: Currently only ``modelscale="cells"`` are supported. Future releases will include other model scales.
        """
        sm.lock_and_load_model_libraries(modelscale=modelscale,
                                         modelname=modelname)
        modelmodule = importlib.import_module("models." + modelscale +
                                              ".model" + modelname)
        chosenmodel = getattr(modelmodule,
                              uu.classesinmodule(modelmodule)[0].__name__)
        return chosenmodel()