def plot_fig_low(calcAna, calcAnaAll, figname=None): plt.rcParams['figure.figsize'] = (3.346, 2.55) plt.rcParams['ytick.labelsize'] = 10 plt.rcParams['xtick.labelsize'] = 10 plt.rcParams['font.size'] = 12 plt.rcParams['legend.fontsize'] = 6 # intialise figure fig = plt.figure() fig.subplots_adjust(wspace=0.2, hspace=0.6, top=0.85, bottom=0.09, left=0.18, right=0.83) ax = plt.subplot2grid((1, 1), (0, 0)) # get data data = get_sensitivity_measure(calcAna, calcAnaAll, mode='low', eig_index=6) fmax, Z, Z_amp, Z_freq, vec, vec_per, eigc = data # plot figure M_plot = [ph.reorder_matrix(Z_amp), ph.reorder_matrix(Z_freq)] M_title = [ r'$\mathbf{Z}^{\mathrm{amp}}(0\mathrm{Hz})$', r'$\mathbf{Z}^{\mathrm{freq}}(0\mathrm{Hz})$' ] zmin = np.min([Z_amp, Z_freq]) zmax = np.max([Z_amp, Z_freq]) z = np.max([abs(zmin), abs(zmax)]) im1 = ax.pcolor(M_plot[0], vmin=-z, vmax=z, cmap=plt.cm.coolwarm) ax.xaxis.tick_top() ax.set_xticks([0.5 + i for i in range(8)]) tpops = ph.populations tpops[0] = '2/3E ' ax.set_xticklabels(tpops, fontsize=9) ax.set_yticks([0.5 + i for i in range(8)]) ax.set_xlabel(M_title[0]) ax.set_title('sources\n', fontsize=12) ax.set_yticklabels(ph.populations[::-1], fontsize=9) ax.set_ylabel('targets', fontsize=12) per = 0.9 box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * per, box.height]) cbar_ax = fig.add_axes([box.x0 + box.width, box.y0, 0.04, box.height]) fig.colorbar(im1, cax=cbar_ax, ticks=[-2.0, -1.0, 0, 1.0, 2.0]) if figname is None: figname = 'sensitivity_measure_low.eps' plt.savefig(figname)
def plot_connectivity_matrix(Mred, ax): M = ph.reorder_matrix(Mred) im1 = ax.pcolor(M, cmap='Greys') ax.xaxis.tick_top() ax.set_xticks([0.5 + i for i in range(8)]) ax.set_xticklabels(ph.populations, fontsize=7) ax.set_yticks([0.5 + i for i in range(8)]) ax.set_yticklabels(ph.populations[::-1], fontsize=7) ax.set_title('sources\n', fontsize=10) ax.set_ylabel('targets', fontsize=10)
def plot_matrices_gamma(M_title, Z, ax, fig, panel, fontsize_pops=7, fontsize_title=9): M_plot = [ph.reorder_matrix(Z[0]), ph.reorder_matrix(Z[1])] zmin = np.min(Z) zmax = np.max(Z) z = np.max([abs(zmin), abs(zmax)]) for j, k in enumerate([3 * panel, 3 * panel + 1]): im1 = ax[k].pcolor(M_plot[j], vmin=-z, vmax=z, cmap=plt.cm.coolwarm) ax[k].xaxis.tick_top() ax[k].set_xticks([0.5 + i for i in range(8)]) ax[k].set_xticklabels(ph.populations, fontsize=fontsize_pops) ax[k].set_yticks([0.5 + i for i in range(8)]) ax[k].set_xlabel(M_title[j]) ax[k].set_title('sources\n', fontsize=fontsize_title) ax[0 + 3 * panel].set_yticklabels(ph.populations[::-1], fontsize=fontsize_pops) ax[1 + 3 * panel].set_yticklabels([]) ax[0 + 3 * panel].set_ylabel('targets', fontsize=fontsize_title) per = 0.9 dMx = 0.07 box = ax[0 + 3 * panel].get_position() ax[0 + 3 * panel].set_position( [box.x0, box.y0, box.width * per, box.height]) box = ax[1 + 3 * panel].get_position() ax[1 + 3 * panel].set_position([ box.x0 - box.width * (1 - per) - dMx, box.y0, box.width * per, box.height ]) box = ax[1 + 3 * panel].get_position() cbar_ax = fig.add_axes( [box.x0 + box.width + 0.1 * box.width, box.y0, 0.015, box.height]) fig.colorbar(im1, cax=cbar_ax, ticks=[-0.8, -0.4, 0, 0.4, 0.8])
def plot_fig_high_gamma(calcAna, calcAnaAll, figname=None): plt.rcParams['figure.figsize'] = (6.929, 3) plt.rcParams['ytick.labelsize'] = 8.5 plt.rcParams['xtick.labelsize'] = 8.5 plt.rcParams['font.size'] = 9 plt.rcParams['legend.fontsize'] = 6 nx = 2 ny = 4 # indices of dominant eigenmodes eig_index = [0, 1, 2, 3] # peak frequencies of dominant eigenmodes fps = [284, 267, 263, 241] # intialise figure fig = plt.figure() fig.subplots_adjust(wspace=0.2, hspace=0.6, top=0.9, bottom=0.07, left=0.065, right=0.97) ax = [] # panel A ax.append([plt.subplot2grid((nx, ny), (0, i)) for i in [0, 1]]) # panel B ax.append([plt.subplot2grid((nx, ny), (0, i)) for i in [2, 3]]) # panel C ax.append([plt.subplot2grid((nx, ny), (1, i)) for i in [0, 1]]) # panel D ax.append([plt.subplot2grid((nx, ny), (1, i)) for i in [2, 3]]) # loop over panels for n in range(4): data = get_sensitivity_measure(calcAna, calcAnaAll, mode='high_gamma', eig_index=eig_index[n]) fmax, Z, Z_amp, Z_freq, vec, vec_per, eigc = data M_plot = [ph.reorder_matrix(Z_amp), ph.reorder_matrix(Z_freq)] M_title = [ r'$\mathbf{Z}^{\mathrm{amp}}($' + str(fps[n]) + r'$\mathrm{Hz})$', r'$\mathbf{Z}^{\mathrm{freq}}($' + str(fps[n]) + r'$\mathrm{Hz})$' ] # normalise plots to dominant mode if n == 0: zmin = np.min([Z_amp, Z_freq]) zmax = np.max([Z_amp, Z_freq]) z = np.max([abs(zmin), abs(zmax)]) tax = ax[n] for k in [1, 0]: im1 = tax[k].pcolor(M_plot[k], vmin=-z, vmax=z, cmap=plt.cm.coolwarm) tax[k].xaxis.tick_top() tax[k].set_xticks([0.5 + i for i in range(8)]) tax[k].set_xticklabels(ph.populations, fontsize=6) tax[k].set_yticks([0.5 + i for i in range(8)]) tax[k].set_xlabel(M_title[k]) tax[k].set_title('sources\n', fontsize=9) tax[0].set_yticklabels(ph.populations[::-1], fontsize=6) tax[1].set_yticklabels([]) tax[0].set_ylabel('targets', fontsize=9) per = 0.9 dMx = 0.02 box = tax[0].get_position() tax[0].set_position([box.x0, box.y0, box.width * per, box.height]) box = tax[1].get_position() tax[1].set_position([ box.x0 - box.width * (1 - per) - dMx, box.y0, box.width * per, box.height ]) box = tax[1].get_position() if n % 2 == 1: cbar_ax = fig.add_axes([ box.x0 + box.width + 0.1 * box.width, box.y0, 0.015, box.height ]) fig.colorbar(im1, cax=cbar_ax, ticks=[-0.8, -0.4, 0, 0.4, 0.8]) for i, label in enumerate(['A', 'B', 'C', 'D']): box = ax[i][0].get_position() fig.text(box.x0 - 0.04, box.y0 + box.height + 0.03, label[0], fontsize=13, fontweight='bold') if figname is None: figname = 'sensitivity_measure_high_gamma.eps' plt.savefig(figname)
def plot_fig(calcData=False, calcAna=False, calcAnaAll=False): plt.rcParams['figure.figsize'] = (6.929, 6.0) plt.rcParams['ytick.labelsize'] = 12 plt.rcParams['xtick.labelsize'] = 12 plt.rcParams['font.size'] = 12 plt.rcParams['legend.fontsize'] = 10 nr_windows = 20 bin_size = 1.0 colors = ph.get_parameter_plot() nx = 5 ny = 4 fig = plt.figure() fig.subplots_adjust(wspace=0.1, hspace=0.1, top=0.93, bottom=0.185, left=0.1, right=0.97) ax = [] ax.append(plt.subplot2grid((nx,ny), (0,0),rowspan=3)) # column ax.append(plt.subplot2grid((nx,ny), (0,3),rowspan=2)) # in-degrees ax.append(plt.subplot2grid((nx,ny), (2,3))) # firing rates ax.append(plt.subplot2grid((nx,ny), (0,1), rowspan=3, colspan=2)) # dotplot ax.append([plt.subplot2grid((nx,ny), (nx-(2-i%2),i/2)) for i in range(8)]) # spectra ### panel A ### ax[0].axis('off') ### panel B ### times, gids = get_dotplot(calcData) box = ax[3].get_position() ax[3].set_position([box.x0+box.width*0.05, box.y0, box.width*0.85, box.height]) clrs=['0','0.5','0','0.5','0','0.5','0','0.5'] pop_sizes = circuit_params['N'] N_temp = 0 for j in range(8): # pick a gid in the middle green_gids = gids[j][np.argmin(abs(abs(gids[j]-77169)- (N_temp+pop_sizes[j]/2.)))] green_times = times[j][np.where(gids[j]==green_gids)] if j == 2: k = 0 while len(green_times) != 2: green_gid = gids[j][k] green_gids = [green_gid,green_gid] green_times = times[j][np.where(gids[j]==green_gid)] k += 1 if k == len(gids[j]): green_times = [green_times,green_times] break N_temp += pop_sizes[j] ax[3].plot(times[j], gids[j], 'o', ms=1, mfc=clrs[j], mec=clrs[j]) if len(green_times) >1: green_gids = [green_gids for i in range(len(green_times))] ax[3].plot(green_times, green_gids,'o',mfc='red',mec='red') # position labels size = 0 layer_labels = [] for layer in [3, 2, 1, 0]: layer_labels.append(sum(pop_sizes[2*layer:2*layer+2])/2. + size) size += sum(pop_sizes[2*layer:2*layer+2]) ax[3].set_xlim(0,50) ax[3].set_ylim(0,77169) ax[3].set_xlabel(r't (ms)') ax[3].set_yticks(layer_labels) ax[3].set_yticklabels(['L2/3','L4','L5','L6'][::-1]) ax[3].tick_params(axis='y',length=0) box = ax[3].get_position() ax[3].set_position([box.x0-box.width*0.07, box.y0, box.width, box.height]) ### panel C ### In = circuit_params['I'] M = ph.reorder_matrix(In) im1 = ax[1].pcolor(M, vmax=3000, cmap='OrRd') ax[1].xaxis.tick_top() ax[1].set_xticks([0.1, 1.45]+[0.5 + j for j in range(2,8)]) ax[1].set_xticklabels(ph.populations, fontsize=6) ax[1].set_yticks([0.5 + j for j in range(8)]) ax[1].set_yticklabels(ph.populations[::-1], fontsize=6) ax[1].tick_params(axis='x', which='both', top='off', labelbottom='off') ax[1].tick_params(axis='y', which='both', right='off', left='off', labelbottom='off') ax[1].set_title('sources\n',fontsize=11) ax[1].set_ylabel('targets',fontsize=11) box = ax[1].get_position() per = 0.88 cbar_ax = fig.add_axes([box.x0, box.y0*1.1, box.width, 0.015]) ax[1].set_position([box.x0, box.y0*1.15, box.width, box.height*0.7]) fig.colorbar(im1, orientation="horizontal", cax=cbar_ax, ticks=[0,3000]) ### panel D ### rates_sim, rates_calc = get_rates(calcData, calcAna, calcAnaAll) ax[2].bar(np.arange(8), rates_sim*1000,0.8, color=['black','grey','black','grey', 'black','grey','black','grey']) ax[2].plot(np.arange(8)+0.4, rates_calc, 'x', mew=2.5, ms=5, color='red') ax[2].set_xticks([1, 3, 5, 7]) ax[2].set_xticklabels(['L2/3', 'L4', 'L5', 'L6']) ax[2].set_yticks([2, 4, 6, 8]) ax[2].set_yticks([1, 3, 5, 7]) ax[2].set_ylabel(r'$\bar r$ (1/$s$)') ### panel E ### power, freq = get_spec_sim(calcData, nr_windows, bin_size) power_1w, freq_1w = get_spec_sim(calcData, 1, bin_size) freq_ana, power_ana = get_spec_ana(calcAna, calcAnaAll) for layer in [0, 1, 2, 3]: for pop in [0, 1]: j = layer*2+pop box = ax[4][j].get_position() ax[4][j].set_position([box.x0, box.y0-box.height*0.58, box.width, box.height]) ax[4][j].plot(freq_1w, power_1w[j], color=(0.8, 0.8, 0.8)) ax[4][j].plot(freq, power[j], color=(0.5, 0.5, 0.5)) ax[4][j].plot(freq_ana,np.sqrt(power_ana[j]), color='black', zorder=2) ax[4][j].set_xlim([10.0, 400.0]) ax[4][j].set_ylim([1e-6, 1e0]) ax[4][j].set_yscale('log') ax[4][j].set_yticks([]) ax[4][j].set_xticks([100, 200, 300]) ax[4][j].set_title(ph.populations[j]) if pop == 0: ax[4][j].set_xticklabels([]) else: box = ax[4][j].get_position() ax[4][j].set_position([box.x0, box.y0-box.height*0.2, box.width, box.height]) ax[4][j].set_xlabel(r'frequency (1/$s$)') ax[4][0].set_yticks([1e-5,1e-3,1e-1]) ax[4][1].set_yticks([1e-5,1e-3,1e-1]) ax[4][0].set_ylabel(r'$|C(\omega)|$') ax[4][1].set_ylabel(r'$|C(\omega)|$') for i,label in enumerate(['A','C','D','B','E']): if label == 'E': box = ax[i][0].get_position() else: box = ax[i].get_position() fig.text(box.x0-0.04, box.y0+box.height+0.015, label,fontsize=16, fontweight='bold') plt.savefig('microcircuit.eps')