diff --git a/ampullaryexamplecell.py b/ampullaryexamplecell.py index a5863b7..4cfdd8b 100644 --- a/ampullaryexamplecell.py +++ b/ampullaryexamplecell.py @@ -33,6 +33,18 @@ def plot_isih(ax, s, rate, cv, isis, pdf): transform=ax.transAxes) +def plot_isih2(ax, s, rate, cv, isis, pdf): + ax.show_spines('b') + ax.fill_between(1000*isis, pdf, facecolor=s.cell_color1) + ax.set_xlim(0, 20) + ax.set_xticks_delta(5) + ax.set_xticks_blank() + #ax.set_xlabel('ISI', 'ms') + ax.text(1, 1.1, f'CV$_{{\\rm base}}$={cv:.2f}', ha='right', + transform=ax.transAxes) + ax.text(1, 0.6, f'$r={rate:.0f}$Hz', ha='right', transform=ax.transAxes) + + def plot_response_spectrum(ax, s, eodf, rate, freqs, prr): rate_i = np.argmax(prr[freqs < 0.7*eodf]) eod_i = np.argmax(prr[freqs > 500]) + np.argmax(freqs > 500) @@ -170,15 +182,16 @@ if __name__ == '__main__': s.lsC2 = s.lsA2 s.psC1 = s.psA1 s.psC2 = s.psA2 - fig, (ax1, ax2, ax3) = plt.subplots(3, 1, height_ratios=[3, 0, 3, 0.5, 3], - cmsize=(s.plot_width, 0.8*s.plot_width)) + fig, (ax1, ax2, ax3) = \ + plt.subplots(3, 1, height_ratios=[3, 0, 3, 0.2, 4.5], + cmsize=(s.plot_width, 0.85*s.plot_width)) fig.subplots_adjust(leftm=8, rightm=9, topm=2, bottomm=4, - wspace=0.4, hspace=0.5) + wspace=0.4, hspace=0.4) axi, axp, axr = ax1.subplots(1, 3, width_ratios=[2, 3, 0, 10]) axg, axc1, axc2, axd = ax2.subplots(1, 4, wspace=0.4) axg = axg.subplots(1, 1, width_ratios=[1, 0.1]) axd = axd.subplots(1, 1, width_ratios=[0.2, 1]) - axs = ax3.subplots(1, 4, wspace=0.4) + axs = ax3.subplots(2, 4, wspace=0.4, hspace=0.2, height_ratios=[1, 4]) plot_isih(axi, s, rate, cv, isis, pdf) plot_response_spectrum(axp, s, eodf, rate, freqs, prr) @@ -205,19 +218,25 @@ if __name__ == '__main__': print('Additional example cells:') for k, (cell, run) in enumerate(example_cells): - eodf, rate, cv, _, _, _, _ = load_baseline(data_path, cell) + eodf, rate, cv, isis, pdf, _, _ = load_baseline(data_path, cell) fcutoff, contrast, freqs, gain, chi2 = load_spectra(data_path, cell, run) dfreqs, diag = diag_projection(freqs, chi2, 2*fcutoff) nli, nlif = peakedness(dfreqs, diag, rate, median=False) print(f' {cell:<22s}: run={run:2d}, fbase={rate:3.0f}Hz, CV={cv:.2f}, SI={nli:3.1f}') - pc = plot_chi2(axs[k], s, contrast, freqs, chi2, fcutoff, 1.2) - axs[k].set_title(f'$r={rate:.0f}$Hz, CV$_{{\\rm base}}$={cv:.2f}', fontsize='medium') - axs[k].text(0.95, 0.9, f'SI($r$)={nli:.1f}', ha='right', zorder=50, - color='white', fontsize='medium', - transform=axs[k].transAxes) - plot_colorbar(axs[-1], pc, 0.4) - fig.common_yticks(axs) - fig.tag(axs, xoffs=-3, yoffs=2) + plot_isih2(axs[0, k], s, rate, cv, isis, pdf) + pc = plot_chi2(axs[1, k], s, contrast, freqs, chi2, fcutoff, 1.2) + #axs[k].set_title(f'$r={rate:.0f}$Hz, CV$_{{\\rm base}}$={cv:.2f}', fontsize='medium') + axs[1, k].text(0.95, 0.9, f'SI($r$)={nli:.1f}', ha='right', zorder=50, + color='white', fontsize='medium', + transform=axs[1, k].transAxes) + axs[0, 0].text(0, 1.6, 'Ampullary cells:', transform=axs[0, 0].transAxes, + color=s.cell_color1, + fontsize='large') + axs[0, -1].text(1, 0, '5\\,ms', ha='right', + transform=axs[0, -1].transAxes) + plot_colorbar(axs[1, -1], pc, 0.4) + fig.common_yticks(axs[1, :]) + fig.tag([axs[0, :]], xoffs=-3, yoffs=1) fig.savefig() print() diff --git a/punitexamplecell.py b/punitexamplecell.py index 2b037c3..5d5b695 100644 --- a/punitexamplecell.py +++ b/punitexamplecell.py @@ -91,6 +91,18 @@ def plot_isih(ax, s, rate, cv, isis, pdf): transform=ax.transAxes) +def plot_isih2(ax, s, rate, cv, isis, pdf): + ax.show_spines('b') + ax.fill_between(1000*isis, pdf, facecolor=s.cell_color1) + ax.set_xlim(0, 20) + ax.set_xticks_delta(5) + ax.set_xticks_blank() + #ax.set_xlabel('ISI', 'ms') + ax.text(1, 1.1, f'CV$_{{\\rm base}}$={cv:.2f}', ha='right', + transform=ax.transAxes) + ax.text(1, 0.6, f'$r={rate:.0f}$Hz', ha='right', transform=ax.transAxes) + + def plot_response_spectrum(ax, s, eodf, rate, freqs, prr): rate_i = np.argmax(prr[freqs < 0.7*eodf]) eod_i = np.argmax(prr[freqs > 500]) + np.argmax(freqs > 500) @@ -222,15 +234,16 @@ if __name__ == '__main__': s.lsC2 = s.lsP2 s.psC1 = s.psP1 s.psC2 = s.psP2 - fig, (ax1, ax2, ax3) = plt.subplots(3, 1, height_ratios=[3, 0, 3, 0.5, 3], - cmsize=(s.plot_width, 0.8*s.plot_width)) + fig, (ax1, ax2, ax3) = \ + plt.subplots(3, 1, height_ratios=[3, 0, 3, 0.2, 4.5], + cmsize=(s.plot_width, 0.85*s.plot_width)) fig.subplots_adjust(leftm=8, rightm=9, topm=2, bottomm=4, - wspace=0.4, hspace=0.5) + wspace=0.4, hspace=0.4) axi, axp, axr = ax1.subplots(1, 3, width_ratios=[2, 3, 0, 10]) axg, axc1, axc2, axd = ax2.subplots(1, 4, wspace=0.4) axg = axg.subplots(1, 1, width_ratios=[1, 0.1]) axd = axd.subplots(1, 1, width_ratios=[0.2, 1]) - axs = ax3.subplots(1, 4, wspace=0.4) + axs = ax3.subplots(2, 4, wspace=0.4, hspace=0.2, height_ratios=[1, 4]) plot_isih(axi, s, rate, cv, isis, pdf) plot_response_spectrum(axp, s, eodf, rate, freqs, prr) @@ -257,19 +270,25 @@ if __name__ == '__main__': print('Additional example cells:') for k, (cell, run) in enumerate(example_cells): - eodf, rate, cv, _, _, _, _ = load_baseline(data_path, cell) + eodf, rate, cv, isis, pdf, _, _ = load_baseline(data_path, cell) fcutoff, contrast, freqs, gain, chi2 = load_spectra(data_path, cell, run) dfreqs, diag = diag_projection(freqs, chi2, 2*fcutoff) nli, nlif = peakedness(dfreqs, diag, rate, median=False) print(f' {cell:<22s}: run={run:2d}, fbase={rate:3.0f}Hz, CV={cv:.2f}, SI={nli:3.1f}') - pc = plot_chi2(axs[k], s, contrast, freqs, chi2, fcutoff, 1.3) - axs[k].set_title(f'$r={rate:.0f}$Hz, CV$_{{\\rm base}}$={cv:.2f}', fontsize='medium') - axs[k].text(0.95, 0.9, f'SI($r$)={nli:.1f}', ha='right', zorder=50, - color='white', fontsize='medium', - transform=axs[k].transAxes) - plot_colorbar(axs[-1], pc) - fig.common_yticks(axs) - fig.tag(axs, xoffs=-3, yoffs=2) + plot_isih2(axs[0, k], s, rate, cv, isis, pdf) + pc = plot_chi2(axs[1, k], s, contrast, freqs, chi2, fcutoff, 1.3) + #axs[k].set_title(f'$r={rate:.0f}$Hz, CV$_{{\\rm base}}$={cv:.2f}', fontsize='medium') + axs[1, k].text(0.95, 0.9, f'SI($r$)={nli:.1f}', ha='right', zorder=50, + color='white', fontsize='medium', + transform=axs[1, k].transAxes) + axs[0, 0].text(0, 1.6, 'P-units:', transform=axs[0, 0].transAxes, + color=s.cell_color1, + fontsize='large') + axs[0, -1].text(1, 0, '5\\,ms', ha='right', + transform=axs[0, -1].transAxes) + plot_colorbar(axs[1, -1], pc) + fig.common_yticks(axs[1, :]) + fig.tag([axs[0, :]], xoffs=-3, yoffs=1) fig.savefig() print()