def test_erpac(): """Test the ERPAC.""" data = np.random.rand(2, 1024) p = Pac(idpac=(4, 0, 0)) pha = p.filter(1024, data, axis=1, ftype='phase') amp = p.filter(1024, data, axis=1, ftype='amplitude') p.erpac(pha, amp, traxis=1)
npts=npts, dpha=10, damp=10, sf=sf) # Generate noise and concatenate the coupling and the noise : x2 = np.random.rand(ntrials, 700) x = np.concatenate((x1, x2), axis=1) # Shape : (ntrials, npts) time = np.arange(x.shape[1]) / sf # Define a PAC object : p = Pac(fpha=[9, 11], famp=(60, 140, 5, 1), dcomplex='wavelet', width=12) # Extract the phase and the amplitude : pha = p.filter(sf, x, axis=1, ftype='phase') # Shape (npha, ntrials, npts) amp = p.filter(sf, x, axis=1, ftype='amplitude') # Shape (namp, ntrials, npts) # Compute the ERPAC and use the traxis to specify that the trial axis is the # first one : erpac, pval = p.erpac(pha, amp, traxis=1) # Remove unused dimensions : erpac, pval = np.squeeze(erpac), np.squeeze(pval) # Plot without p-values : p.pacplot(erpac, time, p.yvec, xlabel='Time (second)', cmap='Spectral_r', ylabel='Amplitude frequency', title=str(p), cblabel='ERPAC', vmin=0., rmaxis=True) # Plot with every non-significant values masked in gray : # p.pacplot(erpac, time, p.yvec, xlabel='Time (second)', cmap='Spectral_r', # ylabel='Amplitude frequency', title='ERPAC example', vmin=0., # vmax=1., pvalues=pval, bad='lightgray', plotas='contour', # cblabel='ERPAC')