def setup_module(module): global tvfcg_plv_ts global tvfcg_plv_fcgs global tvfcg_pac_plv_fcgs original_data = np.load("../examples/data/eeg_32chans_10secs.npy") # TVFCGS with PLV data = original_data[0:2, 0:1024] fb = [1.0, 4.0] fs = 128 estimator = PLV(fb, fs) tvfcg_plv_fcgs = tvfcg(data, estimator, fb, fs) # tvfcg_plv_fcgs = np.real(tvfcg_plv_fcgs) # np.save("data/test_tvfcgs_plv.npy", tvfcg_plv_fcgs) # TVFCGS with PAC and PLV data = original_data[..., 0:1024] fb = [1.0, 4.0] fs = 128 f_lo = fb f_hi = [20.0, 30.0] estimator = PLV(fb, fs) pac = PAC(f_lo, f_hi, fs, estimator) tvfcg_pac_plv_fcgs = tvfcg_cfc(data, pac, f_lo, f_hi, fs)
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)
def try_TVFCG_PAC(data): fb = [1.0, 4.0] fs = 128 f_lo = fb f_hi = [20.0, 30.0] estimator = PLV(fb, fs) pac = PAC(f_lo, f_hi, fs, estimator) fcgs = tvfcg_cfc(data, pac, f_lo, f_hi, fs) return fcgs
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 try_PAC(data): fb = [1.0, 4.0] fs = 128 pairs = None n_jobs = 1 plv = PLV(fb, fs, pairs) f_lo = [1.0, 4.0] f_hi = [20.0, 30.0] pac = PAC(f_lo, f_hi, fs, plv) phases, phases_lohi = pac.preprocess(data) cfc, avg = pac.estimate(phases, phases_lohi) return cfc, avg
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.real(ts) expected_ts = np.load("data/test_pac_plv_ts.npy") expected_ts = np.real(ts) np.testing.assert_array_equal(ts, expected_ts) expected_avg = np.load("data/test_pac_plv_avg.npy") np.testing.assert_array_equal(avg, expected_avg)
fs = 128.0 now = time.time() ts, avg = plv(data, fb, fs) 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)
import numpy as np np.set_printoptions(precision=3, linewidth=256) from dyfunconn.fc import pac, PAC, PLV if __name__ == "__main__": data = np.load( "/home/makism/Github/dyfunconn/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)