started the creation of a model interface and a dataparser for models
This commit is contained in:
parent
c7bcefedbe
commit
2b4380835e
@ -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()
|
||||
|
@ -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
|
||||
|
9
models/AbstractModel.py
Normal file
9
models/AbstractModel.py
Normal file
@ -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")
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user