コード例 #1
0
def make_2models_figure(ax, MODEL1, MODEL2, I0=300e-12,\
                        color1='r', color2='b'):

    params = models.get_model_params(MODEL1, {})
    
    Inorm = np.array([1. if (tt>100e-3 and tt<500e-3) else 0 for tt in t])
    if params.has_key('Istep'):
        I0 = params['Istep']
    I = I0*Inorm

    if (MODEL1.split('-')[0]=='iAdExp') or (MODEL1.split('-')[0]=='iLIF'):
        v1, va1, spikes1 = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                              MODEL=MODEL1, full_I_traces=I, return_threshold=True)
        v2, va2, spikes2 = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                                  MODEL=MODEL2, full_I_traces=I, return_threshold=True)
    else:
        v1, spikes1 = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                                  MODEL=MODEL1, full_I_traces=I)
        v2, spikes2 = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                                  MODEL=MODEL2, full_I_traces=I)

    ax.get_xaxis().set_visible(False)
    ax.get_yaxis().set_visible(False)
    ax.plot(1e3*t, 1e3*v1, color=color1)
    ax.plot(1e3*t, -85+10*Inorm, 'k')
    ax.plot(1e3*t, 1e3*v2+30, color=color2)
    if (MODEL1.split('-')[0]=='iAdExp') or (MODEL1.split('-')[0]=='iLIF'):
        ax.plot(1e3*t, 1e3*va1, 'k:')
        ax.plot(1e3*t, 1e3*va2+30, 'k:')
    ax.plot([1e3*t[0], 1e3*t[0]], [1e3*v1[0], 1e3*v2[0]+30], 'k>', ms=10)
    ax.annotate('-70mV', (.1,.3), xycoords='axes fraction')


    # plt.tight_layout()
    ax.plot([10,10],[-25,-15], 'gray', lw=3)
    ax.plot([10,60],[-25,-25], 'gray', lw=3)
    ax.annotate('10mV', (16,-10), textcoords='data', size=13)
    ax.annotate(str(int(abs(1e12*I0)))+'pA', (16,-20), textcoords='data',size=13)
    ax.annotate('50ms', (17,-40), textcoords='data', size=13)
    ax.annotate('-70mV', (-10, -70), textcoords='data', size=13)
コード例 #2
0
def make_2models_figure(ax, MODEL1, MODEL2, I0=300e-12, color1="r", color2="b"):

    params = models.get_model_params(MODEL1, {})

    Inorm = np.array([1.0 if (tt > 100e-3 and tt < 500e-3) else 0 for tt in t])
    if params.has_key("Istep"):
        I0 = params["Istep"]
    I = I0 * Inorm

    if (MODEL1.split("-")[0] == "iAdExp") or (MODEL1.split("-")[0] == "iLIF"):
        v1, va1, spikes1 = single_experiment(
            t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL1, full_I_traces=I, return_threshold=True
        )
        v2, va2, spikes2 = single_experiment(
            t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL2, full_I_traces=I, return_threshold=True
        )
    else:
        v1, spikes1 = single_experiment(t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL1, full_I_traces=I)
        v2, spikes2 = single_experiment(t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL2, full_I_traces=I)

    ax.get_xaxis().set_visible(False)
    ax.get_yaxis().set_visible(False)
    ax.plot(1e3 * t, 1e3 * v1, color=color1)
    ax.plot(1e3 * t, -85 + 10 * Inorm, "k")
    ax.plot(1e3 * t, 1e3 * v2 + 30, color=color2)
    if (MODEL1.split("-")[0] == "iAdExp") or (MODEL1.split("-")[0] == "iLIF"):
        ax.plot(1e3 * t, 1e3 * va1, "k:")
        ax.plot(1e3 * t, 1e3 * va2 + 30, "k:")
    ax.plot([1e3 * t[0], 1e3 * t[0]], [1e3 * v1[0], 1e3 * v2[0] + 30], "k>", ms=10)
    ax.annotate("-70mV", (0.1, 0.3), xycoords="axes fraction")

    # plt.tight_layout()
    ax.plot([10, 10], [-25, -15], "gray", lw=3)
    ax.plot([10, 60], [-25, -25], "gray", lw=3)
    ax.annotate("10mV", (16, -10), textcoords="data", size=13)
    ax.annotate(str(int(abs(1e12 * I0))) + "pA", (16, -20), textcoords="data", size=13)
    ax.annotate("50ms", (17, -40), textcoords="data", size=13)
    ax.annotate("-70mV", (-10, -70), textcoords="data", size=13)
コード例 #3
0
def make_model_figure(MODEL, I0=100e-12,
                      savefig=False, for_title=None):

    params = models.get_model_params(MODEL, {})
    
    Inorm = np.array([1. if (tt>100e-3 and tt<500e-3) else 0 for tt in t])
    if params.has_key('Istep'):
        I0 = params['Istep']
    I = I0*Inorm
        
    fig = plt.figure(figsize=(6,4))
    ax = plt.subplot(111, frameon=False)
    ax.get_xaxis().set_visible(False)
    ax.get_yaxis().set_visible(False)
    
    plt.title(params['name']+'\n', fontsize=25)
    
    if MODEL.split('-')[0]=='aEIF':
        [v1, va1], spikes = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                                  MODEL=MODEL, full_I_traces=I)
        [v2, va2], spikes2 = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                                  MODEL=MODEL, full_I_traces=-I)
        plt.plot(1e3*t, 1e3*v1, 'k', label='soma')
        plt.plot(1e3*t, 1e3*va1, 'r', label='axon')
        plt.plot(1e3*t, -85+10*Inorm, 'k')
        plt.plot(1e3*t, 1e3*v2, 'k--')
        plt.plot(1e3*t, 1e3*va2, 'r--')
        plt.plot(1e3*t, -85-10*Inorm, 'k--')
        plt.legend(loc='upper right', frameon=False)
        
    elif MODEL.split('-')[0]=='iLIF' or MODEL.split('-')[0]=='iAdExp':
        v1, va1, spikes = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                     MODEL=MODEL, full_I_traces=I, return_threshold=True)
        v2, va2, spikes2 = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                     MODEL=MODEL, full_I_traces=-I, return_threshold=True)
        plt.plot(1e3*t, 1e3*v1, 'k', label=r'$V_\mathrm{m}$')
        plt.plot(1e3*t, 1e3*va1, 'r', label=r'$\theta$')
        plt.plot(1e3*t, -85+10*Inorm, 'k')
        plt.plot(1e3*t, 1e3*v2, 'k--')
        plt.plot(1e3*t, -85-10*Inorm, 'k--')
        plt.legend(loc='upper right', frameon=False)
    else:
        v1, spikes = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                                  MODEL=MODEL, full_I_traces=I)
        v2, spikes2 = single_experiment(t, 0., 0., 0., 0., 1e9, -70e-3, params,\
                                  MODEL=MODEL, full_I_traces=-I)
        plt.plot(1e3*t, 1e3*v1, 'k')
        plt.plot(1e3*t, -85+10*Inorm, 'k')
        plt.plot(1e3*t, 1e3*v2, 'k--')
        plt.plot(1e3*t, -85-10*Inorm, 'k--')

    if MODEL is not 'Wang-Buszaki':
        for s in spikes:
            plt.plot([1e3*s,1e3*s], [5e3*params['delta_v']+\
                                     1e3*params['vthresh'],20], 'k:')
        for s in spikes2:
            plt.plot([1e3*s,1e3*s], [5e3*params['delta_v']+\
                                     1e3*params['vthresh'],20], 'k:')

    plt.tight_layout()
    plt.plot([10,10],[-25,-15], 'gray', lw=3)
    plt.plot([10,60],[-25,-25], 'gray', lw=3)
    plt.annotate('10mV', (16,-10), textcoords='data', size=13)
    plt.annotate(str(int(1e12*I0))+'pA', (16,-20), textcoords='data',size=13)
    plt.annotate('50ms', (17,-40), textcoords='data', size=13)
    if savefig==True:
        fig.savefig('../figures/'+MODEL+'_step_response.svg',\
                    format='svg', transparent=True)
    return fig
コード例 #4
0
def make_model_figure(MODEL, I0=100e-12, savefig=False, for_title=None):

    params = models.get_model_params(MODEL, {})

    Inorm = np.array([1.0 if (tt > 100e-3 and tt < 500e-3) else 0 for tt in t])
    if params.has_key("Istep"):
        I0 = params["Istep"]
    I = I0 * Inorm

    fig = plt.figure(figsize=(6, 4))
    ax = plt.subplot(111, frameon=False)
    ax.get_xaxis().set_visible(False)
    ax.get_yaxis().set_visible(False)

    plt.title(params["name"] + "\n", fontsize=25)

    if MODEL.split("-")[0] == "aEIF":
        [v1, va1], spikes = single_experiment(t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL, full_I_traces=I)
        [v2, va2], spikes2 = single_experiment(
            t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL, full_I_traces=-I
        )
        plt.plot(1e3 * t, 1e3 * v1, "k", label="soma")
        plt.plot(1e3 * t, 1e3 * va1, "r", label="axon")
        plt.plot(1e3 * t, -85 + 10 * Inorm, "k")
        plt.plot(1e3 * t, 1e3 * v2, "k--")
        plt.plot(1e3 * t, 1e3 * va2, "r--")
        plt.plot(1e3 * t, -85 - 10 * Inorm, "k--")
        plt.legend(loc="upper right", frameon=False)

    elif MODEL.split("-")[0] == "iLIF" or MODEL.split("-")[0] == "iAdExp":
        v1, va1, spikes = single_experiment(
            t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL, full_I_traces=I, return_threshold=True
        )
        v2, va2, spikes2 = single_experiment(
            t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL, full_I_traces=-I, return_threshold=True
        )
        plt.plot(1e3 * t, 1e3 * v1, "k", label=r"$V_\mathrm{m}$")
        plt.plot(1e3 * t, 1e3 * va1, "r", label=r"$\theta$")
        plt.plot(1e3 * t, -85 + 10 * Inorm, "k")
        plt.plot(1e3 * t, 1e3 * v2, "k--")
        plt.plot(1e3 * t, -85 - 10 * Inorm, "k--")
        plt.legend(loc="upper right", frameon=False)
    else:
        v1, spikes = single_experiment(t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL, full_I_traces=I)
        v2, spikes2 = single_experiment(t, 0.0, 0.0, 0.0, 0.0, 1e9, -70e-3, params, MODEL=MODEL, full_I_traces=-I)
        plt.plot(1e3 * t, 1e3 * v1, "k")
        plt.plot(1e3 * t, -85 + 10 * Inorm, "k")
        plt.plot(1e3 * t, 1e3 * v2, "k--")
        plt.plot(1e3 * t, -85 - 10 * Inorm, "k--")

    if MODEL is not "Wang-Buszaki":
        for s in spikes:
            plt.plot([1e3 * s, 1e3 * s], [5e3 * params["delta_v"] + 1e3 * params["vthresh"], 20], "k:")
        for s in spikes2:
            plt.plot([1e3 * s, 1e3 * s], [5e3 * params["delta_v"] + 1e3 * params["vthresh"], 20], "k:")

    plt.tight_layout()
    plt.plot([10, 10], [-25, -15], "gray", lw=3)
    plt.plot([10, 60], [-25, -25], "gray", lw=3)
    plt.annotate("10mV", (16, -10), textcoords="data", size=13)
    plt.annotate(str(int(1e12 * I0)) + "pA", (16, -20), textcoords="data", size=13)
    plt.annotate("50ms", (17, -40), textcoords="data", size=13)
    if savefig == True:
        fig.savefig("../figures/" + MODEL + "_step_response.svg", format="svg", transparent=True)
    return fig
コード例 #5
0
def make_simulation_for_model(MODEL, args, return_output=False,\
                              sampling='low'):

    if sampling is 'low':
        # discretization and seed
        SEED = np.arange(2)+1
        dt, tstop = 1e-4, 2.
    else:
        SEED = np.arange(3)+1
        dt, tstop = 1e-5, 10.

                              
    params = models.get_model_params(MODEL, {}) # paramters of the model, see models.py
        
    ### PARAMETERS OF THE EXPERIMENT
    if len(args.RANGE_FOR_3D)>1:
        params['RANGE_FOR_3D'] = args.RANGE_FOR_3D
        
    muV_min, muV_max, sV_min1, sV_max1, sV_min2, sV_max2, Ts_ratio = params['RANGE_FOR_3D']
    muGn_min, muGn_max = 1.15, 8.

    ### cell and synaptic parameters, see models.py !!
    sim_params = {'dt':dt, 'tstop':tstop}
    t_long = np.arange(0,int(tstop/dt))*dt

    muV = np.linspace(muV_min, muV_max, args.DISCRET_muV, endpoint=True)

    # trying with the linear autocorrelation 
    args.DISCRET_muG = args.DISCRET_TvN
    Tv_ratio = np.linspace(1./muGn_max+Ts_ratio, 1./muGn_min+Ts_ratio, args.DISCRET_muG, endpoint=True)
    muGn = 1./(Tv_ratio-Ts_ratio)

    muV, sV, muGn = np.meshgrid(muV, np.zeros(args.DISCRET_sV), muGn)
    Tv_ratio = Ts_ratio+1./muGn

    for i in range(args.DISCRET_muV):
        sv1 = sV_min1+i*(sV_min2-sV_min1)/(args.DISCRET_muV-1)
        sv2 = sV_max1+i*(sV_max2-sV_max1)/(args.DISCRET_muV-1)
        for l in range(args.DISCRET_muG):
            sV[:,i,l] = np.linspace(sv1,sv2,args.DISCRET_sV,endpoint=True)

    I0, Gs, f, Q, Ts = params_variations_calc(muGn,muV,sV,Ts_ratio*np.ones(muGn.shape),params)

    Fout = np.zeros((args.DISCRET_sV, args.DISCRET_muV, args.DISCRET_muG, len(SEED)))

    # measuring the subthreshold fluctuations properties
    muV_exp, sV_exp, TvN_exp = 0*Fout, 0*Fout, 0*Fout

    for i_muV in range(args.DISCRET_muV):
        print '[[[[]]]]=====> muV : ', round(1e3*muV[0, i_muV, 0],1), 'mV'
        for i_sV in range(args.DISCRET_sV):
            print '[[[]]]====> sV : ', round(1e3*sV[i_sV, i_muV, 0],1), 'mV'
            for ig in range(args.DISCRET_muG):
                print '[]=> muGn : ', round(muGn[i_sV, i_muV, ig],1),\
                    'TvN : ', round(100*Tv_ratio[i_sV, i_muV, ig],1), '%'
                for i_s in range(len(SEED)):
                    v, spikes = single_experiment(\
                        t_long, I0[i_sV, i_muV, ig],\
                        Gs[i_sV, i_muV, ig],\
                        f[i_sV, i_muV, ig],\
                        Q[i_sV, i_muV, ig],\
                        Ts[i_sV, i_muV, ig],\
                        muV[i_sV, i_muV, ig],\
                        params, MODEL=MODEL,
                        seed=SEED[i_s]+i_muV+i_sV+ig)

                    Fout[i_sV, i_muV, ig, i_s] =\
                      len(spikes)/t_long.max()

                    muV_exp[i_sV, i_muV, ig, i_s],\
                      sV_exp[i_sV, i_muV, ig, i_s],\
                      TvN_exp[i_sV, i_muV, ig, i_s] = \
                        measuring_subthre_dynamics(v, spikes, dt,\
                                   Tm0=params['Cm']/params['Gl'])

    data_path = '../data/'+MODEL+'_'+args.SUFFIX_NAME+'.npz'


    D = dict(muV=1e3*muV.flatten(), sV=1e3*sV.flatten(),\
             TvN=Ts_ratio+1./muGn.flatten(),\
             muGn=muGn.flatten(),\
             Fout=Fout.mean(axis=-1).flatten(),\
             s_Fout=Fout.std(axis=-1).flatten(),\
             muV_exp=1e3*muV_exp.mean(axis=-1).flatten(),\
             sV_exp=1e3*sV_exp.mean(axis=-1).flatten(),\
             TvN_exp=TvN_exp.mean(axis=-1).flatten(),\
             s_muV_exp=1e3*muV_exp.std(axis=-1).flatten(),\
             s_sV_exp=1e3*sV_exp.std(axis=-1).flatten(),\
             s_TvN_exp=TvN_exp.std(axis=-1).flatten(),\
             MODEL=MODEL,\
             Gl=params['Gl'], Cm=params['Cm'], El=params['El'])

    np.savez(data_path,**D)    
コード例 #6
0
def make_simulation_for_model(MODEL, args, return_output=False,\
                              sampling='low'):

    if sampling is 'low':
        # discretization and seed
        SEED = np.arange(2) + 1
        dt, tstop = 1e-4, 2.
    else:
        SEED = np.arange(3) + 1
        dt, tstop = 1e-5, 10.

    params = models.get_model_params(
        MODEL, {})  # paramters of the model, see models.py

    ### PARAMETERS OF THE EXPERIMENT
    if len(args.RANGE_FOR_3D) > 1:
        params['RANGE_FOR_3D'] = args.RANGE_FOR_3D

    muV_min, muV_max, sV_min1, sV_max1, sV_min2, sV_max2, Ts_ratio = params[
        'RANGE_FOR_3D']
    muGn_min, muGn_max = 1.15, 8.

    ### cell and synaptic parameters, see models.py !!
    sim_params = {'dt': dt, 'tstop': tstop}
    t_long = np.arange(0, int(tstop / dt)) * dt

    muV = np.linspace(muV_min, muV_max, args.DISCRET_muV, endpoint=True)

    # trying with the linear autocorrelation
    args.DISCRET_muG = args.DISCRET_TvN
    Tv_ratio = np.linspace(1. / muGn_max + Ts_ratio,
                           1. / muGn_min + Ts_ratio,
                           args.DISCRET_muG,
                           endpoint=True)
    muGn = 1. / (Tv_ratio - Ts_ratio)

    muV, sV, muGn = np.meshgrid(muV, np.zeros(args.DISCRET_sV), muGn)
    Tv_ratio = Ts_ratio + 1. / muGn

    for i in range(args.DISCRET_muV):
        sv1 = sV_min1 + i * (sV_min2 - sV_min1) / (args.DISCRET_muV - 1)
        sv2 = sV_max1 + i * (sV_max2 - sV_max1) / (args.DISCRET_muV - 1)
        for l in range(args.DISCRET_muG):
            sV[:, i, l] = np.linspace(sv1, sv2, args.DISCRET_sV, endpoint=True)

    I0, Gs, f, Q, Ts = params_variations_calc(muGn, muV, sV,
                                              Ts_ratio * np.ones(muGn.shape),
                                              params)

    Fout = np.zeros(
        (args.DISCRET_sV, args.DISCRET_muV, args.DISCRET_muG, len(SEED)))

    # measuring the subthreshold fluctuations properties
    muV_exp, sV_exp, TvN_exp = 0 * Fout, 0 * Fout, 0 * Fout

    for i_muV in range(args.DISCRET_muV):
        print '[[[[]]]]=====> muV : ', round(1e3 * muV[0, i_muV, 0], 1), 'mV'
        for i_sV in range(args.DISCRET_sV):
            print '[[[]]]====> sV : ', round(1e3 * sV[i_sV, i_muV, 0], 1), 'mV'
            for ig in range(args.DISCRET_muG):
                print '[]=> muGn : ', round(muGn[i_sV, i_muV, ig],1),\
                    'TvN : ', round(100*Tv_ratio[i_sV, i_muV, ig],1), '%'
                for i_s in range(len(SEED)):
                    v, spikes = single_experiment(\
                        t_long, I0[i_sV, i_muV, ig],\
                        Gs[i_sV, i_muV, ig],\
                        f[i_sV, i_muV, ig],\
                        Q[i_sV, i_muV, ig],\
                        Ts[i_sV, i_muV, ig],\
                        muV[i_sV, i_muV, ig],\
                        params, MODEL=MODEL,
                        seed=SEED[i_s]+i_muV+i_sV+ig)

                    Fout[i_sV, i_muV, ig, i_s] =\
                      len(spikes)/t_long.max()

                    muV_exp[i_sV, i_muV, ig, i_s],\
                      sV_exp[i_sV, i_muV, ig, i_s],\
                      TvN_exp[i_sV, i_muV, ig, i_s] = \
                        measuring_subthre_dynamics(v, spikes, dt,\
                                   Tm0=params['Cm']/params['Gl'])

    data_path = '../data/' + MODEL + '_' + args.SUFFIX_NAME + '.npz'


    D = dict(muV=1e3*muV.flatten(), sV=1e3*sV.flatten(),\
             TvN=Ts_ratio+1./muGn.flatten(),\
             muGn=muGn.flatten(),\
             Fout=Fout.mean(axis=-1).flatten(),\
             s_Fout=Fout.std(axis=-1).flatten(),\
             muV_exp=1e3*muV_exp.mean(axis=-1).flatten(),\
             sV_exp=1e3*sV_exp.mean(axis=-1).flatten(),\
             TvN_exp=TvN_exp.mean(axis=-1).flatten(),\
             s_muV_exp=1e3*muV_exp.std(axis=-1).flatten(),\
             s_sV_exp=1e3*sV_exp.std(axis=-1).flatten(),\
             s_TvN_exp=TvN_exp.std(axis=-1).flatten(),\
             MODEL=MODEL,\
             Gl=params['Gl'], Cm=params['Cm'], El=params['El'])

    np.savez(data_path, **D)