Exemple #1
0
plt.title('FBP Reconstruction, axial (X-Y) view', fontsize=19)
ax1.set_aspect('equal')
ax3 = plt.subplot(gs1[1])
plt.plot(phantom[sliceSel,sliceSel,0:N_size],color='k',linewidth=2)
plt.plot(recFBP[sliceSel,sliceSel,0:N_size],linestyle='--',color='g')
plt.title('Profile', fontsize=19)
ax2 = plt.subplot(gs1[2])
plt.imshow(recFBP[:,sliceSel,:],vmin=0, vmax=max_val, cmap="PuOr")
plt.title('FBP Reconstruction, coronal (Y-Z) view', fontsize=19)
ax2.set_aspect('equal')
plt.show()
#plt.savefig('FBP_phantom.pdf', format='pdf', dpi=1600)

# calculate errors 
Qtools = QualityTools(phantom, recFBP)
RMSE_fbp = Qtools.rmse()
print("Root Mean Square Error for FBP is {}".format(RMSE_fbp))

# SSIM measure
Qtools = QualityTools(phantom[128,:,:]*255, recFBP[128,:,:]*235)
win = np.array([gaussian(11, 1.5)])
win2d = win * (win.T)
ssim_fbp = Qtools.ssim(win2d)
print("Mean SSIM for FBP is {}".format(ssim_fbp[0]))
#%%
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("Reconstructing with ADMM method using TomoRec software")
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
# initialise TomoRec ITERATIVE reconstruction class ONCE
from tomorec.methodsIR import RecToolsIR
RectoolsIR = RecToolsIR(DetectorsDimH = Horiz_det,  # DetectorsDimH # detector dimension (horizontal)
Exemple #2
0
        'number_of_iterations': 1000,\
        'time_marching_parameter': 0.00025,\
        'tolerance_constant':0.0}

tic=timeit.default_timer()
(rof_cpu3D, infcpu) = ROF_TV(pars['input'],
             pars['regularisation_parameter'],
             pars['number_of_iterations'],
             pars['time_marching_parameter'],
             pars['tolerance_constant'],'cpu')

toc=timeit.default_timer()

Run_time_rof = toc - tic
Qtools = QualityTools(phantom_tm, rof_cpu3D)
RMSE_rof = Qtools.rmse()

# SSIM measure
Qtools = QualityTools(phantom_tm[sliceSel,:,:]*255, rof_cpu3D[sliceSel,:,:]*235)
win = np.array([gaussian(11, 1.5)])
win2d = win * (win.T)
ssim_rof = Qtools.ssim(win2d)

print("ROF-TV (cpu) ____ RMSE: {}, MMSIM: {}, run time: {} sec".format(RMSE_rof,ssim_rof[0],Run_time_rof))
#%%
print ("#############ROF TV GPU####################")
# set parameters
pars = {'algorithm': ROF_TV, \
        'input' : phantom_noise,\
        'regularisation_parameter':0.06,\
        'number_of_iterations': 8330,\
Exemple #3
0
        'input' : u0,\
        'regularisation_parameter':0.02,\
        'number_of_iterations': 1000,\
        'time_marching_parameter': 0.001,\
        'tolerance_constant':0.0}

print ("#############ROF TV CPU####################")
start_time = timeit.default_timer()
(rof_cpu, infocpu) = ROF_TV(pars['input'],
             pars['regularisation_parameter'],
             pars['number_of_iterations'],
             pars['time_marching_parameter'],
             pars['tolerance_constant'],'cpu')

Qtools = QualityTools(Im, rof_cpu)
pars['rmse'] = Qtools.rmse()

txtstr = printParametersToString(pars)
txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
print (txtstr)
a=fig.add_subplot(1,4,2)

# these are matplotlib.patch.Patch properties
props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
# place a text box in upper left in axes coords
a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
         verticalalignment='top', bbox=props)
imgplot = plt.imshow(rof_cpu, cmap="gray")
plt.title('{}'.format('CPU results'))

print ("##############ROF TV GPU##################")
Exemple #4
0
#%%
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()
#%%
param_space = 30
reg_param_rofllt_vec = np.linspace(0.03,0.15,param_space,dtype='float32') # a vector of parameters
erros_vec_rofllt = np.zeros((param_space)) # a vector of errors