Ejemplo n.º 1
0
# initialise TomoRec ITERATIVE reconstruction class ONCE
from tomorec.methodsIR import RecToolsIR
RectoolsIR = RecToolsIR(DetectorsDimH = Horiz_det,  # DetectorsDimH # detector dimension (horizontal)
                    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")
# initialise TomoRec ITERATIVE reconstruction class ONCE
from tomorec.methodsIR import RecToolsIR
RectoolsIR = RecToolsIR(DetectorsDimH =  np.size(det_y_crop),  # DetectorsDimH # detector dimension (horizontal)
                    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)