Exemplo n.º 1
0
def get_image(number, training):
    if training:
        L = train_list
    else:
        L = eval_list
    adv_path=L[number]
    with mrcfile.open(adv_path) as mrc:
        adv = mrc.data
    with mrcfile.open(locate_gt(adv_path)) as mrc:
        gt = mrc.data
    return gt, adv
Exemplo n.º 2
0
def get_image(noise_level, methode, eval_data):
    if eval_data:
        d = eval_dic
    else:
        d = train_dic
    l = d[noise_level][methode]
    adv_path = random.choice(l)

    with mrcfile.open(adv_path) as mrc:
        adv = mrc.data
    with mrcfile.open(locate_gt(adv_path)) as mrc:
        gt = mrc.data
    return gt, adv
Exemplo n.º 3
0
def get_image(noise_level, method, data_dict, eval_data):
    data_list = data_dict[noise_level][method]
    adv_path = random.choice(data_list)

    if method == 'div':
        #        print('adv_path', adv_path)
        #        raise Exception
        star_file = load_star(adv_path)
        with mrcfile.open(
                cleanStarPath(
                    adv_path, star_file['external_reconstruct_general']
                    ['rlnExtReconsDataReal'])) as mrc:
            data_real = mrc.data
        with mrcfile.open(
                cleanStarPath(
                    adv_path, star_file['external_reconstruct_general']
                    ['rlnExtReconsDataImag'])) as mrc:
            data_im = mrc.data
        with mrcfile.open(
                cleanStarPath(
                    adv_path, star_file['external_reconstruct_general']
                    ['rlnExtReconsWeight'])) as mrc:
            kernel = mrc.data
        adv = np.divide(data_real + 1j * data_im, kernel + 1e-3)
        adv = irfft(adv)
    else:
        with mrcfile.open(adv_path) as mrc:
            adv = mrc.data

    with mrcfile.open(locate_gt(adv_path, noise_level,
                                eval_data=eval_data)) as mrc:
        gt = mrc.data


#    print(locate_gt(adv_path, eval_data=eval_data))
#    print(star_file)
#    raise Exception
    return gt, adv
Exemplo n.º 4
0
# In[19]:

file = load_star(path)

# In[20]:

with mrcfile.open(
        file['external_reconstruct_general']['rlnExtReconsDataReal']) as mrc:
    data_real = mrc.data.copy()
with mrcfile.open(
        file['external_reconstruct_general']['rlnExtReconsDataImag']) as mrc:
    data_im = mrc.data.copy()
with mrcfile.open(
        file['external_reconstruct_general']['rlnExtReconsWeight']) as mrc:
    kernel = mrc.data.copy()
with mrcfile.open(locate_gt(PDB_ID, full_path=False)) as mrc:
    ground_truth = mrc.data.copy()
with mrcfile.open(
        file['external_reconstruct_general']['rlnExtReconsResult']) as mrc:
    naive_recon = mrc.data.copy()

ground_truth = unify_form(ground_truth)
r_gt = Rescaler(ground_truth)
r_gt.normalize(ground_truth)

complex_data = data_real + 1j * data_im

# In[23]:

REG = 0.03