updated figure captions
This commit is contained in:
@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
|
||||
from scipy.stats import pearsonr, linregress, gaussian_kde
|
||||
from thunderlab.tabledata import TableData
|
||||
from pathlib import Path
|
||||
from spectral import whitenoise, diag_projection, peakedness
|
||||
from plotstyle import plot_style, labels_params, significance_str
|
||||
|
||||
|
||||
@@ -26,24 +27,24 @@ def sort_files(cell_name, all_files, n):
|
||||
return files, nums
|
||||
|
||||
|
||||
def plot_chi2(ax, s, data_file):
|
||||
def plot_chi2(ax, s, data_file, rate):
|
||||
fcutoff = 300
|
||||
data = np.load(data_file)
|
||||
n = data['n']
|
||||
alpha = data['alpha']
|
||||
freqs = data['freqs']
|
||||
pss = data['pss']
|
||||
dt_fix = 1 # 0.0005
|
||||
prss = np.abs(data['prss'])/dt_fix*0.5/np.sqrt(pss.reshape(1, -1)*pss.reshape(-1, 1))
|
||||
chi2 = np.abs(data['prss'])*0.5/np.sqrt(pss.reshape(1, -1)*pss.reshape(-1, 1))
|
||||
ax.set_visible(True)
|
||||
ax.set_aspect('equal')
|
||||
i0 = np.argmin(freqs < -300)
|
||||
i0 = np.argmin(freqs < -fcutoff)
|
||||
i0 = np.argmin(freqs < 0)
|
||||
i1 = np.argmax(freqs > 300)
|
||||
i1 = np.argmax(freqs > fcutoff)
|
||||
if i1 == 0:
|
||||
i1 = len(freqs)
|
||||
freqs = freqs[i0:i1]
|
||||
prss = prss[i0:i1, i0:i1]
|
||||
vmax = np.quantile(prss, 0.996)
|
||||
chi2 = chi2[i0:i1, i0:i1]
|
||||
vmax = np.quantile(chi2, 0.996)
|
||||
ten = 10**np.floor(np.log10(vmax))
|
||||
for fac, delta in zip([1, 2, 3, 4, 6, 8, 10],
|
||||
[0.5, 1, 1, 2, 3, 4, 5]):
|
||||
@@ -51,18 +52,22 @@ def plot_chi2(ax, s, data_file):
|
||||
vmax = fac*ten
|
||||
ten *= delta
|
||||
break
|
||||
pc = ax.pcolormesh(freqs, freqs, prss, vmin=0, vmax=vmax,
|
||||
pc = ax.pcolormesh(freqs, freqs, chi2, vmin=0, vmax=vmax,
|
||||
rasterized=True)
|
||||
if 'noise_frac' in data:
|
||||
ax.set_title('$c$=0\\,\\%', fontsize='medium')
|
||||
else:
|
||||
ax.set_title(f'$c$={100*alpha:g}\\,\\%', fontsize='medium')
|
||||
ax.set_xlim(0, 300)
|
||||
ax.set_ylim(0, 300)
|
||||
ax.set_xlim(0, fcutoff)
|
||||
ax.set_ylim(0, fcutoff)
|
||||
ax.set_xticks_delta(100)
|
||||
ax.set_yticks_delta(100)
|
||||
ax.set_xlabel('$f_1$', 'Hz')
|
||||
ax.set_ylabel('$f_2$', 'Hz')
|
||||
dfreqs, diag = diag_projection(freqs, chi2, 2*fcutoff)
|
||||
nli, nlif = peakedness(dfreqs, diag, rate, median=False)
|
||||
ax.text(0.95, 0.88, f'SI($r$)={nli:.1f}', ha='right', zorder=50,
|
||||
color='white', fontsize='medium', transform=ax.transAxes)
|
||||
cax = ax.inset_axes([1.04, 0, 0.05, 1])
|
||||
cax.set_spines_outward('lrbt', 0)
|
||||
if alpha == 0.1:
|
||||
@@ -75,14 +80,18 @@ def plot_chi2(ax, s, data_file):
|
||||
|
||||
|
||||
def plot_chi2_contrasts(axs, s, cell_name):
|
||||
print(f' {cell_name}')
|
||||
d = sims_path / f'baseline-{cell_name}.npz'
|
||||
data = np.load(d)
|
||||
rate = float(data['rate'])
|
||||
cv = float(data['cv'])
|
||||
print(f' {cell_name}: r={rate:3.0f}Hz, CV={cv:4.2f}')
|
||||
files, nums = sort_files(cell_name,
|
||||
sims_path.glob(f'chi2-split-{cell_name}-*.npz'), 1)
|
||||
plot_chi2(axs[0], s, files[-1])
|
||||
plot_chi2(axs[0], s, files[-1], rate)
|
||||
for k, alphastr in enumerate(['010', '030', '100']):
|
||||
files, nums = sort_files(cell_name,
|
||||
sims_path.glob(f'chi2-noisen-{cell_name}-{alphastr}-*.npz'), 2)
|
||||
plot_chi2(axs[k + 1], s, files[-1])
|
||||
plot_chi2(axs[k + 1], s, files[-1], rate)
|
||||
|
||||
|
||||
def plot_nli_cv(ax, s, data, alpha, cells):
|
||||
@@ -173,12 +182,10 @@ def plot_summary_contrasts(axs, s, cells):
|
||||
if __name__ == '__main__':
|
||||
s = plot_style()
|
||||
#labels_params(xlabelloc='right', ylabelloc='top')
|
||||
fig, axs = plt.subplots(6, 4, cmsize=(s.plot_width, 0.95*s.plot_width),
|
||||
height_ratios=[1, 1, 1, 1, 0, 1])
|
||||
fig, axs = plt.subplots(5, 4, cmsize=(s.plot_width, 0.95*s.plot_width),
|
||||
height_ratios=[3, 3, 3, 3, 0, 3])
|
||||
fig.subplots_adjust(leftm=7, rightm=9, topm=2, bottomm=3.5,
|
||||
wspace=1, hspace=0.7)
|
||||
for ax in axs.flat:
|
||||
ax.set_visible(False)
|
||||
wspace=1, hspace=0.5)
|
||||
print('Example cells:')
|
||||
for k in range(len(model_cells)):
|
||||
plot_chi2_contrasts(axs[k], s, model_cells[k])
|
||||
@@ -186,8 +193,8 @@ if __name__ == '__main__':
|
||||
fig.common_yticks(axs[k, :])
|
||||
fig.common_xticks(axs[:4, k])
|
||||
print()
|
||||
plot_summary_contrasts(axs[5], s, model_cells)
|
||||
fig.common_yticks(axs[5, :])
|
||||
plot_summary_contrasts(axs[4], s, model_cells)
|
||||
fig.common_yticks(axs[4, :])
|
||||
fig.tag(axs, xoffs=-4.5, yoffs=1.8)
|
||||
fig.savefig()
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user