def plot_avg_firing_rate_spikes(spikes, tLimits, **kw): '''Plot population-average firing rate from PopulationSpikes.''' # keyword arguments ax = kw.pop('ax', plt.gca()) sigmaTitle = kw.pop('sigmaTitle', False) dt = kw.pop('dt', .5) winLen = kw.pop('winLen', 2.0) kw['xlabel'] = False kw['ylabel'] = kw.get('ylabel', 'r (Hz)') tStart = tLimits[0] tEnd = tLimits[1] rate, times = spikes.slidingFiringRate(tStart, tEnd, dt, winLen) meanRate = np.mean(rate, axis=0) signalPlot(times, meanRate, ax, **kw) ax.set_ylim([0, None]) #ax.spines['left'].set_visible(False) ax.spines['bottom'].set_visible(False) ax.xaxis.set_visible(False) #ax.yaxis.set_visible(False) ax.yaxis.set_major_locator(ti.LinearLocator(2)) # Annotations if (sigmaTitle): ax.set_title('$\sigma$ = {0} pA'.format(int(noise_sigma)), y=1.02, va='bottom', ha='center') return ax
def plot_avg_firing_rate_spikes(spikes, tLimits, **kw): '''Plot population-average firing rate from PopulationSpikes.''' # keyword arguments ax = kw.pop('ax', plt.gca()) sigmaTitle = kw.pop('sigmaTitle', False) dt = kw.pop('dt', .5) winLen = kw.pop('winLen', 2.0) kw['xlabel'] = False kw['ylabel'] = kw.get('ylabel', 'r (Hz)') tStart = tLimits[0] tEnd = tLimits[1] rate, times = spikes.slidingFiringRate(tStart, tEnd, dt, winLen) meanRate = np.mean(rate, axis=0) signalPlot(times, meanRate, ax, **kw) ax.set_ylim([0, None]) #ax.spines['left'].set_visible(False) ax.spines['bottom'].set_visible(False) ax.xaxis.set_visible(False) #ax.yaxis.set_visible(False) ax.yaxis.set_major_locator(ti.LinearLocator(2)) # Annotations if (sigmaTitle): ax.set_title('$\sigma$ = {0} pA'.format(int(noise_sigma)), y=1.02, va='bottom', ha='center') return ax
def plot(self, *args, **kwargs): for n_theta_cycles in range(1, 9): T = n_theta_cycles / self.theta_freq * 1e3 l, b, r, top = self.myc['bbox'] self.fig = self._get_final_fig(self.myc['fig_size']) self.ax_theta = self.fig.add_subplot(3, 1, 1) # Only theta t = np.arange(0, T+self.dt, self.dt) theta = self.const + .5 * (1. + np.cos(2*np.pi*self.theta_freq*t*1e-3 - np.pi)) * (1 - self.const) signalPlot( t, theta, ax=self.ax_theta, color=self.myc['theta_color'], zeroLine=False) self.ax_theta.axis('off') self.ax_theta.set_xlim([t[0], t[-1]]) self.ax_theta.set_ylim(-.2, 1.2) self.ax_theta.set_title('A', x=0, y=.95, size=14, weight='bold', ha='left', va='top') # PAC only gamma self.ax_pac = self.fig.add_subplot(3, 1, 2) gamma = np.cos(2*np.pi*self.gamma_freq*t*1e-3 - np.pi) * theta signalPlot( t, gamma, ax=self.ax_pac, color=self.myc['gamma_color'], zeroLine=False) self.ax_pac.axis('off') self.ax_pac.set_xlim([t[0], t[-1]]) self.ax_pac.set_ylim(-1.02, 1.02) self.ax_pac.set_title('B', x=0, y=1, size=14, weight='bold', ha='left', va='top') # PAC Theta + gamma self.ax_pac_all = self.fig.add_subplot(3, 1, 3) self.ax_pac_all.hold('on') signalPlot( t, theta, ax=self.ax_pac_all, color=self.myc['theta_color'], zeroLine=False) gamma = .25 * np.cos(2*np.pi*self.gamma_freq*t*1e-3 - np.pi) * theta signalPlot( t, theta + gamma, ax=self.ax_pac_all, color=self.myc['gamma_color'], zeroLine=False) bar_x = 1 - 5. / 8 / n_theta_cycles xScaleBar(50, x=bar_x, y=.1, ax=self.ax_pac_all, size='small') self.ax_pac_all.axis('off') self.ax_pac_all.set_xlim([t[0], t[-1]]) self.ax_pac_all.set_ylim(-.02, 1.5) self.ax_pac_all.set_title('C', x=0, y=1, size=14, weight='bold', ha='left', va='top') self.fig.subplots_adjust(left=l, bottom=b, right=r, top=top) fname = self.config['output_dir'] + "/pac_example_{0}.pdf" self.fig.savefig(fname.format(n_theta_cycles), dpi=300, transparent=True) plt.close(self.fig)
def plot(self, *args, **kwargs): for n_theta_cycles in range(1, 9): T = n_theta_cycles / self.theta_freq * 1e3 l, b, r, top = self.myc['bbox'] self.fig = self._get_final_fig(self.myc['fig_size']) self.ax_theta = self.fig.add_subplot(3, 1, 1) # Only theta t = np.arange(0, T + self.dt, self.dt) theta = self.const + .5 * ( 1. + np.cos(2 * np.pi * self.theta_freq * t * 1e-3 - np.pi)) * (1 - self.const) signalPlot(t, theta, ax=self.ax_theta, color=self.myc['theta_color'], zeroLine=False) self.ax_theta.axis('off') self.ax_theta.set_xlim([t[0], t[-1]]) self.ax_theta.set_ylim(-.2, 1.2) self.ax_theta.set_title('A', x=0, y=.95, size=14, weight='bold', ha='left', va='top') # PAC only gamma self.ax_pac = self.fig.add_subplot(3, 1, 2) gamma = np.cos(2 * np.pi * self.gamma_freq * t * 1e-3 - np.pi) * theta signalPlot(t, gamma, ax=self.ax_pac, color=self.myc['gamma_color'], zeroLine=False) self.ax_pac.axis('off') self.ax_pac.set_xlim([t[0], t[-1]]) self.ax_pac.set_ylim(-1.02, 1.02) self.ax_pac.set_title('B', x=0, y=1, size=14, weight='bold', ha='left', va='top') # PAC Theta + gamma self.ax_pac_all = self.fig.add_subplot(3, 1, 3) self.ax_pac_all.hold('on') signalPlot(t, theta, ax=self.ax_pac_all, color=self.myc['theta_color'], zeroLine=False) gamma = .25 * np.cos(2 * np.pi * self.gamma_freq * t * 1e-3 - np.pi) * theta signalPlot(t, theta + gamma, ax=self.ax_pac_all, color=self.myc['gamma_color'], zeroLine=False) bar_x = 1 - 5. / 8 / n_theta_cycles xScaleBar(50, x=bar_x, y=.1, ax=self.ax_pac_all, size='small') self.ax_pac_all.axis('off') self.ax_pac_all.set_xlim([t[0], t[-1]]) self.ax_pac_all.set_ylim(-.02, 1.5) self.ax_pac_all.set_title('C', x=0, y=1, size=14, weight='bold', ha='left', va='top') self.fig.subplots_adjust(left=l, bottom=b, right=r, top=top) fname = self.config['output_dir'] + "/pac_example_{0}.pdf" self.fig.savefig(fname.format(n_theta_cycles), dpi=300, transparent=True) plt.close(self.fig)