Ejemplo n.º 1
0
def CT(load_path, dset, sc, ang_freq, Exp_bin, bin_param, nTrain, nTD, nVal,
       nVD, bpath):
    dataset = ddf.load_and_preprocess_real_data(load_path, dset, sc)
    meta = ddf.load_meta(load_path + dset + '/', sc)
    pix_size = meta['pix_size']
    src_rad = meta['s2o']
    det_rad = meta['o2d']

    data_obj = ddf.real_data(dataset,
                             pix_size,
                             src_rad,
                             det_rad,
                             ang_freq,
                             zoom=False)

    CT_obj = ddf.CCB_CT(data_obj)
    CT_obj.init_algo()
    spf_space, Exp_op = ddf.support_functions.ExpOp_builder(
        bin_param, CT_obj.filter_space, interp=Exp_bin)
    # Create the FDK binned operator
    #    CT_obj.FDK_bin_nn = CT_obj.FDK_op * Exp_op

    # Create the NN-FDK object
    CT_obj.NNFDK = nn.NNFDK_class(CT_obj,
                                  nTrain,
                                  nTD,
                                  nVal,
                                  nVD,
                                  Exp_bin,
                                  Exp_op,
                                  bin_param,
                                  dset=dset,
                                  base_path=bpath)
    CT_obj.rec_methods += [CT_obj.NNFDK]
    return CT_obj
Ejemplo n.º 2
0
def load_and_preprocess(path, dset, redo, ang_freq):
    dataset, vecs = cap.load_and_preprocess(path,
                                            dset,
                                            redo=redo,
                                            ang_freq=ang_freq)
    meta = ddf.load_meta(path + dset + '/', 1)
    return dataset, vecs, meta
Ejemplo n.º 3
0
def CT(load_path, dset, sc, ang_freq):
    dataset = ddf.load_and_preprocess_real_data(load_path, dset, sc)
    meta = ddf.load_meta(load_path + dset + '/', sc)
    pix_size = meta['pix_size']
    src_rad = meta['s2o']
    det_rad = meta['o2d']
    
    data_obj = ddf.real_data(dataset, pix_size, src_rad, det_rad, ang_freq,
                 zoom=False)

    CT_obj = ddf.CCB_CT(data_obj)
    CT_obj.init_algo()
    return CT_obj
Ejemplo n.º 4
0
def CT(path, dset, sc, ang_freq, vox):
    dataset, vecs = cap.load_and_preprocess(path, dset, ang_freq=ang_freq)
    meta = ddf.load_meta(f'{path}{dset}/', 1)
    pix_size = sc * meta['pix_size']
    src_rad = meta['s2o']
    det_rad = meta['o2d']

    data_obj = ddf.real_data(dataset,
                             pix_size,
                             src_rad,
                             det_rad,
                             ang_freq,
                             vox=vox,
                             vecs=vecs)

    CT_obj = ddf.CCB_CT(data_obj)
    CT_obj.init_algo()
    return CT_obj
Ejemplo n.º 5
0
def CT(load_path, dset, sc, ang_freq, Exp_bin, bin_param, offset):
    dataset = ddf.load_and_preprocess_real_data(load_path, dset, sc)
    meta = ddf.load_meta(load_path + dset + '/', sc)
    pix_size = meta['pix_size']
    src_rad = meta['s2o']
    det_rad = meta['o2d']

    data_obj = ddf.real_data(dataset,
                             pix_size,
                             src_rad,
                             det_rad,
                             ang_freq,
                             zoom=True,
                             offset=offset)

    CT_obj = ddf.CCB_CT(data_obj)
    CT_obj.init_algo()
    CT_obj.init_DDF_FDK()
    return CT_obj
Ejemplo n.º 6
0
def CT(path, dset, sc, ang_freq, Exp_bin, bin_param, nTrain, nTD, nVal, nVD,
       vox, bp):
    dataset, vecs = cap.load_and_preprocess(path, dset, ang_freq=ang_freq)
    meta = ddf.load_meta(f'{path}{dset}/', 1)
    pix_size = sc * meta['pix_size']
    src_rad = meta['s2o']
    det_rad = meta['o2d']

    data_obj = ddf.real_data(dataset,
                             pix_size,
                             src_rad,
                             det_rad,
                             ang_freq,
                             vox=vox,
                             vecs=vecs)

    CT_obj = ddf.CCB_CT(data_obj)
    CT_obj.init_algo()
    spf_space, Exp_op = ddf.support_functions.ExpOp_builder(
        bin_param, CT_obj.filter_space, interp=Exp_bin)
    # Create the FDK binned operator
    #    CT_obj.FDK_bin_nn = CT_obj.FDK_op * Exp_op

    # Create the NN-FDK object
    CT_obj.NNFDK = nn.NNFDK_class(CT_obj,
                                  nTrain,
                                  nTD,
                                  nVal,
                                  nVD,
                                  Exp_bin,
                                  Exp_op,
                                  bin_param,
                                  dset=dset,
                                  base_path=bp)
    CT_obj.rec_methods += [CT_obj.NNFDK]
    return CT_obj
Ejemplo n.º 7
0
    filt = filt * (np.cos(freq * np.pi / 2)**2) / 2 / w_detu
    #    filt = filt / 2 / w_detu
    return filt


# %%
path = '/bigstore/lagerwer/data/FleXray/pomegranate1_02MAR/'
#path = '/export/scratch2/lagerwer/data/FleXray/walnuts_10MAY/walnut_01/'
dset = 'noisy'
#dset2 = 'good'
pd = 'processed_data/'
sc = 1
ang_freq = 1
redo = False
dataset = ddf.load_and_preprocess_real_data(path, dset, sc, redo=redo)
meta = ddf.load_meta(path + dset + '/', sc)

pix_size = meta['pix_size']
src_rad = meta['s2o']
det_rad = meta['o2d']
#dataset = {'g': }

# Specifics for the expansion operator
Exp_bin = 'linear'
bin_param = 2

# %% Create a test phantom
# Create a data object
t2 = time.time()
offset = 1.26 / 360 * 2 * np.pi
data_obj = ddf.real_data(dataset,
Ejemplo n.º 8
0
def load_and_preprocess(path, dset, sc, redo, ang_freq):
    dataset, vecs = cap.load_and_preprocess(path, dset, ang_freq=ang_freq)
    meta = ddf.load_meta(f'{path}{dset}/', 1)

    return dataset, meta, vecs
Ejemplo n.º 9
0
def compute_GS_and_mask(path, redo):
    save_path = f'{path}processed_data/'

    niter = 50
    sc = 2
    vecs = np.zeros((0, 12))
    g = np.zeros((0, 768, 972))
    for i in [1, 2, 3]:
        dset = f'tubeV{i}'
        lp = f'{path}{dset}/'
        lpvecs = f'{lp}scan_geom_corrected.geom'
        vecs = np.append(vecs, np.loadtxt(lpvecs)[:-1, :] / 10, axis=0)
        g = np.append(g,
                      preprocess_data_portrait(path, dset, redo=redo),
                      axis=0)
        if i == 2:
            meta = ddf.load_meta(lp, 1)

    rec = do_AGD(meta, vecs, sc, g, niter)

    vox = np.shape(rec)[0]

    save = np.zeros((3, vox, vox))
    save[0, :, :], save[1, :, :] = rec[:, :, vox // 2], rec[:, vox // 2, :]
    save[2, :, :] = rec[vox // 2, :, :]
    np.save(f'{save_path}rec_ax_AGD50', save)
    # %%
    np.save(f'{save_path}rec_AGD50', rec)
    end = time.time()

    # %%
    rec *= (rec > 0.03)
    edge = vox // 32
    edge_t = np.zeros(np.shape(rec))
    edge_t[edge:-edge, edge:-edge, edge:-edge] = 1
    rec *= edge_t
    del edge_t
    save[0, :, :], save[1, :, :] = rec[:, :, vox // 2], rec[:, vox // 2, :]
    save[2, :, :] = rec[vox // 2, :, :]
    np.save(f'{save_path}GT_ax', save)
    diter = int(1.5 * 2**(np.log2(vox) - 5))
    it = 5
    mask = sp.binary_erosion(rec, iterations=it)
    mask = sp.binary_dilation(mask, iterations=diter + it)
    save[0, :, :], save[1, :, :] = mask[:, :, vox // 2], mask[:, vox // 2, :]
    save[2, :, :] = mask[vox // 2, :, :]
    np.save(f'{save_path}mask_ax', save)
    # %%

    np.save(f'{save_path}ground_truth.npy', rec)
    np.save(f'{save_path}mask.npy', mask)

    t3 = time.time()
    print(t3 - end, 'Finished computing mask and ground truth')


# %%
#path = '/export/scratch2/lagerwer/data/FleXray/Walnuts/Walnut1/Projections/'
#dset = f'tubeV{2}'
#pd = 'processed_data/'
#ang_freq = 1
#redo = False
#sc = 4
#
#load_and_preprocess(path, dset, redo=redo)
Ejemplo n.º 10
0
def load_and_preprocess(path, dset, sc, redo):
    dataset = ddf.load_and_preprocess_real_data(path, dset, sc, redo=redo)
    meta = ddf.load_meta(path + dset + '/', sc)
    return dataset, meta