예제 #1
0
from tomobar.methodsIR import RecToolsIR
# set parameters and initiate a class object
Rectools = RecToolsIR(
    DetectorsDimH=
    detectorHoriz,  # DetectorsDimH # detector dimension (horizontal)
    DetectorsDimV=
    None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
    CenterRotOffset=None,  # Center of Rotation (CoR) scalar (for 3D case only)
    AnglesVec=angles_rad,  # array of angles in radians
    ObjSize=N_size,  # a scalar to define reconstructed object dimensions
    datafidelity='LS',  # data fidelity, choose LS, PWLS, GH (wip), Student (wip)
    nonnegativity='ENABLE',  # enable nonnegativity constraint (set to 'ENABLE')
    OS_number=
    None,  # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets
    tolerance=1e-08,  # tolerance to stop outer iterations earlier
    device='gpu')

# Run ADMM-LS-TV reconstrucion algorithm
RecADMM_LS_TV = Rectools.ADMM(data_norm[:,:,slice_to_recon], \
                              rho_const = 500.0, \
                              iterationsADMM = 5,\
                              regularisation = 'FGP_TV', \
                              regularisation_parameter = 0.005,\
                              regularisation_iterations = 100)

fig = plt.figure()
plt.imshow(RecADMM_LS_TV[150:550, 150:550], vmin=0, vmax=0.003, cmap="gray")
#plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('ADMM LS-TV reconstruction')
plt.show()
#fig.savefig('dendr_TV.png', dpi=200)
예제 #2
0
RecFISTA_regNLTV = Rectools.FISTA(_data_, _algorithm_, _regularisation_)
fig = plt.figure()
plt.imshow(RecFISTA_regNLTV, vmin=0, vmax=0.2, cmap="gray")
plt.title('FISTA PWLS-OS-NLTV reconstruction')
plt.show()
#fig.savefig('ice_NLTV.png', dpi=200)
#%%
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("%%%%%%Reconstructing with ADMM LS-NLTV method %%%%%%%%%%%%%%%%")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
_algorithm_ = {'iterations': 5, 'ADMM_rho_const': 500.0}

_regularisation_ = {
    'method': 'PD_TV',
    'regul_param': 0.015,
    'iterations': 80,
    'device_regulariser': 'gpu'
}

# Run ADMM-LS-TV reconstrucion algorithm
RecADMM_LS_TV = Rectools.ADMM(_data_, _algorithm_, _regularisation_)

fig = plt.figure()
plt.imshow(RecADMM_LS_TV, vmin=0, vmax=0.2, cmap="gray")
#plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('ADMM LS-TV reconstruction')
plt.show()
#%%
예제 #3
0
    None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
    CenterRotOffset=None,  # Center of Rotation (CoR) scalar (for 3D case only)
    AnglesVec=angles_rad,  # array of angles in radians
    ObjSize=N_size,  # a scalar to define reconstructed object dimensions
    datafidelity=
    'LS',  # data fidelity, choose LS, PWLS (wip), GH (wip), Student (wip)
    nonnegativity='ENABLE',  # enable nonnegativity constraint (set to 'ENABLE')
    OS_number=
    None,  # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets
    tolerance=1e-06,  # tolerance to stop OUTER iterations earlier
    device='gpu')

# Run ADMM reconstrucion algorithm with regularisation
RecADMM_reg = Rectools.ADMM(noisy_sino,
                              rho_const = 4000.0, \
                              iterationsADMM = 15, \
                              regularisation = 'SB_TV', \
                              regularisation_parameter = 0.06,\
                              regularisation_iterations = 50)

plt.figure()
plt.imshow(RecADMM_reg, vmin=0, vmax=1, cmap="gray")
plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('ADMM reconstruction')
plt.show()

# calculate errors
Qtools = QualityTools(phantom_2D, RecADMM_reg)
RMSE_ADMM = Qtools.rmse()
print("RMSE for regularised ADMM is {}".format(RMSE_ADMM))
#%%
예제 #4
0
# set parameters and initiate a class object
Rectools = RecToolsIR(DetectorsDimH = Horiz_det,  # DetectorsDimH # detector dimension (horizontal)
                    DetectorsDimV = Vert_det,  # DetectorsDimV # detector dimension (vertical) for 3D case only
                    CenterRotOffset = None, # Center of Rotation (CoR) scalar (for 3D case only)
                    AnglesVec = angles_rad, # array of angles in radians
                    ObjSize = N_size, # a scalar to define reconstructed object dimensions
                    datafidelity='LS',# data fidelity, choose LS, PWLS, GH (wip), Student (wip)
                    nonnegativity='ENABLE', # enable nonnegativity constraint (set to 'ENABLE')
                    OS_number = None, # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets
                    tolerance = 1e-06, # tolerance to stop outer iterations earlier
                    device='gpu')

# Run ADMM reconstrucion algorithm with regularisation
RecADMM_reg = Rectools.ADMM(projData3D_analyt_noise,
                              rho_const = 2000.0, \
                              iterationsADMM = 20, \
                              regularisation = 'FGP_TV', \
                              regularisation_parameter = 0.0035,\
                              regularisation_iterations = 200)


sliceSel = int(0.5*N_size)
max_val = 1
plt.figure() 
plt.subplot(131)
plt.imshow(RecADMM_reg[sliceSel,:,:],vmin=0, vmax=max_val)
plt.title('3D ADMM Reconstruction, axial view')

plt.subplot(132)
plt.imshow(RecADMM_reg[:,sliceSel,:],vmin=0, vmax=max_val)
plt.title('3D ADMM Reconstruction, coronal view')
예제 #5
0
    DetectorsDimV=
    100,  # DetectorsDimV # detector dimension (vertical) for 3D case only
    AnglesVec=angles_rad,  # array of angles in radians
    ObjSize=N_size,  # a scalar to define reconstructed object dimensions
    datafidelity=
    'LS',  # data fidelity, choose LS, PWLS, GH (wip), Students t (wip)
    nonnegativity='ENABLE',  # enable nonnegativity constraint (set to 'ENABLE')
    OS_number=
    None,  # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets
    tolerance=0.0,  # tolerance to stop inner (regularisation) iterations earlier
    device='gpu')
#%%
print("Reconstructing with ADMM method using SB-TV penalty")
RecADMM_reg_sbtv = RectoolsIR.ADMM(data_norm[0:100,:,det_y_crop],
                              rho_const = 2000.0, \
                              iterationsADMM = 15, \
                              regularisation = 'SB_TV', \
                              regularisation_parameter = 0.00085,\
                              regularisation_iterations = 50)

sliceSel = 50
max_val = 0.003
plt.figure()
plt.subplot(131)
plt.imshow(RecADMM_reg_sbtv[sliceSel, :, :], vmin=0, vmax=max_val, cmap="gray")
plt.title('3D ADMM-SB-TV Reconstruction, axial view')

plt.subplot(132)
plt.imshow(RecADMM_reg_sbtv[:, sliceSel, :], vmin=0, vmax=max_val, cmap="gray")
plt.title('3D ADMM-SB-TV Reconstruction, coronal view')

plt.subplot(133)
예제 #6
0
# calculate errors
Qtools = QualityTools(phantom_2D, RecFISTA)
RMSE_FISTA = Qtools.rmse()
Qtools = QualityTools(phantom_2D, RecFISTA_reg)
RMSE_FISTA_reg = Qtools.rmse()
print("RMSE for FISTA is {}".format(RMSE_FISTA))
print("RMSE for regularised FISTA is {}".format(RMSE_FISTA_reg))
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("Reconstructing using ADMM method (tomobar)")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
# Run ADMM reconstrucion algorithm with regularisation
RecADMM_reg = RectoolsIR.ADMM(noisy_zing_stripe,
                              rho_const=5000.0,
                              iterationsADMM=10,
                              regularisation='ROF_TV',
                              regularisation_parameter=0.3)

plt.figure()
plt.imshow(RecADMM_reg, vmin=0, vmax=1, cmap="gray")
plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('ADMM reconstruction')
plt.show()

# calculate errors
Qtools = QualityTools(phantom_2D, RecADMM_reg)
RMSE_ADMM_reg = Qtools.rmse()
print("RMSE for regularised ADMM is {}".format(RMSE_ADMM_reg))
#%%
예제 #7
0
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("Reconstructing using ADMM method (tomobar)")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
# Run ADMM reconstrucion algorithm with regularisation
_data_ = {'projection_norm_data': noisy_zing_stripe}  # data dictionary
_algorithm_ = {'iterations': 15, 'ADMM_rho_const': 5000.0}

# adding regularisation using the CCPi regularisation toolkit
_regularisation_ = {
    'method': 'PD_TV',
    'regul_param': 0.1,
    'iterations': 150,
    'device_regulariser': 'gpu'
}

RecADMM_reg = RectoolsIR.ADMM(_data_, _algorithm_, _regularisation_)

plt.figure()
plt.imshow(RecADMM_reg, vmin=0, vmax=2, cmap="gray")
plt.colorbar(ticks=[0, 0.5, 3], orientation='vertical')
plt.title('ADMM reconstruction')
plt.show()

# calculate errors
Qtools = QualityTools(phantom_2D, RecADMM_reg)
RMSE_ADMM_reg = Qtools.rmse()
print("RMSE for regularised ADMM is {}".format(RMSE_ADMM_reg))
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("Reconstructing using FISTA method (tomobar)")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
예제 #8
0
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("%%%%%%Reconstructing with ADMM LS-TV method %%%%%%%%%%%%%%%%")
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
from tomobar.methodsIR import RecToolsIR
# set parameters and initiate a class object
Rectools = RecToolsIR(DetectorsDimH = np.size(det_y_crop),  # DetectorsDimH # detector dimension (horizontal)
                    DetectorsDimV = None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
                    CenterRotOffset = None, # Center of Rotation (CoR) scalar (for 3D case only)
                    AnglesVec = angles_rad, # array of angles in radians
                    ObjSize = N_size, # a scalar to define reconstructed object dimensions
                    datafidelity='LS',# data fidelity, choose LS, PWLS, GH (wip), Student (wip)
                    nonnegativity='ENABLE', # enable nonnegativity constraint (set to 'ENABLE')
                    OS_number = None, # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets
                    tolerance = 1e-08, # tolerance to stop outer iterations earlier
                    device='gpu')

# Run ADMM-LS-TV reconstrucion algorithm
RecADMM_LS_TV = Rectools.ADMM(data_norm[:,det_y_crop], \
                              rho_const = 500.0, \
                              iterationsADMM = 3,\
                              regularisation = 'FGP_TV', \
                              regularisation_parameter = 0.05,\
                              regularisation_iterations = 100)

fig = plt.figure()
plt.imshow(RecADMM_LS_TV, vmin=0, vmax=0.2, cmap="gray")
#plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('ADMM LS-TV reconstruction')
plt.show()
#%%
예제 #9
0
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("%%%%%%Reconstructing with ADMM LS-TV method %%%%%%%%%%%%%%%%")
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
from tomobar.methodsIR import RecToolsIR
# set parameters and initiate a class object
Rectools = RecToolsIR(DetectorsDimH = np.size(det_y_crop),  # DetectorsDimH # detector dimension (horizontal)
                    DetectorsDimV = None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
                    CenterRotOffset = None, # Center of Rotation (CoR) scalar (for 3D case only)
                    AnglesVec = angles_rad, # array of angles in radians
                    ObjSize = N_size, # a scalar to define reconstructed object dimensions
                    datafidelity='LS',# data fidelity, choose LS, PWLS, GH (wip), Student (wip)
                    nonnegativity='ENABLE', # enable nonnegativity constraint (set to 'ENABLE')
                    OS_number = None, # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets
                    tolerance = 1e-08, # tolerance to stop outer iterations earlier
                    device='gpu')

# Run ADMM-LS-TV reconstrucion algorithm
RecADMM_LS_TV = Rectools.ADMM(np.transpose(data_norm[det_y_crop,:,0]), \
                              rho_const = 500.0, \
                              iterationsADMM = 3,\
                              regularisation = 'FGP_TV', \
                              regularisation_parameter = 0.05,\
                              regularisation_iterations = 100)

fig = plt.figure()
plt.imshow(RecADMM_LS_TV, vmin=0, vmax=0.2, cmap="gray")
#plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('ADMM LS-TV reconstruction')
plt.show()
#%%
예제 #10
0
                    ObjSize = N_size, # a scalar to define reconstructed object dimensions
                    datafidelity='LS',# data fidelity, choose LS, PWLS (wip), GH (wip), Student (wip)
                    nonnegativity='ENABLE', # enable nonnegativity constraint (set to 'ENABLE')
                    OS_number = None, # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets
                    tolerance = 0.0, # tolerance to stop inner (regularisation) iterations earlier
                    device='gpu')
#%%
param_space = 30
reg_param_sb_vec = np.linspace(0.03,0.15,param_space,dtype='float32') # a vector of parameters
erros_vec_sbtv = np.zeros((param_space)) # a vector of errors

print ("Reconstructing with ADMM method using SB-TV penalty")
for i in range(0,param_space):
    RecADMM_reg_sbtv = RectoolsIR.ADMM(projdata_norm,
                                  rho_const = 2000.0, \
                                  iterationsADMM = 15, \
                                  regularisation = 'SB_TV', \
                                  regularisation_parameter = reg_param_sb_vec[i],\
                                  regularisation_iterations = 50)
    # calculate errors 
    Qtools = QualityTools(phantom, RecADMM_reg_sbtv)
    erros_vec_sbtv[i] = Qtools.rmse()
    print("RMSE for regularisation parameter {} for ADMM-SB-TV is {}".format(reg_param_sb_vec[i],erros_vec_sbtv[i]))

plt.figure() 
plt.plot(erros_vec_sbtv)

# Saving generated data with a unique time label
h5f = h5py.File('Optim_admm_sbtv.h5', 'w')
h5f.create_dataset('reg_param_sb_vec', data=reg_param_sb_vec)
h5f.create_dataset('erros_vec_sbtv', data=erros_vec_sbtv)
h5f.close()
    DetectorsDimV=
    Vert_det,  # DetectorsDimV # detector dimension (vertical) for 3D case only
    AnglesVec=proj_angles,  # array of angles in radians
    ObjSize=N_size,  # a scalar to define reconstructed object dimensions
    datafidelity=
    'LS',  # data fidelity, choose LS, PWLS (wip), GH (wip), Student (wip)
    nonnegativity='ENABLE',  # enable nonnegativity constraint (set to 'ENABLE')
    OS_number=
    None,  # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets
    tolerance=1e-06,  # tolerance to stop outer -ADMM iterations earlier
    device='gpu')
#%%
print("Reconstructing with ADMM method using SB-TV penalty")
RecADMM_reg_sbtv = RectoolsIR.ADMM(projdata_norm,
                                  rho_const = 2000.0, \
                                  iterationsADMM = 25, \
                                  regularisation = 'SB_TV', \
                                  regularisation_parameter = optimReg_sbtv,\
                                  regularisation_iterations = 50)

sliceSel = int(0.5 * N_size)
max_val = 1
plt.figure(figsize=(20, 3))
gs1 = gridspec.GridSpec(1, 4)
gs1.update(wspace=0.02, hspace=0.01)  # set the spacing between axes.
ax1 = plt.subplot(gs1[0])
plt.plot(reg_param_sb_vec, erros_vec_sbtv, color='k', linewidth=2)
plt.xlabel('Regularisation parameter', fontsize=16)
plt.ylabel('RMSE value', fontsize=16)
plt.title('Regularisation selection', fontsize=19)
ax2 = plt.subplot(gs1[1])
plt.imshow(RecADMM_reg_sbtv[sliceSel, :, :], vmin=0, vmax=max_val, cmap="PuOr")