コード例 #1
0
ファイル: test_pac.py プロジェクト: TomDLT/pacpy
def test_mi_canolty():
    """
    Test PAC function: Canolty MI
    1. Confirm consistency of output with example data
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy')
    np.random.seed(0)
    assert np.allclose(
        mi_canolty(data, data, (13, 30), (80, 200)), 22.08946, atol=10 ** -5)
コード例 #2
0
ファイル: test_pac.py プロジェクト: gimili26/PAC
def test_mi_canolty():
    """
    Test PAC function: Canolty MI
    1. Confirm consistency of output with example data
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy')
    np.random.seed(0)
    assert np.allclose(mi_canolty(data, data, (13, 30), (80, 200)),
                       22.08946,
                       atol=10**-5)
コード例 #3
0
ファイル: test_pac.py プロジェクト: dengemann/pacpy
def test_mi_canolty():
    """
    Test PAC function: Canolty MI
    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(
        mi_canolty(data, data, (13, 30), (80, 200)), 1.10063, atol=10 ** -5)
    assert np.allclose(mi_canolty(
        data, data, (13, 30), (80, 200), filterfn=butterf), 1.14300, atol=10 ** -5)

    # Test that the Canolty MI 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))
    assert mi_canolty(lo, hi, (4, 6), (100, 400)) / np.mean(amp) > 0.99

    lo, hi = genPAC0()
    assert mi_canolty(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(
        mi_canolty(pha, amp, (13, 30), (80, 200), filterfn=False),
        mi_canolty(data, data, (13, 30), (80, 200)), atol=10 ** -5)
コード例 #4
0
def test_mi_canolty():
    """
    Test PAC function: Canolty MI
    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(
        mi_canolty(data, data, (13, 30), (80, 200)), 1.10063, atol=10 ** -5)
    assert np.allclose(mi_canolty(
        data, data, (13, 30), (80, 200), filterfn=butterf), 1.14300, atol=10 ** -5)

    # Test that the Canolty MI 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))
    assert mi_canolty(lo, hi, (4, 6), (100, 400)) / np.mean(amp) > 0.99

    lo, hi = genPAC0()
    assert mi_canolty(lo, hi, (4, 6), (90, 110)) < 0.001