diff --git a/CellData.py b/CellData.py index 1eb7661..d30420e 100644 --- a/CellData.py +++ b/CellData.py @@ -30,6 +30,8 @@ class CellData: def __init__(self, data_path): self.data_path = data_path + self.parser = dpf.get_parser(data_path) + self.base_traces = None # self.fi_traces = None self.fi_intensities = None @@ -38,7 +40,7 @@ class CellData: self.mean_isi_frequencies = None self.time_axes = None # self.metadata = None - self.parser = dpf.get_parser(data_path) + self.sampling_interval = self.parser.get_sampling_interval() self.recording_times = self.parser.get_recording_times() diff --git a/DataParserFactory.py b/DataParserFactory.py index 3ae7cea..b087e93 100644 --- a/DataParserFactory.py +++ b/DataParserFactory.py @@ -2,10 +2,12 @@ from os.path import isdir, exists from warnings import warn import pyrelacs.DataLoader as Dl +from models.AbstractModel import AbstractModel UNKNOWN = -1 DAT_FORMAT = 0 NIX_FORMAT = 1 +MODEL = 2 class AbstractParser: @@ -41,7 +43,7 @@ class DatParser(AbstractParser): self.sampling_interval = -1 def cell_get_metadata(self): - pass + raise NotImplementedError("NOT YET OVERRIDDEN FROM ABSTRACT CLASS") def get_sampling_interval(self): if self.sampling_interval == -1: @@ -206,6 +208,14 @@ class DatParser(AbstractParser): raise RuntimeError(self.fi_file + " file doesn't exist!") + +class ModelParser(AbstractParser): + + def __init__(self, model: AbstractModel): + self.model = model + + + # TODO #################################### class NixParser(AbstractParser): @@ -215,18 +225,23 @@ class NixParser(AbstractParser): # TODO #################################### -def get_parser(data_path: str) -> AbstractParser: +def get_parser(data_path) -> AbstractParser: data_format = __test_for_format__(data_path) if data_format == DAT_FORMAT: return DatParser(data_path) elif data_format == NIX_FORMAT: return NixParser(data_path) + elif MODEL: + return ModelParser(data_path) elif UNKNOWN: raise TypeError("DataParserFactory:get_parser(data_path):\nCannot determine type of data for:" + data_path) def __test_for_format__(data_path): + if isinstance(data_path, AbstractModel): + return MODEL + if isdir(data_path): if exists(data_path + "/fispikes1.dat"): return DAT_FORMAT diff --git a/models/AbstractModel.py b/models/AbstractModel.py new file mode 100644 index 0000000..77666d2 --- /dev/null +++ b/models/AbstractModel.py @@ -0,0 +1,9 @@ + + +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. + + def min_stimulus_strength_to_spike(self): + raise NotImplementedError("NOT IMPLEMENTED") diff --git a/models/LIFAC.py b/models/LIFAC.py index 61b1daf..4fa78d7 100644 --- a/models/LIFAC.py +++ b/models/LIFAC.py @@ -1,9 +1,10 @@ from stimuli.AbstractStimulus import AbstractStimulus +from models.AbstractModel import AbstractModel import numpy as np -class LIFACModel: +class LIFACModel(AbstractModel): # all times in milliseconds KEYS = ["mem_res", "mem_tau", "v_base", "v_zero", "threshold", "step_size", "delta_a", "tau_a"] VALUES = [100 * 1000000, 0.1 * 200, 0, 0, 10, 0.01, 1, 200]