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')
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')
def test_trivec(self): """Definition of triangular vectors.""" assert pac_trivec(2, 200, 10)
ending and therefore, bandwidth coupling. """ from tensorpac import Pac from tensorpac.signals import pac_signals_tort from tensorpac.utils import pac_trivec sf = 256. data, time = pac_signals_tort(f_pha=[5, 7], f_amp=[60, 80], noise=2, n_epochs=5, n_times=3000, sf=sf, dpha=10) trif, tridx = pac_trivec(f_start=30, f_end=140, f_width=3) p = Pac(idpac=(1, 0, 0), f_pha=[5, 7], f_amp=trif) pac = p.filterfit(sf, data) p.triplot(pac.mean(-1), trif, tridx, cmap='Spectral_r', rmaxis=True, title=r'Optimal $[Fmin; Fmax]hz$ band for amplitude') # In this example, we generated a coupling with a phase between [5, 7]hz and an # amplitude between [60, 80]hz. To interpret the figure, the best starting # frequency is around 50hz and the best ending frequency is around 90hz. In # conclusion, the optimal amplitude bandwidth for this [5, 7]hz phase is