diff --git a/fig1.py b/fig1.py index 4e78a34..a4c6b36 100644 --- a/fig1.py +++ b/fig1.py @@ -69,7 +69,7 @@ def quantum(ax1): Qval = np.zeros_like(tt) vals = Q_nak(tt, 30) Qval[int(150/dt):] += vals[:len(Qval[int(150/dt):])] - + lns = ax1.plot(tt, Qval, color='w', alpha=0) # fake line points = np.array([tt, Qval]).T.reshape(-1, 1, 2) segments = np.concatenate([points[:-1], points[1:]], axis=1) norm = plt.Normalize(0, 500) @@ -87,8 +87,10 @@ def quantum(ax1): empty_string_labels = [' ']*len(labels) ax1.set_yticklabels(empty_string_labels) ax1.plot(-25, 0, marker='*', c='k', clip_on=False, markersize=7.5, - markeredgecolor='none') + markeredgewidth=0.5, markeredgecolor='white', zorder=10) ax1.text(s='+Q', x=85, y=27.5, fontsize=7) + fp.add_arrow(lns[0], position=155, color='k', size=6.5) + fp.add_arrow(lns[0], position=300, color='k', size=6.5) ax1.set_xlim(-25, 500) @@ -137,8 +139,10 @@ def excursion(ax2): ax2.set_ylim(0, 1.) ax2.set_xticks([0, 0.5, 1]) ax2.set_yticks([0, 0.5, 1]) + ax2.set_xticklabels([0, '', 1]) + ax2.set_yticklabels([0, '', 1]) ax2.set_xlabel('$ATP_M$') - ax2.set_ylabel(r'$\Delta\psi$') + ax2.set_ylabel(r'$\Delta\psi$', rotation=0) return ax2 @@ -190,9 +194,9 @@ def ros_land(ax, cax=None): boxstyle=bstyle, alpha=0.5, zorder=10, facecolor='None', edgecolor='#d01c8b', linewidth=2) - ax.text(0.07, -.1, 'FETROS', + ax.text(0.07, .5, 'FETROS', fontsize=7, color='#d01c8b').set_clip_on(False) - ax.text(0.65, 0.45, 'RETROS', + ax.text(0.65, 1.05, 'RETROS', fontsize=7, color='#4dac26').set_clip_on(False) retbox.set_clip_on(False) fetbox.set_clip_on(False) @@ -203,8 +207,10 @@ def ros_land(ax, cax=None): ax.set_ylim(0, 1) ax.set_xticks([0, 0.5, 1]) ax.set_yticks([0, 0.5, 1]) + ax.set_xticklabels([0, '', 1]) + ax.set_yticklabels([0, '', 1]) ax.set_xlabel(r'$ATP_M$') - ax.set_ylabel(r'$\Delta\psi$') + ax.set_ylabel(r'$\Delta\psi$', rotation=0) return ax, surf @@ -318,35 +324,44 @@ def figure_steady_state_simpler(ax1): kANT_units = '10$^{-3}$/s' # half a column size is -figsize = fp.cm_to_inches([8.9, 13.]) +figsize = fp.cm_to_inches([8.9, 13.5]) fig = plt.figure(figsize=figsize) fig.set_constrained_layout_pads(w_pad=0, h_pad=0) gs = gridspec.GridSpec(3, 2, figure=fig, height_ratios=[1.35, 1.35, 1], width_ratios=[1, 1]) -gs22 = gridspec.GridSpecFromSubplotSpec(2, 1, subplot_spec=gs[1, 0], - hspace=0.1) - -ax_steadys = fig.add_subplot(gs[0, 0]) -ax_steadys = figure_steady_state_simpler(ax_steadys) -ax_steadys = fp.add_logticks(ax_steadys) - -ax_rosland = fig.add_subplot(gs[0, 1]) +ax_rosland = fig.add_subplot(gs[0, 0]) ax_rosland, surf = ros_land(ax_rosland, None) ax_rosland = plot_bl_curve(ax_rosland) -ax_rosss = fig.add_subplot(gs[2, 0]) +ax_rosss = fig.add_subplot(gs[0, 1]) ax_rosss = ros_ss(ax_rosss) ax_rosss.spines['top'].set_visible(False) ax_rosss.spines['right'].set_visible(False) ax_rosss = fp.add_logticks(ax_rosss) +ax_rosss.tick_params(axis='x', which='major', pad=3) + +ax_excursion = fig.add_subplot(gs[1, 0]) +excursion(ax_excursion) +gs22 = gridspec.GridSpecFromSubplotSpec(2, 1, subplot_spec=gs[1, 1], + hspace=0.1) ax_spikecost = fig.add_subplot(gs22[1, 0]) ax_fakespike = fig.add_subplot(gs22[0, 0], sharex=ax_spikecost) -ax_excursion = fig.add_subplot(gs[1, 1]) single_spike(ax_fakespike) quantum(ax_spikecost) -excursion(ax_excursion) + +ax_steadys = fig.add_subplot(gs[2, 0]) +ax_steadys = figure_steady_state_simpler(ax_steadys) +ax_steadys = fp.add_logticks(ax_steadys) +ax_steadys.tick_params(axis='x', which='major', pad=3) + +ax_compensate = fig.add_subplot(gs[2, 1]) +ax_compensate = metabolic_spikes(ax_compensate) +ax_compensate.spines['top'].set_visible(False) +ax_compensate.spines['right'].set_visible(False) +ax_compensate = fp.add_logticks(ax_compensate) +ax_compensate.tick_params(axis='x', which='major', pad=3) ax_fakespike.spines['top'].set_visible(False) ax_fakespike.spines['right'].set_visible(False) @@ -355,31 +370,36 @@ def figure_steady_state_simpler(ax1): ax_spikecost.spines['top'].set_visible(False) ax_spikecost.spines['right'].set_visible(False) -ax_compensate = fig.add_subplot(gs[2, 1]) -ax_compensate = metabolic_spikes(ax_compensate) -ax_compensate.spines['top'].set_visible(False) -ax_compensate.spines['right'].set_visible(False) -ax_compensate = fp.add_logticks(ax_compensate) -fp.align_axis_labels([ax_steadys, ax_fakespike, - ax_rosss], - axis='y', value=-0.15) -fp.align_axis_labels([ax_spikecost], axis='y', value=-0.02) +# ax_rosland, ax_rosss +# ax_excursion, ax_fakespike +# ax_excursion, ax_spikecost +# ax_steadys, ax_compensate -fp.align_axis_labels([ax_rosland, ax_excursion, +fp.align_axis_labels([ax_steadys, ax_excursion, + ax_rosland], + axis='y', value=-0.15) +fp.align_axis_labels([ax_rosss, ax_fakespike, ax_compensate], axis='y', value=-0.15) -fp.align_axis_labels([ax_steadys], - axis='x', value=-0.14) +fp.align_axis_labels([ax_spikecost], axis='y', value=-0.02) + +# fp.align_axis_labels([ax_rosland, ax_excursion, +# ax_compensate], +# axis='y', value=-0.15) + +# fp.align_axis_labels([ax_steadys, ax_compensate], +# axis='x', value=-0.2) + fp.align_axis_labels([ax_rosland], - axis='x', value=-0.14) + axis='x', value=-0.1) fp.align_axis_labels([ax_spikecost], axis='x', value=-0.28) fp.align_axis_labels([ax_excursion], axis='x', value=-0.14) gs.tight_layout(fig) -rect = 0.6, 0.65, 0.35, 0.01 +rect = 0.125, 0.67, 0.33, 0.01 cbaxes = fig.add_axes(rect) cb = plt.colorbar(surf, cax=cbaxes, orientation='horizontal', ticks=[0, 1]) diff --git a/fig2.py b/fig2.py index 24e7d54..0e9c2c3 100644 --- a/fig2.py +++ b/fig2.py @@ -243,7 +243,7 @@ def ret_cases_considered(gs0, firing_tests, theta_ret=0.025): make_raster_plot(ax0, ii*3, spk, spikes_offset, l_col) # Set limits if case.start is not False: - ax0.set_xlim(case.start-25, 1075) + ax0.set_xlim(case.start-25, 875) ax1.set_xlim(0, end_idx-start_idx) ax2.set_xlim(0, end_idx-start_idx) @@ -254,7 +254,7 @@ def ret_cases_considered(gs0, firing_tests, theta_ret=0.025): ax3.set_ylim(0.018, 0.027) ax3.plot([0, 20000], [theta_ret, theta_ret], lw=0.5, ls='--', color=fp.def_colors['ret'], zorder=-11) - ax3.text(6000, 0.025, s=r'$\theta_{RET}$', ha='right', + ax3.text(6500, 0.025, s=r'$\theta_{RET}$', ha='right', color=fp.def_colors['ret'], va='bottom', transform=ax3.transData, fontsize=7, clip_on=False) # # Ticks @@ -311,7 +311,7 @@ def ret_cases_considered(gs0, firing_tests, theta_ret=0.025): asb0 = AnchoredSizeBar(ax0.transData, int(50), '50 ms', - bbox_to_anchor=(0.89, -0.4), + bbox_to_anchor=(0.8, -0.1), bbox_transform=ax0.transAxes, loc=3, fontproperties=fontprops, pad=0., borderpad=.0, sep=2, @@ -323,7 +323,7 @@ def ret_cases_considered(gs0, firing_tests, theta_ret=0.025): asb1 = AnchoredSizeBar(ax1.transData, int(10*100), '10 ms', fontproperties=fontprops, - bbox_to_anchor=(0.9, -0.3), + bbox_to_anchor=(0.8, -0.1), bbox_transform=ax1.transAxes, loc=3, pad=0., borderpad=.0, sep=2, @@ -334,7 +334,7 @@ def ret_cases_considered(gs0, firing_tests, theta_ret=0.025): ymin, ymax = ax2.get_ybound() asb2 = AnchoredSizeBar(ax2.transData, int(10*100), - '10 ms', bbox_to_anchor=(0.9, -0.3), + '10 ms', bbox_to_anchor=(0.8, -0.1), bbox_transform=ax2.transAxes, loc=3, fontproperties=fontprops, pad=0., borderpad=.0, sep=2, @@ -345,7 +345,7 @@ def ret_cases_considered(gs0, firing_tests, theta_ret=0.025): ymin, ymax = ax3.get_ybound() asb3 = AnchoredSizeBar(ax3.transData, int(10*100), - '10 ms', bbox_to_anchor=(0.9, -0.8), + '10 ms', bbox_to_anchor=(0.8, -0.1), bbox_transform=ax3.transAxes, loc=3, fontproperties=fontprops, pad=0., borderpad=.0, sep=2, @@ -413,7 +413,7 @@ def fet_cases_considered(gs0, firing_tests, theta_fet): make_raster_plot(ax0, ii*3, spk, spikes_offset=0, l_col=l_col) # Set limits - ax0.set_xlim(0, 2000) + ax0.set_xlim(300, 1500) ax1.set_xlim(0, end_idx-start_idx) ax2.set_xlim(0, end_idx-start_idx) ax3.set_xlim(0, end_idx-start_idx) @@ -448,7 +448,7 @@ def fet_cases_considered(gs0, firing_tests, theta_fet): ax0.set_yticks([]) ax0.spines['left'].set_visible(False) # Labels - ax0.text(0.05, 0.85, s='Current clamp', transform=ax0.transAxes, + ax0.text(0.05, 0.9, s='Current \nclamp', transform=ax0.transAxes, ha='left', va='center', color='k', zorder=-1, clip_on=False) ax0.set_ylabel('Spikes') ax1.set_ylabel('ROS\n(a.u.)') @@ -478,44 +478,48 @@ def fet_cases_considered(gs0, firing_tests, theta_fet): asb0 = AnchoredSizeBar(ax0.transData, int(100), '100 ms', fontproperties=fontprops, - loc=3, bbox_to_anchor=(0.89, -0.3), + loc=3, bbox_to_anchor=(0.8, -0.1), bbox_transform=ax0.transAxes, pad=0., borderpad=.0, sep=2, frameon=False, label_top=False, size_vertical=(ymax-ymin)/1000) + asb0.set_clip_on(False) ax0.add_artist(asb0) ymin, ymax = ax1.get_ybound() asb1 = AnchoredSizeBar(ax1.transData, int(50*100), '50 ms', fontproperties=fontprops, - loc=3, bbox_to_anchor=(0.9, -0.6), + loc=3, bbox_to_anchor=(0.8, -0.1), bbox_transform=ax1.transAxes, pad=0., borderpad=.0, sep=2, frameon=False, label_top=False, size_vertical=(ymax-ymin)/1000) + asb1.set_clip_on(False) ax1.add_artist(asb1) ymin, ymax = ax2.get_ybound() asb2 = AnchoredSizeBar(ax2.transData, int(50*100), '50 ms', fontproperties=fontprops, - loc=3, bbox_to_anchor=(0.9, -0.3), + loc=3, bbox_to_anchor=(0.8, -0.1), bbox_transform=ax2.transAxes, pad=0., borderpad=.0, sep=2, frameon=False, label_top=False, size_vertical=(ymax-ymin)/1000) + asb2.set_clip_on(False) ax2.add_artist(asb2) ymin, ymax = ax3.get_ybound() asb3 = AnchoredSizeBar(ax3.transData, int(50*100), '50 ms', fontproperties=fontprops, - loc=3, bbox_to_anchor=(0.9, -0.5), + loc=3, bbox_to_anchor=(0.8, -0.1), bbox_transform=ax3.transAxes, pad=0., borderpad=.0, sep=2, frameon=False, label_top=False, size_vertical=(ymax-ymin)/1000) + asb3.set_clip_on(False) ax3.add_artist(asb3) print('FET') @@ -541,8 +545,11 @@ def metabolic_signal_plot(gs, theta_ret, theta_fet): ax00x, ax00y = ax00.get_xlim() ax00.spines['right'].set_color(ll[0].get_color()) ax00.tick_params(axis='y', colors=ll[0].get_color()) + ax00.set_ylabel('$\partial$ATP', labelpad=-22) + ax00.yaxis.label.set_color(ll[0].get_color()) + ax1.semilogx(bls, ms, lw=0.5, - color='k', label='MS=ROSx$\partial$ATP') + color='k', label='MS=ROS x $\partial$ATP') ax1.legend(frameon=True, handlelength=1, loc=9, borderaxespad=0, facecolor='white', framealpha=.0, edgecolor='white') ax1.plot([10, 100], [theta_ret, theta_ret], lw=0.5, @@ -555,23 +562,23 @@ def metabolic_signal_plot(gs, theta_ret, theta_fet): ax1.text(30, theta_fet, s=r'$\theta_{FET}$', ha='right', color=fp.def_colors['fet'], va='center', transform=ax1.transData, fontsize=7, clip_on=False) - ax0.plot([bls[K_idx], bls[K_idx]], - [0, atp_at_min], ls='--', lw=0.5, - color='gray', zorder=-1) - ax00.plot([bls[K_idx], 2000], - [0, 0], ls='--', lw=0.5, - color='gray', zorder=-1) + # ax0.plot([bls[K_idx], bls[K_idx]], + # [0, atp_at_min], ls='--', lw=0.5, + # color='gray', zorder=-1) + # ax00.plot([bls[K_idx], 2000], + # [0, 0], ls='--', lw=0.5, + # color='gray', zorder=-1) ax00.set_xlim(ax00x, ax00y) ax1.set_xlim(ax00x, ax00y) ax0.set_ylim(0, 1) ax0.set_yticks([0, 0.5, 1]) - ax0.set_yticklabels(['0', '', '1']) - ax0.set_ylabel('(a.u.)') + ax0.set_yticklabels(['0', '0.5', '1']) + ax0.set_ylabel('ROS level (a.u.)') ax00.spines['top'].set_visible(False) ax1.set_ylim([-0.3, 0.3]) ax1.set_yticks([-0.3, 0, 0.3]) ax1.set_yticklabels(['-0.3', '0', '0.3']) - ax1.set_ylabel('(a.u.)') + ax1.set_ylabel('MS (a.u.)') lns = lm+ll labs = [ll.get_label() for ll in lns] ax0.legend(lns, labs, frameon=False, handlelength=0.5, @@ -600,7 +607,9 @@ def clean_ax(axs): ax.spines['bottom'].set_visible(False) -def plot_summary(gs, fet_cases, ret_cases): +def plot_summary(gss, fet_cases, ret_cases): + # gs = gss[:, 2] + # gsx = gss[3, ] filename_prefix_ret = 'refrac_6_rise_0.6' filename_prefix_fet = 'iclamp2' data = np.load('./spike_compensation/spike_compensate_summary_' + @@ -615,14 +624,15 @@ def plot_summary(gs, fet_cases, ret_cases): for cc in range(4)]) mode_bounds = [0, 1, 2, 3, 4] mode_norm = colors.BoundaryNorm(mode_bounds, mode_cmap.N) - ax1 = plt.subplot(gs[0, 0]) - ax1.imshow(mode, origin='lower', cmap=mode_cmap, norm=mode_norm) + ax1 = plt.subplot(gs[2, 0]) + ax1.imshow(mode, origin='lower', aspect='auto', + cmap=mode_cmap, norm=mode_norm) for ii, case in enumerate(ret_cases): if ii > 0: xx = np.searchsorted(mito_baseline, case.bl, side='left') yy = np.searchsorted(spike_quanta, case.q, side='left') ax1.plot(xx, yy, marker='*', clip_on=False, - color=fp.ln_cols_ret[ii], markersize=5, + color=fp.ln_cols_ret[ii], markersize=7, markeredgecolor='k', markeredgewidth=0.3, zorder=10) fix_axis_ticks([ax1], mito_baseline, spike_quanta) @@ -637,16 +647,18 @@ def plot_summary(gs, fet_cases, ret_cases): for cc in [2, 3, 4]]) mode_bounds = [2, 3, 4, 5] mode_norm = colors.BoundaryNorm(mode_bounds, mode_cmap.N) - ax2 = plt.subplot(gs[0, 1]) - ax2.imshow(mode, origin='lower', cmap=mode_cmap, norm=mode_norm) + ax2 = plt.subplot(gs[2, 1]) + ax2.imshow(mode, origin='lower', aspect='auto', + cmap=mode_cmap, norm=mode_norm) for ii, case in enumerate(fet_cases): if ii < 2: xx = np.searchsorted(mito_baseline, case.bl, side='left') yy = np.searchsorted(spike_quanta, case.q, side='left') ax2.plot(xx, yy, marker='*', clip_on=False, - color=fp.ln_cols_fet[ii], markersize=5, + color=fp.ln_cols_fet[ii], markersize=7, markeredgecolor='k', markeredgewidth=0.3, zorder=10) - cax2 = plt.subplot(gs[1, :2]) + cax2 = plt.subplot(gs[3, :]) + # cax2 = plt.subplot(gs[1, :2]) cbar_labels = ['Continuous', 'Bursting', 'Regular', 'Silent', 'Adapting'] @@ -659,20 +671,26 @@ def plot_summary(gs, fet_cases, ret_cases): spacing='proportional', orientation='horizontal') for j, lab in enumerate(cbar_labels): - if j == 0: - cbar.ax.text(j+1, -8, lab, ha='right', - va='center', rotation=0, clip_on=False) - else: - cbar.ax.text(j+0.5, -8, lab, ha='center', - va='center', rotation=0, clip_on=False) + # if j == 0: + # cbar.ax.text(j+1, -8, lab, ha='right', + # va='center', rotation=0, clip_on=False) + # else: + cbar.ax.text(j+0.5, -8, lab, ha='center', + va='center', rotation=0, clip_on=False) cbar.ax.set_xticklabels([]) cbar.ax.tick_params(size=0) cbar.outline.set_visible(False) fix_axis_ticks([ax2], mito_baseline, spike_quanta) - ax2.set_yticklabels([]) + # ax2.set_yticklabels([]) ax1.set_ylabel('Per-spike cost (%s)' % kANT_units) - ax1.text(0.6, -0.25, 'Non-spiking costs (%s)' % kANT_units, - fontsize=7, color='k', transform=ax1.transAxes).set_clip_on(False) + ax2.set_ylabel('Per-spike cost (%s)' % kANT_units) + ax1.set_xlabel('Non-spiking costs (%s)' % kANT_units, + fontsize=7, color='k') + ax2.set_xlabel('Non-spiking costs (%s)' % kANT_units, + fontsize=7, color='k') + + # ax1.text(0.6, -0.25, 'Non-spiking costs (%s)' % kANT_units, + # fontsize=7, color='k', transform=ax1.transAxes).set_clip_on(False) return @@ -740,20 +758,20 @@ def __init__(self, bl, q, psi_fac=1e-5, refrac=6, if __name__ == '__main__': kANT_units = '10$^{-3}$/s' - figsize = fp.cm_to_inches([8.9, 15]) + figsize = fp.cm_to_inches([10, 17]) fig = plt.figure(figsize=figsize) fig.set_constrained_layout_pads(w_pad=0, h_pad=0) - gs = gridspec.GridSpec(4, 1, hspace=0.6, - height_ratios=[5, 7, 7, 7.5]) - gs0 = gridspec.GridSpecFromSubplotSpec(1, 2, wspace=0.5, - width_ratios=[1, 1], - subplot_spec=gs[0, 0]) + gs = gridspec.GridSpec(4, 2, hspace=1, + height_ratios=[2, 5, 2.5, 0.1]) + # gs0 = gridspec.GridSpecFromSubplotSpec(1, 2, wspace=1, + # width_ratios=[1, 1], + # subplot_spec=gs[0, :]) # MS map - metabolic_signal_plot(gs0, theta_ret=0.025, theta_fet=-0.05) + metabolic_signal_plot(gs, theta_ret=0.025, theta_fet=-0.05) # # # # ret cases - gs1 = gridspec.GridSpecFromSubplotSpec(4, 1, hspace=0.5, - height_ratios=[1.5, 1, 1, 1], + gs1 = gridspec.GridSpecFromSubplotSpec(4, 1, + height_ratios=[1.25, 1, 1, 1], subplot_spec=gs[1, 0]) at_min = TestBLCases(bl=30, q=13, test_type='ret', @@ -770,9 +788,9 @@ def __init__(self, bl, q, psi_fac=1e-5, refrac=6, ret_cases_considered(gs1, ret_cases) # fet cases - gs2 = gridspec.GridSpecFromSubplotSpec(4, 1, hspace=0.5, - height_ratios=[1.5, 1, 1, 1], - subplot_spec=gs[2, 0]) + gs2 = gridspec.GridSpecFromSubplotSpec(4, 1, + height_ratios=[1.25, 1, 1, 1], + subplot_spec=gs[1, 1]) at_min = TestBLCases(bl=80, q=13, test_type='fet', align_spike_at=700.0, title_text='80,13') @@ -782,13 +800,13 @@ def __init__(self, bl, q, psi_fac=1e-5, refrac=6, fet_cases = [at_max_q, at_min] fet_cases_considered(gs2, fet_cases, theta_fet=-0.05) - gs3 = gridspec.GridSpecFromSubplotSpec(2, 3, wspace=0.075, hspace=0.6, - width_ratios=[1, 1, 1], - height_ratios=[7, 0.5], - subplot_spec=gs[3, 0]) - plot_summary(gs3, fet_cases, ret_cases) + # gs3 = gridspec.GridSpecFromSubplotSpec(2, 2, hspace=0.6, + # width_ratios=[1, 1], + # height_ratios=[7, 0.5], + # subplot_spec=gs[2, :]) + plot_summary([gs], fet_cases, ret_cases) gs.tight_layout(fig) - plt.savefig('Figure2.png', dpi=300, transparent=False) + plt.savefig('Figure2n.png', dpi=300, transparent=False) # plt.show() diff --git a/fig3_dfb.py b/fig3_dfb.py old mode 100644 new mode 100755 index ffd88b1..751e45b --- a/fig3_dfb.py +++ b/fig3_dfb.py @@ -75,10 +75,26 @@ def ros_ss(ax, ross, cases, atp_bl): fp.def_colors['minisog'], fp.def_colors['aox']] - ax.plot(bls, these_ros[0], label=cases[0], lw=0.5, c=case_clrs[0]) - ax.plot(bls, these_ros[1], label=cases[1], lw=0.5, c=case_clrs[1]) - ax.plot(bls, these_ros[2], label=cases[2], lw=0.5, c=case_clrs[2]) - + xy_leftbox = [1, 0] + p = Rectangle(xy_leftbox, bls[48]-0.1, 1, clip_on=False, + edgecolor='none', facecolor='#dcdcdc', alpha=0.5) + ax.add_patch(p) + xy_leftbox = [bls[72], 0] + p = Rectangle(xy_leftbox, bls[-1], 1, clip_on=False, + edgecolor='none', facecolor='#dcdcdc', alpha=0.5) + ax.add_patch(p) + + ax.plot(bls[:49], these_ros[0][:49], lw=0.5, c='k', ls='-.') + ax.plot(bls[72:], these_ros[0][72:], lw=0.5, c='k', ls='-.') + # ax.plot(bls[:49], these_ros[0][:49], lw=0.7, c='gray', ls=(0, (1, 10))) + # ax.plot(bls[72:], these_ros[0][72:], lw=0.7, c='gray', ls=(0, (1, 10))) + ax.plot(bls[49:72], these_ros[0][49:72], label=cases[0], lw=0.5, c=case_clrs[0]) + ax.plot(bls[49:72], these_ros[0][49:72], label=' ', lw=0.5, c='white', alpha=0) + ax.plot(bls[49:72], these_ros[1][49:72], label=cases[1], lw=0.5, c=case_clrs[1]) + ax.plot(bls[49:72], these_ros[2][49:72]-0.05, label=cases[2], lw=0.5, c=case_clrs[2]) + + + leg1 = plt.legend(bbox_to_anchor=(-0.4, 0.9, 0.4, 0.2), bbox_transform=ax.transAxes, frameon=False, loc='lower left', @@ -86,26 +102,39 @@ def ros_ss(ax, ross, cases, atp_bl): cnt_ros = ross[0](atp(atp_bl[0]), psi(atp_bl[0])) sog_ros = ross[1](atp(atp_bl[0]), psi(atp_bl[0])) aox_ros = ross[2](atp(atp_bl[0]), psi(atp_bl[0])) - - ax.plot((atp_bl[0], atp_bl[0]), (0, sog_ros), c='gray', ls='--', lw=0.5) - ax.plot((0, atp_bl[0]), (cnt_ros, cnt_ros), c='k', ls='--', lw=0.5) - ax.plot((0, atp_bl[0]), (sog_ros, sog_ros), - c=fp.def_colors['minisog'], ls='--', lw=0.5) - ax.plot((0, atp_bl[0]), (cnt_ros, aox_ros), - c=fp.def_colors['aox'], ls='--', lw=0.5) - + sd_ros = ross[0](atp(10), psi(10)) + + # # draw vertical lines + # ax.plot((atp_bl[0], atp_bl[0]), (0, sog_ros), c='gray', ls='--', lw=0.5) + # ax.plot((10, 10), (0, sd_ros), c=fp.def_colors['SD'], + # ls='--', lw=0.5) + # ax.plot((0, atp_bl[0]), (cnt_ros, cnt_ros), c='k', ls='--', lw=0.5) + # ax.plot((0, atp_bl[0]), (sog_ros, sog_ros), + # c=fp.def_colors['minisog'], ls='--', lw=0.5) + # ax.plot((0, atp_bl[0]), (cnt_ros, aox_ros), + # c=fp.def_colors['aox'], ls='--', lw=0.5) + + # ax.annotate('', (atp_bl[0], cnt_ros), xytext=(10, cnt_ros), + # textcoords='data', xycoords='data', + # arrowprops=dict(facecolor='black', shrink=0.01), + # horizontalalignment='right', verticalalignment='top') + ax.plot(atp_bl[0], -0.1, marker='*', c='k', clip_on=False, markersize=7, markeredgewidth=0.5, markeredgecolor='none') - ax.plot(70, -0.1, marker='*', clip_on=False, markersize=7, c='gold', + # ax.plot(70, -0.1, marker='*', clip_on=False, markersize=7, c='gold', + # markeredgecolor='k', markeredgewidth=0.5, zorder=10) + ax.plot(70, -0.1, marker='*', clip_on=False, markersize=7, c='#ff8c00', markeredgecolor='k', markeredgewidth=0.5, zorder=10) ax.plot(10, -0.1, marker='*', clip_on=False, markersize=7, c=fp.def_colors['SD'], markeredgecolor='k', markeredgewidth=0.5, zorder=10) + ax.set_ylim(-0.1, 1.1) ax.set_yticks([0., .5, 1]) ax.set_xscale('log') ax.set_xlabel('Non-spiking costs (%s)' % kANT_units) ax = fp.add_logticks(ax) + ax.tick_params(axis='x', which='major', pad=3) ax.set_ylabel(r'ROS level (a.u.)') plt.gca().add_artist(leg1) return ax @@ -132,7 +161,8 @@ def voltage_trace(ax, ff_sleep=0.7, ff_awake=0): ikas_awake[i] = I_KA(y[i-1], aj[i], bj[i], cj[i], f=ff_awake) ikas_sleep[i] = I_KA(y[i-1], aj[i], bj[i], cj[i], f=ff_sleep) norm_max = max(max(ikas_awake), max(ikas_sleep)) - ax.plot(t, ikas_awake/norm_max, lw=0.5, color='gold', label='Inactivating') + # ax.plot(t, ikas_awake/norm_max, lw=0.5, color='gold', label='Inactivating') + ax.plot(t, ikas_awake/norm_max, lw=0.5, color='#ff8c00', label='Inactivating') ax.plot(t, ikas_sleep/norm_max, lw=0.5, color='k', label='Non inactivating') ax.legend(frameon=False, loc=9, ncol=1, handlelength=0.7) @@ -235,7 +265,8 @@ def plot_membpot(ax, ff, clamp, t, mem_pots_dict): y = mem_pots_dict[clamp] if ff == 0: label = 'Inactivating' - color = 'gold' + # color = 'gold' + color = '#ff8c00' axs = True else: label = 'Non inactivating' diff --git a/fig3_nw.py b/fig3_nw.py index d15bcde..ca317d1 100644 --- a/fig3_nw.py +++ b/fig3_nw.py @@ -63,7 +63,10 @@ def summary_spikes(total_neurons, sim_time, times, nidx, M, dict_key, gs0 = gridspec.GridSpecFromSubplotSpec(1, 4, wspace=0.4, hspace=0.3, width_ratios=[1, 1, 1, 1], subplot_spec=gs[5, :]) - gs1 = gridspec.GridSpecFromSubplotSpec(1, 3, wspace=0.4, hspace=0., + # gs1 = gridspec.GridSpecFromSubplotSpec(1, 4, wspace=0.4, hspace=0.3, + # width_ratios=[1, 1, 1, 1], + # subplot_spec=gs[6, :]) + gs1 = gridspec.GridSpecFromSubplotSpec(1, 3, wspace=0.4, hspace=0, width_ratios=[1, 1, 1], subplot_spec=gs[6, :]) ax4 = plt.subplot(gs0[0, 0]) # Average fr @@ -74,6 +77,8 @@ def summary_spikes(total_neurons, sim_time, times, nidx, M, dict_key, ax8 = plt.subplot(gs1[0, 0]) # Avalanches time ax9 = plt.subplot(gs1[0, 1]) # Avalanches pop ax91 = plt.subplot(gs1[0, 2]) # Avalanches space + # ax10 = plt.subplot(gs1[0, 2]) # ISI vs FR + # ax11 = plt.subplot(gs1[0, 3]) # ISI_n vs ISI_n+1 times_zoom = times[np.logical_and((times >= start_time), (times < end_time))] nidx_zoom = nidx[np.logical_and((times >= start_time), (times < end_time))] @@ -345,18 +350,49 @@ def summary_spikes(total_neurons, sim_time, times, nidx, M, dict_key, ax9.set_ylabel('P(S)', loc='top', rotation=0, labelpad=-12) ax9.set_xticks([1, 100, 10000, 1000000]) ax9.set_ylim([2*10**-7, 2*10**0]) - #ax9.set_yticks([10**-4, 10**-2, 10**0]) + # # Plot ISI vs FR, ISI(n) vs ISI(n+1) + # frate_sh = opt_dicts[1]['avg_fr'] + # train_isi_sh = opt_dicts[1]['train_isi'] + # inds_sh = np.argsort(frate_sh) + + # all_spikes_x = [] + # all_spikes_y = [] + # th = [] + # ys = [] + # for ii in range(10000): + # tt = train_isi[inds_sh[9999-ii]] + # th.append(tt) + # ys.append([ii]*len(tt)) + # all_spikes_x.append(train_isi_sh[ii][:-1]) + # all_spikes_y.append(train_isi_sh[ii][1:]) + # th = np.hstack(th) + # ys = np.hstack(ys) + # all_spikes_x = np.hstack(all_spikes_x) + # all_spikes_y = np.hstack(all_spikes_y) + # ax10.scatter(th, ys, c='k', marker=',', + # alpha=0.025, s=0.08) + # ax10.set_xscale('log') + # ax10.set_xlabel('ISI (ms)') + # ax10.set_ylabel('Neuron idx') + # ax11.scatter(all_spikes_x, all_spikes_y, c='k', + # alpha=0.025, s=0.08, marker=',') + # ax11.set_xscale('log') + # ax11.set_yscale('log') + # ax11.set_xlabel(r'ISI$_n$ (ms)') + # ax11.set_ylabel(r'ISI$_(n+1)$ (ms)') + + avaln_s = opt_dicts[1]['avalns'] avaln_t = opt_dicts[1]['avalns_t'] + # logx = np.log10(avaln_t) # logy = np.log10(avaln_s) # coeffs = np.polyfit(logx, logy, deg=3) # poly = np.poly1d(coeffs) # yfit = lambda x: 10**(poly(np.log(x))) # ax91.loglog(avaln_t, yfit(avaln_t), lw=0.5, color='k') - ax91.loglog(avaln_t, avaln_s, color='k', markersize=1, marker='o', - linestyle='None') + # slope = opt_dicts[1]['beta_fit'][0] # intercept = opt_dicts[1]['beta_fit'][1] # test_pts = [1, 1000] @@ -366,19 +402,26 @@ def summary_spikes(total_neurons, sim_time, times, nidx, M, dict_key, # horizontalalignment='left', # verticalalignment='center', # transform=ax91.transAxes, color='k') + + ax91.loglog(avaln_t, avaln_s, color='k', markersize=1, marker='o', + linestyle='None') ax91.set_ylabel('Avalanche size') ax91.set_xlabel('Avalanche dur.\n(ms)') ax91.set_xticks([1, 10, 100, 1000]) ax91.set_yticks([1, 100, 10000, 1000000]) + # ax9.set_xticks([1, 100, 10000, 1000000]) # ax9.set_ylim([2*10**-7, 2*10**0]) # ax9.set_yticks([10**-4, 10**-2, 10**0]) # ax3c.plot([0, 100], [0, 100]) - gs.tight_layout(fig) + + gs.tight_layout(fig) align_axis_labels([ax4, ax5, ax6, ax7], axis='x', value=-0.3) # align_axis_labels([ax8, ax9, ax91], axis='x', value=-0.5) neat_axs([ax0, ax1, ax2, ax3, ax3c, ax4, ax5, ax6, ax7, ax8, ax9, ax91]) + # neat_axs([ax0, ax1, ax2, ax3, ax3c, + # ax4, ax5, ax6, ax7, ax8, ax9, ax10, ax11]) # ax91]) if len(filename) > 0: plt.savefig(filename, dpi=300) diff --git a/fig4.py b/fig4.py index 897d227..e8ac43c 100644 --- a/fig4.py +++ b/fig4.py @@ -12,7 +12,7 @@ import matplotlib.pyplot as plt from matplotlib import gridspec from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar - +from matplotlib.patches import Rectangle def run_sim(mito_baseline, spike_quanta, ros, time, dt, i_inj=None, Q_nak_def=Q_nak, psi_fac=0.1e-4): @@ -197,15 +197,30 @@ def ros_sss(ax, ross, cases, atp_bl): ros1_vals[ii] = ros(atp(bl), psi(bl)) these_ros.append(ros1_vals) case_clrs = ['k', fp.def_colors['park1']] + + xy_leftbox = [1, 0] + p = Rectangle(xy_leftbox, bls[46]-0.1, 1, clip_on=False, + edgecolor='none', facecolor='#dcdcdc', alpha=0.5) + ax.add_patch(p) + xy_leftbox = [bls[80], 0] + p = Rectangle(xy_leftbox, bls[-1], 1, clip_on=False, + edgecolor='none', facecolor='#dcdcdc', alpha=0.5) + ax.add_patch(p) + for ii, rr in enumerate(these_ros): - ax.plot(bls, rr, label=cases[ii], lw=0.5, + ax.plot(bls[46:80], rr[46:80], label=cases[ii], lw=0.7, c=case_clrs[ii]) + ax.plot(bls[:45], rr[:45], lw=0.5, + c=case_clrs[ii], ls='-.') + ax.plot(bls[81:], rr[81:], lw=0.5, + c=case_clrs[ii], ls='-.') + cnt_ros = ross[0](atp(atp_bl[0]), psi(atp_bl[0])) park_ros = ross[1](atp(atp_bl[0]), psi(atp_bl[0])) ax.plot(atp_bl[0], -0.1, marker='*', c='k', clip_on=False, markersize=7, markeredgecolor='none') - ax.plot(60, -0.1, marker='*', c='gold', label='Lysosomal', + ax.plot(60, -0.1, marker='*', c='gold', label='Lysosomal\ndefects', clip_on=False, markersize=7, zorder=10, linestyle='None', markeredgecolor='k', markeredgewidth=0.5) @@ -247,7 +262,7 @@ def quantum(ax1): ax1.set_yticks([]) ax1.set_yticklabels([]) ax1.plot(-25, 0, marker='*', c='k', clip_on=False, markersize=7, - markeredgecolor='none') + markeredgewidth=0.5, markeredgecolor='white', zorder=10) ax1.text(s='+Q', x=85, y=27.5, fontsize=5) ax1.text(s='+3Q', x=85, y=87.5, fontsize=5) @@ -260,7 +275,7 @@ def quantum(ax1): if __name__ == '__main__': Kant_units = '(10$^{-3}$/s)' - figsize = fp.cm_to_inches([8.9, 12]) + figsize = fp.cm_to_inches([8.9, 15]) fig = plt.figure(figsize=figsize) fig.set_constrained_layout_pads(w_pad=0, h_pad=0) gs = gridspec.GridSpec(2, 2, wspace=0.5, hspace=0.5, height_ratios=[1, 4]) @@ -276,10 +291,13 @@ def quantum(ax1): hndles2, lbels2 = ax2.get_legend_handles_labels() hndles.append(hndles2[-1]) lbels.append(lbels2[-1]) - leg1 = plt.legend(hndles, lbels, frameon=False, loc='upper center', - ncol=4, bbox_to_anchor=(0, 0.816, 1, 0.2), - bbox_transform=fig.transFigure, handlelength=1) - plt.gca().add_artist(leg1) + # leg1 = plt.legend(hndles, lbels, frameon=False, loc='upper center', + # ncol=4, bbox_to_anchor=(0, 0.82, 1, 0.2), + # bbox_transform=fig.transFigure, handlelength=1) + # plt.gca().add_artist(leg1) + + # plt.gca().add_artist(leg1) + align_axis_labels([ax1, ax2], axis='x', value=-0.2) gs00 = gridspec.GridSpecFromSubplotSpec(5, 1, subplot_spec=gs[1, :], hspace=0.3, @@ -330,4 +348,9 @@ def quantum(ax1): axis='y', value=-0.07) align_axis_labels([ax1], axis='y', value=-0.2) gs.tight_layout(fig) - plt.savefig('Figure4.png', dpi=300) + # plt.subplots_adjust(top=0.8) + leg1 = fig.legend(hndles, lbels, frameon=False, loc='upper center', + ncol=4, bbox_to_anchor=(0, 0.85, 1, 0.2), + bbox_transform=fig.transFigure, handlelength=1) + + plt.savefig('Figure4.png', dpi=300, bbox_inches='tight')