93 lines
3.0 KiB
Python
93 lines
3.0 KiB
Python
|
|
from stimuli.AbstractStimulus import AbstractStimulus
|
|
|
|
|
|
class AbstractModel:
|
|
|
|
# TODO what information about the model does the ModelParser need to be able to simulate the right kind of data
|
|
# for further analysis in cell_data/fi_curve etc.
|
|
|
|
# TODO change key + values list to a dict
|
|
KEYS = []
|
|
VALUES = []
|
|
|
|
def __init__(self, params: dict = None):
|
|
self.parameters = {}
|
|
if params is None:
|
|
self._set_default_parameters()
|
|
else:
|
|
self._test_given_parameters(params)
|
|
self.set_parameters(params)
|
|
|
|
def simulates_voltage_trace(self) -> bool:
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def simulates_frequency(self) -> bool:
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def simulates_spiketimes(self) -> bool:
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def simulate(self, stimulus: AbstractStimulus, total_time_s):
|
|
"""
|
|
Simulate the given stimulus in the model
|
|
and simulate up to the given total time
|
|
and saves the simulated data in the model.
|
|
|
|
:param stimulus: given stimulus
|
|
:param total_time_s: time to simulate
|
|
:return: depending on availability: [voltage, spiketimes, frequency]
|
|
"""
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def get_voltage_trace(self):
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def get_spiketimes(self):
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def get_frequency(self):
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def min_stimulus_strength_to_spike(self):
|
|
"""
|
|
return the minimal stimulus strength needed for the model to spike
|
|
:return: min stimulus strength to spike
|
|
"""
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def get_sampling_interval(self):
|
|
"""
|
|
return the "sampling" interval of the model: the time step the model simulates by
|
|
:return: the sampling interval
|
|
"""
|
|
raise NotImplementedError("NOT IMPLEMENTED")
|
|
|
|
def set_parameters(self, params):
|
|
self._test_given_parameters(params)
|
|
|
|
for k in params.keys():
|
|
self.parameters[k] = params[k]
|
|
|
|
for i in range(len(self.KEYS)):
|
|
if self.KEYS[i] not in self.parameters.keys():
|
|
self.parameters[self.KEYS[i]] = self.VALUES[i]
|
|
|
|
def get_parameters(self):
|
|
return self.parameters
|
|
|
|
def set_variable(self, key, value):
|
|
if key not in self.KEYS:
|
|
raise ValueError("Given key is unknown!\n"
|
|
"Please check spelling and refer to list LIFAC.KEYS.")
|
|
self.parameters[key] = value
|
|
|
|
def _set_default_parameters(self):
|
|
for i in range(len(self.KEYS)):
|
|
self.parameters[self.KEYS[i]] = self.VALUES[i]
|
|
|
|
def _test_given_parameters(self, params):
|
|
for k in params.keys():
|
|
if k not in self.KEYS:
|
|
err_msg = "Unknown key in the given parameters:" + str(k)
|
|
raise ValueError(err_msg) |