def plot_voltage_ipsp(ax, v_mat, ipsp_mat): colors = ['b', 'g', 'r'] labels = [ r'$ref_{init}^{MSN}$', r'$ref_{max}^{MSN}$', r'$ref_{25 Hz}^{GPe}$' ] coords = [[0.64, 0.3], [0.1, 0.29], [0.55, 0.7]] for i, color in enumerate(colors): ax.plot(v_mat[i, :], ipsp_mat[i, :], **{'color': color}) ax.set_ylabel('IPSP amplitude (mV)') ax.set_xlabel('Holding potential (mV)') ax.set_xlim(misc.adjust_limit([-80, -65])) #ax.set_ylim(misc.adjust_limit([-4,2])) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[-80, -65]) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'] + 2, **{'color': color}) ax.my_set_no_ticks(yticks=8, xticks=6)
def plot_example_3x_freq(ax, times, spk_mean, hzs=[10, 20, 40]): spk_mean = spk_mean colors = misc.make_N_colors('YlOrBr', 5)[2:] labels = ['%i Hz' % hzs[0], '%i Hz' % hzs[1], '%i Hz' % hzs[2]] coords = [[0.4, 0.52], [0.05, 0.22], [0.1, 0.74]] for i, col in enumerate(colors): ax.plot(times, misc.convolve(spk_mean[i, :], 50, 'triangle', single=True)[0], color=col) #ax.plot(times, spk_mean[i,:], col) lines = ax.lines for line in lines: line.set_xdata(line.get_xdata() - ADJUST_XDATA_MS) misc.slice_line(line, xlim=[0, 1490]) #ax.set_ylim([0,40]) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=font_size_text, **{'color': color}) ax.set_ylabel('Rate SNr (spikes/s)') ax.set_xlabel('Time (ms)') ax.my_set_no_ticks(yticks=6, xticks=8) ax.set_xlim(misc.adjust_limit([0, 1500])) ax.set_ylim(misc.adjust_limit([0, 40]))
def plot_selection_vs_neurons_full(ax, hzs, data): colors = ['b', 'g', 'm'] labels = [ r'$\delta_{weak}^{MSN}$', r'$\delta_{strong}^{MSN}$', r'$\delta_{fac}^{MSN}$' ] coords = [[0.03, 0.8], [0.05, 0.07], [0.03, 0.50]] syn = SYNAPSE_MODELS_TESTED for id, label, color in zip([0, 1, 2], labels, colors): ax.plot(hzs, data[syn[id]]['thrVec'], **{'color': color}) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 48]) ax.set_xlabel('Frequency MSN (Hz)') ax.set_ylabel('MSNs at thr (#)') ax.my_set_no_ticks(yticks=6, xticks=6) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color}) ax.set_xlim(misc.adjust_limit([0, 48])) ax.set_ylim(misc.adjust_limit([0, 75]))
def plot_SNr_rate_vs_syn_event1(ax, syn_events, meanRates): colors = ['k'] labels = [r'$\delta_{dep}^{GPe}$'] coords = [[0.1, 0.15]] for id, label, color in zip([0], labels, colors): ax.plot(syn_events, meanRates[id, :], **{'color': color}) vec = [0, 800] ax.set_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Synaptic events (#/s)') ax.my_set_no_ticks(yticks=6, xticks=5) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color}) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 800]) ax.set_xlim(misc.adjust_limit([0, 800])) ax.set_ylim(misc.adjust_limit([20, 115]))
def plot_selection_vs_neurons_indirect_linear_fit_and_spread(ax, mods, slope): colors = ['b', 'g', 'r'] labels = [r'First 100 ms', r'250-350 ms', r'Last 100 ms'] coords = [[0.55, 0.15], [0.07, 0.47], [0.15, 0.78]] ps = [] for i, color in enumerate(colors): ax.plot(mods, slope[i, :], **{'color': color, 'linestyle': '-'}) #x,y,dy=fit_pol(MSNmeanRates,SNRmeanRates[i,:]) #ax.plot(x,y,**{'color':color}) ''' ax.plot([0,2.5],[SELECTION_THR]*len([0,2]),**{'color':[0.6,0.6,0.6], 'label':'', 'linewidth':1, 'linestyle':'--'}) ax.text( 0.8, 0.20,'Thr' , transform=ax.transAxes, **{ 'color' : [0.6,0.6,0.6]}) ''' ax.set_ylabel('$\Delta_{SNr}/ \Delta_{MSN_{D2}}$') ax.set_xlabel('Percent bursting $MSN_{D2}$ (%)') ax.my_set_no_ticks(yticks=8, xticks=6) #ax.set_xlim(misc.adjust_limit([15, 50])) ax.set_ylim(misc.adjust_limit([0, 1.3])) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 50]) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=12, **{'color': color})
def plot_selection_vs_neurons_full_extra(ax, hzs, data): colors = ['b', 'g', 'm'] labels = [ r'$\delta_{weak}^{MSN}$', r'$\delta_{strong}^{MSN}$', r'$\delta_{fac}^{MSN}$' ] syn = SYNAPSE_MODELS_TESTED for id, label, color in zip([0, 1, 2], labels, colors): ax.plot(hzs, data[syn[id]]['thrVec'], **{ 'color': color, 'linestyle': '--' }) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 48]) line1 = ax.plot(1, 1, '-k') line2 = ax.plot(1, 1, '--k') leg = ax.legend( [line1, line2], ['First 200 ms of \nthe burst', '300-500 ms of \nthe burst'], loc='best') frame = leg.get_frame() #frame.set_visible(False) pylab.setp(frame, edgecolor='w') ltext = leg.get_texts() # all the text.Text instance in the legend pylab.setp(ltext, fontsize=10., backgroundcolor='w') ax.set_xlim(misc.adjust_limit([-7, 48])) ax.set_ylim(misc.adjust_limit([0, 100]))
def plot_SNr_rate_vs_syn_event1(ax, syn_events, meanRates, meanRatesStd): colors = ['k'] labels = [r'$\delta_{fac}^{MSN}$'] coords = [[0.04, 0.16]] for id, label, color in zip([2], labels, colors): ax.plot(syn_events, meanRates[id, :], **{'color': color}) # ax.fill_between(syn_events, meanRates[id,:]+meanRatesStd[id,:], # meanRates[id,:]-meanRatesStd[id,:], # facecolor=color, alpha=0.5) vec = [50, 600] ax.plot( vec, [SELECTION_THR] * len(vec), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.8, 0.17, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) ax.set_ylabel('Frequency SNr (Hz)') ax.set_xlabel('Synaptic events (#/s)') ax.my_set_no_ticks(yticks=6, xticks=5) x_arrow = 285. / 600. y_arrow = 2. / 50. ax.arrow(x_arrow, y_arrow, 0, 0.02, transform=ax.transAxes, width=0.01, head_width=0.03, head_starts_at_zero=True, head_length=0.02, **{'color': 'k'}) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color}) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 600]) ax.set_xlim(misc.adjust_limit([50, 600])) ax.set_ylim(misc.adjust_limit([0, 35]))
def plot_SNr_rate_vs_syn_event2(ax, nbNeurons, meanRates): colors = ['k'] ax.plot(nbNeurons, meanRates[2, :], **{ 'color': colors[0], 'linestyle': '-.' }) ax.set_ylabel('Frequency SNr (Hz)') ax.set_xlabel('Synaptic events (#/s)') ax.my_set_no_ticks(yticks=5, xticks=5) line1 = ax.plot(1, 1, '-k') line2 = ax.plot(1, 1, '-.k') leg = ax.legend( [line1, line2], ['Bursting subpopulation', 'Increased activity in \nall MSNs'], loc='best') frame = leg.get_frame() frame.set_visible(False) ltext = leg.get_texts() # all the text.Text instance in the legend lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 600]) pylab.setp(ltext, fontsize=10.) ax.set_xlim(misc.adjust_limit([50, 600])) ax.set_ylim(misc.adjust_limit([0, 35]))
def plot_example_rebound_spike(ax, SNR): SNR.signals['V_m'].plot(display=ax, kwargs={'color': 'k'}) ax.set_xlim(misc.adjust_limit([300, 1000])) ax.set_ylim(misc.adjust_limit([-85, 30])) line = ax.lines misc.slice_line(line[0], xlim=[300, 1000]) ax.my_set_no_ticks(yticks=3, xticks=6) ax.set_ylabel('SNr potential (mV)')
def plot_steady_state_freq(ax, freq_, relative_fac): colors = ['b', 'g', 'm'] linestyles = ['--', '--', '-'] labels = [ r'$ref_{init}^{MSN_{D1}}$', r'$ref_{max}^{MSN_{D1}}$', r'$fac^{MSN_{D1}}$' ] coords = [[0.1, 0.22], [0.2, 0.74], [0.65, 0.45]] syn_static = ['MSN_SNR_gaba_s_min', 'MSN_SNR_gaba_s_max'] ax.plot(freq_, relative_fac[0, :], **{'color': colors[2]}) ytext = ax.set_ylabel(r'$p_{ss}$/$p_1$') #pylab.setp(ytext, fontsize=14.) ax.set_xlabel('Firing rate (spikes/s)') ax.my_set_no_ticks(yticks=5, xticks=5) my_nest.ResetKernel() model_list, model_dict = models() syns = [SYNAPSE_MODELS[0]] syns.extend(syn_static) my_nest.MyLoadModels(model_list, syns) xdata = ax.lines[0].get_xdata() ss = my_nest.GetDefaults(SYNAPSE_MODELS[0]) synapticEficacy = ss['weight'] * ss['U'] for syn, color, ls in zip(syn_static, colors[0:2], linestyles[0:2]): sw = my_nest.GetDefaults(syn) ax.plot( [min(xdata), 48], [sw['weight'] / synapticEficacy, sw['weight'] / synapticEficacy], **{ 'color': color, 'linestyle': ls }) for coord, label, color in zip(coords, labels, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['font.size'] + 2, **{'color': color}) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 48]) ax.set_xlim(misc.adjust_limit([0, 50])) ax.set_ylim(misc.adjust_limit([0, 5])) ax.my_set_no_ticks(yticks=6, xticks=6) pylab.setp(ax.lines, linewidth=2.0) # Need to pu ti before generating legend
def plot_selection_vs_neurons_full(ax, hzs, data): colors = ['b', 'g', 'm'] labels = [ r'$ref_{init}^{MSN_{D1}}$', r'$ref_{max}^{MSN_{D1}}$', r'$fac_{MSN_{D1}}$' ] coords = [[0.03, 0.8], [0.05, 0.07], [0.03, 0.50]] syn = SYNAPSE_MODELS_TESTED for id, label, color in zip([0, 1, 2], labels, colors): ax.plot(hzs, numpy.array(data[id]['msn_at_thr'][0]) / float(N_MSN) * 100., **{'color': color}) for id, label, color in zip([0, 1, 2], labels, colors): ax.plot(hzs, numpy.array(data[id]['msn_at_thr'][1]) / float(N_MSN) * 100., **{ 'color': color, 'linestyle': '--' }) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 48]) ax.set_xlabel(r'Rate $MSN_{D1}$ (spikes/s)') ax.set_ylabel(r'Bursting $MSN_{D1}$ at thr (%)') ax.my_set_no_ticks(yticks=8, xticks=6) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color}) line1 = ax.plot(1, 1, '-k') line2 = ax.plot(1, 1, '--k') leg = ax.legend( [line1, line2], ['First 100 ms of \nthe burst', 'Last 100 ms of \nthe burst'], loc='best') frame = leg.get_frame() #frame.set_visible(False) pylab.setp(frame, edgecolor='w') ltext = leg.get_texts() # all the text.Text instance in the legend pylab.setp(ltext, fontsize=font_size_text, backgroundcolor='w') ax.set_xlim(misc.adjust_limit([6, 48])) ax.set_ylim(misc.adjust_limit([0, 30]))
def plot_indirect(ax, data, idx_show=[0, 1, 2], title='', ylim=[0, 34]): colors = ['k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k'] labels = [r'1 % bursting', r'2 % bursting', r'4 % bursting'] linestyles = [ '-', '--', '-.', '-', '--', '-.', '-', '--', '-.', '-', '--', '-.' ] coords = [[0.4, 0.42], [0.02, 0.001], [0.15, 0.78]] data = [data[i] for i in idx_show] for i, d in enumerate(data): lb = r'%i %s bursting' % (d[0][0], '%') x, y_mean, y_std = d.take([1, 2, 3], axis=0) ax.plot( x, y_mean, **{ 'color': colors[i], 'label': lb, 'linestyle': linestyles[i] }) ax.fill_between(x, y_mean - y_std, y_mean + y_std, facecolor=colors[i], alpha=0.5) pylab.setp(ax.lines, linewidth=2.0) # Need to pu ti before generating legend leg = ax.legend(loc='best') frame = leg.get_frame() frame.set_visible(False) ltext = leg.get_texts() # all the text.Text instance in the legend pylab.setp(ltext, fontsize=font_size_text) ''' ax.plot([0,2.5],[SELECTION_THR]*len([0,2]),**{'color':[0.6,0.6,0.6], 'label':'', 'linewidth':1, 'linestyle':'--'}) ax.text( 0.8, 0.20,'Thr' , transform=ax.transAxes, **{ 'color' : [0.6,0.6,0.6]}) ''' ax.set_ylabel('Rate SNr (spikes/s)') ax.set_xlabel('Burst rate $MSN_{D2}$ (spikes/s)') ax.my_set_no_ticks(yticks=8, xticks=6) ax.set_title(title, fontsize=font_size_text) ax.set_xlim(misc.adjust_limit([15, 50])) ax.set_ylim(misc.adjust_limit(ylim)) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 50])
def plot_example_SNR(ax, SNR_list): time_bin = 20 colors = ['r', 'c'] labels = [r'$\delta_{ref}^{GPe}$', r'$\delta_{dep}^{GPe}$'] coords = [[0.05, 0.60], [0.05, 0.2]] SNR_list = [SNR_list[0], SNR_list[1]] for color, label, SNR in zip(colors, labels, SNR_list): signal = SNR.signals['spikes'] signal.my_firing_rate(bin=time_bin, display=ax, kwargs={'color': color}) lines = ax.lines lines[0].set_xdata(lines[0].get_xdata() - ADJUST_XDATA_MS) lines[1].set_xdata(lines[1].get_xdata() - ADJUST_XDATA_MS) ax.plot([0, 1690], [SELECTION_THR] * len([0, 2990]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.9, 0.13, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) misc.slice_line(lines[0], xlim=[0, 1690]) misc.slice_line(lines[1], xlim=[0, 1690]) #ax.set_title('bin=%i'%(time_bin),**{'fontsize':12}) ax.set_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Time (ms)') ax.my_set_no_ticks(yticks=6, xticks=8) ax.set_xlim(misc.adjust_limit([0, 1700])) ax.set_ylim(misc.adjust_limit([0, 50])) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color})
def plot_example_SNR(ax, SNR_list, flag): time_bin=20 colors=misc.make_N_colors('cool',3) colors=['m','c',colors[1]] #labels=[r'$\delta_{fac}^{MSN}$' , r'$\delta_{dep}^{GPe}$', # r'$\delta_{fac}^{MSN}$+$\delta_{dep}^{GPe}$'] coords=[[0.05, 0.2], [ 0.05, 0.65], [0.05, 0.8]] SNR_list=[SNR_list[0], SNR_list[1], SNR_list[2]] for color, SNR in zip(colors, SNR_list): signal=SNR.signals['spikes'] signal.my_firing_rate(bin=time_bin, display=ax, kwargs={'color':color}) lines = ax.lines for line in lines: line.set_xdata(line.get_xdata()-ADJUST_XDATA_MS) misc.slice_line(line, xlim=[0,1490]) if flag==0: leg=ax.legend(lines,['Burst in MSN subpopulation' , 'Burst in GPe subpopulation', 'Burst in both MSN- and GPe subpopulations'], loc=2) if flag==1: leg=ax.legend(lines,['Burst in MSN subpopulation' , 'Pause in GPe subpopulation', 'Burst in MSN- and pause in GPe subpopulations'], loc=2) frame = leg.get_frame() #frame.set_visible(False) pylab.setp(frame, edgecolor='w') ltext = leg.get_texts() # all the text.Text instance in the legend pylab.setp(ltext, fontsize=12., backgroundcolor='w') ax.plot([0, 1490],[SELECTION_THR]*len([0, 1490]),**{'color':[0.6,0.6,0.6], 'label':'', 'linewidth':1, 'linestyle':'--'}) ax.text( 0.9, 0.11,'Thr' , transform=ax.transAxes, **{ 'color' : [0.6,0.6,0.6]}) #ax.set_title('bin=%i'%(time_bin),**{'fontsize':12}) ax.set_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Time (ms)') ax.my_set_no_ticks( yticks=7, xticks=8 ) ax.set_xlim(misc.adjust_limit([0,1500])) ax.set_ylim(misc.adjust_limit([0,115]))
def plot_selection_vs_neurons_direct(ax, MSNmeanRates, SNRmeanRates): colors = ['b', 'g', 'm'] labels = [ r'$\delta_{weak}^{MSN}$', r'$\delta_{strong}^{MSN}$', r'$\delta_{fac}^{MSN}$' ] coords = [[0.4, 0.42], [0.02, 0.001], [0.15, 0.78]] for i, color in enumerate(colors): ax.plot(MSNmeanRates, SNRmeanRates[i, :], **{ 'color': color, 'marker': '.', 'linestyle': '' }) #x,y,dy=fit_pol(MSNmeanRates,SNRmeanRates[i,:]) #x,y,dy=fit_exp(MSNmeanRates,SNRmeanRates[i,:]) #ax.plot(x,y,**{'color':color}) ax.plot([0, 2.5], [SELECTION_THR] * len([0, 2]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.8, 0.20, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) ax.set_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Firing rate MSN (spikes/s)') ax.my_set_no_ticks(yticks=8, xticks=6) ax.set_xlim(misc.adjust_limit([0, 50])) ax.set_ylim(misc.adjust_limit([0, 34])) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 50]) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color})
def plot_selection_vs_neurons(ax, GPEmeanRates, SNRmeanRates): colors = ['b', 'b', 'g', 'g'] linestyles = ['-', '--', '-', '--'] for i, color in enumerate(colors): ax.plot(GPEmeanRates[i, :], SNRmeanRates[i, :], **{ 'color': color, 'linestyle': linestyles[i] }) vec = [0, 100] ax.set_ylabel('Rate SNr (spikes/s)') ax.set_xlabel(r'Rate $MSN_{D2}$ (spikes/s)') ax.my_set_no_ticks(yticks=8, xticks=6) line1 = ax.plot(1, 1, '-k') line2 = ax.plot(1, 1, '--k') pylab.setp(ax.lines, linewidth=2.0) # Need to pu ti before generating legend leg = ax.legend([line1, line2], ['$dep^{GPe}$', '$ref_{32 Hz}^{GPe}$'], loc='best') frame = leg.get_frame() frame.set_visible(False) ltext = leg.get_texts() # all the text.Text instance in the legend pylab.setp(frame, edgecolor='w') ltext = leg.get_texts() # all the text.Text instance in the legend pylab.setp(ltext, fontsize=pylab.rcParams['text.fontsize'] - 2, backgroundcolor='w') lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 100]) labels = ['Static \nSTN-SNr', 'Depressing \nSTN-SNr'] coords = [[0.55, 0.3], [0.3, 0.6]] colors = ['b', 'g'] for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=font_size_text, **{'color': color}) ax.set_xlim(misc.adjust_limit([0, 4])) ax.set_ylim(misc.adjust_limit([25, 150]))
def plot_filtering(ax, MSNmeanRates, SNRmeanRates): colors = ['b', 'g', 'm'] linestyle = ['--', '--', '-'] labels = [ r'$ref_{init}^{MSN_{D1}}$', r'$ref_{max}^{MSN_{D1}}$', r'$fac^{MSN_{D1}}$' ] coords = [[0.4, 0.42], [0.02, 0.001], [0.15, 0.78]] for i, color in enumerate(colors): ax.plot(MSNmeanRates, SNRmeanRates[i, :], **{ 'color': color, 'linestyle': linestyle[i] }) ax.plot([0, 2.5], [SELECTION_THR] * len([0, 2]), **{ 'color': 'k', 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.8, 0.20, 'Thr', fontsize=pylab.rcParams['font.size'] - 2, transform=ax.transAxes, **{'color': 'k'}) ax.set_ylabel('Rate SNr (spikes/s)') ax.set_xlabel('Rate $MSN_{D1}$ (spikes/s)') ax.my_set_no_ticks(yticks=8, xticks=6) ax.set_xlim(misc.adjust_limit([0, 2.5])) ax.set_ylim(misc.adjust_limit([-3, 34])) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 2.6]) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['font.size'], **{'color': color}) pylab.setp(ax.lines, linewidth=2.0) # Need to pu ti before generating legend
def plot_example_SNR(ax, SNR_list): time_bin = 20 colors = ['b', 'g', 'm'] labels = [ r'$\delta_{weak}^{MSN}$', r'$\delta_{strong}^{MSN}$', r'$\delta_{fac}^{MSN}$' ] coords = [[0.4, 0.49], [0.05, 0.27], [0.1, 0.75]] for color, SNR in zip(colors, SNR_list): signal = SNR.signals['spikes'] signal.my_firing_rate(bin=time_bin, display=ax, kwargs={'color': color}) lines = ax.lines for line in lines: line.set_xdata(line.get_xdata() - ADJUST_XDATA_MS) misc.slice_line(line, xlim=[0, 1490]) ax.plot([0, 1490], [SELECTION_THR] * len([0, 1490]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.9, 0.15, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) #ax.set_title('bin=%i'%(time_bin),**{'fontsize':12}) ax.set_ylabel('Frequency SNr (Hz)') ax.set_xlabel('Time (ms)') ax.my_set_no_ticks(yticks=6, xticks=7) ax.set_xlim(misc.adjust_limit([0, 1500])) ax.set_ylim(misc.adjust_limit([0, 40])) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color})
def plot_diff_3x_freq(ax, times, spk_mean ): spk_mean=spk_mean colors=['b','g','r'] for i, col in enumerate(colors): #ax.plot(times, misc.convolve(spk_mean, 50, 'triangle',single=True)[0]*1000,col) ax.plot(times, spk_mean[i,:], col) lines = ax.lines for line in lines: line.set_xdata(line.get_xdata()-ADJUST_XDATA_MS) misc.slice_line(line, xlim=[0,1490]) #ax.set_ylim([0,40]) ax.set_xlim(misc.adjust_limit([0,1500])) ax.set_ylim(misc.adjust_limit([0,40])) pylab.show()
def plot_example_snr(ax, SNR): time_bin = 20 signal = SNR.signals['spikes'] colors = ['k'] sim_time = 2500 hist = signal.spike_histogram(time_bin=1, normalized=True) spk_mean = numpy.mean(hist, axis=0) spk_mean = misc.convolve(spk_mean, 100, 'triangle', single=True)[0] time = numpy.arange(1, len(spk_mean) + 1) ax.plot(time, spk_mean, 'k') ax.my_set_no_ticks(yticks=6, xticks=7) lines = ax.lines lines = ax.lines for line in lines: misc.slice_line(line, xlim=[50, 2450]) ax.plot([0, sim_time], [SELECTION_THR] * len([0, sim_time]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.9, 0.14, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) misc.slice_line(lines[0], xlim=[0, sim_time]) ax.plot([1000, 1500], [39, 39], color='k', marker='|') ax.text(0.47, 0.84, 'stop', transform=ax.transAxes, **{'color': 'k'}) ax.plot([500, 700], [30, 30], color='k', marker='|') ax.text(0.23, 0.67, '1st', transform=ax.transAxes, **{'color': 'k'}) ax.plot([1500, 1700], [30, 30], color='k', marker='|') ax.text(0.60, 0.67, '2nd', transform=ax.transAxes, **{'color': 'k'}) ax.set_xlim(misc.adjust_limit([0, sim_time])) ax.set_ylim(misc.adjust_limit([0, 45])) ax.set_ylabel('Firing rate SNr (spikes/s)')
def plot_rate_first_and_second_bursts_full(ax, x, data): colors = ['k'] max_delay = 3100 ax.text(0.1, 0.4, r'$\delta_{fac}^{MSN}$', fontsize=pylab.rcParams['text.fontsize'], transform=ax.transAxes, **{'color': colors[0]}) line1 = ax.plot(1, 1, '-k') line2 = ax.plot(1, 1, '-.k') leg = ax.legend([line1, line2], ['1st', '2nd'], loc='best') frame = leg.get_frame() frame.set_visible(False) ax.plot([0, max_delay], [SELECTION_THR] * len([0, max_delay]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.8, 0.3, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) ax.plot(x, data[0], **{'label': '1st', 'color': colors[0]}) ax.plot(x, data[1], **{ 'label': '2nd', 'color': colors[0], 'linestyle': '-.' }) ax.set_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Burst stop (ms)') ax.my_set_no_ticks(yticks=6, xticks=5) lines = ax.lines misc.slice_line(lines[2], xlim=[0, max_delay]) misc.slice_line(lines[3], xlim=[0, max_delay]) ax.set_xlim(misc.adjust_limit([0, max_delay])) ax.set_ylim(misc.adjust_limit([3, 10]))
def plot_selection_vs_neurons_full(ax, hzs, data): colors = ['m'] labels = [r'$\delta_{fac}^{MSN}$'] # , r'$\delta_{strong}^{MSN}$', # r'$\delta_{fac}^{MSN}$'] coords = [[0.03, 0.8]] #, [ 0.05, 0.07], [0.03, 0.50]] syn = SYNAPSE_MODELS_TESTED for id, label, color in zip([0], labels, colors): ax.plot(hzs, data[id]['msn_at_thr'][0], **{'color': color}) #for id, label, color in zip([0,1,2],labels,colors): # ax.plot(hzs,data[id]['msn_at_thr'][1],**{'color':color,'linestyle':'--'}) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 48]) ax.set_xlabel('Firing rate MSN (spikes/s)') ax.set_ylabel('Bursting MSNs at thr (#)') ax.my_set_no_ticks(yticks=8, xticks=6) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color}) line1 = ax.plot(1, 1, '-k') line2 = ax.plot(1, 1, '--k') leg = ax.legend( [line1, line2], ['First 100 ms of \nthe burst', 'Last 100 ms of \nthe burst'], loc='best') frame = leg.get_frame() #frame.set_visible(False) pylab.setp(frame, edgecolor='w') ltext = leg.get_texts() # all the text.Text instance in the legend pylab.setp(ltext, fontsize=10., backgroundcolor='w') ax.set_xlim(misc.adjust_limit([6, 48])) ax.set_ylim(misc.adjust_limit([0, 100]))
def plot_selection_vs_neurons_direct2(ax, data, title, ylim=[0, 34]): colors = ['k', 'k', 'k', 'k'] labels = [r'1 % bursting', r'2 % bursting', r'4 % bursting'] linestyles = ['-', '--', '-.', '.'] coords = [[0.4, 0.42], [0.02, 0.001], [0.15, 0.78]] for i, d in enumerate(data): c = 'k' lb = r'%i %s bursting' % (d[0][0], '%') ls = '--' x, y_mean, y_std = d.take([1, 2, 3], axis=0) ax.plot(x, y_mean, **{'color': c, 'label': lb, 'linestyle': ls}) ax.fill_between(x, y_mean - y_std, y_mean + y_std, facecolor=c, alpha=0.5) #x,y,dy=fit_pol(MSNmeanRates,SNRmeanRates[i,:]) #ax.plot(x,y,**{'color':color}) leg = ax.legend(loc='best') frame = leg.get_frame() frame.set_visible(False) ltext = leg.get_texts() # all the text.Text instance in the legend pylab.setp(ltext, fontsize=10.) ''' ax.plot([0,2.5],[SELECTION_THR]*len([0,2]),**{'color':[0.6,0.6,0.6], 'label':'', 'linewidth':1, 'linestyle':'--'}) ax.text( 0.8, 0.20,'Thr' , transform=ax.transAxes, **{ 'color' : [0.6,0.6,0.6]}) ''' ax.set_ylabel('Rate SNr (spikes/s)') ax.set_xlabel('Burst rate $MSN_{D1}$ (spikes/s)') ax.my_set_no_ticks(yticks=8, xticks=6) ax.set_title(title, fontsize=12) ax.set_xlim(misc.adjust_limit([15, 50])) ax.set_ylim(misc.adjust_limit(ylim)) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 50])
def plot_selection_vs_neurons(ax, GPEmeanRates, SNRmeanRates): colors=['r','c' ] labels=[r'$\delta_{ref}^{GPe}$' , r'$\delta_{dep}^{GPe}$'] coords=[[0.15, 0.6], [ 0.4, 0.17]] for i, color in enumerate(colors): ax.plot(GPEmeanRates,SNRmeanRates[i,:],**{'color':color}) vec=[0,100] ax.plot(vec,[SELECTION_THR]*len(vec),**{'color':[0.6,0.6,0.6], 'label':'', 'linewidth':1, 'linestyle':'--'}) ax.text( 0.05, 0.08,'Thr' , transform=ax.transAxes, **{ 'color' : [0.6,0.6,0.6]}) ax.set_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Firing rate GPe (spikes/s)') ax.my_set_no_ticks( yticks=8, xticks=8 ) SNRmr=SNRmeanRates[1,SNRmeanRates[1,:]<25] GPEmr=GPEmeanRates[SNRmeanRates[1,:]<25] GPEmr=GPEmr[SNRmr>=6.5] SNRmr=SNRmr[SNRmr>=6.5]+7 #x_arrow=GPEmr[-1] #y_arrow=SNRmr[-1] #ax.arrow(x_arrow, y_arrow, 0, -2, #width=1, head_width=3, head_starts_at_zero=True, #head_length=2,**{ 'color':'k'}) ax.set_xlim(misc.adjust_limit([0,100])) ax.set_ylim(misc.adjust_limit([0,110])) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0,100]) for label, coord, color in zip(labels,coords,colors): ax.text( coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color})
def plot_selection_vs_neurons_indirect2(ax, MSNmeanRates, SNRmeanRates): colors = ['b', 'g', 'r'] labels = [r'First 100 ms', r'250-350 ms', r'Last 100 ms'] coords = [[0.4, 0.42], [0.02, 0.001], [0.15, 0.78]] for i, color in enumerate(colors): ax.plot(MSNmeanRates, SNRmeanRates[i, :], **{ 'color': color, 'marker': '.', 'linestyle': '--' }) #x,y,dy=fit_pol(MSNmeanRates,SNRmeanRates[i,:]) #ax.plot(x,y,**{'color':color}) ax.plot([0, 2.5], [SELECTION_THR] * len([0, 2]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.8, 0.20, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) ax.set_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Firing rate $MSN_{D2}$ (spikes/s)') ax.my_set_no_ticks(yticks=8, xticks=6) ax.set_xlim(misc.adjust_limit([17, 50])) ax.set_ylim(misc.adjust_limit([34, 110])) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 50]) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=12, **{'color': color})
def plot_SNr_rate_std_vs_syn_event_x3_late(ax, hzs): colors = misc.make_N_colors('YlOrBr', 5)[2:] labels = ['%i Hz' % hzs[0], '%i Hz' % hzs[1], '%i Hz' % hzs[2]] coords = [[0.4, 0.52], [0.05, 0.22], [0.1, 0.74]] i_inverval = 1 # 0-100 ms i_syn = 2 # Plastic for hz, col in zip(hzs, colors): nb, rate_data, r_std_data, n_max_sel, s = simulate_selection_vs_neurons( SEL_INTERVALS, msn_burst_rate=hz, load=True) syn_events = nb * hz + (N_MSN - nb) * 0.1 ax.plot( syn_events, rate_data[i_inverval][i_syn, :] / r_std_data[i_inverval][i_syn, :], **{'color': col}) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=font_size_text, **{'color': color}) ax.set_ylabel('Signal to noise ratio') ax.set_xlabel('Input SNr (events/s)') lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, LIM_SYN_EVENTS]) ax.my_set_no_ticks(yticks=6, xticks=5) ax.set_xlim(misc.adjust_limit([50, LIM_SYN_EVENTS])) ax.set_ylim(misc.adjust_limit([0, 4])) ax.text(0.1, 0.85, 'Last 100 ms of the burst', transform=ax.transAxes, fontsize=font_size_text, **{'color': 'k'})
def plot_MSN_vs_SNR_const_syn_events(ax, nMSN_range, SNRmeanRates): colors = ['b', 'g', 'm'] labels = [ r'$\delta_{weak}^{MSN}$', r'$\delta_{strong}^{MSN}$', r'$\delta_{fac}^{MSN}$' ] coords = [[0.1, 0.68], [0.05, 0.12], [0.35, 0.45]] for i, color in enumerate(colors): ax.plot(nMSN_range, SNRmeanRates[i, :], **{'color': color}) ax.set_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Bursting MSN (#)') ax.my_set_no_ticks(yticks=7, xticks=6) lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, N_MAX_BURSTING]) ax.plot([0, N_MAX_BURSTING], [SELECTION_THR] * len([0, 2]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.1, 0.33, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color}) ax.set_xlim(misc.adjust_limit([0, N_MAX_BURSTING])) ax.set_ylim(misc.adjust_limit([0, 18]))
def plot_signal_rates(ax, hzs, rates): colors = ['b', 'm'] labels = [r'$\delta_{weak}^{MSN}$', r'$\delta_{fac}^{MSN}$'] coords = [[0.53, 0.49], [0.05, 0.21]] syn = DP['SYNAPSE_MODELS_TESTED'] for id, label, color in zip([0, 2], labels, colors): ax.plot(hzs, rates[:, id], **{'color': color}) ax.set_xlabel('Firing rate MSN burst (spikes/s)') ax.set_ylabel('Firing rate SNr (spikes/s)') ax.my_set_no_ticks(yticks=8, xticks=6) for label, coord, color in zip(labels, coords, colors): ax.text(coord[0], coord[1], label, transform=ax.transAxes, fontsize=pylab.rcParams['text.fontsize'], **{'color': color}) ax.set_yticks(hzs, hzs) ax.plot([min(hzs), max(hzs)], [DP['LOWER_THR']] * len([0, max(hzs)]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) #ax.text( 0.8, 0.11,'Thr' , transform=ax.transAxes, **{ 'color' : [0.6,0.6,0.6]}) ''' ax.semilogx([min(hzs), max(hzs)],[DP['UPPER_THR']]*len([0, max(hzs)]),**{'color':[0.6,0.6,0.6], 'label':'', 'linewidth':1, 'linestyle':'--'}) #ax.text( 0.8, 0.11,'Thr' , transform=ax.transAxes, **{ 'color' : [0.6,0.6,0.6]}) ''' lines = ax.lines for line in lines: misc.slice_line(line, xlim=[0, 48]) ax.set_xlim(misc.adjust_limit([0, 48])) ax.set_ylim(misc.adjust_limit([0, 30]))
def plot_example_snr(ax, SNR): time_bin = 20 signal = SNR[0].signals['spikes'] colors = ['k'] sim_time = 2500 signal.my_firing_rate(bin=time_bin, display=ax, kwargs={'color': colors[0]}) ax.my_set_no_ticks(yticks=6, xticks=7) lines = ax.lines for line in lines: line.set_xdata(line.get_xdata() - ADJUST_XDATA_MS) ax.plot([0, sim_time], [SELECTION_THR] * len([0, sim_time]), **{ 'color': [0.6, 0.6, 0.6], 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.9, 0.14, 'Thr', transform=ax.transAxes, **{'color': [0.6, 0.6, 0.6]}) misc.slice_line(lines[0], xlim=[0, sim_time]) ax.plot([1000, 1500], [39, 39], color='k', marker='|') ax.text(0.47, 0.84, 'stop', transform=ax.transAxes, **{'color': 'k'}) ax.plot([500, 700], [30, 30], color='k', marker='|') ax.text(0.23, 0.67, '1st', transform=ax.transAxes, **{'color': 'k'}) ax.plot([1500, 1700], [30, 30], color='k', marker='|') ax.text(0.60, 0.67, '2nd', transform=ax.transAxes, **{'color': 'k'}) ax.set_xlim(misc.adjust_limit([0, sim_time])) ax.set_ylim(misc.adjust_limit([0, 45])) ax.set_ylabel('Firing rate SNr (spikes/s)')
def plot_example_firing_frequency_GPE(ax, GPE_list): global ADJUST_XDATA_MS global N_GPE global N_SEL time_bin = 20 GPE_a = GPE_list[0] GPE_s = GPE_a.slice(GPE_a.ids[N_GPE - N_SEL:]) GPE_b = GPE_a.slice(GPE_a.ids[0:N_GPE - N_SEL]) for g in GPE_list[1:]: GPE_a.merge(g) GPE_s.merge(g.slice(g.ids[N_GPE - N_SEL:])) GPE_b.merge(g.slice(g.ids[0:N_GPE - N_SEL])) GPE_a.signals['spikes'].my_firing_rate(bin=time_bin, display=ax, kwargs={'color': 'k'}) GPE_s.signals['spikes'].my_firing_rate(bin=time_bin, display=ax, kwargs={'color': 'r'}) GPE_b.signals['spikes'].my_firing_rate(bin=time_bin, display=ax, kwargs={'color': 'b'}) ax.set_xlim(misc.adjust_limit([0, 1500])) ax.set_ylim(misc.adjust_limit([0, 50])) lines = ax.lines for line in lines: line.set_xdata(line.get_xdata() - ADJUST_XDATA_MS) misc.slice_line(lines[0], xlim=[0, 1490]) misc.slice_line(lines[1], xlim=[0, 1490]) misc.slice_line(lines[2], xlim=[0, 1490]) #ax.set_title('bin=%i'%(time_bin),**{'fontsize':12}) ax.set_ylabel('Firing rate GPe (spikes/s)') ax.my_set_no_ticks(yticks=6, xticks=5) ax.text(0.05, 0.75, 'Non-pausing GPe neurons', backgroundcolor='w', transform=ax.transAxes, **{'color': 'b'}) ax.text(0.05, 0.85, 'Pausing GPe neurons', backgroundcolor='w', transform=ax.transAxes, **{'color': 'r'}) ax.text(0.05, 0.65, 'Average over all', backgroundcolor='w', transform=ax.transAxes, **{'color': 'k'})