def __init__(self, collection, selector, numObjs, obj, trialNum):
    conn = pymongo.Connection(port=22334, host='localhost')
    db = conn.mturk
    col = db[collection]
    self.obj = obj
    self.trialNum = trialNum
    self.subj_data = list(col.find(selector))
    self.numObjs = numObjs
    if (obj != 'face'):
        obj_inds = []
        for (idx, t) in enumerate(self.subj_data[0]['ImgData']):
            if (len(np.unique(obj_inds)) == self.numObjs):
                break
            elif (len(t) < 10):
                obj_inds.append(t[0]['obj'])
            else:
                obj_inds.append(t['obj'])
        self.models = np.unique(obj_inds)
        self.models_idxs = {}
        for (idx, model) in enumerate(self.models):
            self.models_idxs[model] = idx
            self.models_idxs = self.models_idxs
    self.trial_data = self.preprocess(self.subj_data, self.obj, self.trialNum)
    self.numResp = numObjs
    self.totalTrials = len(self.trial_data)
    self.corr_type = 'pearson'
def __init__(self, collection, selector, numObjs, obj, trialNum):
    conn = pymongo.Connection(port=22334, host='localhost')
    db = conn.mturk
    col = db[collection]
    self.obj = obj
    self.trialNum = trialNum
    self.subj_data = list(col.find(selector))
    self.numObjs = numObjs
    if (obj != 'face'):
        obj_inds = []
        for (idx, t) in enumerate(self.subj_data[0]['ImgData']):
            if (len(np.unique(obj_inds)) == self.numObjs):
                break
            elif (len(t) < 10):
                obj_inds.append(t[0]['obj'])
            else:
                obj_inds.append(t['obj'])
        self.models = np.unique(obj_inds)
        self.models_idxs = {}
        for (idx, model) in enumerate(self.models):
            self.models_idxs[model] = idx
            self.models_idxs = self.models_idxs
    self.trial_data = self.preprocess(self.subj_data, self.obj, self.trialNum)
    self.numResp = numObjs
    self.totalTrials = len(self.trial_data)
    self.corr_type = 'pearson'