From 7077c5b8e6dd244e777ad1288f57d6f555f79062 Mon Sep 17 00:00:00 2001 From: "a.ott" Date: Thu, 4 Jun 2020 17:12:15 +0200 Subject: [PATCH] add prototype to plot sam pdf comparisions cell-model --- sam_experiments.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/sam_experiments.py b/sam_experiments.py index fcad28c..fb1e244 100644 --- a/sam_experiments.py +++ b/sam_experiments.py @@ -4,6 +4,7 @@ from models.LIFACnoise import LifacNoiseModel import numpy as np import matplotlib.pyplot as plt import helperFunctions as hF +from CellData import CellData def main(): @@ -12,8 +13,23 @@ def main(): 'v_base': 0, 'step_size': 5e-05, 'dend_tau': 0.0008667253013050408, 'v_zero': 0, 'v_offset': -6.25, 'noise_strength': 0.03337309379328535, 'a_zero': 2, 'threshold': 1, 'delta_a': 0.0726267312975076} eod_freq = 658 - + cell_data = CellData("./data/2012-12-13-ao-invivo-1/") model = LifacNoiseModel(parameters) + mean_duration = np.mean(cell_data.get_sam_durations()) + contrasts = cell_data.get_sam_contrasts() + spiketimes = cell_data.get_sam_spiketimes() + for i, m_freq in enumerate(cell_data.get_sam_delta_frequencies()): + + stimulus = SAM(eod_freq, contrasts[i], m_freq) + prob_desnity_function_model = generate_pdf(model, stimulus, sim_length=mean_duration) + for spikes in spiketimes[i]: + prob_density_cell = spiketimes_calculate_pdf(spikes, cell_data.get_sampling_interval()) + + plt.plot(prob_density_cell) + plt.plot(prob_desnity_function_model) + plt.show() + plt.close() + # __init__(carrier_frequency, contrast, modulation_frequency, start_time=0, duration=np.inf, amplitude=1) mod_freqs = np.arange(-60, eod_freq*4 + 61, 10) @@ -58,6 +74,19 @@ def generate_pdf(model, stimulus, trials=4, sim_length=3, kernel_width=0.005): return mean_rate +def spiketimes_calculate_pdf(spikes, step_size, kernel_width=0.005): + length = int(spikes[-1] / step_size)+1 + binary = np.zeros(length) + spikes = [int(s / step_size) for s in spikes] + for s_idx in spikes: + binary[s_idx] = 1 + + kernel = gaussian_kernel(kernel_width, step_size) + rate = np.convolve(binary, kernel, mode='same') + + return rate + + def gaussian_kernel(sigma, dt): x = np.arange(-4. * sigma, 4. * sigma, dt) y = np.exp(-0.5 * (x / sigma) ** 2) / np.sqrt(2. * np.pi) / sigma