Esempio n. 1
0
def test_compute_kernel():

    kernel_pnts = 100
    new_kernel = np.zeros(kernel_pnts)
    new_kernel[0] = 1
    f_block = ns.filter_block(1, new_kernel, 1)

    trials = 1000
    contrast = 10
    mean = 127
    length = trials * kernel_pnts * ns.sim_delta_t
    ker_length = kernel_pnts * ns.sim_delta_t
    stim = ns.fake_noise('gaussian', contrast, length=length, mean=mean)
    
    # simulate linear response
    lp = f_block.temporal_filter(stim)
    stim = stim[kernel_pnts-1:]         # now stim and lp_center are aligned

    # Recompute kernel from the stim and the lp
    new_kernel = ns.compute_kernel(stim, lp, kernel_pnts,10)
    
    plt.close('kernel_test')
    fix, ax = plt.subplots(num='kernel_test')
    ax.plot(f_block.kernel)
    ax.plot(new_kernel)

    return new_kernel, f_block.kernel, stim
Esempio n. 2
0
def test_temporal_filter():
    # make a kernel that is a delta function at t=0
    new_kernel = np.zeros(100)
    new_kernel[0] = 1
    kernel = ns.filter_block(1, new_kernel, 1)

    # make stim
    stim = ns.fake_noise('gaussian', 10)

    lp = kernel.temporal_filter(stim)

    # First len(new_kernel)-1 points of stim were not properly filtered and are not included in lp
    np.testing.assert_almost_equal(lp, stim[len(new_kernel)-1:])