Exemplo n.º 1
0
from tqdm import tqdm

from delfi.distribution import Uniform
from dap.utils import obs_params_gbar, syn_current
from dap.dap_sumstats_moments import DAPSummaryStatsMoments
from dap import DAPcython
from dap.dap_simulator import DAPSimulator

# General Settings Pick
n_samples = 100
n_summary = 13
dt = 0.01
percent_accept = 1

# Get current
I, t, t_on, t_off = syn_current(duration=70, dt=dt, t_on=15, t_off=20, amp=3.1)
params, labels = obs_params_gbar(reduced_model=True)
dap = DAPcython(-75, params * 10)

# Set up the model
sim = DAPSimulator(I, dt, -75, dim_param=2)
stats = DAPSummaryStatsMoments(t_on, t_off, n_summary=n_summary)

# Setup Priors
prior_min = np.array([0, 0])
prior_max = np.array([2, 2])
prior_unif = Uniform(lower=prior_min, upper=prior_max)

# generate desired data
U = dap.simulate(dt, t, I)
y_o = {'data': U.reshape(-1), 'time': t, 'dt': dt, 'I': I}
Exemplo n.º 2
0
import matplotlib.pyplot as plt
from dap.dap_simulator import DAPSimulator
from dap.utils import obs_params_gbar, syn_current

params, labels = obs_params_gbar()
I, t, t_on, t_off = syn_current(duration=150, dt=0.01)

# define model
dap1 = DAPSimulator(I, 0.01, -75)

# run model
stats = dap1.gen_single(params)

# plot voltage trace
fig, ax = plt.subplots(ncols=1, nrows=2, figsize=(20, 10))
ax[0].grid()
ax[0].set_ylabel('V (mV)')
ax[0].set_xlabel('t (ms)')
ax[0].plot(stats['time'], stats['data'], label='DAP')
ax[0].legend()
ax[1].plot(t, I)

plt.show()
Exemplo n.º 3
0
import matplotlib.pyplot as plt
from dap import DAP, DAPBe
from dap import DAPcython
from dap.utils import obs_params, obs_params_gbar, syn_current


dt = 1e-2
params, labels = obs_params(reduced_model=True)
params, labels = obs_params_gbar(reduced_model=False)
I, t, t_on, t_off = syn_current(duration=120, dt=dt)

print(params)

# define models / check setters
dap = DAP(-75, params)
dap_back = DAPBe(-75, params)
dap_cython = DAPcython(-75, params, solver=1)
dap_cython_back = DAPcython(-75, params, solver=2)

# run models
U = dap.simulate(dt, t, I)
U_cython = dap_cython.simulate(dt, t, I)
U_back = dap_back.simulate(dt, t, I)
U_cython_back = dap_cython_back.simulate(dt, t, I)


# plot
fig, ax = plt.subplots(5, 1, figsize=(20, 10));
ax[0].plot(t, U, label='forward')
ax[1].plot(t, U_cython)
ax[2].plot(t, U_back, label='backward')
Exemplo n.º 4
0
n_params = 4
n_summary = 17
n_samples = 10
n_hiddens = [30]
n_components = 1
dt = 0.01
reg_lambda = 0.01

# Load the current
# data_dir = '/home/alteska/Desktop/LFI_DAP/data/rawData/2015_08_26b.dat'    # best cell
# protocol = 'rampIV' # 'IV' # 'rampIV' # 'Zap20'
# ramp_amp = 3.1
# I, v, t, t_on, t_off, dt = load_current(data_dir, protocol=protocol, ramp_amp=ramp_amp)
I, t, t_on, t_off = syn_current(duration=50,
                                dt=0.01,
                                t_on=15,
                                t_off=20,
                                amp=3.1)

# Set up themodel
params, labels = obs_params(reduced_model=True)
dap = DAPcython(-75, params)
U = dap.simulate(dt, t, I)

# generate data format for SNPE / OBSERVABLE
x_o = {'data': U.reshape(-1), 'time': t, 'dt': dt, 'I': I}

# Setup Priors
prior_min, prior_max, labels = load_prior_ranges(n_params)
prior_unif = Uniform(lower=prior_min, upper=prior_max)