def readxrl(self): """ :param xrl: a *.xrl file :return: par: a dataframe merging params for all selected sessions :return: xls: a dataframe merging results for all selected sessions """ xrl = 'data/' + self.sub + '/' + self.sub + '.xrl' with open(xrl) as f: lines = f.read().splitlines() finished = [line for line in lines if line.endswith('.xlsx')] if self.sel_par is not None: finished = [line for line in finished if any(p in line for p in self.sel_par)] if self.sel_ses is not None: finished = [line for line in finished if any(s in line for s in self.sel_ses)] if self.rm_ses is not None: finished = [line for line in finished if all(s not in line for s in self.rm_ses)] par = [None] * len(finished) xls = [None] * len(finished) count = 0 for line in finished: stim_list = [v for k, v in config_tools.read_yml(line.split(', ')[1]).items() if k.startswith('stimulus')] for idx, s in enumerate(stim_list): s['stimulus'] = idx par[count] = pd.DataFrame(stim_list) xls[count] = pd.read_excel(pd.ExcelFile(line.split(', ')[3]), sheet_name=None) count += 1 return par, xls, count
def __init__(self, subject, par_file, cfg_file, res_dir, priors_file_path): self.subject = subject self.idx = time.strftime("%Y%m%dT%H%M", time.localtime()) # add the current date if not res_dir: res_dir = 'data/' self.res_dir = res_dir self.priors_file_path = priors_file_path self.cfg_file = cfg_file self.cfg = config_tools.read_yml(cfg_file) self.par_file = par_file self.param = config_tools.read_yml(par_file) self.patch_nmb = self.cfg['patch_nmb'] self.trial_nmb = self.cfg['trial_nmb'] self.trial_dur = self.cfg['trial_dur'] self.depthBits = self.cfg['depthBits'] self.ColorPicker = ColorPicker(c=self.param['c'], sscale=self.param['sscale'], unit='deg', depthBits=self.depthBits, subject=self.subject) self.ColorSpace = self.ColorPicker.colorSpace hue_list_path = 'config/colorlist/' + self.subject if not os.path.exists(hue_list_path): self.ColorPicker.gencolorlist(0.2) self.hue_list = hue_list_path + '/hue-list-10bit-res0.2-sub-' + self.subject + '.npy' self.Csml = self.ColorPicker.center() self.Crgb = self.ColorPicker.sml2rgb(self.ColorPicker.center()) self.mon = monitors.Monitor(name=self.cfg['monitor']['name'], width=self.cfg['monitor']['width'], distance=self.cfg['monitor']['distance']) self.mon.setSizePix((self.cfg['monitor']['size'])) self.win = visual.Window(monitor=self.mon, unit='deg', colorSpace=self.ColorSpace, color=self.Crgb, allowGUI=True, fullscr=True, bpc=(self.depthBits, self.depthBits, self.depthBits), depthBits=self.depthBits)