# Create the kernel kernel = create_kernel(dx, lx, dy, ly, sigma_surround, sigma_center, dt_kernel, kernel_size, inverse=1, x_tra=xc, y_tra=yc) # Calculate the firing rate for index in signal_indexes: firing_rate[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel, stimuli) firing_rate += 10 # Add background noise # Rectify the firing rate firing_rate[firing_rate < 0] = 0 remove_start = int(kernel_size * dt_kernel) visualize_firing_rate(firing_rate[signal_indexes], dt, T_simulation - remove_start, label='Firing rate') #visualize_firing_rate(firing_rate / np.max(firing_rate), dt, T_simulation, label='Firing rate') # Produce spikes with the signal spike_times_thin = produce_spikes(firing_rate, dt, T_simulation, remove_start) spike_times_thin -= remove_start
stimuli2 = sine_grating(dx, lx, dy, ly, A2, K, Phi, Theta, dt_stimuli, N_stimuli, w) # Chose the particular cell xc = 0 yc = 0 # Create the kernels kernel_on = create_kernel(dx, lx, dy, ly, sigma_surround, sigma_center, dt_kernel, kernel_size, inverse=1, x_tra=0, y_tra=0) kernel_off = create_kernel(dx, lx, dy, ly, sigma_surround, sigma_center, dt_kernel, kernel_size, inverse=-1, x_tra=0, y_tra=0) # Calculate the firing rate through convolution for index in signal_indexes: firing_rate_on1[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_on, stimuli1) for index in signal_indexes: firing_rate_off1[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_off, stimuli1) for index in signal_indexes: firing_rate_on2[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_on, stimuli2) for index in signal_indexes: firing_rate_off2[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_off, stimuli2) # Add background noise on_noise = 10 # Hz off_noise = 15 # Hz firing_rate_on1 += on_noise
xc = x yc = y positions.append((x,y)) # Create the kernel kernel = create_kernel(dx, lx, dy, ly, sigma_surround, sigma_center, dt_kernel, kernel_size, inverse=on_off_cells, x_tra=xc, y_tra=yc) # Initialize the signal array to be filled firing_rate = np.zeros(Nt_simulation) # Calculate the firing rate for index in signal_indexes: firing_rate[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel, stimuli) firing_rate += 10 # Add background noise # Rectify the firing rate firing_rate[firing_rate < 0] = 0 # Produce spikes with the signal spike_times_thin = produce_spikes(firing_rate, dt, T_simulation, remove_start, 60.0) spike_times_thin -= remove_start # Translate the spikes to the origin spike_train.append(spike_times_thin) # Count the spikes in the cell number_of_spikes_array[counter1, counter2] = len(spike_times_thin) print 'counters 1, 2=', counter1, counter2 counter1 += 1
# Create the stimuli # stimuli = ternary_noise(N_stimuli, int(lx /dx), int(ly/dt)) stimuli = sine_grating(dx, lx, dy, ly, A, K, Phi, Theta, dt_stimuli, N_stimuli, w) # Chose the particular cell xc = 0 yc = 0 # Create the kernel kernel_on = create_kernel(dx, lx, dy, ly, sigma_surround, sigma_center, dt_kernel, kernel_size, inverse=1, x_tra=0, y_tra=0) kernel_off = create_kernel(dx, lx, dy, ly, sigma_surround, sigma_center, dt_kernel, kernel_size, inverse=-1, x_tra=0, y_tra=0) # Calculate the firing rate for index in signal_indexes: firing_rate_on[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_on, stimuli) for index in signal_indexes: firing_rate_off[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_off, stimuli) # Add background noise on_noise = 10 # Hz off_noise = 15 # HZ firing_rate_on += on_noise firing_rate_off += off_noise # Rectify firing rates firing_rate_on[firing_rate_on < 0] = 0 firing_rate_off[firing_rate_off < 0] = 0
y_tra=0) kernel_off = create_kernel(dx, lx, dy, ly, sigma_surround, sigma_center, dt_kernel, kernel_size, inverse=-1, x_tra=0, y_tra=0) # Calculate the firing rate for index in signal_indexes: firing_rate_on[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_on, stimuli) for index in signal_indexes: firing_rate_off[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_off, stimuli) # Add background noise on_noise = 10 # Hz off_noise = 15 # HZ firing_rate_on += on_noise firing_rate_off += off_noise # Rectify firing rates firing_rate_on[firing_rate_on < 0] = 0 firing_rate_off[firing_rate_off < 0] = 0
N_stimuli = int(T_simulation / dt_stimuli) # Number of stimuli points # And now the spatial parameters of the sinus grating K = 0.8 # Cycles per degree Phi = 0 Theta = 0 max_contrast = 2.0 * 2 contrast = 0.5 # Percentage A = contrast * max_contrast # Temporal frequency of sine grating w = 3 # Hz stimuli = sine_grating(dx, lx, dy, ly, A, K, Phi, Theta, dt_stimuli, N_stimuli, w) ## Now we can do the convolution # First we define the necessary indexes to the convolution signal_indexes, delay_indexes, stimuli_indexes = create_standar_indexes(dt, dt_kernel, dt_stimuli, kernel_size, Nt_simulation) working_indexes, kernel_times = create_extra_indexes(kernel_size, Nt_simulation) # Now we calculate the signal signal = np.zeros(Nt_simulation) for index in signal_indexes: signal[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_on, stimuli) #Plot the signal t = np.arange(kernel_size*dt_kernel, T_simulation, dt) plt.plot(t, signal[signal_indexes]) plt.show()
kernel_off = create_kernel(dx, lx, dy, ly, sigma_surround, sigma_center, dt_kernel, kernel_size, inverse=-1, x_tra=0, y_tra=0) # Calculate the firing rate through convolution for index in signal_indexes: firing_rate_on1[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_on, stimuli1) for index in signal_indexes: firing_rate_off1[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_off, stimuli1) for index in signal_indexes: firing_rate_on2[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_on, stimuli2) for index in signal_indexes: firing_rate_off2[index] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernel_off, stimuli2)
x_tra=xc[xi] + dx / 5, y_tra=yc[yj] + dy / 5) '''plt.figure(5) plt.subplot(2,2,1) plt.imshow(kernelON[n,0,...],extent=[-lx/2,lx/2,ly/2,-ly/2]) plt.subplot(2,2,2) plt.imshow(stimuli[0,...],extent=[-lx/2,lx/2,ly/2,-ly/2]) plt.subplot(2,2,3) plt.imshow(kernelOFF[n,0,...],extent=[-lx/2,lx/2,ly/2,-ly/2]) plt.show() ''' # Calculate the firing rate for index in signal_indexes: firing_rate_ON[index, n] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernelON[n, ...], stimuli) firing_rate_OFF[index, n] = convolution(index, kernel_times, delay_indexes, stimuli_indexes, kernelOFF[n, ...], stimuli) firing_rate_ON[:, n] += 10 # Add background noise # Rectify the firing rate firing_rate_ON[firing_rate_ON[:, n] < 0, n] = 0 firing_rate_OFF[:, n] += 10 # Add background noise # Rectify the firing rate firing_rate_OFF[firing_rate_OFF[:, n] < 0, n] = 0 n += 1 remove_start = int(kernel_size * dt_kernel)