Ejemplo n.º 1
0
    def test_pac_comodulogram(self):
        """Test Pac object definition.

        This test works locally but failed on travis...
        """
        matplotlib.use('agg')
        f, tridx = pac_trivec()
        pac = np.random.rand(20, 10)
        pval = np.random.rand(20, 10)
        p = Pac(f_pha=np.arange(11), f_amp=np.arange(21))
        p.comodulogram(np.random.rand(10, 10, 20))
        p.comodulogram(pac, rmaxis=True, dpaxis=True, interp=(.1, .1))
        p.comodulogram(pac, plotas='contour', pvalues=pval)
        p.comodulogram(pac,
                       plotas='pcolor',
                       pvalues=pval,
                       levels=[.5, .7],
                       under='gray',
                       over='red',
                       bad='orange')
        p = Pac(f_pha=np.arange(11), f_amp=f)
        pac = np.random.rand(len(f))
        p.triplot(pac, f, tridx)
        p.savefig('test_savefig.png')
        p.show()
        matplotlib.pyplot.close('all')
Ejemplo n.º 2
0
plt.figure(figsize=(20, 35))
# Plot the prefered phase :
plt.subplot(221)
plt.pcolormesh(p.yvec, np.arange(100), np.rad2deg(pp), cmap='Spectral_r')
cb = plt.colorbar()
plt.clim(vmin=-180., vmax=180.)
plt.axis('tight')
plt.xlabel('Amplitude center frequency (Hz)')
plt.ylabel('Ndatasets')
plt.title("PP for each dataset and for several amplitudes.\n100hz amplitudes"
          " are phase locked to 90° (<=> pi/2)")
cb.set_label('PP (in degrees)')

# Then, we show  the histogram corresponding to an 100hz amplitude :
idx100 = np.abs(p.yvec - 100.).argmin()
plt.subplot(222)
h = plt.hist(pp[:, idx100], color='#ab4642')
plt.xlim((-np.pi, np.pi))
plt.xlabel('PP')
plt.title('PP across trials for the 100hz amplitude')
plt.xticks([-np.pi, -np.pi / 2, 0, np.pi / 2, np.pi])
plt.gca().set_xticklabels([r"$-\pi$", r"$-\frac{\pi}{2}$", "$0$",
                          r"$\frac{\pi}{2}$", r"$\pi$"])

p.polar(ambin.T, vecbin, p.yvec, cmap='Spectral_r', interp=.1, subplot=212,
        cblabel='Amplitude bins')

# plt.savefig('pp.png', dpi=300, bbox_inches='tight')

p.show()