Example #1
0
def test_nl(contrast, thresh):
    bipolar = ns.cell(.005)

    lp = bipolar.sim_central_pathway('gaussian', contrast, length=1000, mean=127)

    bipolar.nl_basal.thresh = thresh
    letters = bipolar.nl_basal.torate(lp)

    nl = ns.compute_nl(lp, letters, 100)
    #vesicles = bipolar.adaptation.adapt(letters)
    
    plt.close('nl')
    fig, ax = plt.subplots(num='nl')
    ax.plot(nl[0], nl[1])

    return nl
Example #2
0
def test_adaptation_2(delta_t):
    '''
    fake gaussian stimuli of different contrasts and pass them through the model
    '''
    #pdb.set_trace()

    mean = 127
    bipolar = ns.cell(delta_t)
    bipolar.adaptation.offset=.6
    bipolar.nl_basal.thresh=59

    # I want to simulate the central pathway for N trials each lasting the same as periphery_kernel
    trials = 1000
    length = trials * len(bipolar.periphery.kernel) * ns.sim_delta_t

    gaussian_psth = []
    nls = []
    for c in [3,6,12,24,100]:
        # simulate central pathway
        lp = bipolar.sim_central_pathway('gaussian', c, length=length, mean=mean)

        # redimension lp to be shape = (trials, len(peirphery.kernel))
        lp = lp.reshape(trials, -1)

        # add peipheral pathway 
        lp += bipolar.periphery.weight*bipolar.periphery.kernel

        # generate [Ca] from lp, using peripheral signal
        letters = bipolar.nl_basal.torate(lp)
        
        # generate vesicle release by adapting [Ca]
        vesicles = bipolar.adaptation.adapt(letters)

        # generate PSTH from vesicles
        psth_pnts = len(bipolar.periphery.kernel)
        gaussian_psth.append(vesicles.mean(axis=0))

        #nl.append(ns.compute_nl(lp.flatten(), vesicles.flatten(), 100))
        # Divide vesicles and lp into time bins according to time from saccade and compute nls
        nl_perTW =[]
        for i in range(10):
            startP = int(i*lp.shape[1]/10)
            endP = int((i+1)*lp.shape[1]/10)
            nl_perTW.append(ns.compute_nl(lp[:,startP:endP].flatten(), vesicles[:,startP:endP].flatten(),100))

        nls.append(nl_perTW)

    constant_psth = []
    trials = 10
    length = trials * len(bipolar.periphery.kernel) * ns.sim_delta_t
    for m in [32,64,128,256]:
        # simulate central pathway
        lp = bipolar.sim_central_pathway('gaussian', 0, length=length, mean=m)

        # redimension lp to be shape = (trials, len(peirphery.kernel))
        lp = lp.reshape(trials, -1)

        # add peipheral pathway 
        lp += bipolar.periphery.weight*bipolar.periphery.kernel

        # generate [Ca] from lp, using peripheral signal
        letters = bipolar.nl_basal.torate(lp)
        
        # generate vesicle release by adapting [Ca]
        vesicles = bipolar.adaptation.adapt(letters)

        # generate PSTH from vesicles
        psth_pnts = len(bipolar.periphery.kernel)
        constant_psth.append(vesicles.mean(axis=0))
        
    return gaussian_psth, nls, constant_psth