예제 #1
0
    def test_tomobarDIR(self):
        model = 4  # select a model
        N_size = 64  # set dimension of the phantom

        # create sinogram analytically
        angles_num = int(0.5 * np.pi * N_size)
        # angles number
        angles = np.linspace(0.0, 179.9, angles_num, dtype='float32')
        angles_rad = angles * (np.pi / 180.0)
        P = int(np.sqrt(2) * N_size)  # detectors
        sino_num = np.ones((P, angles_num))

        RectoolsDirect = RecToolsDIR(
            DetectorsDimH=P,  # DetectorsDimH # detector dimension (horizontal)
            DetectorsDimV=
            None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
            CenterRotOffset=0.0,  # Center of Rotation (CoR) scalar
            AnglesVec=angles_rad,  # array of angles in radians
            ObjSize=N_size,  # a scalar to define reconstructed object dimensions
            device_projector='cpu')
        """
        RectoolsIterative = RecToolsIR(DetectorsDimH = P,  # DetectorsDimH # detector dimension (horizontal)
                            DetectorsDimV = None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
                            CenterRotOffset = 0.0, # Center of Rotation (CoR) scalar
                            AnglesVec = angles_rad, # array of angles in radians
                            ObjSize = N_size, # a scalar to define reconstructed object dimensions
                            datafidelity = 'LS',
                            device_projector = 'cpu')
        """
        RecFourier = RectoolsDirect.FOURIER(sino_num, 'linear')
예제 #2
0
h5f.close()
data_norm = np.swapaxes(data_norm[:, :, 0], 0, 1)
data_raw = np.swapaxes(data_raw[:, :, 0], 0, 1)

N_size = 2000
angles_number, detectorHoriz = np.shape(data_norm)
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("%%%%%%%%%%%%Reconstructing with FBP method %%%%%%%%%%%%%%%%%")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
from tomobar.methodsDIR import RecToolsDIR

RectoolsDIR = RecToolsDIR(
    DetectorsDimH=detectorHoriz,  # Horizontal detector dimension
    DetectorsDimV=None,  # Vertical detector dimension (3D case)
    CenterRotOffset=92,  # Center of Rotation scalar
    AnglesVec=angles_rad,  # A vector of projection angles in radians
    ObjSize=N_size,  # Reconstructed object dimensions (scalar)
    device_projector='gpu')

FBPrec = RectoolsDIR.FBP(data_norm)

plt.figure()
#plt.imshow(FBPrec[500:1500,500:1500], vmin=0, vmax=1, cmap="gray")
plt.imshow(FBPrec, vmin=0, vmax=1, cmap="gray")
plt.title('FBP reconstruction')
#%%
from tomobar.methodsIR import RecToolsIR
# set parameters and initiate a class object
Rectools = RecToolsIR(
    DetectorsDimH=detectorHoriz,  # Horizontal detector dimension
예제 #3
0
dataRaw = np.float32(np.divide(dataRaw, np.max(dataRaw).astype(float)))

detectorHoriz = np.size(data_norm, 1)
N_size = 1000
slice_to_recon = 19  # select which slice to reconstruct
angles_rad = angles * (np.pi / 180.0)
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("%%%%%%%%%%%%Reconstructing with FBP method %%%%%%%%%%%%%%%%%")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
from tomobar.methodsDIR import RecToolsDIR
RectoolsDIR = RecToolsDIR(
    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
    device='gpu')

FBPrec = RectoolsDIR.FBP(data_norm[:, :, slice_to_recon])

plt.figure()
plt.imshow(FBPrec[150:550, 150:550], vmin=0, vmax=0.005, cmap="gray")
plt.title('FBP reconstruction')

from tomobar.methodsIR import RecToolsIR
# set parameters and initiate a class object
Rectools = RecToolsIR(
    DetectorsDimH=
예제 #4
0
plt.imshow(ProjData3D[:, sliceSel, :], vmin=0, vmax=intens_max)
plt.title('2D Projection (analytical)')
plt.subplot(132)
plt.imshow(ProjData3D[sliceSel, :, :], vmin=0, vmax=intens_max)
plt.title('Sinogram view')
plt.subplot(133)
plt.imshow(ProjData3D[:, :, sliceSel], vmin=0, vmax=intens_max)
plt.title('Tangentogram view')
plt.show()
#%%
# initialise tomobar DIRECT reconstruction class ONCE
from tomobar.methodsDIR import RecToolsDIR
RectoolsDIR = RecToolsDIR(
    DetectorsDimH=Horiz_det,  # DetectorsDimH # detector dimension (horizontal)
    DetectorsDimV=
    Vert_det,  # DetectorsDimV # detector dimension (vertical) for 3D case only
    AnglesVec=angles_rad,  # array of angles in radians
    ObjSize=N3D_size,  # a scalar to define reconstructed object dimensions
    device='gpu')
#%%
"""
print ("Adding noise to projection data")
from tomophantom.supp.artifacts import ArtifactsClass
artifacts_add = ArtifactsClass(projData3D_analyt)

projData3D_analyt_noisy = artifacts_add.noise(sigma=15000,noisetype='Poisson')

intens_max = 70
sliceSel = 150
plt.figure() 
plt.subplot(131)
예제 #5
0
plt.figure()
plt.axis('off')
plt.imshow(projections_dff[:, 5, :], vmin=-0.1, vmax=0.4, cmap="gray")

#%%
# do reconstruction
angles_rad = np.zeros(N_size)
angles_step_rad = (360.0 / float(N_size)) * np.pi / 180.0
for i in range(0, N_size):
    angles_rad[i] = i * angles_step_rad

RectoolsDIR = RecToolsDIR(
    DetectorsDimH=N_cut,  # DetectorsDimH # detector dimension (horizontal)
    DetectorsDimV=
    None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
    CenterRotOffset=-118.0,  # Center of Rotation (CoR) scalar 
    AnglesVec=np.float32(angles_rad),  # array of angles in radians
    ObjSize=1600,  # a scalar to define reconstructed object dimensions
    device_projector='cpu')

print("Reconstruction using FBP from tomobar")
recFBP = RectoolsDIR.FBP(projections_norm[:, 5, :])  # FBP reconstruction

plt.figure()
plt.imshow(recFBP, vmin=0, vmax=0.00095, cmap="gray")

#%%
# do reconstruction
angles_rad = np.zeros(N_cut)
angles_step_rad = (360.0 / float(N_cut)) * np.pi / 180.0
for i in range(0, N_cut):
예제 #6
0
plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('{}'.format('Distorted Phantom'))

#%%
# Generate projection data of distorted phantom

angles_num = int(np.pi * N_size)
# angles number
angles = np.linspace(0.0, 179.9, angles_num, dtype='float32')
angles_rad = angles * (np.pi / 180.0)
P = N_size  #detectors

Rectools = RecToolsDIR(
    DetectorsDimH=P,  # Horizontal detector dimension
    DetectorsDimV=None,  # Vertical detector dimension (3D case)
    CenterRotOffset=0.0,  # Center of Rotation scalar
    AnglesVec=angles_rad,  # A vector of projection angles in radians
    ObjSize=N_size,  # Reconstructed object dimensions (scalar)
    device_projector='gpu')

sino_num = Rectools.FORWPROJ(Object)

_noise_ = {}
_zingers_ = {}
_sinoshifts_ = {}

_stripes_ = {
    'percentage': 0.75,
    'maxthickness': 2.0,
    'intensity': 0.15,
    'type': 'mix',