def process(self, out=None): DATA = self.get_input() pad = False if len(DATA.shape) == 2: #for 2D cases pad = True data_temp = numpy.expand_dims(DATA.as_array(), axis=0) else: data_temp = DATA.as_array() rec_id, arr_out = astra.create_backprojection3d_gpu( data_temp, self.proj_geom, self.vol_geom) astra.data3d.delete(rec_id) if pad is True: arr_out = numpy.squeeze(arr_out, axis=0) if out is None: out = ImageData(arr_out, deep_copy=False, geometry=self.volume_geometry.copy(), suppress_warning=True) return out else: out.fill(arr_out)
def adjoint(self, x, out=None): if self.tigre_geom.is2D: data_temp = np.expand_dims(x.as_array(),axis=1) arr_out = Atb.Atb(data_temp, self.tigre_geom, self.tigre_angles, krylov=self.method['adjoint']) arr_out = np.squeeze(arr_out, axis=0) else: arr_out = Atb.Atb(x.as_array(), self.tigre_geom, self.tigre_angles, krylov=self.method['adjoint']) if out is None: out = ImageData(arr_out, deep_copy=False, geometry=self._domain_geometry.copy(), suppress_warning=True) return out else: out.fill(arr_out)
def process(self, out=None): DATA = self.get_input() data_temp = DATA.as_array() rec_id, arr_out = astra.create_backprojection(data_temp, self.proj_id) astra.data2d.delete(rec_id) if out is None: out = ImageData(arr_out, deep_copy=False, geometry=self.volume_geometry.copy(), suppress_warning=True) return out else: out.fill(arr_out)
def process(self, out=None): if self.tigre_geom.is2D: data_temp = np.expand_dims(self.get_input().as_array(), axis=1) arr_out = fdk(data_temp, self.tigre_geom, self.tigre_angles) arr_out = np.squeeze(arr_out, axis=0) else: arr_out = fdk(self.get_input().as_array(), self.tigre_geom, self.tigre_angles) if out is None: out = ImageData(arr_out, deep_copy=False, geometry=self.volume_geometry.copy(), suppress_warning=True) return out else: out.fill(arr_out)
def process(self, out=None): # Get DATA DATA = self.get_input() pad = False if len(DATA.shape) == 2: #for 2D cases pad = True data_temp = numpy.expand_dims(DATA.as_array(), axis=0) else: data_temp = DATA.as_array() rec_id = astra.data3d.create('-vol', self.vol_geom_astra) sinogram_id = astra.data3d.create('-sino', self.proj_geom_astra, data_temp) cfg = astra.astra_dict('FDK_CUDA') cfg['ReconstructionDataId'] = rec_id cfg['ProjectionDataId'] = sinogram_id alg_id = astra.algorithm.create(cfg) astra.algorithm.run(alg_id) arr_out = astra.data3d.get(rec_id) astra.data3d.delete(rec_id) astra.data3d.delete(sinogram_id) astra.algorithm.delete(alg_id) if pad == True: arr_out = numpy.squeeze(arr_out, axis=0) if out is None: out = ImageData(arr_out, deep_copy=False, geometry=self.volume_geometry.copy(), suppress_warning=True) return out else: out.fill(arr_out)
def test_BlockDataContainer_fill(self): ig0 = ImageGeometry(2, 3, 4) ig1 = ImageGeometry(2, 3, 5) data0 = ImageData(geometry=ig0) data1 = ImageData(geometry=ig1) + 1 data2 = ImageData(geometry=ig0) + 2 data3 = ImageData(geometry=ig1) + 3 cp0 = BlockDataContainer(data0, data1) #cp1 = BlockDataContainer(data2,data3) cp2 = BlockDataContainer(data0 + 1, data1 + 1) data0.fill(data2) self.assertNumpyArrayEqual(data0.as_array(), data2.as_array()) data0 = ImageData(geometry=ig0) cp0.fill(cp2) self.assertBlockDataContainerEqual(cp0, cp2)
def adjoint(self, x, out=None): data = x.as_array() #if single angle projection add the dimension in for TIGRE if x.dimension_labels[0] != AcquisitionGeometry.ANGLE: data = np.expand_dims(data, axis=0) if self.tigre_geom.is2D: data = np.expand_dims(data, axis=1) arr_out = self.__call_Atb(data) arr_out = np.squeeze(arr_out, axis=0) else: arr_out = self.__call_Atb(data) if out is None: out = ImageData(arr_out, deep_copy=False, geometry=self._domain_geometry.copy(), suppress_warning=True) return out else: out.fill(arr_out)
def test_BlockDataContainer_fill(self): print ("test block data container") ig0 = ImageGeometry(2,3,4) ig1 = ImageGeometry(2,3,5) data0 = ImageData(geometry=ig0) data1 = ImageData(geometry=ig1) + 1 data2 = ImageData(geometry=ig0) + 2 data3 = ImageData(geometry=ig1) + 3 cp0 = BlockDataContainer(data0,data1) #cp1 = BlockDataContainer(data2,data3) cp2 = BlockDataContainer(data0+1, data1+1) data0.fill(data2) self.assertNumpyArrayEqual(data0.as_array(), data2.as_array()) data0 = ImageData(geometry=ig0) for el,ot in zip(cp0, cp2): print (el.shape, ot.shape) cp0.fill(cp2) self.assertBlockDataContainerEqual(cp0, cp2)