def __init__(self, collection, selector, block_num=None, objects_oi=None, mongo_reload=False):
        
        if mongo_reload:
            conn = pymongo.Connection(port = 22334, host = 'localhost')
            db = conn.mturk
            col = db[collection]
            data = list(col.find(selector))
            print 'Loaded from mongoDB ...'
        else:
            local_backup = BKPDATAPATH + collection + '_bkp.pkl'
            data = pk.load(open(local_backup, 'r'))
            print 'Loaded from local mongo backup...'

        if (collection == 'objectome64') | (collection == 'objectome_imglvl'):
            ind_subj_flag = 0
            semantic_data = 0
        elif collection == 'monkobjectome':
            ind_subj_flag = 1
            semantic_data = 0
        elif collection == 'mobj-semantic':
            ind_subj_flag = 0
            semantic_data = 1

        if block_num != None:
            models = all_models[block_num]
            outfn = out_filenames[ind_subj_flag][block_num]
        elif objects_oi != None:
            models = objects_oi
            outfn = 'tmp'

        models_idxs = {}
        invert_rosch_labels = {}
        for idx, model in enumerate(models):
            models_idxs[model] = idx
            invert_rosch_labels[rl.return_label(model)] = idx
        rosch_labels = invert_rosch_labels.keys()
    
        self.collection = collection
        self.models = models
        self.models_idxs = models_idxs
        self.rosch_labels = rosch_labels
        self.invert_rosch_labels = invert_rosch_labels

        self.subj_data = data
        self.numObjs = len(models)
        self.outfn = outfn
        self.keep_subj = np.nan

        if semantic_data == 1:
            self.get_semantic_data()
        else:
            self.get_data()

        if mongo_reload == True:
            self.backup_to_disk()
def run_random():
    """ DELETION OF RANDOM AXIS FOR FIXED BOUNDARY ONE VS OTHER """
    import time 
    start = time.clock()

    params = pk.load(file('/mindhive/dicarlolab/u/esolomon/objectome_32/64obj_20dim_modelparams.pkl', 'rb'))
    cents_all = params['centers']
    radii_all = np.sqrt(params['radii'][:,0,0])  # this should be Lcovs

    cents_all_silenced = nullspc_rand(cents_all, np.random.randint(100))
    cents_all_silenced = nullspc_rand(cents_all_silenced, np.random.randint(100))

    import objectome as obj
    # objs = obj.models_combined16
    objs = obj.models_simulation
    # objs = obj.models_objectome64

    print 'Random silencing simulation with objects: ' + str(objs)

    inds = []
    for m in objs:
        inds.append(obj.models_objectome64.index(m))

    import dldata.human_data.roschlib as rl
    models = rl.ps64_models
    obj_names_all = [rl.return_label(m) for m in models]

    cents = cents_all[inds,:]
    cents_silence = cents_all_silenced[inds,:]
    radii = radii_all[inds]
    obj_names = [obj_names_all[ii] for ii in inds]

    # dp_o, dp_s, obj_pairs = perf_all_flexible(cents, cents_silence, radii, obj_names)
    # # plot_comparisons(dp_o, dp_s)
    # res_flex = {'dp_o':dp_o, 'dp_s':dp_s, 'objn':obj_pairs}

    dp_o, dp_s, bias_o, bias_s, perf_o, perf_s, obj_pairs = perf_all_fixed(cents, cents_silence, radii, obj_names)
    res_fix = {'dp_o':dp_o, 'dp_s':dp_s, 
        'bias_o':bias_o, 'bias_s':bias_s,
        'perf_o':perf_o, 'perf_s':perf_s,
        'objn':obj_pairs} 
    res = {'fix':res_fix}
    io.savemat('pspace/multrandDeletion0408_wface.mat', res)

    finish = time.clock()
    print 'Done in ' + str(finish-start) + ' s'
    return res