# Plotting
############

if save_figures:

    symmetric = 0
    colorbar = False
    closest_square_to_kernel = int(np.sqrt(kernel_size))**2

    directory = './figures/'
    formating = '.pdf'
    title = 'real_regresion_h1'
    save_filename = directory + title + formating

    plot_mutliplot_bilinear(closest_square_to_kernel,
                            h1,
                            colorbar=colorbar,
                            symmetric=symmetric)
    figure = plt.gcf()  # get current figure

    if remove_axis:
        # Remove axis
        for i in xrange(closest_square_to_kernel):
            figure.get_axes()[i].get_xaxis().set_visible(False)
            figure.get_axes()[i].get_yaxis().set_visible(False)

    figure.set_size_inches(16, 12)
    plt.savefig(save_filename, dpi=100)
    os.system("pdfcrop %s %s" % (save_filename, save_filename))

    plt.show()
示例#2
0
n1 = 7.0
n2 = 8.0
t1 = -6.0
t2 = -6.0
td = 6.0

p1 = K1 * ((c1*(t - t1))**n1 * np.exp(-c1*(t - t1))) / ((n1**n1) * np.exp(-n1))
p2 = K2 * ((c2*(t - t2))**n2 * np.exp(-c2*(t - t2))) / ((n2**n2) * np.exp(-n2))
p3 = p1 - p2


plt.plot(t, p3, label='temporal kernel')
plt.xlabel('time (ms)')
plt.legend()
plt.show()


## Now create the spatio-temporal filter 

# Initialize and fill the spatio-temporal kernel  
kernel = np.zeros((kernel_size, int(lx/dx), int(ly/dy)))

for k, p in enumerate(p3):
    kernel[k,...] = p * Z
    
plot_mutliplot_bilinear(25,kernel, colorbar=True, symmetric=2)
p

plt.show()

############
# Plotting 
############

if save_figures:

    symmetric = 0
    colorbar = False 
    closest_square_to_kernel = int(np.sqrt(kernel_size)) ** 2
    
    directory = './figures/'
    formating='.pdf'
    title = 'real_regresion_h1'
    save_filename = directory + title + formating 
     
    plot_mutliplot_bilinear(closest_square_to_kernel, h1, colorbar=colorbar, symmetric=symmetric)
    figure = plt.gcf() # get current figure
    
    if remove_axis:
        # Remove axis 
        for i in xrange(closest_square_to_kernel):
            figure.get_axes()[i].get_xaxis().set_visible(False)
            figure.get_axes()[i].get_yaxis().set_visible(False)
    
    figure.set_size_inches(16, 12)
    plt.savefig(save_filename, dpi = 100)
    os.system("pdfcrop %s %s" % (save_filename, save_filename))
    
    
    plt.show()
    
            ims,
            training_indexes,
            delay_indexes,
            image_indexes,
            kernel_to_input,
            input_to_image,
            kernel_times,
            verbose=verbose)

############
# Plotting and saving
############
symmetric = 1
colorbar = True
closest_square_to_kernel = int(np.sqrt(kernel_size))**2
plot_mutliplot_bilinear(closest_square_to_kernel, sta)

directory = './figures/'
formating = '.pdf'
title = 'STA' + quality + stimuli_type
save_filename = directory + title + formating

figure = plt.gcf()  # get current figure

if remove_axis:
    #Remove axis
    for i in xrange(closest_square_to_kernel):
        figure.get_axes()[i].get_xaxis().set_visible(False)
        figure.get_axes()[i].get_yaxis().set_visible(False)

figure.set_size_inches(16, 12)
示例#5
0
############
# Plotting
############
symmetric = 1
colorbar = True
closest_square_to_kernel = int(np.sqrt(kernel_size))**2

# Plot dense

directory = './figures/'
formating = '.pdf'
title = 'simulation_regresion_h1' + quality + stimuli_type_dense
save_filename = directory + title + formating

plot_mutliplot_bilinear(closest_square_to_kernel,
                        h1_dense,
                        colorbar=colorbar,
                        symmetric=symmetric)
figure = plt.gcf()  # get current figure

if remove_axis:
    #Remove axis
    for i in xrange(closest_square_to_kernel):
        figure.get_axes()[i].get_xaxis().set_visible(False)
        figure.get_axes()[i].get_yaxis().set_visible(False)

figure.set_size_inches(16, 12)
plt.savefig(save_filename, dpi=100)
os.system("pdfcrop %s %s" % (save_filename, save_filename))

if show_plot:
    plt.show()
# Calculate STA
############
print 'file name:',  quality+ stimuli_type
print 'Examples used to calculate it :', training_indexes.size
print 'kernel size', kernel_size
verbose = True # Whether we want the delays to be display or not

sta = sta_v(V, ims, training_indexes, delay_indexes, image_indexes, kernel_to_input, input_to_image, kernel_times, verbose=verbose)

############
# Plotting and saving 
############
symmetric = 1
colorbar = True
closest_square_to_kernel = int(np.sqrt(kernel_size)) ** 2
plot_mutliplot_bilinear(closest_square_to_kernel, sta)

directory = './figures/'
formating='.pdf'
title = 'STA' + quality + stimuli_type
save_filename = directory + title + formating 

figure = plt.gcf() # get current figure

if remove_axis:
    #Remove axis 
    for i in xrange(closest_square_to_kernel):
        figure.get_axes()[i].get_xaxis().set_visible(False)
        figure.get_axes()[i].get_yaxis().set_visible(False)

figure.set_size_inches(16, 12)
 #symmetric = 1
  symmetric = 0
  colorbar = True
  closest_square_to_kernel = int(np.sqrt(kernel_size)) ** 2
  aux1=-0.70 
  aux2=0.45
  
  # Plot dense
  
  directory = './figures/'
  formating='.pdf'
  title = 'simulation_regresion_h1' + quality + 'cell' + cell_number + '_'+ stimuli_type_dense
  save_filename = directory + title + formating 
   
 #plot_mutliplot_bilinear(closest_square_to_kernel, h1_dense, colorbar=colorbar, symmetric=symmetric)
  plot_mutliplot_bilinear(closest_square_to_kernel, h1_dense, colorbar=colorbar, symmetric=symmetric, aux1=aux1, aux2=aux2)
  figure = plt.gcf() # get current figure
  
  if remove_axis:
      #Remove axis 
      for i in xrange(closest_square_to_kernel):
          figure.get_axes()[i].get_xaxis().set_visible(False)
          figure.get_axes()[i].get_yaxis().set_visible(False)
      
  figure.set_size_inches(16, 12)
  plt.savefig(save_filename, dpi = 100)
  os.system("pdfcrop %s %s" % (save_filename, save_filename))
  
  if show_plot:
      plt.show()