def produce_restingVm(self, **kwargs):
     """
     kwargs = { "parameters": dictionary with keys,
                "stimparameters": dictionary with keys "type" and "stimlist",
                "onmodel": instantiated model }
     """
     print("Sim produce_restingVm starting ...")
     ec = ExecutiveControl() # only works when in ~/cerebmodels
     model = ec.launch_model( parameters = kwargs["parameters"],
                              stimparameters = kwargs["stimparameters"],
                              stimloc = kwargs["stimloc"], onmodel = kwargs["onmodel"],
                              capabilities = {"model": "produce_voltage_response",
                                              "vtest": ProducesElectricalResponse},
                              mode="capability")
     #self.fullfilename # already saved by invoking produce_voltage_response above
     #print("Signal Processing ...")
     nwbfile = rm.load_nwbfile(model.fullfilename)
     orderedepochs = rm.order_all_epochs_for_region(nwbfile=nwbfile, region="soma")
     timestamps_over_epochs = [ rm.timestamps_for_epoch( orderedepochs[i] )
                                for i in range(len(orderedepochs)) ]
     data_over_epochs = [ rm.data_for_epoch( orderedepochs[i] )
                                for i in range(len(orderedepochs)) ]
     baseVms = spm.distill_Vm_pre_epoch( timestamps = timestamps_over_epochs,
                                         datavalues = data_over_epochs )
     #print("Signal Processing Done.")
     setattr(model, "prediction", baseVms)
     print("Simulation produce_restingVm Done.")
     return model
Beispiel #2
0
 def produce_inputR(self, roi, **kwargs):
     """
     roi, region of interest is a string, i.e, 1 key in chosenmodel.regions
     kwargs = { "parameters": dictionary with keys,
                "stimparameters": dictionary with keys "type" and "stimlist",
                "onmodel": instantiated model }
     """
     print("Sim produce_" + roi + "_inputR starting ...")
     ec = ExecutiveControl()  # only works when in ~/cerebmodels
     model = ec.launch_model(parameters=kwargs["parameters"],
                             stimparameters=kwargs["stimparameters"],
                             stimloc=kwargs["stimloc"],
                             onmodel=kwargs["onmodel"],
                             capabilities={
                                 "model": "produce_voltage_response",
                                 "vtest": ProducesElectricalResponse
                             },
                             mode="capability")
     nwbfile = rm.load_nwbfile(model.fullfilename)
     orderedepochs = rm.order_all_epochs_for_region(nwbfile=nwbfile,
                                                    region=roi)
     timestamps_over_epochs = [
         rm.timestamps_for_epoch(orderedepochs[i])
         for i in range(len(orderedepochs))
     ]
     data_over_epochs = [
         rm.data_for_epoch(orderedepochs[i])
         for i in range(len(orderedepochs))
     ]
     baseVms = spm.distill_baseVm_pre_epoch(
         timestamps=timestamps_over_epochs, datavalues=data_over_epochs)
     setattr(model, "prediction",
             self._compute_inputR(baseVms, kwargs["stimparameters"]))
     print("Simulation produce_" + roi + "_inputR Done.")
     return model
Beispiel #3
0
 def produce_soma_spikeheight(self, **kwargs):
     """
     kwargs = { "parameters": dictionary with keys,
                "stimparameters": dictionary with keys "type" and "stimlist",
                "onmodel": instantiated model }
     """
     print("Sim produce_soma_spikeheight starting ...")
     ec = ExecutiveControl()  # only works when in ~/cerebmodels
     model = ec.launch_model(parameters=kwargs["parameters"],
                             stimparameters=kwargs["stimparameters"],
                             stimloc=kwargs["stimloc"],
                             onmodel=kwargs["onmodel"],
                             capabilities={
                                 "model": "produce_voltage_response",
                                 "vtest": ProducesElectricalResponse
                             },
                             mode="capability")
     nwbfile = rm.load_nwbfile(model.fullfilename)
     orderedepochs = rm.order_all_epochs_for_region(nwbfile=nwbfile,
                                                    region="soma v")
     timestamps_over_epochs = [
         rm.timestamps_for_epoch(orderedepochs[i])
         for i in range(len(orderedepochs))
     ]
     data_over_epochs = [
         rm.data_for_epoch(orderedepochs[i])
         for i in range(len(orderedepochs))
     ]
     baseVm = spm.distill_baseVm_pre_epoch(
         timestamps=timestamps_over_epochs, datavalues=data_over_epochs)
     try:
         peakVms = spm.distill_peakVm_from_spikes(
             timestamps=timestamps_over_epochs, datavalues=data_over_epochs)
     except:
         peakVms = baseVm
     setattr(model, "prediction", peakVms[0] - baseVm[0])
     print("Simulation produce_soma_spikeheight Done.")
     return model
 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