From b1fdc18111a30bbe66091e75f1914c7ba08d26a0 Mon Sep 17 00:00:00 2001 From: Jan Benda Date: Tue, 24 Nov 2015 17:17:58 +0100 Subject: [PATCH] Improved STA figure --- bootstrap/lecture/bootstrap-chapter.tex | 4 +- likelihood/lecture/likelihood-chapter.tex | 4 +- pointprocesses/lecture/pointprocesses.tex | 2 - pointprocesses/lecture/sta.py | 52 ++++++++++++++--------- regression/lecture/regression-chapter.tex | 4 +- 5 files changed, 39 insertions(+), 27 deletions(-) diff --git a/bootstrap/lecture/bootstrap-chapter.tex b/bootstrap/lecture/bootstrap-chapter.tex index 0f306cd..7ecd9a5 100644 --- a/bootstrap/lecture/bootstrap-chapter.tex +++ b/bootstrap/lecture/bootstrap-chapter.tex @@ -5,8 +5,8 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{} -\setcounter{chapter}{-1} +\setcounter{page}{81} +\setcounter{chapter}{4} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/likelihood/lecture/likelihood-chapter.tex b/likelihood/lecture/likelihood-chapter.tex index 00d7138..0f74fe3 100644 --- a/likelihood/lecture/likelihood-chapter.tex +++ b/likelihood/lecture/likelihood-chapter.tex @@ -5,8 +5,8 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{} -\setcounter{chapter}{-1} +\setcounter{page}{101} +\setcounter{chapter}{6} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/pointprocesses/lecture/pointprocesses.tex b/pointprocesses/lecture/pointprocesses.tex index a9b5fda..3ca29cc 100644 --- a/pointprocesses/lecture/pointprocesses.tex +++ b/pointprocesses/lecture/pointprocesses.tex @@ -503,5 +503,3 @@ die Zellantwort mit dem STA verfaltet. genauso gro{\ss} ist wie der Originalstimulus aus der Datei \file{sta\_data.mat}. \end{exercise} - - diff --git a/pointprocesses/lecture/sta.py b/pointprocesses/lecture/sta.py index 0e3c350..c5d702b 100644 --- a/pointprocesses/lecture/sta.py +++ b/pointprocesses/lecture/sta.py @@ -38,18 +38,22 @@ def reconstruct_stimulus(spike_times, sta, stimulus, t_max=30., dt=1e-4): def plot_results(sta_time, st_average, stim_time, s_est, stimulus, duration, dt): + plt.xkcd() sta_ax = plt.subplot2grid((1, 3), (0, 0), rowspan=1, colspan=1) stim_ax = plt.subplot2grid((1, 3), (0, 1), rowspan=1, colspan=2) fig = plt.gcf() - fig.set_size_inches(15, 5) + fig.set_size_inches(8, 3) fig.subplots_adjust(left=0.08, bottom=0.15, top=0.9, right=0.975) fig.set_facecolor("white") - sta_ax.plot(sta_time * 1000, st_average, color="dodgerblue", lw=2.) - sta_ax.set_xlabel("time [ms]", fontsize=20) - sta_ax.set_ylabel("stimulus", fontsize=20) - sta_ax.set_xlim([-50, 50]) + sta_ax.plot(sta_time * 1000, st_average, color="#FF9900", lw=2.) + sta_ax.set_xlabel("Time (ms)") + sta_ax.set_ylabel("Stimulus") + sta_ax.set_xlim(-40, 20) + sta_ax.set_xticks(np.arange(-40, 21, 20)) + sta_ax.set_ylim(-0.1, 0.2) + sta_ax.set_yticks(np.arange(-0.1, 0.21, 0.1)) # sta_ax.xaxis.grid('off') sta_ax.spines["right"].set_visible(False) sta_ax.spines["top"].set_visible(False) @@ -57,32 +61,42 @@ def plot_results(sta_time, st_average, stim_time, s_est, stimulus, duration, dt) sta_ax.xaxis.set_ticks_position('bottom') sta_ax.spines["bottom"].set_linewidth(2.0) sta_ax.spines["left"].set_linewidth(2.0) - sta_ax.tick_params(direction="out", width=2.0, labelsize=18) - + sta_ax.tick_params(direction="out", width=2.0) ylim = sta_ax.get_ylim() xlim = sta_ax.get_xlim() - sta_ax.plot(list(xlim), [0., 0.], zorder=1, color='darkgray', ls='--', lw=0.75) - sta_ax.plot([0., 0.], list(ylim), zorder=1, color='darkgray', ls='--', lw=0.75) + sta_ax.plot(list(xlim), [0., 0.], zorder=1, color='darkgray', ls='--', lw=1) + sta_ax.plot([0., 0.], list(ylim), zorder=1, color='darkgray', ls='--', lw=1) sta_ax.set_xlim(list(xlim)) sta_ax.set_ylim(list(ylim)) - sta_ax.text(-0.25, 1.04, "A", transform=sta_ax.transAxes, size=24) + sta_ax.annotate('Time of\nspike', + xy=(0, 0.18), xycoords='data', + xytext=(-35, 0.19), textcoords='data', ha='left', + arrowprops=dict(arrowstyle="->", relpos=(1.0,0.5), + connectionstyle="angle3,angleA=0,angleB=-70") ) + sta_ax.annotate('STA', + xy=(-10, 0.05), xycoords='data', + xytext=(-33, 0.09), textcoords='data', ha='left', + arrowprops=dict(arrowstyle="->", relpos=(1.0,0.0), + connectionstyle="angle3,angleA=60,angleB=-40") ) + #sta_ax.text(-0.25, 1.04, "A", transform=sta_ax.transAxes, size=24) - stim_ax.plot(stim_time * 1000, stimulus[:,1], label='stimulus', color='dodgerblue', lw=2.) - stim_ax.plot(stim_time * 1000, s_est, label='reconstruction', color='red', lw=2) - stim_ax.set_xlabel('time[ms]', fontsize=20) - stim_ax.set_xlim([0.0, 250]) + stim_ax.plot(stim_time * 1000, stimulus[:,1], label='stimulus', color='#0000FF', lw=2.) + stim_ax.plot(stim_time * 1000, s_est, label='reconstruction', color='#FF9900', lw=2) + stim_ax.set_xlabel('Time (ms)') + stim_ax.set_xlim(0.0, 200) stim_ax.set_ylim([-1., 1.]) - stim_ax.legend() - stim_ax.plot([0.0, 250], [0., 0.], color="darkgray", lw=0.75, ls='--', zorder=1) + stim_ax.legend(loc=(0.3, 0.85), frameon=False, fontsize=12) + stim_ax.plot([0.0, 250], [0., 0.], color="darkgray", lw=1, ls='--', zorder=1) stim_ax.spines["right"].set_visible(False) stim_ax.spines["top"].set_visible(False) stim_ax.yaxis.set_ticks_position('left') stim_ax.xaxis.set_ticks_position('bottom') stim_ax.spines["bottom"].set_linewidth(2.0) stim_ax.spines["left"].set_linewidth(2.0) - stim_ax.tick_params(direction="out", width=2.0, labelsize=18) - stim_ax.text(-0.1, 1.04, "B", transform=stim_ax.transAxes, size=24) - + stim_ax.tick_params(direction="out", width=2.0) + #stim_ax.text(-0.1, 1.04, "B", transform=stim_ax.transAxes, size=24) + + fig.tight_layout() fig.savefig("sta.pdf") plt.close() diff --git a/regression/lecture/regression-chapter.tex b/regression/lecture/regression-chapter.tex index 11f9132..0df5e2b 100644 --- a/regression/lecture/regression-chapter.tex +++ b/regression/lecture/regression-chapter.tex @@ -5,8 +5,8 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{} -\setcounter{chapter}{-1} +\setcounter{page}{89} +\setcounter{chapter}{5} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%