90 lines
2.8 KiB
Python
90 lines
2.8 KiB
Python
|
|
from Baseline import get_baseline_class
|
|
from CellData import CellData, icelldata_of_dir
|
|
from models.LIFACnoise import LifacNoiseModel
|
|
from Baseline import BaselineCellData, BaselineModel
|
|
from os import listdir
|
|
import numpy as np
|
|
from IPython import embed
|
|
import pyrelacs.DataLoader as Dl
|
|
from ModelFit import ModelFit, get_best_fit
|
|
from FiCurve import FICurveModel, FICurveCellData
|
|
import os
|
|
import matplotlib.pyplot as plt
|
|
import functions as fu
|
|
from scipy.optimize import curve_fit
|
|
from scipy.signal import find_peaks
|
|
from thunderfish.eventdetection import threshold_crossing_times, threshold_crossings, detect_peaks
|
|
import helperFunctions as hF
|
|
import models.smallModels as sM
|
|
from stimuli.SinusoidalStepStimulus import SinusoidalStepStimulus
|
|
from matplotlib import gridspec
|
|
# from plottools.axes import labelaxes_params
|
|
|
|
|
|
|
|
cell = "data/final/2018-05-08-ab-invivo-1/"
|
|
cell_data = CellData(cell)
|
|
step = cell_data.get_sampling_interval()
|
|
v1 = cell_data.get_base_traces(cell_data.V1)[0]
|
|
time = cell_data.get_base_traces(cell_data.TIME)[0]
|
|
spiketimes = cell_data.get_base_spikes()[0]
|
|
start = 0
|
|
duration = 25
|
|
|
|
fig, ax = plt.subplots(1, 1)
|
|
ax.plot((np.array(time[:int(duration/step)]) - start) * 1000, v1[:int(duration/step)])
|
|
ax.eventplot([s * 1000 for s in spiketimes if start < s < start + duration],
|
|
lineoffsets=max(v1[:int(duration/step)])+1.25, color="black", linelengths=2)
|
|
|
|
plt.show()
|
|
plt.close()
|
|
quit()
|
|
|
|
# sp = self.spikes(index)
|
|
# binary = np.zeros(t.shape)
|
|
# spike_indices = ((sp - t[0]) / dt).astype(int)
|
|
# binary[spike_indices[(spike_indices >= 0) & (spike_indices < len(binary))]] = 1
|
|
# g = gaussian_kernel(kernel_width, dt)
|
|
# rate = np.convolve(binary, g, mode='same')
|
|
|
|
fit = get_best_fit("results/final_2/2012-12-21-am-invivo-1/")
|
|
model = fit.get_model()
|
|
cell_data = fit.get_cell_data()
|
|
eodf = cell_data.get_eod_frequency()
|
|
parameters = model.parameters
|
|
|
|
time_param_keys = ["refractory_period", "tau_a", "mem_tau", "dend_tau"]
|
|
contrasts = np.arange(-0.3, 0.3, 0.05)
|
|
baseline_normal = BaselineModel(model, eodf)
|
|
fi_curve_normal = FICurveModel(model, contrasts, eodf)
|
|
fi_curve_normal.plot_fi_curve()
|
|
normal_isis = baseline_normal.get_interspike_intervals() * eodf
|
|
normal_bins = np.arange(0, 0.05, 0.0001) * eodf
|
|
|
|
factor = 1.1
|
|
scaled_eodf = eodf * factor
|
|
scaled_model = model.get_model_copy()
|
|
|
|
for key in time_param_keys:
|
|
scaled_model.parameters[key] = parameters[key] / factor
|
|
|
|
baseline_scaled = BaselineModel(scaled_model, scaled_eodf)
|
|
fi_curve_scaled = FICurveModel(scaled_model, contrasts, scaled_eodf)
|
|
fi_curve_scaled.plot_fi_curve()
|
|
scaled_isis = np.array(baseline_scaled.get_interspike_intervals()) * scaled_eodf
|
|
scaled_bins = np.arange(0, 0.05, 0.0001) * scaled_eodf
|
|
|
|
# plt.hist(normal_isis, bins=normal_bins, alpha=0.5, label="normal")
|
|
# plt.hist(scaled_isis, bins=scaled_bins, alpha=0.5, label="scaled")
|
|
# plt.legend()
|
|
# plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|