def plot_example(ax, SNR): SNR.signals['V_m'].plot(display=ax, kwargs={'color': 'k'}) ax.set_xlim(misc.adjust_limit([0, 2000])) ax.set_ylim(misc.adjust_limit([-80, 30])) ax.my_set_no_ticks(yticks=3, xticks=6)
def plot_example_raster_MSN(ax, MSN_spikes_and_ids): global ADJUST_XDATA_MS global N_MSN_BURST global N_MSN colors = ['r', 'b'] for c, data in zip(colors, MSN_spikes_and_ids): ax.plot(data[:, 0], data[:, 1], ',', color=c) lines1 = ax.lines #ax_twinx.set_ylim([0,500]) ax.set_ylabel('MSN id') for line in lines1: line.set_xdata(line.get_xdata() - ADJUST_XDATA_MS) ax.set_xlim(misc.adjust_limit([0, 1500])) ax.set_ylim(misc.adjust_limit([0, N_MSN])) ax.my_set_no_ticks(yticks=6, xticks=5) ax.text(0.05, 0.05, 'Non-bursting MSNs', backgroundcolor='w', transform=ax.transAxes, **{'color': 'b'}) ax.text(0.05, 0.15, 'Bursting MSNs', backgroundcolor='w', transform=ax.transAxes, **{'color': 'r'})
def plot_IF(ax, I_vec, fIsi, mIsi, lIsi): color='g' ax.plot(I_vec, 1000./fIsi, **{'label':'First ISI', 'color':color, 'linestyle':'--'}) ax.plot(I_vec, 1000./lIsi, **{'label':'Steady-state ISI', 'color':color}) print 1000./lIsi[I_vec<100] print I_vec[I_vec<100] ax.my_set_no_ticks( yticks=8, xticks = 6 ) ax.set_xlabel('Current (pA)') ax.set_ylabel('Rate (spikes/s)') leg=ax.legend(numpoints=1, loc='upper left') ltext = leg.get_texts() # all the text.Text instance in the legend llines = leg.get_lines() # all the lines.Line2D instance in the legend frame = leg.get_frame() pylab.setp(ltext, fontsize=14) frame.set_visible(False) speed=numpy.diff(1000./lIsi)/numpy.diff(I_vec) #ax.text( 0.3, 0.02, 'Mean slope steady-state\nISI '+str(round(numpy.median(speed),2))+' Hz/pA', backgroundcolor='w', # transform=ax.transAxes,fontsize=10, **{ 'color' : color }) point=numpy.nonzero(I_vec==101)[0][0] ax.text( 0.6, 0.2, 'GPe', backgroundcolor='w', transform=ax.transAxes,fontsize=16, **{ 'color' : color }) ax.text( 0.6, 0.02, str(round(speed[point],2))+' Hz/pA', backgroundcolor='w', transform=ax.transAxes,fontsize=16, **{ 'color' : 'k' }) ax.plot(I_vec[point], 1000./lIsi[point],color=color, marker='.',markersize=10) ax.set_xlim(misc.adjust_limit([-100,300])) ax.set_ylim(misc.adjust_limit([0,260])) 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'$\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, 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_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_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_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_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_SNr_rate_vs_syn_event2(ax, syn_events, meanRates): colors = ['k'] ax.plot(syn_events, meanRates[1, :], **{ 'color': colors[0], 'linestyle': '-.' }) ax.set_ylabel('Firing rate SNr (spikes/s)') 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], ['Pausing subpopulation', 'Increased activity in \nall GPe neurons'], 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., backgroundcolor='w') ax.set_xlim(misc.adjust_limit([0, 800])) ax.set_ylim(misc.adjust_limit([20, 110]))
def plot_IV(ax, current, voltage): ax.plot(current, voltage, **{'color': 'k'}) ax.my_set_no_ticks(yticks=5, xticks=5) ax.set_xlabel('Current (pA)') ax.set_ylabel('Potential (mV)') ax.set_xlim(misc.adjust_limit([-150 - I_E, -90 - I_E])) ax.set_ylim(misc.adjust_limit([-80, -64]))
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'})
def plot_thr_prop(ax, thr_prop, rate_MSN): colors = ['m', 'm', 'b', 'g'] linstyles = ['-', '-', '--', '--'] 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]] for y, ls, c in zip(thr_prop, linstyles, colors): ax.plot(rate_MSN, y * 100.0, **{'color': c, 'linestyle': ls}) ax.set_xlabel(r'Rate $MSN_{D1}$ (spikes/s)') ax.set_ylabel(r'Bursting at thr (%)') colors = ['b', 'g', 'm'] labels = [ r'$ref_{init}^{MSN_{D1}}$', r'$ref_{max}^{MSN_{D1}}$', r'$fac^{MSN_{D1}}$', ] coords = [[0.4, 0.52], [0.05, 0.22], [0.1, 0.74]] 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}) colors = ['k', 'k'] labels = ['First 100 ms of the \nburst', 'Last 100 ms of the \nburst'] coords = [[0.3, 0.54], [0.3, 0.34]] 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}) #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],[, ], 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([-3, 30]))
def plot_SNR_rate(ax, d_SNR, d_SNR2, name='SNr'): d_SNR.extend(d_SNR2) colors = ['m', 'm', 'b', 'b'] linstyles = ['--', '-', '--', '-'] labels = [ 'Diffuse $MSN_{D2}$ \nwith $ref_{30 Hz}^{GPe}$', 'Diffuse $MSN_{D2}$ \nwith $dep^{GPe}$', 'Non-diffuse $MSN_{D2}$ \nwith $ref_{32 Hz}^{GPe}$' ] for d, c, ls in zip(d_SNR, colors, linstyles): y_mean = d[0][ADJUST_XDATA_MS:] y_std = d[1][ADJUST_XDATA_MS:] x = numpy.arange(1, len(y_mean) + 1) ax.plot(x, y_mean, **{'color': c, 'linestyle': ls}) ax.fill_between(x, y_mean - y_std, y_mean + y_std, facecolor=c, alpha=0.25) ax.text(0.05, 0.75, 'Diffuse $MSN_{D2}$ to \nGPe projection', fontsize=font_size_text, backgroundcolor='w', transform=ax.transAxes, **{'color': colors[0]}) ax.text(0.05, 0.85, 'Non-Diffuse $MSN_{D2}$ to \nGPe projection', fontsize=font_size_text, backgroundcolor='w', transform=ax.transAxes, **{'color': colors[2]}) 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_{30 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['font.size'], backgroundcolor='w') ax.set_ylim(misc.adjust_limit([10, 80])) ax.set_xlim(misc.adjust_limit([0, 1500])) ax.set_ylabel('Rate ' + name + ' (spikes/s)') ax.set_xlabel('Time (ms)') ax.my_set_no_ticks(yticks=6, xticks=8)
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_example_raster_GPE(ax, GPE_list): global ADJUST_XDATA_MS global N_GPE global N_SEL GPE = GPE_list[0] GPE.signals['spikes'].raster_plot(id_list=GPE[N_GPE - N_SEL:], display=ax, kwargs={ 'color': 'r', 'zorder': 1 }) GPE.signals['spikes'].raster_plot(id_list=GPE[0:N_GPE - N_SEL], display=ax, kwargs={ 'color': 'b', 'zorder': 1 }) lines = ax.lines #ax_twinx.set_ylim([0,500]) ax.set_ylabel('GPe id') for line in lines: line.set_xdata(line.get_xdata() - ADJUST_XDATA_MS) ax.set_xlim(misc.adjust_limit([0, 1700])) ax.set_ylim(misc.adjust_limit([0, N_GPE])) ax.my_set_no_ticks(yticks=6, xticks=5) ax.text(0.05, 0.35, 'GPe neurons with a pause', backgroundcolor='w', transform=ax.transAxes, **{'color': 'r'}) ax.text(0.05, 0.25, 'plus a burst', backgroundcolor='w', transform=ax.transAxes, **{'color': 'r'}) ax.text(0.05, 0.15, 'GPe neurons with no rate', backgroundcolor='w', transform=ax.transAxes, **{'color': 'b'}) ax.text(0.05, 0.05, 'change', backgroundcolor='w', transform=ax.transAxes, **{'color': 'b'})
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_selection_vs_neurons_hyperdirect2(ax, MSNmeanRates, SNRmeanRates, linestyle='-'): colors = ['b', 'g', 'r'] labels = [r'First 100 ms', r'250-350 ms', r'Last 100 ms'] coords = [[0.55, 0.05], [0.35, 0.7], [0.1, 0.45]] for i, color in enumerate(colors): ax.plot(MSNmeanRates, SNRmeanRates[i, :], **{ 'color': color, 'marker': '.', 'linestyle': 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]}) ''' line1 = ax.plot(1, 1, '-k') line2 = ax.plot(1, 1, '--k') leg = ax.legend( [line1, line2], [r'Static STN $\rightarrow$ SNr', r'Depressing STN $\rightarrow$ SNr'], 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_ylabel('Firing rate SNr (spikes/s)') ax.set_xlabel('Firing rate STN (spikes/s)') ax.my_set_no_ticks(yticks=8, xticks=6) ax.set_xlim(misc.adjust_limit([10, 36])) ax.set_ylim(misc.adjust_limit([25, 80])) 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_example_firing_rate_MSN(ax, layer, name, color='b', ylim=[]): time_bin = 20 signal = layer.signals['spikes'] #signal.my_firing_rate(bin=time_bin, display=ax, # kwargs={'color':color}) print name, 'CV:', numpy.mean(signal.cv_isi()) print name, 'mean:', signal.mean_rate() print name, 'std:', signal.mean_rate_std() 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] print spk_mean.shape time = numpy.arange(1, len(spk_mean) + 1) ax.plot(time, spk_mean) shift = 0 if layer.id_mod: print numpy.array(layer.id_mod) - layer.ids[0] - 1 spk_mean = numpy.mean( hist[numpy.array(layer.id_mod) - layer.ids[0], :] - shift, axis=0) spk_mean = misc.convolve(spk_mean, 50, 'triangle', single=True)[0] print spk_mean.shape time = numpy.arange(1, len(spk_mean) + 1) ax.plot(time, spk_mean, 'r') pylab.setp(ax.lines, linewidth=2.0) # Need to pu ti before generating legend ax.set_ylabel('Rate ' + name + ' (spikes/s)') ax.set_xlabel('Time (ms)') ax.my_set_no_ticks(yticks=6, xticks=5) ax.set_xlim(misc.adjust_limit([0, 1500])) ax.set_ylim(misc.adjust_limit(ylim)) ax.text(0.05, 0.65, 'Bursting \n$MSN_{D1}$', backgroundcolor='w', transform=ax.transAxes, fontsize=font_size_text, **{'color': 'r'}) ax.text(0.05, 0.85, 'Average \nover all', backgroundcolor='w', transform=ax.transAxes, fontsize=font_size_text, **{'color': 'b'}) for line in ax.lines: line.set_xdata(line.get_xdata() - 500)
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_const_syn_events(ax, nMSN_range, SNRmeanRates): colors = ['b', 'g', 'm'] linestyle = ['--', '--', '-'] labels = [ r'$ref_{init}^{MSN_{D1}}$', r'$ref_{max}^{MSN_{D1}}$', r'$fac^{MSN_{D1}}$' ] coords = [[0.1, 0.68], [0.05, 0.12], [0.35, 0.45]] for i, color in enumerate(colors): ax.plot(nMSN_range * 100.0, SNRmeanRates[i, :], **{ 'color': color, 'linestyle': linestyle[i] }) ax.set_ylabel('Rate SNr (spikes/s)') ax.set_xlabel('Percent bursting $MSN_{D1}$ (%)') 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, max(nMSN_range * 100.0)], [SELECTION_THR] * len([0, 2]), **{ 'color': 'k', 'label': '', 'linewidth': 1, 'linestyle': '--' }) ax.text(0.1, 0.33, 'Thr', transform=ax.transAxes, fontsize=pylab.rcParams['font.size'] - 2, **{'color': 'k'}) 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 ax.set_xlim(misc.adjust_limit([0, 4.2])) ax.set_ylim(misc.adjust_limit([-3, 23]))
def plot_IV(ax, current, voltage): color = 'b' ''' lower_limit=-55 upper_limit=-80 current=current[voltage<lower_limit] voltage=voltage[voltage<lower_limit] current=current[voltage>upper_limit] voltage=voltage[voltage>upper_limit] ''' current = current - current[-1] ax.plot(current, voltage, **{'color': color}) line = ax.lines ax.my_set_no_ticks(yticks=8, xticks=6) ax.set_xlabel('Current (pA)') ax.set_ylabel('Potential (mV)') #ax.set_xlim(misc.adjust_limit([-220-I_E,-110-I_E])) #ax.set_ylim(misc.adjust_limit([-80,limit])) df = my_nest.GetDefaults(NEURON_MODELS[0]) speed = numpy.diff(voltage) / numpy.diff(current / 1000.) mean_resistance = numpy.mean(speed) mean_membrane_time_constant = mean_resistance * df['C_m'] * 0.001 point = -15 ax.text(0.50, 0.75, str(round(speed[point])) + r' M$\Omega$', backgroundcolor='w', transform=ax.transAxes, fontsize=16, **{'color': 'k'}) ax.plot(current[point], voltage[point], color=color, marker='.', markersize=10) x = [current[point], current[point] - 100] y = [voltage[point], voltage[point] - (100) * speed[point] / 1000.] ax.plot(x, y, color=color, linestyle='--') ax.set_xlim(misc.adjust_limit([-200, 0])) ax.set_ylim(misc.adjust_limit([-85, -55])) pylab.setp(ax.lines, linewidth=2.0) # Need to pu ti before generating legend
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_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): 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_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_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_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()