def test_ozkurt(): """ Test PAC function: Ozkurt 1. Confirm consistency of output with example data 2. Confirm PAC=1 when expected 3. Confirm PAC=0 when expected """ # Load data data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy') assert np.allclose( ozkurt(data, data, (13, 30), (80, 200)), 0.07658, atol=10 ** -5) # Test that the Ozkurt PAC function outputs close to 0 and 1 when expected lo, hi = genPAC1(phabias=.2, fhi=300) hif = firf(hi, (100, 400)) amp = np.abs(hilbert(hif)) weight = (np.sqrt(len(amp)) * np.sqrt(np.sum(amp ** 2))) / np.sum(amp) assert ozkurt(lo, hi, (4, 6), (100, 400)) * weight > 0.98 lo, hi = genPAC0() assert ozkurt(lo, hi, (4, 6), (100, 400)) < 0.01
def test_ozkurt(): """ Test PAC function: Ozkurt 1. Confirm consistency of output with example data 2. Confirm consistency of output with example data using iir filter 3. Confirm PAC=1 when expected 4. Confirm PAC=0 when expected """ # Load data data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy') assert np.allclose( ozkurt(data, data, (13, 30), (80, 200)), 0.07548, atol=10 ** -5) assert np.allclose( ozkurt(data, data, (13, 30), (80, 200), filterfn=butterf), 0.07555, atol=10 ** -5) # Test that the Ozkurt PAC function outputs close to 0 and 1 when expected lo, hi = genPAC1(phabias=.2, fhi=300) hif = firf(hi, (100, 400)) amp = np.abs(hilbert(hif)) weight = (np.sqrt(len(amp)) * np.sqrt(np.sum(amp ** 2))) / np.sum(amp) assert ozkurt(lo, hi, (4, 6), (100, 400)) * weight > 0.99 lo, hi = genPAC0() assert ozkurt(lo, hi, (4, 6), (90, 110)) < 0.001 # Test that Filterfn = False works as expected datalo = firf(data, (13,30)) datahi = firf(data, (80,200)) pha = np.angle(hilbert(datalo)) amp = np.abs(hilbert(datahi)) assert np.allclose( ozkurt(pha, amp, (13, 30), (80, 200), filterfn=False), ozkurt(data, data, (13, 30), (80, 200)), atol=10 ** -5)
def test_ozkurt(): """ Test PAC function: Ozkurt 1. Confirm consistency of output with example data 2. Confirm PAC=1 when expected 3. Confirm PAC=0 when expected """ # Load data data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy') assert np.allclose(ozkurt(data, data, (13, 30), (80, 200)), 0.07658, atol=10**-5) # Test that the Ozkurt PAC function outputs close to 0 and 1 when expected lo, hi = genPAC1(phabias=.2, fhi=300) hif = firf(hi, (100, 400)) amp = np.abs(hilbert(hif)) weight = (np.sqrt(len(amp)) * np.sqrt(np.sum(amp**2))) / np.sum(amp) assert ozkurt(lo, hi, (4, 6), (100, 400)) * weight > 0.98 lo, hi = genPAC0() assert ozkurt(lo, hi, (4, 6), (100, 400)) < 0.01