Пример #1
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')
Пример #2
0
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}
y = stats.calc([y_o])
Пример #3
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()