def plot_example_snr(ax, SNR): time_bin = 500 colors = misc.make_N_colors('Blues', 5) colors = ['g', 'r', colors[1], colors[2], colors[3]] signal = SNR.signals['spikes'] signal.my_firing_rate(id_list=[SNR[0]], bin=time_bin, display=ax, kwargs={'color': colors[0]}) signal.my_firing_rate(id_list=[SNR[1]], bin=time_bin, display=ax, kwargs={'color': colors[1]}) signal.my_firing_rate(id_list=[SNR[2]], bin=time_bin, display=ax, kwargs={'color': colors[2]}) #signal.my_firing_rate(id_list=[SNR[3]], bin=time_bin, display=ax, # kwargs={'color':colors[3]}) #signal.my_firing_rate(id_list=[SNR[4]], bin=time_bin, display=ax, # kwargs={'color':colors[4]}) ax.my_set_no_ticks(yticks=4, xticks=4) ax.set_ylim([0, 40]) ax.text(7000, 33, 'Weak', **{'color': colors[0]}) ax.text(4000, 7, 'Strong', **{'color': colors[1]}) ax.text(7000, 24, 'Set 1', **{'color': colors[2]}) #ax.text( 7000, 20, 'Set 1+2' , **{ 'color' : colors[3] }) #ax.text( 7000, 16, 'Set 2' , **{ 'color' : colors[4] }) #ax.legend(('Weak','Strong','Data 1','Data 1+2','Data 2'), loc='best') ax.set_title('bin=%i' % (time_bin), **{'fontsize': 12}) ax.set_ylabel('Frequency SNr (Hz)')
def plot_selection_vs_neurons(ax, GPEmeanRates, SNRmeanRates): colors = misc.make_N_colors('Blues', 5) colors = ['g', 'r', colors[1], colors[2], colors[3]] ax.plot(GPEmeanRates, SNRmeanRates[0, :], **{ 'label': 'Weak', 'color': colors[0] }) ax.plot(GPEmeanRates, SNRmeanRates[1, :], **{ 'label': 'Strong', 'color': colors[1] }) ax.plot(GPEmeanRates, SNRmeanRates[2, :], **{ 'label': 'Data 1', 'color': colors[2] }) #ax.plot(GPEmeanRates,SNRmeanRates[3,:],**{'label':'Data 1+2','color':colors[3]}) #ax.plot(GPEmeanRates,SNRmeanRates[4,:],**{'label':'Data 3','color':colors[4]}) ax.set_ylabel('Frequency SNr (Hz)') ax.set_xlabel('Frequency GPEs (Hz)') ax.my_set_no_ticks(yticks=4, xticks=4) ax.set_ylim([0, 40]) #ax.set_xlim([0,1.4]) ax.text(0.7, 0.85, 'Weak', transform=ax.transAxes, **{'color': colors[0]}) ax.text(0.7, 0.75, 'Strong', transform=ax.transAxes, **{'color': colors[1]}) ax.text(0.7, 0.65, 'Set 1', transform=ax.transAxes, **{'color': colors[2]})
def plot_example_SNR(ax, SNR_list): time_bin = 100 colors = misc.make_N_colors('Blues', 5) colors = ['g', colors[1]] labels = ['static', 'plastic'] 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}) 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=4, xticks=4) ax.set_xlim([2000, 3500]) #ax.set_ylim([10,30]) #ax.text('Data 1') ax.text(0.05, 0.45, 'static', transform=ax.transAxes, **{'color': colors[0]}) ax.text(0.05, 0.25, 'plastic', transform=ax.transAxes, **{'color': colors[1]})
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_example_SNR(ax, SNR_list): time_bin = 5 colors = misc.make_N_colors('Blues', 5) colors = ['g', 'm'] labels = ['Ref', 'Dyn GPe'] SNR_list = [SNR_list[0], SNR_list[2]] 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.set_title('bin=%i' % (time_bin), **{'fontsize': 12}) ax.set_ylabel('Frequency SNr (Hz)') ax.set_xlabel('Time (ms)') #ax.set_ylim([0,55]) ax.my_set_no_ticks(yticks=4, xticks=4) ax.set_xlim([0, 500]) t_a = ax.transAxes ax.text(0.1, 0.45, 'Ref', transform=t_a, **{'color': colors[0]}) #ax.text( 0.05, 0.25, 'Strong' , transform=t_a, **{ 'color' : colors[1] }) ax.text(0.1, 0.35, 'Dyn GPe', transform=t_a, **{'color': 'm'})
def plot_example_firing_rate(ax, groups, name, color='b', ylim=[], ylabel=True, xlabel=False): time_bin=20 colors=misc.make_N_colors('gist_rainbow', len(groups)) #signal.my_firing_rate(bin=time_bin, display=ax, # kwargs={'color':color}) for group, col in zip(groups, colors): signal=group.signals['spikes'] 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, **{'color':col}) ax.set_ylabel('Firing rate '+name+'\n (spikes/s)', fontsize=12.,multialignment='center') ax.set_xlabel('Time (ms)') ax.my_set_no_ticks( yticks=6, xticks = 8 ) ax.set_ylim(ylim) ax.set_xlim([time[0],time[-1]]) ax.my_remove_axis( xaxis=not xlabel, yaxis=not ylabel )
def plot_max_freq(ax, frequencies, relativeFacilitation ): colors = misc.make_N_colors('Blues', 5) ax.plot(frequencies,relativeFacilitation[0,:],**{'label':'Data 1', 'color':colors[1]}) ax.set_ylabel('Pmax/P1') ax.set_xlabel('Frequency (Hz)') ax.my_set_no_ticks( yticks=4, xticks = 4 ) ax.text( 0.4, 0.4,'Set 1' , transform=ax.transAxes, **{ 'color' : colors[1] })
def plot_recovery(ax, revoceryTimes, relativeRecovery ): colors = misc.make_N_colors('Blues', 5) ax.plot(revoceryTimes,relativeRecovery[0,:],**{'label':'Data 1', 'color':colors[1]}) ax.set_ylabel('Prec/P1') ax.set_xlabel('Time (ms)') ax.my_set_no_ticks( yticks=4, xticks = 4 ) ax.text( 0.4, 0.5,'Set 1' , transform=ax.transAxes, **{ 'color' : colors[1] }) ax.text( 0.4, 0.4, 'Set 1+2' , transform=ax.transAxes, **{ 'color' : colors[2] }) ax.text( 0.4, 0.3, 'Set 2' , transform=ax.transAxes, **{ 'color' : colors[3] })
def plot_selection(ax, data, legend=True): #! Colors for spike voltage traces fo AMPA, NMDA and GANA (color 0, 1 and 2 in #! ``color_list``). color_map = 'Set1' no_colors = 6 color_list = misc.make_N_colors(cmap_name=color_map, N=no_colors) sel_dic = {0: [], 1: [], 2: []} for d in zip(*data): sel_dic[d[4]].append((d[0], d[1])) pprint.pprint(sel_dic) plot_prop = [(sel_dic[2], 'k.', 'No selection'), (sel_dic[0], 'ob', 'Selection'), (sel_dic[1], 'ys', 'Intermediate')] #! Create figure where figsize(width,height) and figure dimenstions window #! width = figsize(width) x dpi and window hight = figsize(hight) x dpi #fig=pylab.figure(figsize=(11, 10), dpi=50) #! [left, bottom, width, hight] #ax=pylab.axes([0.05, .25, .9, .7]) iter = 0 for cords, color_marker, sel in plot_prop: if cords != []: cords_zip = zip(*cords) ax.plot(cords_zip[0], cords_zip[1], color_marker, markersize=20, label=sel, zorder=2) iter += 1 # beautify #ax.axis([0.0, 48.0, 0, 48]) #ax.set_xlim(misc.adjust_limit([15, 80])) #ax.set_ylim(misc.adjust_limit([15,50])) #ax.set_aspect('equal', 'box') #ax.set_axes([0.1, 0.5, 0.7,0.1]) #ax.set_xticks((0, 4, 8, 12 ,16, 20, 24, 28,32,36,40)) #ax.set_yticks((0, 4, 8, 12 ,16, 20, 24, 28,32,36,40)) ax.grid(True) ax.set_ylabel('Burst rate (Spikes/s)') ax.set_xlabel('Bursting $MSN_{D1}$ (%)') if legend: ax.legend(numpoints=1, ncol=1, loc=[-1.3, 0.5], borderpad=.75) ax.my_set_no_ticks(yticks=8, xticks=4)
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_full(ax, hzs, data): colors = misc.make_N_colors('Blues', 5) colors = ['g', 'r', colors[1], colors[2], colors[3]] syn = SYNAPSE_MODELS ax.plot(hzs, data[syn[0]]['thrVec'], **{ 'label': 'Weak', 'color': colors[0] }) ax.plot(hzs, data[syn[1]]['thrVec'], **{ 'label': 'Strong', 'color': colors[1] }) ax.plot(hzs, data[syn[2]]['thrVec'], **{ 'label': 'Set 1', 'color': colors[2] }) ax.plot(hzs, data[syn[3]]['thrVec'], **{ 'label': 'Set 1+2', 'color': colors[3] }) ax.plot(hzs, data[syn[4]]['thrVec'], **{ 'label': 'Set 2', 'color': colors[4] }) ax.set_xlabel('Frequency GPE (Hz)') ax.set_ylabel('GPEs at thr (#)') ax.my_set_no_ticks(yticks=4, xticks=5) ax.set_xlim([0, 51]) ax.set_ylim([0, 75]) #ax.text('Data 1') ax.text(0.7, 0.85, 'Weak', transform=ax.transAxes, **{'color': colors[0]}) ax.text(0.7, 0.75, 'Strong', transform=ax.transAxes, **{'color': colors[1]}) ax.text(0.7, 0.65, 'Set 1', transform=ax.transAxes, **{'color': colors[2]}) ax.text(0.7, 0.55, 'Set 1+2', transform=ax.transAxes, **{'color': colors[3]}) ax.text(0.7, 0.45, 'Set 2', transform=ax.transAxes, **{'color': colors[4]})
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_selection_vs_neurons2(ax, nbNeurons, meanRates): colors = misc.make_N_colors('Blues', 5) colors = ['g', 'r', colors[1], colors[2], colors[3]] ax.plot(nbNeurons, meanRates[0, :], **{ 'label': 'Weak', 'color': colors[0] }) ax.plot(nbNeurons, meanRates[1, :], **{ 'label': 'Strong', 'color': colors[1] }) ax.plot(nbNeurons, meanRates[2, :], **{ 'label': 'Set 1', 'color': colors[2] }) ax.plot(nbNeurons, meanRates[3, :], **{ 'label': 'Set 1+2', 'color': colors[3] }) ax.plot(nbNeurons, meanRates[4, :], **{ 'label': 'Set 2', 'color': colors[4] }) ax.plot(nbNeurons, [SELECTIONTHR] * len(nbNeurons), '--k', **{'label': ''}) ax.set_ylabel('Frequency SNr (Hz)') ax.set_xlabel('GPEs (#)') ax.my_set_no_ticks(yticks=4, xticks=4) ax.set_xlim([0, 61]) ax.text(0.7, 0.85, 'Weak', transform=ax.transAxes, **{'color': colors[0]}) ax.text(0.7, 0.75, 'Strong', transform=ax.transAxes, **{'color': colors[1]}) ax.text(0.7, 0.65, 'Set 1', transform=ax.transAxes, **{'color': colors[2]}) ax.text(0.7, 0.55, 'Set 1+2', transform=ax.transAxes, **{'color': colors[3]}) ax.text(0.7, 0.45, 'Set 2', transform=ax.transAxes, **{'color': colors[4]})
def plot_example_snr(ax, SNR): time_bin=500 colors = misc.make_N_colors('Blues', 5) colors=['g','r', colors[1], 'b', colors[3]] signal=SNR.signals['spikes'] signal.my_firing_rate(id_list=[SNR[0]], bin=time_bin, display=ax, kwargs={'color':colors[0]}) signal.my_firing_rate(id_list=[SNR[1]], bin=time_bin, display=ax, kwargs={'color':colors[1]}) signal.my_firing_rate(id_list=[SNR[3]], bin=time_bin, display=ax, kwargs={'color':colors[3]}) ax.my_set_no_ticks( yticks=4, xticks = 4 ) ax.set_ylim([0,40]) ax.text( 6500, 33, 'Ref 1' , **{ 'color' : colors[0] }) ax.text( 4000, 7, 'Ref 2' , **{ 'color' : colors[1] }) ax.text( 6500, 24, 'Dyn MSN' , **{ 'color' : colors[3] }) ax.set_title('bin=%i'%(time_bin),**{'fontsize':12}) ax.set_ylabel('Frequency SNr (Hz)')
def plot_selection(ax, data, legend=True): #! Colors for spike voltage traces fo AMPA, NMDA and GANA (color 0, 1 and 2 in #! ``color_list``). color_map = 'Set1' no_colors = 6 color_list = misc.make_N_colors(cmap_name=color_map, N=no_colors) sel_dic = {0: [], 1: [], 2: []} for d in zip(*data): sel_dic[d[4]].append((d[0], d[1])) pprint.pprint(sel_dic) plot_prop = [(sel_dic[2], 'k.', 'No selection'), (sel_dic[0], 'ob', 'Selection'), (sel_dic[1], 'ys', 'Intermediate')] iter = 0 for cords, color_marker, sel in plot_prop: if cords != []: cords_zip = zip(*cords) ax.plot(cords_zip[0], cords_zip[1], color_marker, markersize=20, label=sel, zorder=2) iter += 1 ax.grid(True) ax.set_ylabel('Bursting $MSN_{D2}$ (%)') ax.set_xlabel('Bursting $MSN_{D1}$ (%)') if legend: ax.legend(numpoints=1, ncol=1, loc=[-1.3, 0.5], borderpad=.75) ax.my_set_no_ticks(yticks=8, xticks=4)
def plot_max_freq(ax, frequencies, relativeFacilitation): colors = misc.make_N_colors('Blues', 5) ax.plot(frequencies, relativeFacilitation[0, :], **{ 'label': 'Data 1', 'color': colors[1] }) ax.plot(frequencies, relativeFacilitation[1, :], **{ 'label': 'Data 1+2', 'color': colors[2] }) ax.plot(frequencies, relativeFacilitation[2, :], **{ 'label': 'Data 2', 'color': colors[3] }) ax.set_ylabel('Pmax/P1') ax.set_xlabel('Firing rate (spikes/s)') ax.my_set_no_ticks(yticks=4, xticks=4) ax.text(0.4, 0.4, 'Set 1', transform=ax.transAxes, **{'color': colors[1]}) ax.text(0.4, 0.3, 'Set 1+2', transform=ax.transAxes, **{'color': colors[2]}) ax.text(0.4, 0.2, 'Set 2', transform=ax.transAxes, **{'color': colors[3]})
def plot_example_raster(ax, groups, name, ylabel=True, xlabel=False): global ADJUST_XDATA_MS colors=misc.make_N_colors('gist_rainbow', len(groups)) for group, col in zip(groups, colors): group.signals['spikes'].raster_plot(display=ax, kwargs={'color':col, 'zorder':1}) lines = ax.lines ax.set_ylabel(name+' id') ax.my_set_no_ticks( yticks=6, xticks = 5 ) ax.set_ylim([groups[0].ids[0],groups[-1].ids[-1]]) for line in lines: line.set_xdata(line.get_xdata()-ADJUST_XDATA_MS) ax.set_xlim([0.,10500]) #ax.set_xlim(misc.adjust_limit([0,1500])) #if not ylabel: ax.set_ylabel('') #if not xlabel: ax.set_xlabel('') ax.my_remove_axis( xaxis=not xlabel, yaxis=not ylabel )
# MSN mean rate ax = ax_list[2] my_nest.ResetKernel() MSN = create_input_population(nInput, nRep=nRep, simTime=simTime) plot_input_mean_rate(ax, binSize=binSize, Input=MSN, nRep=nRep, nYticks=nb_yticks_sr, simTime=simTime) ax.set_xlim(tLim) # Example plots axes = [ax_list[3], ax_list[4], ax_list[5], ax_list[6], ax_list[7]] my_nest.ResetKernel() colors = misc.make_N_colors('Blues', 5) colors = ['g', 'r', colors[1], colors[2], colors[3]] plot_output_example(axes, colors, SNR_example_plot, useSynapses) # SNR mean rate ax = ax_list[8] labels = [ 'Weak static', 'Strong static', 'Plastic data I', 'Plastic data I+II', 'Plastic data II' ] plot_output_mean_rate(ax, binSize, colors, labels, nRep, SNR_mean_rate, nOutputPerSynapse, simTime, synapses) ax.legend(numpoints=1, loc=[1.1, 1.6]) ax = ax_list[8] ax.set_xlim(tLim)