예제 #1
0
def test_pac_comodulogram():
    """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(fpha=np.arange(11), famp=np.arange(21))
    print(len(p.xvec), len(p.yvec))
    p.comodulogram(pac, rmaxis=True, dpaxis=True)
    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(fpha=np.arange(11), famp=f)
    p.polar(pac, np.arange(10), np.arange(20), interp=.8)
    pac = np.random.rand(len(f))
    p.triplot(pac, f, tridx)
    matplotlib.pyplot.close('all')
예제 #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()