proberight = np.where(pside == -1, 1, 0) pleft_neut = np.where(np.logical_and(pside == 1, cues == 0), 1, 0) pleft_cued = np.where(np.logical_and(pside == 1, cues == 1), 1, 0) pright_neut = np.where(np.logical_and(pside == -1, cues == 0), 1, 0) pright_cued = np.where(np.logical_and(pside == -1, cues == 1), 1, 0) regressors.append(glm.regressors.CategoricalRegressor(category_list = pleft_neut, codes = 1, name = 'probe left neutral')) regressors.append(glm.regressors.CategoricalRegressor(category_list = pleft_cued, codes = 1, name = 'probe left cued')) regressors.append(glm.regressors.CategoricalRegressor(category_list = pright_neut, codes = 1, name = 'probe right neutral')) regressors.append(glm.regressors.CategoricalRegressor(category_list = pright_cued, codes = 1, name = 'probe right cued')) error = tfr.metadata.absrdif.to_numpy() err_npleft = nanzscore(np.where(pleft_neut == 1, error, np.nan)) err_cleft = nanzscore(np.where(pleft_cued == 1, error, np.nan)) err_npright = nanzscore(np.where(pright_neut == 1, error, np.nan)) err_cright = nanzscore(np.where(pright_cued == 1, error, np.nan)) regressors.append(glm.regressors.ParametricRegressor(name = 'err_pleft_neut', values = err_npleft, preproc = None, num_observations = nobs)) regressors.append(glm.regressors.ParametricRegressor(name = 'err_pleft_cued', values = err_cleft, preproc = None, num_observations = nobs)) regressors.append(glm.regressors.ParametricRegressor(name = 'err_pright_neut', values = err_npright, preproc = None, num_observations = nobs)) regressors.append(glm.regressors.ParametricRegressor(name = 'err_pright_cued', values = err_cright, preproc = None, num_observations = nobs)) contrasts = list() contrasts.append(glm.design.Contrast([ 1, 0, 0, 0, 0, 0, 0, 0], 'pleft_neutral') ) contrasts.append(glm.design.Contrast([ 0, 1, 0, 0, 0, 0, 0, 0], 'pleft_cued') ) contrasts.append(glm.design.Contrast([ 0, 0, 1, 0, 0, 0, 0, 0], 'pright_neutral') ) contrasts.append(glm.design.Contrast([ 0, 0, 0, 1, 0, 0, 0, 0], 'pright_cued') )
pleft_neut = np.where(np.logical_and(pside == 1, cues == 0), 1, 0) pleft_cued = np.where(np.logical_and(pside == 1, cues == 1), 1, 0) pright_neut = np.where(np.logical_and(pside == -1, cues == 0), 1, 0) pright_cued = np.where(np.logical_and(pside == -1, cues == 1), 1, 0) regressors.append(glm.regressors.CategoricalRegressor(category_list = pleft_neut, codes = 1, name = 'probe left neutral')) regressors.append(glm.regressors.CategoricalRegressor(category_list = pleft_cued, codes = 1, name = 'probe left cued')) regressors.append(glm.regressors.CategoricalRegressor(category_list = pright_neut, codes = 1, name = 'probe right neutral')) regressors.append(glm.regressors.CategoricalRegressor(category_list = pright_cued, codes = 1, name = 'probe right cued')) prevtrlerr = tfr.metadata.prevtrlerr.to_numpy() pterr_npleft = nanzscore(np.where(pleft_neut == 1, prevtrlerr, np.nan)) pterr_cleft = nanzscore(np.where(pleft_cued == 1, prevtrlerr, np.nan)) pterr_npright = nanzscore(np.where(pright_neut == 1, prevtrlerr, np.nan)) pterr_cright = nanzscore(np.where(pright_cued == 1, prevtrlerr, np.nan)) regressors.append(glm.regressors.ParametricRegressor(name = 'pterr_pleft_neut', values = pterr_npleft, preproc = None, num_observations = nobs)) regressors.append(glm.regressors.ParametricRegressor(name = 'pterr_pleft_cued', values = pterr_cleft, preproc = None, num_observations = nobs)) regressors.append(glm.regressors.ParametricRegressor(name = 'pterr_pright_neut', values = pterr_npright, preproc = None, num_observations = nobs)) regressors.append(glm.regressors.ParametricRegressor(name = 'pterr_pright_cued', values = pterr_cright, preproc = None, num_observations = nobs)) contrasts = list() contrasts.append(glm.design.Contrast([ 1, 0, 0, 0, 0, 0, 0, 0], 'pleft_neutral') ) contrasts.append(glm.design.Contrast([ 0, 1, 0, 0, 0, 0, 0, 0], 'pleft_cued') ) contrasts.append(glm.design.Contrast([ 0, 0, 1, 0, 0, 0, 0, 0], 'pright_neutral') )
glmdata = glm.data.TrialGLMData(data = epochs.get_data(), time_dim = 2, sample_rate = 500) nobs = glmdata.num_observations trials = np.ones(nobs) cues = epochs.metadata.cue.to_numpy() error = epochs.metadata.absrdif.to_numpy() confwidth = epochs.metadata.confwidth.to_numpy() #confidence width in degrees, higher = less confident conf = np.radians(np.multiply(confwidth, -1)) #reverse the sign so higher (less negative) = more confident, then convert to radians so same scale as error confdiff = np.radians(epochs.metadata.confdiff.to_numpy()) #error awareness (metacognition) on that trial (or prediction error) neutral = np.where(cues == 0, 1, 0) targinconf = np.less_equal(confdiff,0) targoutsideconf = np.greater(confdiff,0) incorrvscorr = np.where(targinconf == 0, 1, -1) errorcorr = nanzscore(np.where(targinconf == 1, error, np.nan)) errorincorr = nanzscore(np.where(targoutsideconf == 1, error, np.nan)) confcorr = nanzscore(np.where(targinconf == 1, conf, np.nan)) confincorr = nanzscore(np.where(targoutsideconf == 1, conf, np.nan)) pside = epochs.metadata.pside.to_numpy() pside = np.where(pside == 0, 1, -1) #add regressors to the model regressors = list() regressors.append(glm.regressors.CategoricalRegressor(category_list = targinconf, codes = 1, name = 'correct')) regressors.append(glm.regressors.CategoricalRegressor(category_list = targoutsideconf, codes = 1, name = 'incorrect')) regressors.append( glm.regressors.ParametricRegressor(name = 'error-correct', values = errorcorr, preproc = None, num_observations = nobs)) regressors.append( glm.regressors.ParametricRegressor(name = 'error-incorrect', values = errorincorr, preproc = None, num_observations = nobs))
regressors.append( glm.regressors.CategoricalRegressor(category_list=pright_neut, codes=1, name='probe right neutral')) regressors.append( glm.regressors.CategoricalRegressor(category_list=pright_cued, codes=1, name='probe right cued')) cw = tfr.metadata.confwidth.to_numpy() conf = np.multiply( cw, -1 ) #make this regressor indicate confidence, not confidence width. #multiply by -1 as large confidence widths = low confidence. now lower numbers = lower confidence conf_npleft = nanzscore(np.where(pleft_neut == 1, conf, np.nan)) conf_cleft = nanzscore(np.where(pleft_cued == 1, conf, np.nan)) conf_npright = nanzscore(np.where(pright_neut == 1, conf, np.nan)) conf_cright = nanzscore(np.where(pright_cued == 1, conf, np.nan)) regressors.append( glm.regressors.ParametricRegressor(name='conf_pleft_neut', values=conf_npleft, preproc=None, num_observations=nobs)) regressors.append( glm.regressors.ParametricRegressor(name='conf_pleft_cued', values=conf_cleft, preproc=None, num_observations=nobs)) regressors.append(
error = epochs.metadata.absrdif.to_numpy() confwidth = epochs.metadata.confwidth.to_numpy( ) #confidence width in degrees, higher = less confident conf = np.radians( np.multiply(confwidth, -1) ) #reverse the sign so higher (less negative) = more confident, then convert to radians so same scale as error confdiff = np.radians( epochs.metadata.confdiff.to_numpy() ) #error awareness (metacognition) on that trial (or prediction error) neutral = np.where(cues == 0, 1, 0) targinconf = np.less_equal(confdiff, 0) targoutsideconf = np.greater(confdiff, 0) incorrvscorr = np.where(targinconf == 0, 1, -1) errorcorr = nanzscore(np.where(targinconf == 1, error, np.nan)) errorincorr = nanzscore(np.where(targoutsideconf == 1, error, np.nan)) confcorr = nanzscore(np.where(targinconf == 1, conf, np.nan)) confincorr = nanzscore(np.where(targoutsideconf == 1, conf, np.nan)) pside = epochs.metadata.pside.to_numpy() pside = np.where(pside == 0, 1, -1) #add regressors to the model if model == 1: glm_folder = 'epochs_glm5' regressors = list() regressors.append( glm.regressors.CategoricalRegressor(category_list=targinconf, codes=1,
glmdata = glm.data.TrialGLMData(data=tfr.data, time_dim=3, sample_rate=100) nobs = glmdata.num_observations trials = np.ones( glmdata.num_observations) #regressor for just grand mean response error = tfr.metadata.absrdif.to_numpy() confwidth = tfr.metadata.confwidth.to_numpy( ) #confidence width in degrees, higher = less confident conf = np.radians( np.multiply(confwidth, -1) ) #reverse the sign so higher (less negative) = more confident, then convert to radians so same scale as error confdiff = tfr.metadata.confdiff.to_numpy( ) #error awareness (metacognition) on that trial (or prediction error) err = nanzscore(error) #dont worry about nans this is just normal zscore cw = nanzscore(confwidth) confidence = nanzscore(conf) regressors = list() regressors.append( glm.regressors.ParametricRegressor(name='mean induced', values=trials, preproc=None, num_observations=nobs)) regressors.append( glm.regressors.ParametricRegressor(name='error', values=err, preproc=None, num_observations=nobs)) regressors.append(
confdiff = epochs.metadata.confdiff.to_numpy( ) #error awareness on that trial neutral = np.where(cues == 0, 1, 0) nxttrlcw = epochs.metadata.nexttrlcw.to_numpy() nxttrlconf = np.multiply(nxttrlcw, -1) # trlupdate = np.subtract(confwidth, nxttrlcw) #positive value means that the confidence with got narrower -- negative value means it got wider trlupdate = np.subtract( nxttrlconf, conf ) #positive values mean they became more confident, negative values they became less confident targinconf = np.less_equal(confdiff, 0) targoutsideconf = np.greater(confdiff, 0) incorrvscorr = np.where(targinconf == 0, 1, -1) confwidth = nanzscore(confwidth) conf = nanzscore(conf) confdiff = nanzscore(confdiff) trlupdate = nanzscore(trlupdate) regressors = list() contrasts = list() if glmnum == 7: regressors.append( glm.regressors.ParametricRegressor(name='trials', values=trials, preproc=None, num_observations=nobs)) regressors.append( glm.regressors.ParametricRegressor(name='update', values=trlupdate,
neutral = np.where(cues == 0, 1, 0) targinconf = np.less_equal(confdiff, 0) targoutsideconf = np.greater(confdiff, 0) threshold = -10 if threshold == -6: glmnum = 5 else: glmnum = 6 defscorr = np.less_equal( confdiff, threshold) #easily correct (over 5 degrees underconfident) justcorr = np.isin( confdiff, np.arange(threshold + 1, 1) ) #within 5 degrees of the boundary (less than 5 degrees underconfident) err_defscorr = nanzscore(np.where(defscorr == 1, error, np.nan)) err_justcorr = nanzscore(np.where(justcorr == 1, error, np.nan)) err_incorr = nanzscore(np.where(targoutsideconf == 1, error, np.nan)) conf_defscorr = nanzscore(np.where(defscorr == 1, conf, np.nan)) conf_justcorr = nanzscore(np.where(justcorr == 1, conf, np.nan)) conf_incorr = nanzscore(np.where(targoutsideconf == 1, conf, np.nan)) pside = epochs.metadata.pside.to_numpy() pside = np.where(pside == 0, 1, -1) #add regressors to the model regressors = list() regressors.append( glm.regressors.CategoricalRegressor(category_list=defscorr,
regressors.append( glm.regressors.CategoricalRegressor(category_list=pleft_cued, codes=1, name='probe left cued')) regressors.append( glm.regressors.CategoricalRegressor(category_list=pright_neut, codes=1, name='probe right neutral')) regressors.append( glm.regressors.CategoricalRegressor(category_list=pright_cued, codes=1, name='probe right cued')) dt = tfr.metadata.DT.to_numpy() dt_npleft = nanzscore(np.where(pleft_neut == 1, dt, np.nan)) dt_cleft = nanzscore(np.where(pleft_cued == 1, dt, np.nan)) dt_npright = nanzscore(np.where(pright_neut == 1, dt, np.nan)) dt_cright = nanzscore(np.where(pright_cued == 1, dt, np.nan)) regressors.append( glm.regressors.ParametricRegressor(name='dt_pleft_neut', values=dt_npleft, preproc=None, num_observations=nobs)) regressors.append( glm.regressors.ParametricRegressor(name='dt_pleft_cued', values=dt_cleft, preproc=None, num_observations=nobs)) regressors.append(