Esempio n. 1
0
    def __init__(self, t_on, t_off, n_summary=6, seed=None):
        """See SummaryStats.py for docstring"""
        super(DAPSummaryStats, self).__init__(seed=seed)
        self.t_on = t_on
        self.t_off = t_off
        self.n_summary = n_summary

        data_dir = '/home/ateska/Desktop/LFI_DAP/data/rawData/2015_08_26b.dat'
        I, v, t, t_on, t_off, dt = load_current(data_dir,
                                                protocol='rampIV',
                                                ramp_amp=3.1)

        self.t = t
        self.v0 = v
from dap import DAPcython


# General Settings Pick
n_rounds = 1
n_summary = 17
n_samples = 5
n_hiddens = [15]
n_components = 1
dt = 0.01
reg_lambda = 0.01
n_params = 2

# Load the current
data_dir = '/home/alteska/Desktop/LFI_DAP/data/rawData/2015_08_26b.dat'    # best cell
I, v, t, t_on, t_off, dt = load_current(data_dir, protocol='IV', ramp_amp=1)

params, labels = obs_params(reduced_model=True)
print(params)
print(labels)

# Set up themodel
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}
# General Settings Pick
n_rounds = 1
n_summary = 17
n_samples = 1000
n_hiddens = [10]
n_components = 1
dt = 0.01
reg_lambda = 0.01
n_params = 2

# 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_step, v_step, t_step, t_on_step, t_off_step, dt_step = load_current(
    data_dir, protocol='IV', ramp_amp=1)

tstep = t_step[0:16200]
Istep = I_step[2500:18700]
vstep = v_step[2500:18700]

I_all = [I, Istep]
dt_all = [dt, dt_step]

params, labels = obs_params(reduced_model=True)
params = params[:n_params]
print(params)
print(labels)
Esempio n. 4
0
from dap.utils import load_current
from dap.analyze_APs import (get_spike_characteristics,
                             get_spike_characteristics_dict, check_measures)

data_dir = '/home/ateska/Desktop/LFI_DAP/data/rawData/2015_08_26b.dat'  # best cell
# data_dir = '/home/ateska/Desktop/LFI_DAP/data/rawData/2015_08_11d.dat'  # second best cell

# load the data
i_inj, v, t, t_on, t_off, dt = load_current(data_dir,
                                            protocol='rampIV',
                                            ramp_amp=3.1)

# extract AP/DAP characteristics
return_characteristics = [
    'AP_amp', 'AP_width', 'DAP_amp', 'DAP_width', 'DAP_deflection', 'DAP_time'
]
get_spike_characteristics_dict = get_spike_characteristics_dict(
    for_data=True)  # standard parameters to use
# AP_amp, AP_width, DAP_amp, DAP_width, DAP_deflection, DAP_time = get_spike_characteristics(v, t, return_characteristics,
# v_rest=v[0], std_idx_times=(0, 1),
# check=True, **get_spike_characteristics_dict)

characteristics = get_spike_characteristics(v,
                                            t,
                                            return_characteristics,
                                            v_rest=v[0],
                                            std_idx_times=(0, 1),
                                            check=True,
                                            **get_spike_characteristics_dict)

check_measures(v, t, characteristics)
Esempio n. 5
0
# load the file
directory = './parameters/'
dir = glob.glob(directory + '*')

fname_start = dir[0].find('dap_')
fname_stop = dir[0].find('n_')
fname = dir[0][fname_start:fname_stop]

df_param = pd.read_csv(fname + '.csv')
df_param.set_index('Unnamed: 0', inplace=True)

# calculate DAP
# load the input data
Ir, vr, tr, t_onr, t_offr, dtr = load_current(data_dir,
                                              protocol='rampIV',
                                              ramp_amp=3.1)
Is, vs, ts, t_ons, t_offs, dts = load_current(data_dir,
                                              protocol='IV',
                                              ramp_amp=1)

# get traces for both currents
U_steps, U_ramps = [], []

for i, j in tqdm(df_param.iterrows()):
    # get parameters
    par_temp = j.values

    # define a model
    dap = DAPcython(-75, j)
Esempio n. 6
0
reg_lambda = 0.01

# picking experiments observables
observables = {
    'loss.lprobs', 'imputation_values', 'h1.mW', 'h1.mb', 'h2.mW', 'h2.mb',
    'weights.mW', 'weights.mb', 'means.mW0', 'means.mW1', 'means.mb0',
    'means.mb1', 'precisions.mW0', 'precisions.mW1', 'precisions.mb0',
    'precisions.mb1'
}

# Load the current
data_dir = '/home/alteska/Desktop/LFI_DAP/data/rawData/2015_08_26b.dat'  # best cell
protocol = 'IV'  # 'IV' # 'rampIV' # 'Zap20'
ramp_amp = 1
I, v, t, t_on, t_off, dt = load_current(data_dir,
                                        protocol=protocol,
                                        ramp_amp=ramp_amp)
I_ramp, v_ramp, t_ramp, t_on_ramp, t_off_ramp, dt_ramp = load_current(
    data_dir, protocol='rampIV', ramp_amp=3.1)

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

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

# Setup Priors
prior_min, prior_max, labels = load_prior_ranges(n_params)
import timeit
import matplotlib.pyplot as plt
from dap import DAPcython
from dap.utils import load_current, obs_params_gbar

params, labels = obs_params_gbar()
data_dir = '/home/ateska/Desktop/LFI_DAP/data/rawData/2015_08_26b.dat'    # best cell
# data_dir = '/home/ateska/Desktop/LFI_DAP/data/rawData/2015_08_11d.dat'  # second best cell

# load the data
I, v, t, t_on, t_off, dt = load_current(data_dir, protocol='rampIV', ramp_amp=3.1)
I_iv, v_iv, t_iv, t_on_iv, t_off_iv, dt_iv = load_current(data_dir, protocol='IV', ramp_amp=1)



# define and run the model
dap = DAPcython(-75, params)
U = dap.simulate(dt, t, I)
U_iv = dap.simulate(dt_iv, t_iv, I_iv)

print("cython:", timeit.timeit(lambda: dap.simulate(dt, t, I), number=int(1)))
print("cython:", timeit.timeit(lambda: dap.simulate(dt_iv, t_iv, I_iv), number=int(1)))

print(dt, dt_iv)

fig, ax = plt.subplots(2, 1, figsize=(10,20))
ax[0].plot(t, I)
ax[0].plot(t, v)
ax[0].plot(t, U)
ax[1].plot(t_iv, I_iv)
ax[1].plot(t_iv, v_iv)