def test_pac_one_channel(): data = np.load("../examples/data/eeg_32chans_10secs.npy") data = data[0:1, 0:128] fs = 128 f_lo = [1.0, 4.0] f_hi = [20.0, 30.0] estimator = PLV(f_lo, fs) ts, avg = pac(data, f_lo, f_hi, fs, estimator) avg = np.squeeze(np.real(avg)) expected = 0.468296707219 nose.tools.assert_almost_equal(avg, expected)
def test_pac_multiple_channels(): data = np.load("../examples/data/eeg_32chans_10secs.npy") fs = 128 fb_lo = [1.0, 4.0] fb_hi = [20.0, 30.0] estimator = PLV(fb_lo, fs) ts, avg = pac(data, fb_lo, fb_hi, 128, estimator) ts = np.nan_to_num(ts) avg = np.nan_to_num(avg) expected_ts = np.load("data/test_pac_plv_ts.npy") expected_ts = np.nan_to_num(ts) np.testing.assert_array_equal(ts, expected_ts) avg = np.float32(avg) expected_avg = np.load("data/test_pac_plv_avg.npy") expected_avg = np.nan_to_num(expected_avg) expected_avg = np.float32(expected_avg) np.testing.assert_allclose(avg, expected_avg, rtol=1e-10, atol=0.0)
if __name__ == "__main__": data = np.load( "/home/makism/Github/dyconnmap/examples/data/eeg_32chans_10secs.npy") # # Common configuration # fb = [1.0, 4.0] fs = 128 pairs = None estimator = PLV(fb, fs, pairs) f_lo = [1.0, 4.0] f_hi = [20.0, 30.0] # # Functional # cfc, avg = pac(data, f_lo, f_hi, fs, estimator, pairs=None) print(avg) # # Object-oriented # pac = PAC(f_lo, f_hi, fs, estimator) phases, phases_lohi = pac.preprocess(data) cfc, avg = pac.estimate(phases, phases_lohi) print(avg)
print("Finished in", time.time() - now, "sec") # TVFCGs from time seriess now = time.time() fcgs = tvfcg_ts(ts, [1.0, 4.0], 128) print("Finished in", time.time() - now, "sec") # TVFCGs fb = [1.0, 4.0] fs = 128.0 estimator = PLV(fb, fs) fcgs = tvfcg(data, estimator, fb, fs) # PAC lo = [1.0, 4.0] hi = [8.0, 13.0] fs = 128.0 estimator = PLV(fb, fs) now = time.time() cfc_ts, cfc_avg = pac(data, lo, hi, fs, estimator) print("Finished in", time.time() - now, "sec") # TVFCGs + PAC pac_estimator = PAC(lo, hi, fs, estimator) now = time.time() fcgs = tvfcg_cfc(data, pac_estimator, lo, hi, fs) print("Finished in", time.time() - now, "sec")