def test_FBPcpu(self): #2D parallel ag = self.ag_parallel.subset(vertical='centre') ig = ag.get_ImageGeometry() A = ProjectionOperator(ig, ag, device='cpu') fp_2D = A.direct(self.golden_data_cs) fbp = FBP(ig, ag, 'cpu') fbp.set_input(fp_2D) fbp_2D_parallel = fbp.get_output() np.testing.assert_allclose(fbp_2D_parallel.as_array(),self.golden_data_cs.as_array(),atol=0.6)
def test_FBP_with_Astra(self): reco_ASTRA = AstraFBP(self.ig, self.ag)(self.fp.subset(vertical='centre')) reco_TIGRE = FBP(self.ig, self.ag)(self.fp.subset(vertical='centre')) mean_diff = (reco_ASTRA - reco_TIGRE).abs().mean() self.assertLess(mean_diff, 1e-4) np.testing.assert_allclose(reco_ASTRA.as_array(), reco_TIGRE.as_array(), atol=1e-2) astra_transpose = self.fp.subset(['vertical', 'angle', 'horizontal']) reco_ASTRA3D = AstraFBP(self.ig3D, astra_transpose.geometry)(astra_transpose) reco_TIGRE3D = FBP(self.ig3D, self.ag3D)(self.fp) diff = (reco_ASTRA3D - reco_TIGRE3D).abs() self.assertLess(diff.mean(), 1e-4) np.testing.assert_allclose(reco_ASTRA3D.as_array(), reco_TIGRE3D.as_array(), atol=1e-2)
def FBP_recon_per_slice(image_geom, data): # get 3D image geometry recon = image_geom.allocate() ag2D = data.geometry.subset(channel=0) ig2D = ag2D.get_ImageGeometry() ig2D.voxel_num_x = 256 ig2D.voxel_num_y = 256 for i in range(recon.geometry.channels): tmp = FBP(ig2D, ag2D)(data.subset(channel=i)) recon.fill(tmp, channel=i) return recon
rec = A.fdk(ldata) # plotter2D([bck, rec], cmap='gist_earth') print ("direct") fwd = ldata * 0. + 1 A.direct(bck*0+1, out=fwd) print (fwd.shape, ldata.shape, bck.shape) # fwd = A.direct(bck*0+1) # if fwd.mean() > 0: # plotter2D([ldata, fwd], cmap='gist_earth', stretch_y=True) plotter2D([bck, fwd], cmap='gist_earth', stretch_y=True) sys.exit(0) #%% Centre slice FDK fbp = FBP(ig_cs, ag_cs) fbp.set_input(ldata) FBP_cs = fbp.get_output() #%% plotter2D([FBP_cs,rec], cmap='gist_earth',) sys.exit(0) data_cs = ldata # #%% Full 3D FDK # fbp = FBP(ig, ag) # fbp.set_input(data) # FBP_3D_out = fbp.get_output() # plotter2D(FBP_3D_out.subset(vertical=999)) #reconstruct the slice using FBP fbp = FBP(ig_cs, ag_shift)