
from Baseline import get_baseline_class
from CellData import CellData
from models.LIFACnoise import LifacNoiseModel
from Baseline import BaselineCellData, BaselineModel
from os import listdir
from IPython import embed
import pyrelacs.DataLoader as Dl
from ModelFit import ModelFit



fit = ModelFit("results/invivo_results/start_parameter_7_err_6.87/")

print(fit.comparable_error())
fit.generate_master_plot()



quit()



def icelldata_of_dir(base_path):
    global COUNT
    for item in sorted(listdir(base_path)):
        item_path = base_path + item

        try:
            data = CellData(item_path)

            yield data

        except TypeError as e:
            print(str(e))

        except IndexError as e:
            print(str(e), "\n")

        except ValueError as e:
            print(str(e), "\n")

    print("Currently throw errors: {}".format(COUNT))


for data in icelldata_of_dir("invivo_data/"):
    v1 = data.get_base_traces(data.V1)

    if len(v1) == 0:
        embed()
        quit()


quit()

parameter_bursty_model = {'step_size': 5e-05, 'mem_tau': 0.0066693150193490695, 'v_base': 0, 'v_zero': 0,
                          'threshold': 1, 'v_offset': -45.703125, 'input_scaling': 172.13861987237314,
                          'delta_a': 0.06148215166012024, 'tau_a': 0.03391674075000068, 'a_zero': 2,
                          'noise_strength': 0.0684136549210377, 'dend_tau': 0.0013694103932013805,
                          'refractory_period': 0.001}
eod = 752
model = LifacNoiseModel(parameter_bursty_model)
baseline_model = get_baseline_class(model, 752, trials=2)
baseline_model.get_burstiness()

quit()


for cell_data in icelldata_of_dir("data/"):
    baseline = get_baseline_class(cell_data)

    baseline.get_burstiness()