Beispiel #1
0
        "/Users/Dani/TDK/parameter_estim/stim_protocol2/zap/best_comb/%i/stim.txt"
        % item)
    working_path = "/Users/Dani/TDK/parameter_estim/stim_protocol2/zap/best_comb/%i" % item

    # Do statistics for each parameter
    stat_list = []
    for _ in p_names:
        stat_list.append(np.empty((n, 6), dtype=np.float))

    # Load fixed parameters: list of parameters to be inferred
    fixed_params = []
    for name in p_names:
        fixed_params.append(get_default_param(name))

    # Generate deterministic trace and create synthetic data with noise model
    t, v = model(stype='custom', custom_stim=stim)
    data = white(noise, v)

    pset = ParameterSet(*fixed_params)

    modell = partial(model, stype='custom', custom_stim=stim)
    inf = IndependentInference(model=modell,
                               noise_std=noise,
                               target_trace=data,
                               parameter_set=pset,
                               working_path=working_path,
                               speed=speed)

    if __name__ == '__main__':
        inf.run_sim()
Beispiel #2
0
                          range_min=gpas_start,
                          range_max=gpas_end,
                          resolution=40,
                          mean=current_gpas,
                          sigma=pgpas.sigma)
    cm = RandomVariable(name='cm',
                        range_min=cm_start,
                        range_max=cm_end,
                        resolution=40,
                        mean=current_cm,
                        sigma=pcm.sigma)

    Ra_cm_gpas = ParameterSet(Ra, cm, gpas)
    inference = IndependentInference(
        data,
        Ra_cm_gpas,
        working_path="/Users/Dani/TDK/parameter_estim/stim_protocol2/ramp",
        speed='min')

    multi_comp = partial(
        stick_and_ball, stype='custom',
        custom_stim=stim)  # fix chosen stimulus type for simulations

    if __name__ == '__main__':
        inference.run_sim(multi_comp, noise_sigma)

    inference.run_evaluation()

    # Do statistics for the current inference
    Ra_stat[i, 0], Ra_stat[i, 1], Ra_stat[i, 2], Ra_stat[
        i, 3], Ra_stat[4], Ra_stat[5] = stat(Ra)
Beispiel #3
0
        # Stimulus path
        stim = np.loadtxt("/Users/Dani/TDK/parameter_estim/stim_protocol2/zap/%i/stim.txt" % item)
        working_path = "/Users/Dani/TDK/parameter_estim/stim_protocol2/zaps/%i(%i)" % (item,i)

        # Generate deterministic trace and create synthetic data with noise model
        _, v = model(stype='custom', custom_stim=stim,
                     Ra=current_value['Ra'], gpas=current_value['gpas'], cm=current_value['cm'])

        # Generate noise_rep synthetic data (noise_rep portion noise realisation)
        data = more_w_trace(noise, v, noise_rep)

        pset = ParameterSet(*current_params)

        modell = partial(model, stype='custom', custom_stim=stim)
        inf = IndependentInference(model=modell, noise_std=noise, target_trace=data, parameter_set=pset, working_path=working_path)

        if __name__ == '__main__':
            inf.run_moretrace_inf()

    for item in duration:
        print("\n\n---------------------------------------- Running %i ms impulse protocol" % item)

        # Stimulus path
        stim = np.loadtxt("/Users/Dani/TDK/parameter_estim/stim_protocol2/steps/%i/stim.txt" % item)
        working_path = "/Users/Dani/TDK/parameter_estim/stim_protocol2/steps/%i(%i)" % (item, i)

        # Generate deterministic trace and create synthetic data with noise model
        _, v = model(stype='custom', custom_stim=stim,
                     Ra=current_value['Ra'], gpas=current_value['gpas'], cm=current_value['cm'])
Beispiel #4
0
noise_sigma = 7.
stim = np.loadtxt("/Users/Dani/TDK/parameter_estim/stim_protocol2/ramp/stim.txt")

Ra = RandomVariable(name='Ra', range_min=40., range_max=150., resolution=160, mean=100., sigma=20)
gpas = RandomVariable(name='gpas', range_min=0.00005, range_max=0.00015, resolution=160, mean=0.0001, sigma=0.00002)
cm = RandomVariable(name='cm', range_min=0.5, range_max=1.7, resolution=160, mean=1., sigma=0.2)

# Generate deterministic trace and create synthetic data with noise model
# t, v = stick_and_ball(stype='custom', custom_stim=stim)
# data = white(noise_sigma, v)
# np.savetxt("/Users/Dani/TDK/parameter_estim/stim_protocol2/ramp/single/data(9).txt", data)

data = np.loadtxt("/Users/Dani/TDK/parameter_estim/stim_protocol2/ramp/single/data(9).txt")

multi_comp = partial(stick_and_ball, stype='custom', custom_stim=stim)  # fix chosen stimulus type for simulations

Ra_cm_gpas = ParameterSet(Ra, cm, gpas)
inference = IndependentInference(model=multi_comp, noise_std=noise_sigma, target_trace=data, parameter_set=Ra_cm_gpas,
                                 working_path="/Users/Dani/TDK/parameter_estim/stim_protocol2/ramp/single", speed="min")

if __name__ == '__main__':
    inference.run_sim()

# inference.save_result()
inference.run_evaluation()

print(inference)
fullplot(inference)
plot_joint(inference, Ra, gpas)
plot_joint(inference, Ra, cm)
plot_joint(inference, cm, gpas)
Beispiel #5
0
                      value=0.0001)
# Ra = RandomVariable(name='Ra', range_min=50., range_max=150., resolution=60, mean=100., sigma=20.)

# 2.) Set up parameter set
cm_gpas = ParameterSet(cm, gpas)

# 3.) Sythetic data
t, v = stick_and_ball()
exp_v = white(noise, v)

# 4.) Set up inference
inf = IndependentInference(
    model=stick_and_ball,
    noise_std=noise,
    target_trace=exp_v,
    parameter_set=cm_gpas,
    working_path=
    "/home/terbed/PROJECTS/SPE/parameter-inference/module/examples/output",
    speed='max',
    save=False)

# 5.) Run inference
if __name__ == "__main__":
    inf.run_sim()

# 6.) Run evaluation
inf.run_evaluation()

print("KL divergence test: %f" % inf.KL)

# 7.) Plot solution
Beispiel #6
0
        for idx, item in enumerate(p_names):
            current_params.append(
                RandomVariable(item,
                               range_min=current_minrange[idx],
                               range_max=current_maxrange[idx],
                               resolution=res[idx],
                               mean=current_mean[item],
                               sigma=fixed_params[idx].sigma))

        # Generate deterministic trace and create synthetic data with noise model
        t, v = model(stype='custom', custom_stim=stim, **current_mean)
        data = white(noise, v)

        pset = ParameterSet(*current_params)
        inf = IndependentInference(data,
                                   pset,
                                   working_path=working_path,
                                   speed=speed)

        modell = partial(model, stype='custom', custom_stim=stim)
        if __name__ == '__main__':
            inf.run_sim(modell, noise)

        inf.run_evaluation()

        m = 0
        if inf.analyse_result() is None:
            print("\nCouldn't fit gauss to data!")
            for i, item in enumerate(stat_list):
                stat_list[i] = np.delete(stat_list, (i - m), axis=0)
            m += 1
        else:
Beispiel #7
0
    cm = RandomVariable(name='cm',
                        range_min=cm_start,
                        range_max=cm_end,
                        resolution=100,
                        mean=current_cm,
                        sigma=cm_sig)
    gpas = RandomVariable(name='gpas',
                          range_min=gpas_start,
                          range_max=gpas_end,
                          resolution=100,
                          mean=current_gpas,
                          sigma=gpas_sig)

    cm_gpas = ParameterSet(cm, gpas)
    inference = IndependentInference(
        data,
        cm_gpas,
        working_path="/Users/Dani/TDK/parameter_estim/stim_protocol/ow/steps")
    one_comp = partial(
        one_compartment,
        stype='steps')  # fix chosen stimulus type for simulations

    if __name__ == '__main__':
        inference.run_sim(one_comp, noise_sigma)

    inference.run_evaluation()

    # Do statistics for the current inference
    if stat(cm) is not str:
        cm_stat[i,
                0], cm_stat[i,
                            1], cm_stat[i,