def only_complete_data(partIDs, TO, label, SHF_NUM): pid = -1 incomplete_data = [] for partID in partIDs: pid += 1 dmp = depickle( getResultFN("%(rpsm)s/%(lb)d/WTL_1.dmp" % { "rpsm": partID, "lb": label })) _prob_mvs = dmp["cond_probs"][SHF_NUM] __hnd_dat = dmp["all_tds"][SHF_NUM] _hnd_dat = __hnd_dat[0:TO] if _hnd_dat.shape[0] < TO: incomplete_data.append(pid) for inc in incomplete_data[::-1]: # remove from list partIDs.pop(inc) return partIDs, incomplete_data
incomplete_data = [] IGIs = _N.empty(len(partIDs)) for partID in partIDs: pid += 1 # if data == "TMB2": # __hnd_dat, start_time, end_time, UA, cnstr = _rt.return_hnd_dat(partID, has_useragent=True, has_start_and_end_times=True, has_constructor=True, visit=1, expt="TMB2") # if data == "EEG1": # __hnd_dat, start_time, end_time, UA, cnstr = _rt.return_hnd_dat(partID, has_useragent=True, has_start_and_end_times=True, has_constructor=True, visit=None, expt="EEG1") # if data == "RAND": # __hnd_dat, start_time, end_time, UA, cnstr = _rt.return_hnd_dat(partID, has_useragent=True, has_start_and_end_times=True, has_constructor=True, visit=1, expt="RAND") dmp = depickle( getResultFN("%(rpsm)s/%(lb)d/WTL_1.dmp" % { "rpsm": partID, "lb": label })) _prob_mvs = dmp["cond_probs"][SHF_NUM][:, strtTr:] _hnd_dat = dmp["all_tds"][SHF_NUM][strtTr:] netwins[pid - 1] = _N.sum(_hnd_dat[:, 2]) IGIs[pid - 1] = _N.sum(_N.diff(_hnd_dat[:, 3])) / 300000 # IGIs fig = _plt.figure() throwAway = _N.where(IGIs < 0.8)[0] keep = _N.where(IGIs >= 0.8)[0] _plt.scatter(IGIs[throwAway], netwins[throwAway], s=8, color="#CDCDCD") _plt.scatter(IGIs[keep], netwins[keep], s=8, color="black") _plt.axvline(x=0.8, ls=":", color="red") _plt.axhline(y=0., ls=":", color="grey") _plt.ylabel("#wins - #lose / 300 games", fontsize=18) _plt.yticks(fontsize=16)
"av": armv_ver, "gv": gcoh_ver, "wn": win, "sld": slideby }) # #lm = depickle("../Neurable/DSi_dat/%(dat)s_gcoh_%(w)s_%(s)s.dmp" % {"dat" : dat, "w" : bin, "s" : slide}) # #A_gcoh_mat = _scio.loadmat("DSi_dat/%(dat)s_gcoh_%(w)d_%(sl)d.mat" % {"dat" : dat, "w" : bin, "sl" : slide}) # #A_gcoh = A_gcoh_mat["Cs"] strt = 0 # if start at middle of experiment A_gcoh = lm["Cs"][strt:] n_fs = lm["fs"] outdir = getResultFN("%(dir)s/v%(av)d%(gv)d" % { "dir": dat, "av": armv_ver, "gv": gcoh_ver }) if not os.access(getResultFN(dat), os.F_OK): os.mkdir(getResultFN(dat)) ################ egenvectors #imag_evs = A_gcoh_mat["VEC"][0] imag_evs = lm["VEC"][strt:, :, ev_n] L_gcoh = A_gcoh.shape[0] nChs = imag_evs.shape[2] real_evs = _N.empty((L_gcoh, n_fs.shape[0], nChs)) chs = lm["chs_picks"] ch_names = arr_ch_names[chs].tolist()
all_x= _N.arange(-141, 142) ch_w_CM, rm_chs, list_ch_names, ch_types = datconf.getConfig(datconf._RPS) arr_ch_names = _N.array(list_ch_names) for key in key_dats: iexpt += 1 f12 = frg.split("-") f1 = f12[0] f2 = f12[1] allWFs = [] vs = "%(a)d%(g)d" % {"a" : armv_ver, "g" : gcoh_ver} #if key == "Jan092020_15_05_39": pikdir = getResultFN("%(dir)s/v%(vs)s" % {"dir" : key, "vs" : vs}) lmXCr = depickle(getResultFN("%(k)s/v%(vs)s/xcorr_out_0_%(w)d_%(sb)d_%(f1)s_%(f2)s_v%(vs)s.dmp" % {"k" : key, "vs" : vs, "f1" : f1, "f2" : f2, "w" : win, "sb" : slideby})) lmACr = depickle(getResultFN("%(k)s/v%(vs)s/acorr_out_0_%(w)d_%(sb)d_%(f1)s_%(f2)s_v%(vs)s.dmp" % {"k" : key, "vs" : vs, "f1" : f1, "f2" : f2, "w" : win, "sb" : slideby})) lmBhv = depickle("%(od)s/%(rk)s_%(w)d_%(s)d_pkld_dat_v%(vs)s.dmp" % {"rk" : rpsms.rpsm_eeg_as_key[key], "w" : win, "s" : slideby, "vs" : vs, "od" : pikdir}) lmEEG = depickle(datconf.getDataFN(datconf._RPS, "%(dsf)s_artfctrmvd/v%(av)d/%(dsf)s_gcoh_%(wn)d_%(sld)d_v%(av)d%(gv)d.dmp" % {"dsf" : key, "av" : armv_ver, "gv" : gcoh_ver, "wn" : win, "sld" : slideby})) fs_gcoh = lmBhv["fs"] fL = int(f1) fH = int(f2) irngs = _N.where((fs_gcoh > fL) & (fs_gcoh < fH))[0] iL = irngs[0] iH = irngs[-1] real_evs = lmBhv["EIGVS"]
srvrs = "" if rvrs and hlfs_intrchg: srvrs = "_hi_revrsd" elif rvrs and not hlfs_intrchg: srvrs = "_revrsd" elif not rvrs and hlfs_intrchg: srvrs = "_hi" f12 = frg.split("-") f1 = f12[0] f2 = f12[1] allWFs = [] vs = "%(a)d%(g)d" % {"a" : armv_ver, "g" : gcoh_ver} pikdir = getResultFN("%(dir)s/v%(vs)s" % {"dir" : key, "vs" : vs}) outdir = getResultFN("%(dir)s/v%(vs)s/%(lb)d_%(st)s_%(sec)d_%(to)d" % {"dir" : key, "vs" : vs, "lb" : label, "st" : shfl_type_str[shfl_type], "to" : t_offset, "sec" : sections}) sub_prm_dir = "%(pd)s/%(prm)s" % {"pd" : outdir, "prm" : prm_dir} if not os.access(sub_prm_dir, os.F_OK): print("make dir %s" % sub_prm_dir) os.mkdir(sub_prm_dir) cmp_xcorr_dir = "%(spd)s/cmp_xcorrs" % {"spd" : sub_prm_dir} if not os.access(cmp_xcorr_dir, os.F_OK): os.mkdir(cmp_xcorr_dir) lmBhv = depickle("%(od)s/%(rk)s_%(w)d_%(s)d_pkld_dat_v%(vs)s_%(lb)d.dmp" % {"rk" : rpsms.rpsm_eeg_as_key[key], "w" : win, "s" : slideby, "vs" : vs, "od" : pikdir, "lb" : label}) lmXCr = depickle("%(od)s/xcorr_out_0_%(w)d_%(sb)d_%(f1)s_%(f2)s_v%(vs)s_%(lb)d%(rv)s.dmp" % {"od" : outdir, "vs" : vs, "f1" : f1, "f2" : f2, "w" : win, "sb" : slideby, "rv" : srvrs, "lb" : label}) lmEEG = depickle(datconf.getDataFN(datconf._RPS, "%(dsf)s_artfctrmvd/v%(av)d/%(dsf)s_gcoh_%(wn)d_%(sld)d_v%(av)d%(gv)d.dmp" % {"dsf" : key, "av" : armv_ver, "gv" : gcoh_ver, "wn" : win, "sld" : slideby})) fs_gcoh = lmBhv["fs"]
def pkg_all_data(partID): """ d_reprtd_start: delay RPSM game start relative to DSi - as calculated by reported JS start time and DSi start time. dt_sys_clks: how much system times are off. d_reprtd_start = RPSM(start) - DSi(start) RPSM say 12:00:00, DSi says 11:59:30 +30 if same_time_RPSM is 12:00:00 and same_time_EEG is 11:59:35, then d_sys_clks = 25 11:59:35 (RPSM) and 11:59:30 (DSi) als d_start = d_reprtd_start - d_sys_clks if d_start > 0, RPSM started AFTER EEG if d_start < 0, RPSM started BEFORE EEG """ print("partID %s" % partID) dat_pkg = {} dsi_fn = rpsms.rpsm_partID_as_key[partID] #same_time_RPSM = params4partID[partID][0] # from calibration.html #same_time_EEG = params4partID[partID][1] # from calibration.html rpsm_fn = "rpsm_%s.dat" % partID _hnd_dat, start_time, end_time, UA, cnstr = _rt.return_hnd_dat( partID, has_useragent=True, has_start_and_end_times=True, has_constructor=True, visit=None, expt="EEG1") reprtd_start_RPSM_str = start_time #rpsm_key[8:15] # from key name #if dsi_fn is not None: # reprtd_start_EEG_str = dsi_fn[10:18] #day = partID[0:8] #time= partID[9:] #eeg_dir = "~/Sites/taisen/DATA/EEG1/%(day)s/%(dt)s/" % {"day" : day, "dt" : partID} trials = _hnd_dat.shape[0] print("!!!!! trials %d" % trials) # the weight each one should have is just proportional to the # of events # of the condition (WTL) observed. tr0 = 0 tr1 = trials hnd_dat = _N.array(_hnd_dat[tr0:tr1]) #0:trials-trim_trials]) dat_pkg["lat"] = [] dat_pkg["behv"] = [] dat_pkg["behv_ts"] = [] #savgol_win = params4partID[partID][5] #%(dat)s,%(rel)s,%(cov)s%(ran)s sum_chosen_behv_sig = None #_N.zeros((len(behv_list), Tm1)) sigcov_behv_sig = None sigcov_behv_fsig = None behv_list = _N.array([0, 1, 2], _N.int) for bi in range(0, 1): if behv_list[bi] == _cnst._WTL: sig_cov = _N.array([_W, _T, _L]) else: sig_cov = _N.array([_R, _P, _S]) sig_cov = behv_list[bi] behv_file = fns[bi] print( getResultFN("%(rpsm)s/%(lb)d/%(fl)s.dmp" % { "rpsm": partID, "fl": behv_file, "lb": label })) dmp = depickle( getResultFN("%(rpsm)s/%(lb)d/%(fl)s.dmp" % { "rpsm": partID, "fl": behv_file, "lb": label })) cond_probs = dmp["cond_probs"] cond_probs = cond_probs.reshape((3, 3, cond_probs.shape[1])) s1 = _N.sum(_hnd_dat[0:TO_GAME, 2]) s2 = _N.sum(_hnd_dat[:, 2]) print("%(1)d %(2)d" % {"1": s1, "2": s2}) return cond_probs, _N.sum(_hnd_dat[0:TO_GAME, 2])
inds = _N.arange(tr1) if rndmz: _N.random.shuffle(inds) sran = "rndmz" hnd_dat = _N.array(rr_hnd_dat[inds]) N_all = hnd_dat.shape[0] - 1 smp_offsets_all = _N.empty((6, ITER)) smp_Bns_all = _N.ones((6, ITER, N_all)) * -100 conds = [] conds.append(_N.where(hnd_dat[0:-1, 2] == 1)[0]) # WIN conds.append(_N.where(hnd_dat[0:-1, 2] == 0)[0]) # TIE conds.append(_N.where(hnd_dat[0:-1, 2] == -1)[0]) # LOSE out_dir = getResultFN("%(dfn)s" % {"dfn": dat_fn}) if not os.access(out_dir, os.F_OK): os.mkdir(out_dir) out_dir = getResultFN("%(dfn)s/%(lbl)d" % {"dfn": dat_fn, "lbl": label}) if not os.access(out_dir, os.F_OK): os.mkdir(out_dir) col_n0 = 0 # current col_n1 = 0 # previous # can't directly use hnd_dat, as it condX are discontinuous, stay_win, wekr_win, strg_win, \ stay_tie, wekr_tie, strg_tie, \ stay_los, wekr_los, strg_los, \ win_cond, tie_cond, los_cond = _rd.get_ME_WTL(hnd_dat, tr0, tr1)
def pkg_all_data(partID): """ d_reprtd_start: delay RPSM game start relative to DSi - as calculated by reported JS start time and DSi start time. dt_sys_clks: how much system times are off. d_reprtd_start = RPSM(start) - DSi(start) RPSM say 12:00:00, DSi says 11:59:30 +30 if same_time_RPSM is 12:00:00 and same_time_EEG is 11:59:35, then d_sys_clks = 25 11:59:35 (RPSM) and 11:59:30 (DSi) als d_start = d_reprtd_start - d_sys_clks if d_start > 0, RPSM started AFTER EEG if d_start < 0, RPSM started BEFORE EEG """ print("partID %s" % partID) dat_pkg = {} dsi_fn = rpsms.rpsm_partID_as_key[partID] same_time_RPSM = params4partID[partID][0] # from calibration.html same_time_EEG = params4partID[partID][1] # from calibration.html rpsm_fn = "rpsm_%s.dat" % partID _hnd_dat, start_time, end_time = _rt.return_hnd_dat( partID, has_useragent=True, has_start_and_end_times=True, has_constructor=True) reprtd_start_RPSM_str = start_time #rpsm_key[8:15] # from key name if dsi_fn is not None: reprtd_start_EEG_str = dsi_fn[10:18] day = partID[0:8] time = partID[9:] print(day) print(time) eeg_dir = "~/Sites/taisen/DATA/EEG1/%(day)s/%(dt)s/" % { "day": day, "dt": partID } trials = _hnd_dat.shape[0] print("!!!!! trials %d" % trials) # the weight each one should have is just proportional to the # of events # of the condition (WTL) observed. tr0 = 0 tr1 = trials label = params4partID[partID][2] #covWTLRPS = dats[rpsm_key][6] if dats[rpsm_key][6] is not None else [_N.array([_W, _T, _L]), _N.array([_R, _P, _S])] #covWTLRPS = dats[rpsm_key][6] if dats[rpsm_key][6] is not None else [_N.array([_W, _T, _L])] armv_ver = params4partID[partID][3] gcoh_ver = params4partID[partID][4] win_spec, slideby_spec = _ppv.get_win_slideby(gcoh_ver) win_gcoh = win_spec slideby_gcoh = slideby_spec gcoh_fn = "gcoh_%(ws)d_%(ss)d" % {"ws": win_spec, "ss": slideby_spec} hnd_dat = _N.array(_hnd_dat[tr0:tr1]) #0:trials-trim_trials]) """ ## calculate weight each conditional stay_win, strg_win, wekr_win, stay_tie, wekr_tie, strg_tie, stay_los, wekr_los, strg_los, win_cond, tie_cond, los_cond = _rt.get_ME_WTL(hnd_dat, tr0, tr1) # p(stay | W) nWins = len(win_cond) nTies = len(tie_cond) nLoss = len(los_cond) cond_events = [[stay_win, wekr_win, strg_win], [stay_tie, wekr_tie, strg_tie], [stay_los, wekr_los, strg_los]] marg_cond_events = [win_cond, tie_cond, los_cond] cond_wgts = _N.array([[[win_cond.shape[0]]], [[tie_cond.shape[0]]], [[los_cond.shape[0]]]]) cond_wgts = cond_wgts / _N.sum(cond_wgts) """ dat_pkg["lat"] = [] dat_pkg["behv"] = [] dat_pkg["behv_ts"] = [] savgol_win = params4partID[partID][5] #%(dat)s,%(rel)s,%(cov)s%(ran)s sum_chosen_behv_sig = None #_N.zeros((len(behv_list), Tm1)) sigcov_behv_sig = None sigcov_behv_fsig = None behv_list = _N.array([0, 1, 2], _N.int) fig = _plt.figure(figsize=(10, 8)) for bi in range(3): #covWTLRPS = _N.array([_W, _T, _L])# if behv_list[bi] == _ME_WTL else _N.array([_R, _P, _S]) if behv_list[bi] == _cnst._WTL: sig_cov = _N.array([_W, _T, _L]) else: sig_cov = _N.array([_R, _P, _S]) sig_cov = behv_list[bi] behv_file = fns[bi] print( getResultFN("%(rpsm)s/%(lb)d/%(fl)s.dmp" % { "rpsm": partID, "fl": behv_file, "lb": label })) dmp = depickle( getResultFN("%(rpsm)s/%(lb)d/%(fl)s.dmp" % { "rpsm": partID, "fl": behv_file, "lb": label })) cond_probs = dmp["cond_probs"] cond_probs = cond_probs.reshape((3, 3, cond_probs.shape[1])) Tm1 = cond_probs.shape[2] # because AR1 filter is shorter by 1 # dNGS then should at most be Tm1 - 1 print("trials %(tr)d Tm1 %(Tm1)d" % {"tr": trials, "Tm1": Tm1}) if sigcov_behv_sig is None: # Tm1 - 1 (because derivative) sigcov_behv_sig = _N.zeros((3, Tm1 - 1)) sigcov_behv_fsig = _N.zeros((3, Tm1 - 1)) prob_mvs = cond_probs #prob_mvs[1] *= 0.001 # make TIE condition contribution small prob_fmvs = _N.zeros((3, 3, Tm1)) for iw in range(3): for ix in range(3): # if savgol_win is not None: # prob_fmvs[iw, ix] = savgol_filter(prob_mvs[iw, ix], savgol_win, 3) # window size 51, polynomial ord # else: prob_fmvs[iw, ix] = prob_mvs[iw, ix] these_covs = _N.array([0, 1, 2]) # sum over WTL condition first sigcov_behv_sig[bi] = _N.sum(_N.sum(_N.abs( _N.diff(prob_mvs[these_covs], axis=2)), axis=1), axis=0) sigcov_behv_fsig[bi] = _N.sum(_N.sum(_N.abs( _N.diff(prob_fmvs[these_covs], axis=2)), axis=1), axis=0) n = 0 fig.add_subplot(3, 2, bi * 2 + 1) bhv = sigcov_behv_sig[bi] _plt.acorr(bhv - _N.mean(bhv), maxlags=30) _plt.grid() fig.add_subplot(3, 2, bi * 2 + 2) fbhv = sigcov_behv_fsig[bi] _plt.acorr(fbhv - _N.mean(fbhv), maxlags=30) _plt.grid() print(".................................. %d" % bi) print(sigcov_behv_sig[bi]) print(sigcov_behv_fsig[bi]) # bhv1 = sigcov_behv_sig[0] # bhv2 = sigcov_behv_sig[1] # fig.add_subplot(3, 2, 5) # _plt.xcorr(bhv1 - _N.mean(bhv1), bhv2 - _N.mean(bhv2), maxlags=30) # bhv1 = sigcov_behv_fsig[0] # bhv2 = sigcov_behv_fsig[1] # fig.add_subplot(3, 2, 6) # _plt.xcorr(bhv1 - _N.mean(bhv1), bhv2 - _N.mean(bhv2), maxlags=30) print(sigcov_behv_sig) dat_pkg["behv"] = sigcov_behv_sig print(sigcov_behv_fsig) dat_pkg["fbehv"] = sigcov_behv_fsig dat_pkg["savgol_win"] = savgol_win # It is 2: because derivative of filter signal. # original hand data: size N. N-1 filtered time points, N-2 derivative points. So our behavioral data is size N-2 dat_pkg["behv_ts"] = hnd_dat[2:, 3] print("behv_ts shape") print(dat_pkg["behv_ts"].shape) dat_pkg["hnd_dat"] = hnd_dat #chg_rps = _N.loadtxt("Results/%s/mdl7b_chg_rps_mns" % rpsm_key) #btp_rps = _N.loadtxt("Results/%s/mdl7b_btp_rps_mns" % rpsm_key) # combine this with time stamp ########### Reported start times of RPS, EEG print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") reprtd_start_RPSM = int(reprtd_start_RPSM_str[8:10]) * 3600 + 60 * int( reprtd_start_RPSM_str[10:12]) + int(reprtd_start_RPSM_str[13:15]) if gcoh_fn is not None: reprtd_start_EEG = int(reprtd_start_EEG_str[0:2]) * 3600 + 60 * int( reprtd_start_EEG_str[3:5]) + int(reprtd_start_EEG_str[6:8]) else: reprtd_start_EEG = reprtd_start_RPSM d_reprtd_start = reprtd_start_RPSM - reprtd_start_EEG rpsm_hrs, rpsm_min, rpsm_secs = same_time_RPSM.split(":") eeg_hrs, eeg_min, eeg_secs = same_time_EEG.split(":") t_rpsm = int(rpsm_hrs) * 3600 + int(rpsm_min) * 60 + int(rpsm_secs) t_eeg = int(eeg_hrs) * 3600 + int(eeg_min) * 60 + int(eeg_secs) d_start = d_reprtd_start - (t_rpsm - t_eeg) print( "recording start time difference between page load and EEG hit record (negative means EEG started earlier) %d" % d_start) ####################################### hnd_dat[:, 3] += d_start * 1000 # RPS hands N pts # latent state is paired with previous hand and next hand obs (N-1) pts # diff latent state is difference between points (N-2) pts #dchg_wtl_with_ts[:, 3] = hnd_dat[2:, 3] #dbtp_wtl_with_ts[:, 3] = hnd_dat[2:, 3] #dat_pkg["dchg_wtl_with_ts"] = dchg_wtl_with_ts #dat_pkg["dbtp_wtl_with_ts"] = dbtp_wtl_with_ts if gcoh_fn is not None: eeg_dat = _N.loadtxt( "../DSi_dat/%(dsf)s_artfctrmvd/v%(av)d/%(dsf)s_artfctrmvd_v%(av)d.dat" % { "dsf": dsi_fn, "av": armv_ver, "gv": gcoh_ver }) gcoh_lm = depickle( "../DSi_dat/%(dsf)s_artfctrmvd/v%(av)d/%(dsf)s_%(gf)s_v%(av)d%(gv)d.dmp" % { "gf": gcoh_fn, "dsf": dsi_fn, "av": armv_ver, "gv": gcoh_ver }) if not os.access(getResultFN("%(dsf)s" % {"dsf": dsi_fn}), os.F_OK): os.mkdir(getResultFN("%(dsf)s" % {"dsf": dsi_fn})) savedir = getResultFN("%(dsf)s/v%(av)d%(gv)d" % { "gf": gcoh_fn, "dsf": dsi_fn, "av": armv_ver, "gv": gcoh_ver }) if not os.access(savedir, os.F_OK): os.mkdir(savedir) if gcoh_fn is not None: gcoh_fs = gcoh_lm["fs"] imag_evs = gcoh_lm["VEC"][:, :, 0:2] gcoh = gcoh_lm["Cs"] print("imag_evs.shape") print(imag_evs.shape) num_f_lvls = len(gcoh_fs) L_gcoh = imag_evs.shape[0] nChs = imag_evs.shape[3] real_evs = _N.empty((2, L_gcoh, num_f_lvls, nChs)) print("real_evs.shape") print(real_evs.shape) for ti in range(L_gcoh): real_evs[0, ti] = _N.abs(imag_evs[ti, :, 0]) real_evs[1, ti] = _N.abs(imag_evs[ti, :, 1]) """ mn = _N.mean(real_evs, axis=0) sd = _N.std(real_evs, axis=0) OUTLR = 10 outlrs = [] for ifr in range(num_f_lvls): for ich in range(nChs): abv = _N.where(real_evs[:, ifr, ich] > mn[ifr, ich] + OUTLR*sd[ifr, ich])[0] bel = _N.where(real_evs[:, ifr, ich] < mn[ifr, ich] - OUTLR*sd[ifr, ich])[0] outlrs.extend(abv) outlrs.extend(bel) unq_outlrs = _N.unique(outlrs) for io in unq_outlrs[0:-1]: real_evs[io+1] = real_evs[io] + 0.1*sd*_N.random.randn() """ dat_pkg["EIGVS"] = real_evs dat_pkg["fs"] = gcoh_fs dat_pkg["Cs"] = gcoh print(eeg_dat.shape[0]) print(win_gcoh) print(slideby_gcoh) dat_pkg["ts_gcoh"] = overlapping_window_center_times( eeg_dat.shape[0], win_gcoh, slideby_gcoh, 300.) print(dat_pkg["ts_gcoh"]) dat_pkg["gcoh_fn"] = gcoh_fn #### time ts_eeg_dfind = _N.linspace(0, eeg_dat.shape[0] / 300., eeg_dat.shape[0]) ch_spectrograms = [] maxHz = 50 for ch in range(21): spectrograms = [] fs, ts, Sxx = _ss.spectrogram(eeg_dat[:, ch], fs=300, nperseg=win_spec, noverlap=(win_spec - slideby_spec)) use_fs = _N.where(fs < maxHz)[0] for ihz in use_fs: spectrograms.append(Sxx[ihz]) ch_spectrograms.append(_N.array(spectrograms)) dat_pkg["ch_spectrograms"] = ch_spectrograms dat_pkg["ts_spectrograms"] = ts dat_pkg["fs_spectrograms"] = fs dat_pkg["eeg_smp_dt"] = 1. / 300 dat_pkg["win_gcoh"] = win_gcoh dat_pkg["slide_gcoh"] = slideby_gcoh dat_pkg["win_spec"] = win_spec dat_pkg["slide_spec"] = slideby_spec return savedir, dat_pkg, win_gcoh, slideby_gcoh, armv_ver, gcoh_ver, label
RPS_ratios = _N.empty((len(partIDs), 3)) RPS_ratiosMet = _N.empty(len(partIDs)) # DISPLAYED AS R,S,P # look for RR RS RP # look for SR SS SP # look for PR PS PP for partID in partIDs: pid += 1 dmp = depickle( getResultFN("%(rpsm)s/%(lb)d/WTL_%(v)d.dmp" % { "rpsm": partID, "lb": label, "v": visit })) ## Conditional Response (UP, DN, STAY | WTL) _prob_mvs = dmp["cond_probs"][SHF_NUM][:, strtTr:] ## Conditional Response (R, P, S | WTL) _prob_mvsRPS = dmp["cond_probsRPS"][SHF_NUM][:, strtTr:] ## Conditional Response (R, P, S | WTL) _prob_mvsDSURPS = dmp["cond_probsDSURPS"][SHF_NUM][:, strtTr:] ## Conditional Response (STAY, SWITCH | WTL) _prob_mvs_STSW = dmp["cond_probsSTSW"][SHF_NUM][:, strtTr:] ## Other things we might look at: ## prob(UP, DN, ST | RPS) prob(ST | R) _hnd_dat = dmp["all_tds"][SHF_NUM][strtTr:] end_strts[pid - 1] = _N.mean(_hnd_dat[-1, 3] - _hnd_dat[0, 3]) all_AI_weights[pid - 1] = dmp["AI_weights"][0:TO + 1]
for cov in [_AIconst._WTL]: #, _AIconst._HUMRPS, _AIconst._AIRPS]: scov = _AIconst.sCOV[cov] sran = "" SHUFFLES = 1 a_s = _N.zeros((len(datetms), SHUFFLES + 1)) acs = _N.zeros((len(datetms), SHUFFLES + 1, 61)) if gk_w > 0: gk = gauKer(gk_w) gk /= _N.sum(gk) sFlip = "_flip" if flip_human_AI else "" label = "%(wins)d%(gkw)d" % {"wins": wins, "gkw": gk_w} out_dir = getResultFN("%(dfn)s" % {"dfn": datetm}) if not os.access(out_dir, os.F_OK): os.mkdir(out_dir) out_dir = getResultFN("%(dfn)s/%(lbl)s" % { "dfn": datetm, "lbl": label }) if not os.access(out_dir, os.F_OK): os.mkdir(out_dir) td, start_time, end_time, UA, cnstr, inp_meth, ini_percep, fin_percep = _rt.return_hnd_dat( datetm, has_useragent=True, has_start_and_end_times=True, has_constructor=True,
t_offset = 0 # ms offset behv_sig_ts stop_early = 0 #180 ev_n = 0 gk_std = 1 gk = gauKer(gk_std) gk /= _N.sum(gk) show_shuffled = False rvrs = False process_keyval_args(globals(), sys.argv[1:]) ######################################################3 srvrs = "_revrsd" if rvrs else "" sshf = "_sh" if show_shuffled else "" rpsmdir = getResultFN(dat) pikdir = getResultFN("%(dir)s/v%(av)d%(gv)d" % { "dir": dat, "av": armv_ver, "gv": gcoh_ver }) outdir = pikdir print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") print("stop_early %d" % stop_early) print("t_offset %d" % t_offset) print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") print( "%(od)s/%(rk)s_%(w)d_%(s)d_pkld_dat_v%(av)d%(gv)d.dmp" % { "rk": rpsm_key,