plt.subplot(132)
plt.imshow(phantom_tm[:,128,:],vmin=0, vmax=1)
plt.title('3D Phantom, coronal view')

plt.subplot(133)
plt.imshow(phantom_tm[:,:,128],vmin=0, vmax=1)
plt.title('3D Phantom, sagittal view')
plt.show()


print ("Building a subset of 3D projection data using TomoPhantom software")
Horiz_det = int(np.sqrt(2)*N_size) # detector column count (horizontal)
Vert_det = N_size # detector row count (vertical) (no reason for it to be > N)
angles_num = int(0.5*np.pi*N_size); # angles number
angles = np.linspace(0.0,179.9,angles_num,dtype='float32') # in degrees

projData3D_cut = TomoP3D.ModelSinoSub(model, N_size, Horiz_det, Vert_det, DIM_z, angles, path_library3D)

intens_max = 60
plt.figure() 
plt.subplot(131)
plt.imshow(projData3D_cut[:,sliceSel,:],vmin=0, vmax=intens_max)
plt.title('2D Projection (analytical)')
plt.subplot(132)
plt.imshow(projData3D_cut[sliceSel,:,:],vmin=0, vmax=intens_max)
plt.title('Sinogram view')
plt.subplot(133)
plt.imshow(projData3D_cut[:,:,sliceSel],vmin=0, vmax=intens_max)
plt.title('Tangentogram view')
plt.show()
#%%
Exemplo n.º 2
0
    def process_frames(self, data):
        # print "The input data shape is", data[0].shape
        if (self.out_shape_sino[1] == 1):
            # create a 2D phantom
            model = TomoP2D.Model(self.model, self.dims, self.path_library2D)
            # create a 2D sinogram
            projdata_clean = TomoP2D.ModelSino(self.model, self.dims,
                                               self.detectors_num, self.angles,
                                               self.path_library2D)
            # Adding artifacts and noise
            # forming dictionaries with artifact types
            _noise_ = {
                'type': self.parameters['artifacts_noise_type'],
                'sigma': self.parameters['artifacts_noise_sigma'],
                'seed': 0,
                'prelog': False
            }

            # misalignment dictionary
            _sinoshifts_ = {}
            if self.parameters[
                    'artifacts_misalignment_maxamplitude'] is not None:
                _sinoshifts_ = {
                    'maxamplitude':
                    self.parameters['artifacts_misalignment_maxamplitude']
                }

            # adding zingers and stripes
            _zingers_ = {}
            if self.parameters['artifacts_zingers_percentage'] is not None:
                _zingers_ = {
                    'percentage':
                    self.parameters['artifacts_zingers_percentage'],
                    'modulus': 10
                }

            _stripes_ = {}
            if self.parameters['artifacts_stripes_percentage'] is not None:
                _stripes_ = {
                    'percentage':
                    self.parameters['artifacts_stripes_percentage'],
                    'maxthickness':
                    self.parameters['artifacts_stripes_maxthickness'],
                    'intensity':
                    self.parameters['artifacts_stripes_intensity'],
                    'type':
                    self.parameters['artifacts_stripes_type'],
                    'variability':
                    self.parameters['artifacts_stripes_variability']
                }

            if self.parameters[
                    'artifacts_misalignment_maxamplitude'] is not None:
                [projdata,
                 shifts] = _Artifacts_(projdata_clean, _noise_, _zingers_,
                                       _stripes_, _sinoshifts_)
            else:
                projdata = _Artifacts_(projdata_clean, _noise_, _zingers_,
                                       _stripes_, _sinoshifts_)
        else:
            # create a 3D phantom
            frame_idx = self.out_pData[0].get_current_frame_idx()[0]
            model = TomoP3D.ModelSub(self.model, self.dims,
                                     (frame_idx, frame_idx + 1),
                                     self.path_library3D)
            model = np.swapaxes(model, 0, 1)
            model = np.flipud(model[:, 0, :])
            # create a 3D projection data
            projdata_clean = TomoP3D.ModelSinoSub(
                self.model, self.dims, self.detectors_num, self.dims,
                (frame_idx, frame_idx + 1), self.angles, self.path_library3D)
            # Adding artifacts and noise
            # forming dictionaries with artifact types
            _noise_ = {
                'type': self.parameters['artifacts_noise_type'],
                'sigma': self.parameters['artifacts_noise_sigma'],
                'seed': 0,
                'prelog': False
            }

            # misalignment dictionary
            _sinoshifts_ = {}
            if self.parameters[
                    'artifacts_misalignment_maxamplitude'] is not None:
                _sinoshifts_ = {
                    'maxamplitude':
                    self.parameters['artifacts_misalignment_maxamplitude']
                }

            # adding zingers and stripes
            _zingers_ = {}
            if self.parameters['artifacts_zingers_percentage'] is not None:
                _zingers_ = {
                    'percentage':
                    self.parameters['artifacts_zingers_percentage'],
                    'modulus': 10
                }

            _stripes_ = {}
            if self.parameters['artifacts_stripes_percentage'] is not None:
                _stripes_ = {
                    'percentage':
                    self.parameters['artifacts_stripes_percentage'],
                    'maxthickness':
                    self.parameters['artifacts_stripes_maxthickness'],
                    'intensity':
                    self.parameters['artifacts_stripes_intensity'],
                    'type':
                    self.parameters['artifacts_stripes_type'],
                    'variability':
                    self.parameters['artifacts_stripes_variability']
                }

            if self.parameters[
                    'artifacts_misalignment_maxamplitude'] is not None:
                [projdata,
                 shifts] = _Artifacts_(projdata_clean, _noise_, _zingers_,
                                       _stripes_, _sinoshifts_)
            else:
                projdata = _Artifacts_(projdata_clean, _noise_, _zingers_,
                                       _stripes_, _sinoshifts_)
            projdata = np.swapaxes(projdata, 0, 1)
        return [projdata, model]