P = float(args['-p']) Q = float(args['-q']) s = float(args['-s']) if np.allclose(s, 0): Ps = np.repeat(P, N) Qs = np.repeat(Q, N) else: Ps = np.random.normal(P, P * s, size=N) Qs = np.random.normal(Q, Q * s, size=N) sigma = float(args['--sigma']) # - I, E = ie(t, Ps, Qs, N, dt=dt, sigma=sigma) lfp = (E + I) # - save_kdf( str(args['NAME']), N=N, E=E, I=I, lfp=lfp, t=t, dt=dt, sigma=sigma, Ps=Ps, Qs=Qs)
if __name__ == "__main__": args = docopt(__doc__, version='alpha') # - # Process params t = float(args['-t']) dt = float(args['--dt']) P = float(args['-p']) Q = float(args['-q']) sigma = float(args['--sigma']) # - I, E = ie(t, P, Q, dt=dt, sigma=sigma) lfp = E + I # - save_kdf(str(args['NAME']), E=E, I=I, lfp=lfp, t=t, dt=dt, sigma=sigma, P=P, Q=Q)
pass np.random.seed(seed) # - # Process params t = float(args['-t']) dt = float(args['--dt']) P0 = float(args['--p0']) PN = float(args['--pn']) Q = float(args['-q']) sigma = float(args['--sigma']) # - # Run model I, E = ie(t, P0, PN, sigma=sigma) lfp = (E + I) # - save_kdf(str(args['NAME']), E=E, I=I, lfp=lfp, t=t, dt=dt, P0=P0, PN=PN, Q=Q, sigma=sigma)
if M_no > (M_pre + (SD_pre * threshold)): false_alarm = 1 hits[j, i] = hit false_alarms[j, i] = false_alarm # D prime d_prime = (M_stim - M_no) / np.sqrt((SD_stim**2 + SD_no**2) / 2) d_primes[j, i] = d_prime # ------------------------------------------------------------------- # Calculate signal detection statistics # First calculate misses and correct_rejections misses = np.ones_like(hits) - hits correct_rejections = np.ones_like(false_alarm) - false_alarms # ------------------------------------------------------------------- # Save save_kdf( name, hits=hits, misses=misses, correct_rejections=correct_rejections, false_alarms=false_alarms, d_primes=d_primes, n_stim=n_stim, stims=range(n_stim), rates=rates)
M_right = M_pow2 p_left = np.exp(M_left) / np.sum([np.exp(M_left), np.exp(M_right)]) p_right = 1 - p_left p_lefts[j, i] = p_left p_rights[j, i] = p_right # ------------------------------------------------------------------- # Calculate remaining signal detection statistics misses = np.ones_like(hits) - hits correct_rejections = np.ones_like(false_alarm) - false_alarms # ------------------------------------------------------------------- # Save save_kdf( name, hits=hits, misses=misses, correct_rejections=correct_rejections, false_alarms=false_alarms, p_lefts=p_lefts, p_rights=p_rights, d_primes=d_primes, n_stim=n_stim, stims=range(n_stim), pow1=pow1, powers2=powers2, sigma=sigma, loc=loc)
x_e = x_e[times > drop_before] to_calc = ('HX', 'HY', 'HXY') q_in, _, _ = en.quantise(x_in, m) q_e, _, _ = en.quantise(x_e, m) info = en.DiscreteSystem(q_in, (1, m), q_e, (1, m)) info.calculate_entropies(method='pt', calc=to_calc) mi_pac = info.I() # Save del_mi[j, i] = mi_pac - mi_no save_kdf(os.path.join(save_path, name), del_mi=del_mi, n_stim=n_stim, n_sigma=n_sigma, stims=range(n_stim), sigmas=sigmas) # ------------------------------------------------------------------- # b. osc elif exp == "b": name = "b" nopac = os.path.join(pars_path, 'pac_osc_noalpha.yaml') pac = os.path.join(pars_path, 'pac_osc.yaml') del_mi = np.zeros((n_stim, n_sigma)) for i, s in enumerate(sigmas): for j in range(n_stim): print(">>> Fig {}, sigma {}, stim {}".format(name, s, j))
lif( t, Is, f, r_e=r_e * a, r_i=r_i * a, w_e=w_e, w_i=w_i, min_rate=min_rate * a, # TODO keep this scaling too? n_bursts=n_bursts, back_seed=42 * k, verbose=False)) fis.append(np.vstack(fi_t).mean(0)) save_kdf(os.path.join(save_path, "a"), Is=Is, f=f, amps=amps, fis=fis) # -- # b) print("Running b)") n_bursts = [2, 4, 6, 8] fis = [] for n in n_bursts: print("N bursts {}".format(n)) fi_t = [] for k in range(n_trials): fi_t.append( lif(t, Is, f,
# - thetas, times = simulate(theta0, T, omegas, K, N, sigma, p, dt) # - # From the unit circle to sin waves, and the simulated lfp. waves = [] for n in range(N): th = thetas[:, n] f = omegas[n] wave = np.sin(f * 2 * np.pi * times + th) waves.append(wave) waves = np.vstack(waves) lfp = waves.mean(0) # - save_kdf(str(args['NAME']), thetas=thetas, theta0=theta0, omegas=omegas, waves=waves, lfp=lfp, seed=seed, sigma=sigma, N=N, K=K, times=times, t=T, dt=dt)
r_i=r_i, w_e=w_e, w_i=w_i, min_rate=min_rate, return_trains=True) ns2, ts2 = sp.spikedict_to(trains2) save_kdf( os.path.join(save_path, "a"), Is=Is, f=10, fixed=1, osc=2, fi1=fi1, fi2=fi2, ns1=ns1, ts1=ts1, ns2=ns2, ts2=ts2, ge1=ge1, gi1=gi1, v1=v1, ge2=ge2, gi2=gi2, v2=v2, ) # -- # b) phase plot, and full FI for peak/trough # we turn osc off because were estimating gain at peak/trough by # simulating at the peak/trough rates for longer periods of time than # the peak/trough lasts peak. f = 0