Skip to content

Instantly share code, notes, and snippets.

@rythorpe
Last active September 11, 2020 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rythorpe/e7bac070bff41f108996b98c8b58ac14 to your computer and use it in GitHub Desktop.
Save rythorpe/e7bac070bff41f108996b98c8b58ac14 to your computer and use it in GitHub Desktop.
Demo lack of variability in hnn-core simulation trials https://github.com/jonescompneurolab/hnn-core/issues/136
import os.path as op
import matplotlib.pyplot as plt
import hnn_core
from hnn_core import simulate_dipole, read_params, Params, Network, MPIBackend, JoblibBackend
from hnn_core.viz import plot_dipole
param_dict = {"sim_prefix": "med_nerve_2020_04_27_2prox_2dist_opt1_smooth", "tstop": 170, "N_pyr_x": 10, "N_pyr_y": 10, "L2Basket_Gauss_A_weight": 0.0, "L2Basket_Gauss_mu": 2000.0, "L2Basket_Gauss_sigma": 3.6, "L2Basket_Pois_A_weight_ampa": 0.0, "L2Basket_Pois_A_weight_nmda": 0.0, "L2Basket_Pois_lamtha": 0.0, "L2Pyr_Gauss_A_weight": 0.0, "L2Pyr_Gauss_mu": 2000.0, "L2Pyr_Gauss_sigma": 3.6, "L2Pyr_Pois_A_weight_ampa": 0.0, "L2Pyr_Pois_A_weight_nmda": 0.0, "L2Pyr_Pois_lamtha": 0.0, "L5Pyr_Gauss_A_weight": 0.0, "L5Pyr_Gauss_mu": 2000.0, "L5Pyr_Gauss_sigma": 4.8, "L5Pyr_Pois_A_weight_ampa": 0.0, "L5Pyr_Pois_A_weight_nmda": 0.0, "L5Pyr_Pois_lamtha": 0.0, "L5Basket_Gauss_A_weight": 0.0, "L5Basket_Gauss_mu": 2000.0, "L5Basket_Gauss_sigma": 2.0, "L5Basket_Pois_A_weight_ampa": 0.0, "L5Basket_Pois_A_weight_nmda": 0.0, "L5Basket_Pois_lamtha": 0.0, "gbar_L2Pyr_L2Pyr_ampa": 0.0002, "gbar_L2Pyr_L2Pyr_nmda": 0.0002, "gbar_L2Basket_L2Pyr_gabaa": 0.05, "gbar_L2Basket_L2Pyr_gabab": 0.05, "gbar_L2Pyr_L2Basket": 0.0005, "gbar_L2Basket_L2Basket": 0.02, "gbar_L5Pyr_L5Pyr_ampa": 0.001, "gbar_L5Pyr_L5Pyr_nmda": 0.0005, "gbar_L2Pyr_L5Pyr": 0.0002, "gbar_L2Basket_L5Pyr": 0.002, "gbar_L5Basket_L5Pyr_gabaa": 0.02, "gbar_L5Basket_L5Pyr_gabab": 0.06, "gbar_L5Basket_L5Basket": 0.02, "gbar_L5Pyr_L5Basket": 0.0005, "gbar_L2Pyr_L5Basket": 0.00025, "distribution_prox": "normal", "t0_input_prox": 50.0, "tstop_input_prox": 710.0, "f_input_prox": 10.0, "f_stdev_prox": 20.0, "events_per_cycle_prox": 2, "repeats_prox": 10, "t0_input_stdev_prox": 0.0, "distribution_dist": "normal", "t0_input_dist": 50.0, "tstop_input_dist": 710.0, "f_input_dist": 10.0, "f_stdev_dist": 20.0, "events_per_cycle_dist": 2, "repeats_dist": 10, "t0_input_stdev_dist": 0.0, "input_prox_A_weight_L2Pyr_ampa": 0.0, "input_prox_A_weight_L2Pyr_nmda": 0.0, "input_prox_A_weight_L5Pyr_ampa": 0.0, "input_prox_A_weight_L5Pyr_nmda": 0.0, "input_prox_A_weight_L2Basket_ampa": 0.0, "input_prox_A_weight_L2Basket_nmda": 0.0, "input_prox_A_weight_L5Basket_ampa": 0.0, "input_prox_A_weight_L5Basket_nmda": 0.0, "input_prox_A_delay_L2": 0.1, "input_prox_A_delay_L5": 1.0, "input_dist_A_weight_L2Pyr_ampa": 0.0, "input_dist_A_weight_L2Pyr_nmda": 0.0, "input_dist_A_weight_L5Pyr_ampa": 0.0, "input_dist_A_weight_L5Pyr_nmda": 0.0, "input_dist_A_weight_L2Basket_ampa": 0.0, "input_dist_A_weight_L2Basket_nmda": 0.0, "input_dist_A_delay_L2": 5.0, "input_dist_A_delay_L5": 5.0, "dt_evprox0_evdist": -1, "dt_evprox0_evprox1": -1, "sync_evinput": 1, "inc_evinput": 0.0, "save_spec_data": 0, "f_max_spec": 40.0, "dipole_scalefctr": 40, "dipole_smooth_win": 20, "save_figs": 0, "save_dpl": 0, "N_trials": 100, "prng_seedcore_input_prox": 4, "prng_seedcore_input_dist": 4, "prng_seedcore_extpois": 4, "prng_seedcore_extgauss": 4, "t0_pois": 0.0, "T_pois": -1, "dt": 0.025, "celsius": 37.0, "threshold": 0.0, "L2Pyr_soma_L": 22.1, "L2Pyr_soma_diam": 23.4, "L2Pyr_soma_cm": 0.6195, "L2Pyr_soma_Ra": 200.0, "L2Pyr_dend_cm": 0.6195, "L2Pyr_dend_Ra": 200.0, "L2Pyr_apicaltrunk_L": 59.5, "L2Pyr_apicaltrunk_diam": 4.25, "L2Pyr_apical1_L": 306.0, "L2Pyr_apical1_diam": 4.08, "L2Pyr_apicaltuft_L": 238.0, "L2Pyr_apicaltuft_diam": 3.4, "L2Pyr_apicaloblique_L": 340.0, "L2Pyr_apicaloblique_diam": 3.91, "L2Pyr_basal1_L": 85.0, "L2Pyr_basal1_diam": 4.25, "L2Pyr_basal2_L": 255.0, "L2Pyr_basal2_diam": 2.72, "L2Pyr_basal3_L": 255.0, "L2Pyr_basal3_diam": 2.72, "L2Pyr_ampa_e": 0.0, "L2Pyr_ampa_tau1": 0.5, "L2Pyr_ampa_tau2": 5.0, "L2Pyr_nmda_e": 0.0, "L2Pyr_nmda_tau1": 1.0, "L2Pyr_nmda_tau2": 20.0, "L2Pyr_gabaa_e": -80.0, "L2Pyr_gabaa_tau1": 0.5, "L2Pyr_gabaa_tau2": 5.0, "L2Pyr_gabab_e": -80.0, "L2Pyr_gabab_tau1": 1.0, "L2Pyr_gabab_tau2": 20.0, "L2Pyr_soma_gkbar_hh2": 0.01, "L2Pyr_soma_gnabar_hh2": 0.18, "L2Pyr_soma_el_hh2": -65.0, "L2Pyr_soma_gl_hh2": 4.26e-05, "L2Pyr_soma_gbar_km": 250.0, "L2Pyr_dend_gkbar_hh2": 0.01, "L2Pyr_dend_gnabar_hh2": 0.15, "L2Pyr_dend_el_hh2": -65.0, "L2Pyr_dend_gl_hh2": 4.26e-05, "L2Pyr_dend_gbar_km": 250.0, "L5Pyr_soma_L": 39.0, "L5Pyr_soma_diam": 28.9, "L5Pyr_soma_cm": 0.85, "L5Pyr_soma_Ra": 200.0, "L5Pyr_dend_cm": 0.85, "L5Pyr_dend_Ra": 200.0, "L5Pyr_apicaltrunk_L": 102.0, "L5Pyr_apicaltrunk_diam": 10.2, "L5Pyr_apical1_L": 680.0, "L5Pyr_apical1_diam": 7.48, "L5Pyr_apical2_L": 680.0, "L5Pyr_apical2_diam": 4.93, "L5Pyr_apicaltuft_L": 425.0, "L5Pyr_apicaltuft_diam": 3.4, "L5Pyr_apicaloblique_L": 255.0, "L5Pyr_apicaloblique_diam": 5.1, "L5Pyr_basal1_L": 85.0, "L5Pyr_basal1_diam": 6.8, "L5Pyr_basal2_L": 255.0, "L5Pyr_basal2_diam": 8.5, "L5Pyr_basal3_L": 255.0, "L5Pyr_basal3_diam": 8.5, "L5Pyr_ampa_e": 0.0, "L5Pyr_ampa_tau1": 0.5, "L5Pyr_ampa_tau2": 5.0, "L5Pyr_nmda_e": 0.0, "L5Pyr_nmda_tau1": 1.0, "L5Pyr_nmda_tau2": 20.0, "L5Pyr_gabaa_e": -80.0, "L5Pyr_gabaa_tau1": 0.5, "L5Pyr_gabaa_tau2": 5.0, "L5Pyr_gabab_e": -80.0, "L5Pyr_gabab_tau1": 1.0, "L5Pyr_gabab_tau2": 20.0, "L5Pyr_soma_gkbar_hh2": 0.01, "L5Pyr_soma_gnabar_hh2": 0.16, "L5Pyr_soma_el_hh2": -65.0, "L5Pyr_soma_gl_hh2": 4.26e-05, "L5Pyr_soma_gbar_ca": 60.0, "L5Pyr_soma_taur_cad": 20.0, "L5Pyr_soma_gbar_kca": 0.0002, "L5Pyr_soma_gbar_km": 200.0, "L5Pyr_soma_gbar_cat": 0.0002, "L5Pyr_soma_gbar_ar": 1e-06, "L5Pyr_dend_gkbar_hh2": 0.01, "L5Pyr_dend_gnabar_hh2": 0.14, "L5Pyr_dend_el_hh2": -71.0, "L5Pyr_dend_gl_hh2": 4.26e-05, "L5Pyr_dend_gbar_ca": 60.0, "L5Pyr_dend_taur_cad": 20.0, "L5Pyr_dend_gbar_kca": 0.0002, "L5Pyr_dend_gbar_km": 200.0, "L5Pyr_dend_gbar_cat": 0.0002, "L5Pyr_dend_gbar_ar": 1e-06, "gbar_evprox_1_L2Pyr_ampa": 0.003903, "gbar_evprox_1_L2Pyr_nmda": 0.000505, "gbar_evprox_1_L5Pyr_ampa": 0.001963, "gbar_evprox_1_L5Pyr_nmda": 0.001869, "gbar_evprox_1_L2Basket_ampa": 0.003617, "gbar_evprox_1_L2Basket_nmda": 0.002893, "gbar_evprox_1_L5Basket_ampa": 0.003037, "gbar_evprox_1_L5Basket_nmda": 0.00278, "t_evprox_1": 20.808669, "sigma_t_evprox_1": 4.121563, "prng_seedcore_evprox_1": 4, "numspikes_evprox_1": 1, "gbar_evprox_2_L2Pyr_ampa": 0.008833, "gbar_evprox_2_L2Pyr_nmda": 0.00926, "gbar_evprox_2_L5Pyr_ampa": 0.00238, "gbar_evprox_2_L5Pyr_nmda": 0.003047, "gbar_evprox_2_L2Basket_ampa": 0.003989, "gbar_evprox_2_L2Basket_nmda": 0.008614, "gbar_evprox_2_L5Basket_ampa": 0.006875, "gbar_evprox_2_L5Basket_nmda": 0.002055, "t_evprox_2": 134.383155, "sigma_t_evprox_2": 4.5, "prng_seedcore_evprox_2": 4, "numspikes_evprox_2": 1, "gbar_evdist_1_L2Pyr_ampa": 0.003248, "gbar_evdist_1_L2Pyr_nmda": 0.005126, "gbar_evdist_1_L5Pyr_ampa": 0.000932, "gbar_evdist_1_L5Pyr_nmda": 0.000983, "gbar_evdist_1_L2Basket_ampa": 0.004265, "gbar_evdist_1_L2Basket_nmda": 0.002884, "t_evdist_1": 31.592845, "sigma_t_evdist_1": 2.714237, "prng_seedcore_evdist_1": 4, "numspikes_evdist_1": 1, "gbar_evdist_2_L2Pyr_ampa": 0.001884, "gbar_evdist_2_L2Pyr_nmda": 0.00177, "gbar_evdist_2_L5Pyr_ampa": 0.001802, "gbar_evdist_2_L5Pyr_nmda": 0.001749, "gbar_evdist_2_L2Basket_ampa": 0.004065, "gbar_evdist_2_L2Basket_nmda": 0.003188, "t_evdist_2": 83.962981, "sigma_t_evdist_2": 4.356796, "prng_seedcore_evdist_2": 0, "numspikes_evdist_2": 1}
hnn_core_root = op.dirname(hnn_core.__file__)
params_fname = op.join(hnn_core_root, 'param', 'default.json')
#params = read_params(params_fname)
params = Params(param_dict)
net = Network(params)
with MPIBackend(n_procs=5, mpi_cmd='mpiexec'):
#with JoblibBackend(n_jobs=5):
dpls = simulate_dipole(net, n_trials=10)
fig, axes = plt.subplots(2, 1, sharex=True, figsize=(6, 6))
plot_dipole(dpls, ax=axes[0], layer='agg', show=False)
net.spikes.plot_hist(ax=axes[1], spike_types=['evprox', 'evdist'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment