def main(): # jason's f-f curve for model cell #156 in Schwartz2012 # (supposedly the one closest to having average parameter values), # in presence of tonic GABA jason_stim_range = np.arange(60, 660, 60)/4 jason_rates_156 = np.array([0.0, 0.7755102040816326, 4.55813953488372, 20.65625, 49.46153846153846, 88.9047619047619, 139.2222222222222, 187.6875, 227.64285714285717, 253.7142857142857]) n_stims_range = np.arange(1, 11, 1, dtype=np.int) n_stims_range = np.array([4]) exc_rate_range = np.arange(10, 155, 5) out_rates = np.zeros(shape=(n_stims_range.size, exc_rate_range.size)) sim_duration = 50 # s for d, n_stims in enumerate(n_stims_range): for k, exc_rate in enumerate(exc_rate_range): sim_data = simulation_tools.simulate_poisson_stimulation([exc_rate for each in range(n_stims)], sim_duration) spike_count = sim_data[-1,2] out_rates[d,k] = float(spike_count) / sim_duration print("stims: {}; input: {}Hz; output: {:.2f}Hz".format(n_stims, exc_rate, out_rates[d,k])) # plotting setup ff_fig, ff_ax = plt.subplots() #ff_ax.plot(jason_stim_range, jason_rates_156, color='k', linewidth=1.5, marker='o', label='Schwartz2012 cell #156') cm = plt.get_cmap('RdYlBu') c_norm = colors.Normalize(vmin=0, vmax=n_stims_range[-1]) scalar_map = cmx.ScalarMappable(norm=c_norm, cmap=cm) matplotlib.rcParams.update({'axes.labelsize': 30}) matplotlib.rcParams.update({'xtick.labelsize': 30}) matplotlib.rcParams.update({'ytick.labelsize': 30}) for d, n_stims in enumerate(n_stims_range): color = scalar_map.to_rgba(n_stims) ff_ax.plot(exc_rate_range, out_rates[d], linewidth=1.5, marker='o', color='b') ff_ax.set_title('GrC model: rate I/O with {} to {} Poisson stimuli and tonic GABA'.format(n_stims_range[0], n_stims_range[-1])) ff_ax.legend(loc='best') ff_ax.set_xlabel("MF firing rate (Hz)") ff_ax.set_ylabel("GrC firing rate (Hz)") ff_ax.xaxis.set_ticks_position('bottom') ff_ax.yaxis.set_ticks_position('left') ff_ax.spines['top'].set_color('none') ff_ax.spines['right'].set_color('none') plt.show()
def main(): exc_rates = [80, 80, 10, 10] # Hertz # use excitatory conductance scaling exc_scaling_factor = 4./len(exc_rates) sim_duration = 0.25 # seconds linewidth = 2.5 n_stims = len(exc_rates) sim_data = simulation_tools.simulate_poisson_stimulation(exc_rates, sim_duration, save_synaptic_conductances=True, exc_scaling_factor=exc_scaling_factor) time = sim_data[:,0] * 1000 voltage = sim_data[:,1] * 1000 derivative = np.diff(voltage) voltage[derivative<-1] = 40 # plot GrC membrane potential fig_v, ax_v = plt.subplots() ax_v.plot(time, voltage, linewidth=linewidth, color='b') ax_v.set_xlabel("Time (ms)") ax_v.set_ylabel("Membrane potential (mV)") bottom_left_axes(ax_v) # plot excitatory conductance trains fig_c, ax_c = plt.subplots(nrows=n_stims+1, ncols=1, sharex=True, sharey=True) for stim in range(n_stims): conductance_AMPA = sim_data[:,3+2*stim]*1e9 conductance_NMDA = sim_data[:,4+2*stim]*1e9 ax_c[stim].plot(time, conductance_AMPA, linewidth=linewidth, color='r') ax_c[stim].plot(time, conductance_NMDA, linewidth=linewidth, color='#5F04B4') # plot tonic inhibition ax_c[-1].plot(time, 0.438+np.zeros_like(time), linewidth=linewidth, color='g') # prettify conductance axes for ax in ax_c: ax.axes.get_yaxis().set_ticks([0, 0.3, 0.6]) bottom_left_axes(ax) ax_c[-1].set_xlabel("Time (ms)") ax_c[-1].set_ylabel("Conductance (nS)") plt.show()
def main(): exc_rate_range = np.array([80]) out_rates = np.zeros_like(exc_rate_range) sim_duration = 400. # s n_bins = 200 upper_hist_limit = 0.100 # s for k, exc_rate in enumerate(exc_rate_range): exc_rates = [exc_rate, exc_rate, exc_rate, 10] sim_data = simulation_tools.simulate_poisson_stimulation(exc_rates, sim_duration) timepoints = sim_data[:,0] voltage = sim_data[:,1] spike_times = timepoints[np.diff(sim_data[:,2]) != 0] out_rates[k] = float(spike_times.size) / sim_duration print("input: {}Hz; output: {}Hz".format(exc_rate, out_rates[k])) relative_times = [] for s, t in enumerate(spike_times): stop_idx = np.searchsorted(spike_times, t+upper_hist_limit) relative_times.extend((spike_times[s+1:stop_idx] - t).tolist()) small_relative_times = np.array(relative_times) if small_relative_times.size: fig, ax = plt.subplots() bin_length = upper_hist_limit/n_bins weights = np.ones_like(small_relative_times)/(bin_length*sim_duration) n, bins, patches = ax.hist(small_relative_times*1000, bins=n_bins, color='k', weights=weights, normed=False) uniform_baseline_spikes_per_bin = out_rates[k]*bin_length ax.plot([0, bins[-1]], [out_rates[k]**2, out_rates[k]**2], color='r', linewidth=1.5) ax.set_title('Spike time autocorrelation for stim rate {}Hz'.format(exc_rate)) ax.set_xlabel('lag (ms)') ax.set_ylabel('autocorrelation (Hz$^2$)') if out_rates.size > 1: ff_fig, ff_ax = plt.subplots() ff_ax.plot(exc_rate_range, out_rates, color='k', linewidth=1.5) ff_ax.set_xlabel("MF firing rate (Hz)") ff_ax.set_xlabel("GrC firing rate (Hz)") plt.show()
def main(): # jason's f-f curve for model cell #156 in Schwartz2012 # (supposedly the one closest to having average parameter values), # in presence of tonic GABA jason_stim_range = np.arange(60, 660, 60)/4 jason_rates_156 = np.array([0.0, 0.7755102040816326, 4.55813953488372, 20.65625, 49.46153846153846, 88.9047619047619, 139.2222222222222, 187.6875, 227.64285714285717, 253.7142857142857]) scale_exc = False scale_inh = True n_stims_range = np.arange(1,9,1) exc_rate_range = np.arange(10, 155, 10) #exc_scaling_factor_range = np.arange(0.5, 1.6, 0.25) out_rates = np.zeros(shape=(n_stims_range.size, exc_rate_range.size)) sim_duration = 6 # s for i, n_stims in enumerate(n_stims_range): if scale_exc: exc_scaling_factor = 4./n_stims inh_scaling_factor = 1. elif scale_inh: exc_scaling_factor = 1. inh_scaling_factor = n_stims/4. else: exc_scaling_factor = 1. inh_scaling_factor = 1. for k, exc_rate in enumerate(exc_rate_range): sim_data = simulation_tools.simulate_poisson_stimulation([exc_rate for each in range(n_stims)], sim_duration, inh_scaling_factor=inh_scaling_factor, exc_scaling_factor=exc_scaling_factor) spike_count = sim_data[-1,2] out_rates[i,k] = float(spike_count) / sim_duration print("inh: {}; exc: {}; input: {}Hz; output: {:.2f}Hz".format(inh_scaling_factor, exc_scaling_factor, exc_rate, out_rates[i,k])) # plotting setup ff_fig, ff_ax = plt.subplots() #ff_ax.plot(jason_stim_range, jason_rates_156, color='k', linewidth=1.5, marker='o', label='Schwartz2012 cell #156') cm = plt.get_cmap('RdYlBu_r') c_norm = colors.Normalize(vmin=n_stims_range[0], vmax=n_stims_range[-1]) scalar_map = cmx.ScalarMappable(norm=c_norm, cmap=cm) matplotlib.rcParams.update({'axes.labelsize': 30}) matplotlib.rcParams.update({'xtick.labelsize': 30}) matplotlib.rcParams.update({'ytick.labelsize': 30}) for i, exc_scaling_factor in enumerate(n_stims_range): color = scalar_map.to_rgba(exc_scaling_factor) ff_ax.plot(exc_rate_range, out_rates[i], linewidth=1.5, marker='o', color=color) print('input: {}'.format(exc_rate_range)) print('output: {}'.format(out_rates[i])) #ff_ax.legend(loc='best') ff_ax.set_xlabel("MF firing rate (Hz)") ff_ax.set_ylabel("GrC firing rate (Hz)") ff_ax.xaxis.set_ticks_position('bottom') ff_ax.yaxis.set_ticks_position('left') ff_ax.spines['top'].set_color('none') ff_ax.spines['right'].set_color('none') cb_ax, kw = matplotlib.colorbar.make_axes(ff_ax) cb = matplotlib.colorbar.ColorbarBase(cb_ax, cmap=cm, norm=c_norm, **kw) cb.set_ticks(n_stims_range) cb.set_label('dendrites') plt.show()