def preprocess(self, subj_data, obj, trialNum):
    RV = []
    SV = []
    DV = []
    if (obj == 'face'):
        RV = []
        DV = []
        RT = []
        for subj in self.subj_data:
            models_name = np.unique(subj['Response'])
            models_size = np.unique(subj['Size'])
            self.models = []
            for idx1 in models_name:
                for idx2 in models_size:
                    self.models.append([((str(idx1) + '_') + str(idx2))])
            models_idxs = {}
            for (idx, model) in enumerate(self.models):
                models_idxs[tuple(model)] = idx
            self.models_idxs = models_idxs
            for (t_idx, t) in enumerate(subj['RT']):
                if ((t_idx >= trialNum[0]) and (t_idx < trialNum[1])):
                    RT.append(t)
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    RV.append([((str(r) + '_') + str(subj['Size'][r_idx]))])
            for (s_idx, s) in enumerate(subj['StimShown']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    DV.append([((str(s) + '_') + str(subj['Size'][s_idx]))])
    elif (obj == 'obj_lack'):
        RV_s = []
        DV_s = []
        RV_p = []
        DV_p = []
        RV_r = []
        DV_r = []
        RV = []
        DV = []
        for subj in self.subj_data:
            self.models = np.unique(subj['Response'])
            models_idxs = {}
            for (idx, model) in enumerate(self.models):
                models_idxs[tuple(model)] = idx
            self.models_idxs = models_idxs
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    if (subj['ImgData'][r_idx]['tname'] == 'obj_size'):
                        RV_s.append(r)
                    elif (subj['ImgData'][r_idx]['tname'] == 'position'):
                        RV_p.append(r)
                    elif (subj['ImgData'][r_idx]['tname'] == 'rotation'):
                        RV_r.append(r)
                    else:
                        RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    if (subj['ImgData'][s_idx]['tname'] == 'obj_size'):
                        DV_s.append(s)
                    elif (subj['ImgData'][s_idx]['tname'] == 'position'):
                        DV_p.append(s)
                    elif (subj['ImgData'][s_idx]['tname'] == 'rotation'):
                        DV_r.append(s)
                    else:
                        DV.append(s)
    elif (obj == 'obj'):
        RV_s = []
        DV_s = []
        RV_p = []
        DV_p = []
        RV_r = []
        DV_r = []
        RV = []
        DV = []
        for subj in self.subj_data:
            self.models = np.unique(subj['Response'])
            models_idxs = {}
            for (idx, model) in enumerate(self.models):
                models_idxs[tuple(model)] = idx
            self.models_idxs = models_idxs
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    if (subj['ImgData'][r_idx][0]['tname'] == 'obj_size'):
                        RV_s.append(r)
                    elif (subj['ImgData'][r_idx][0]['tname'] == 'position'):
                        RV_p.append(r)
                    elif (subj['ImgData'][r_idx][0]['tname'] == 'rotation'):
                        RV_r.append(r)
                    else:
                        RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    if (subj['ImgData'][s_idx][0]['tname'] == 'obj_size'):
                        DV_s.append(s)
                    elif (subj['ImgData'][s_idx][0]['tname'] == 'position'):
                        DV_p.append(s)
                    elif (subj['ImgData'][s_idx][0]['tname'] == 'rotation'):
                        DV_r.append(s)
                    else:
                        DV.append(s)
    elif (obj == '2way'):
        RV = []
        DV = []
        RV_s = []
        DV_s = []
        SV_s = []
        SV = []
        for subj in self.subj_data:
            for (t_idx, t) in enumerate(subj['ImgData']):
                if ((t_idx >= trialNum[0]) and (t_idx < trialNum[1])):
                    if (subj['ImgData'][t_idx][0]['tname'] == 'obj_size'):
                        SV_s.append([t[1]['obj'], t[2]['obj']])
                    else:
                        SV.append([t[1]['obj'], t[2]['obj']])
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    if (subj['ImgData'][r_idx][0]['tname'] == 'obj_size'):
                        RV_s.append(r)
                    else:
                        RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    if (subj['ImgData'][s_idx][0]['tname'] == 'obj_size'):
                        DV_s.append(s)
                    else:
                        DV.append(s)
    elif (obj == '2way_face'):
        RV = []
        DV = []
        RV_s = []
        DV_s = []
        SV_s = []
        SV = []
        for subj in self.subj_data:
            for (t_idx, t) in enumerate(subj['ImgData']):
                if ((t_idx >= trialNum[0]) and (t_idx < trialNum[1])):
                    if (subj['ImgData'][t_idx][0]['var'] == 'V0_size'):
                        SV_s.append([t[1]['obj'], t[2]['obj']])
                    else:
                        SV.append([t[1]['obj'], t[2]['obj']])
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    if (subj['ImgData'][r_idx][0]['var'] == 'V0_size'):
                        RV_s.append(r)
                    else:
                        RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    if (subj['ImgData'][s_idx][0]['var'] == 'V0_size'):
                        DV_s.append(s)
                    else:
                        DV.append(s)
    else:
        RV = []
        DV = []
        for subj in subj_data:
            self.models = np.unique(subj['TestStim'])
            models_idxs = {}
            for (idx, model) in enumerate(self.models):
                models_idxs[tuple(model)] = idx
            self.models_idxs = models_idxs
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    DV.append(s)
    if (obj == 'obj'):
        new_data_s = []
        new_data_p = []
        new_data_r = []
        new_data = []
        for (idx, shown) in enumerate(DV_s):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV_s[idx])]
            new_data_s.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        for (idx, shown) in enumerate(DV_p):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV_p[idx])]
            new_data_p.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        for (idx, shown) in enumerate(DV_r):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV_r[idx])]
            new_data_r.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        for (idx, shown) in enumerate(DV):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV[idx])]
            new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        return [new_data_s, new_data_p, new_data_r, new_data]
    elif (obj == '2way'):
        new_data_s = []
        new_data = []
        for (idx, shown) in enumerate(DV_s):
            model = shown
            CF_col_idx = self.models_idxs[model]
            CF_row_idx = self.models_idxs[RV_s[idx]]
            new_data_s.append([CF_col_idx, CF_row_idx, [self.models_idxs[m] for m in SV_s[idx]]])
        for (idx, shown) in enumerate(DV):
            model = shown
            CF_col_idx = self.models_idxs[model]
            CF_row_idx = self.models_idxs[RV[idx]]
            new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[m] for m in SV[idx]]])
        return [new_data_s, new_data]
    elif (obj == '2way_face'):
        new_data_s = []
        new_data = []
        for (idx, shown) in enumerate(DV_s):
            model = shown
            CF_col_idx = self.models_idxs[model]
            CF_row_idx = self.models_idxs[RV_s[idx]]
            new_data_s.append([CF_col_idx, CF_row_idx, [self.models_idxs[m] for m in SV_s[idx]]])
        for (idx, shown) in enumerate(DV):
            model = shown
            CF_col_idx = self.models_idxs[model]
            CF_row_idx = self.models_idxs[RV[idx]]
            new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[m] for m in SV[idx]]])
        return [new_data_s, new_data]
    elif (obj == 'face'):
        new_data = []
        for (idx, shown) in enumerate(DV):
            if (RT[idx] < 3000):
                model = shown
                CF_col_idx = self.models_idxs[tuple(model)]
                CF_row_idx = self.models_idxs[tuple(RV[idx])]
                new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        return new_data
    else:
        new_data = []
        for (idx, shown) in enumerate(DV):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV[idx])]
            new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        return new_data
def preprocess(self, subj_data, obj, trialNum):
    RV = []
    SV = []
    DV = []
    if (obj == 'face'):
        RV = []
        DV = []
        RT = []
        for subj in self.subj_data:
            models_name = np.unique(subj['Response'])
            models_size = np.unique(subj['Size'])
            self.models = []
            for idx1 in models_name:
                for idx2 in models_size:
                    self.models.append([((str(idx1) + '_') + str(idx2))])
            models_idxs = {}
            for (idx, model) in enumerate(self.models):
                models_idxs[tuple(model)] = idx
            self.models_idxs = models_idxs
            for (t_idx, t) in enumerate(subj['RT']):
                if ((t_idx >= trialNum[0]) and (t_idx < trialNum[1])):
                    RT.append(t)
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    RV.append([((str(r) + '_') + str(subj['Size'][r_idx]))])
            for (s_idx, s) in enumerate(subj['StimShown']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    DV.append([((str(s) + '_') + str(subj['Size'][s_idx]))])
    elif (obj == 'obj_lack'):
        RV_s = []
        DV_s = []
        RV_p = []
        DV_p = []
        RV_r = []
        DV_r = []
        RV = []
        DV = []
        for subj in self.subj_data:
            self.models = np.unique(subj['Response'])
            models_idxs = {}
            for (idx, model) in enumerate(self.models):
                models_idxs[tuple(model)] = idx
            self.models_idxs = models_idxs
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    if (subj['ImgData'][r_idx]['tname'] == 'obj_size'):
                        RV_s.append(r)
                    elif (subj['ImgData'][r_idx]['tname'] == 'position'):
                        RV_p.append(r)
                    elif (subj['ImgData'][r_idx]['tname'] == 'rotation'):
                        RV_r.append(r)
                    else:
                        RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    if (subj['ImgData'][s_idx]['tname'] == 'obj_size'):
                        DV_s.append(s)
                    elif (subj['ImgData'][s_idx]['tname'] == 'position'):
                        DV_p.append(s)
                    elif (subj['ImgData'][s_idx]['tname'] == 'rotation'):
                        DV_r.append(s)
                    else:
                        DV.append(s)
    elif (obj == 'obj'):
        RV_s = []
        DV_s = []
        RV_p = []
        DV_p = []
        RV_r = []
        DV_r = []
        RV = []
        DV = []
        for subj in self.subj_data:
            self.models = np.unique(subj['Response'])
            models_idxs = {}
            for (idx, model) in enumerate(self.models):
                models_idxs[tuple(model)] = idx
            self.models_idxs = models_idxs
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    if (subj['ImgData'][r_idx][0]['tname'] == 'obj_size'):
                        RV_s.append(r)
                    elif (subj['ImgData'][r_idx][0]['tname'] == 'position'):
                        RV_p.append(r)
                    elif (subj['ImgData'][r_idx][0]['tname'] == 'rotation'):
                        RV_r.append(r)
                    else:
                        RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    if (subj['ImgData'][s_idx][0]['tname'] == 'obj_size'):
                        DV_s.append(s)
                    elif (subj['ImgData'][s_idx][0]['tname'] == 'position'):
                        DV_p.append(s)
                    elif (subj['ImgData'][s_idx][0]['tname'] == 'rotation'):
                        DV_r.append(s)
                    else:
                        DV.append(s)
    elif (obj == '2way'):
        RV = []
        DV = []
        RV_s = []
        DV_s = []
        SV_s = []
        SV = []
        for subj in self.subj_data:
            for (t_idx, t) in enumerate(subj['ImgData']):
                if ((t_idx >= trialNum[0]) and (t_idx < trialNum[1])):
                    if (subj['ImgData'][t_idx][0]['tname'] == 'obj_size'):
                        SV_s.append([t[1]['obj'], t[2]['obj']])
                    else:
                        SV.append([t[1]['obj'], t[2]['obj']])
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    if (subj['ImgData'][r_idx][0]['tname'] == 'obj_size'):
                        RV_s.append(r)
                    else:
                        RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    if (subj['ImgData'][s_idx][0]['tname'] == 'obj_size'):
                        DV_s.append(s)
                    else:
                        DV.append(s)
    elif (obj == '2way_face'):
        RV = []
        DV = []
        RV_s = []
        DV_s = []
        SV_s = []
        SV = []
        for subj in self.subj_data:
            for (t_idx, t) in enumerate(subj['ImgData']):
                if ((t_idx >= trialNum[0]) and (t_idx < trialNum[1])):
                    if (subj['ImgData'][t_idx][0]['var'] == 'V0_size'):
                        SV_s.append([t[1]['obj'], t[2]['obj']])
                    else:
                        SV.append([t[1]['obj'], t[2]['obj']])
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    if (subj['ImgData'][r_idx][0]['var'] == 'V0_size'):
                        RV_s.append(r)
                    else:
                        RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    if (subj['ImgData'][s_idx][0]['var'] == 'V0_size'):
                        DV_s.append(s)
                    else:
                        DV.append(s)
    else:
        RV = []
        DV = []
        for subj in subj_data:
            self.models = np.unique(subj['TestStim'])
            models_idxs = {}
            for (idx, model) in enumerate(self.models):
                models_idxs[tuple(model)] = idx
            self.models_idxs = models_idxs
            for (r_idx, r) in enumerate(subj['Response']):
                if ((r_idx >= trialNum[0]) and (r_idx < trialNum[1])):
                    RV.append(r)
            for (s_idx, s) in enumerate(subj['StimPresent']):
                if ((s_idx >= trialNum[0]) and (s_idx < trialNum[1])):
                    DV.append(s)
    if (obj == 'obj'):
        new_data_s = []
        new_data_p = []
        new_data_r = []
        new_data = []
        for (idx, shown) in enumerate(DV_s):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV_s[idx])]
            new_data_s.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        for (idx, shown) in enumerate(DV_p):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV_p[idx])]
            new_data_p.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        for (idx, shown) in enumerate(DV_r):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV_r[idx])]
            new_data_r.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        for (idx, shown) in enumerate(DV):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV[idx])]
            new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        return [new_data_s, new_data_p, new_data_r, new_data]
    elif (obj == '2way'):
        new_data_s = []
        new_data = []
        for (idx, shown) in enumerate(DV_s):
            model = shown
            CF_col_idx = self.models_idxs[model]
            CF_row_idx = self.models_idxs[RV_s[idx]]
            new_data_s.append([CF_col_idx, CF_row_idx, [self.models_idxs[m] for m in SV_s[idx]]])
        for (idx, shown) in enumerate(DV):
            model = shown
            CF_col_idx = self.models_idxs[model]
            CF_row_idx = self.models_idxs[RV[idx]]
            new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[m] for m in SV[idx]]])
        return [new_data_s, new_data]
    elif (obj == '2way_face'):
        new_data_s = []
        new_data = []
        for (idx, shown) in enumerate(DV_s):
            model = shown
            CF_col_idx = self.models_idxs[model]
            CF_row_idx = self.models_idxs[RV_s[idx]]
            new_data_s.append([CF_col_idx, CF_row_idx, [self.models_idxs[m] for m in SV_s[idx]]])
        for (idx, shown) in enumerate(DV):
            model = shown
            CF_col_idx = self.models_idxs[model]
            CF_row_idx = self.models_idxs[RV[idx]]
            new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[m] for m in SV[idx]]])
        return [new_data_s, new_data]
    elif (obj == 'face'):
        new_data = []
        for (idx, shown) in enumerate(DV):
            if (RT[idx] < 3000):
                model = shown
                CF_col_idx = self.models_idxs[tuple(model)]
                CF_row_idx = self.models_idxs[tuple(RV[idx])]
                new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        return new_data
    else:
        new_data = []
        for (idx, shown) in enumerate(DV):
            model = shown
            CF_col_idx = self.models_idxs[tuple(model)]
            CF_row_idx = self.models_idxs[tuple(RV[idx])]
            new_data.append([CF_col_idx, CF_row_idx, [self.models_idxs[tuple(m)] for m in self.models]])
        return new_data